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 } // anonymous namespace
252 //& purpose: Testing New API
253 int UtcDaliActorNew(void)
255 TestApplication application;
257 Actor actor = Actor::New();
259 DALI_TEST_CHECK(actor);
263 //& purpose: Testing Dali::Actor::DownCast()
264 int UtcDaliActorDownCastP(void)
266 TestApplication application;
267 tet_infoline("Testing Dali::Actor::DownCast()");
269 Actor actor = Actor::New();
270 BaseHandle object(actor);
271 Actor actor2 = Actor::DownCast(object);
272 DALI_TEST_CHECK(actor2);
276 //& purpose: Testing Dali::Actor::DownCast()
277 int UtcDaliActorDownCastN(void)
279 TestApplication application;
280 tet_infoline("Testing Dali::Actor::DownCast()");
282 BaseHandle unInitializedObject;
283 Actor actor = Actor::DownCast(unInitializedObject);
284 DALI_TEST_CHECK(!actor);
288 //& purpose: Testing Dali::Actor::GetName()
289 int UtcDaliActorGetName(void)
291 TestApplication application;
293 Actor actor = Actor::New();
295 DALI_TEST_CHECK(actor.GetName().empty());
299 //& purpose: Testing Dali::Actor::SetName()
300 int UtcDaliActorSetName(void)
302 TestApplication application;
304 string str("ActorName");
305 Actor actor = Actor::New();
308 DALI_TEST_CHECK(actor.GetName() == str);
312 int UtcDaliActorGetId(void)
314 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
315 TestApplication application;
317 Actor first = Actor::New();
318 Actor second = Actor::New();
319 Actor third = Actor::New();
321 DALI_TEST_CHECK(first.GetId() != second.GetId());
322 DALI_TEST_CHECK(second.GetId() != third.GetId());
326 int UtcDaliActorIsRoot(void)
328 TestApplication application;
330 Actor actor = Actor::New();
331 DALI_TEST_CHECK(!actor.IsRoot());
333 // get the root layer
334 actor = Stage::GetCurrent().GetLayer( 0 );
335 DALI_TEST_CHECK( actor.IsRoot() );
339 int UtcDaliActorOnStage(void)
341 TestApplication application;
343 Actor actor = Actor::New();
344 DALI_TEST_CHECK( !actor.OnStage() );
346 // get the root layer
347 actor = Stage::GetCurrent().GetLayer( 0 );
348 DALI_TEST_CHECK( actor.OnStage() );
352 int UtcDaliActorIsLayer(void)
354 TestApplication application;
356 Actor actor = Actor::New();
357 DALI_TEST_CHECK( !actor.IsLayer() );
359 // get the root layer
360 actor = Stage::GetCurrent().GetLayer( 0 );
361 DALI_TEST_CHECK( actor.IsLayer() );
365 int UtcDaliActorGetLayer(void)
367 TestApplication application;
369 Actor actor = Actor::New();
370 Stage::GetCurrent().Add(actor);
371 Layer layer = actor.GetLayer();
373 DALI_TEST_CHECK(layer);
375 // get the root layers layer
376 actor = Stage::GetCurrent().GetLayer( 0 );
377 DALI_TEST_CHECK( actor.GetLayer() );
381 int UtcDaliActorAddP(void)
383 tet_infoline("Testing Actor::Add");
384 TestApplication application;
386 Actor parent = Actor::New();
387 Actor child = Actor::New();
389 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
393 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
395 Actor parent2 = Actor::New();
396 parent2.Add( child );
398 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
399 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
401 // try Adding to same parent again, works
402 parent2.Add( child );
403 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
405 // try reparenting an orphaned child
407 Actor temporaryParent = Actor::New();
408 temporaryParent.Add( child );
409 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
411 // temporaryParent has now died, reparent the orphaned child
412 parent2.Add( child );
413 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
418 int UtcDaliActorAddN(void)
420 tet_infoline("Testing Actor::Add");
421 TestApplication application;
423 Actor child = Actor::New();
425 Actor parent2 = Actor::New();
426 parent2.Add( child );
431 parent2.Add( parent2 );
432 tet_printf("Assertion test failed - no Exception\n" );
433 tet_result(TET_FAIL);
435 catch(Dali::DaliException& e)
437 DALI_TEST_PRINT_ASSERT( e );
438 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
439 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
443 tet_printf("Assertion test failed - wrong Exception\n" );
444 tet_result(TET_FAIL);
447 // try reparenting root
450 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
451 tet_printf("Assertion test failed - no Exception\n" );
452 tet_result(TET_FAIL);
454 catch(Dali::DaliException& e)
456 DALI_TEST_PRINT_ASSERT( e );
457 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
458 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
462 tet_printf("Assertion test failed - wrong Exception\n" );
463 tet_result(TET_FAIL);
470 parent2.Add( empty );
471 tet_printf("Assertion test failed - no Exception\n" );
472 tet_result(TET_FAIL);
474 catch(Dali::DaliException& e)
476 DALI_TEST_PRINT_ASSERT( e );
477 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
478 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
482 tet_printf("Assertion test failed - wrong Exception\n" );
483 tet_result(TET_FAIL);
489 int UtcDaliActorRemoveN(void)
491 tet_infoline("Testing Actor::Remove");
492 TestApplication application;
494 Actor parent = Actor::New();
495 Actor child = Actor::New();
496 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
499 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
501 parent.Remove(child);
502 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
504 // remove again, no problem
505 parent.Remove(child);
506 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
510 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
511 // try Remove self, its a no-op
512 parent.Remove( parent );
513 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
519 parent.Remove( empty );
520 tet_printf("Assertion test failed - no Exception\n" );
521 tet_result(TET_FAIL);
523 catch(Dali::DaliException& e)
525 DALI_TEST_PRINT_ASSERT( e );
526 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
527 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
531 tet_printf("Assertion test failed - wrong Exception\n" );
532 tet_result(TET_FAIL);
537 int UtcDaliActorRemoveP(void)
539 TestApplication application;
541 Actor parent = Actor::New();
542 Actor child = Actor::New();
543 Actor random = Actor::New();
545 Stage::GetCurrent().Add( parent );
547 DALI_TEST_CHECK(parent.GetChildCount() == 0);
551 DALI_TEST_CHECK(parent.GetChildCount() == 1);
553 parent.Remove(random);
555 DALI_TEST_CHECK(parent.GetChildCount() == 1);
557 Stage::GetCurrent().Remove( parent );
559 DALI_TEST_CHECK(parent.GetChildCount() == 1);
563 int UtcDaliActorGetChildCount(void)
565 TestApplication application;
567 Actor parent = Actor::New();
568 Actor child = Actor::New();
570 DALI_TEST_CHECK(parent.GetChildCount() == 0);
574 DALI_TEST_CHECK(parent.GetChildCount() == 1);
578 int UtcDaliActorGetChildren01(void)
580 TestApplication application;
582 Actor parent = Actor::New();
583 Actor first = Actor::New();
584 Actor second = Actor::New();
585 Actor third = Actor::New();
591 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
592 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
593 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
597 int UtcDaliActorGetChildren02(void)
599 TestApplication application;
601 Actor parent = Actor::New();
602 Actor first = Actor::New();
603 Actor second = Actor::New();
604 Actor third = Actor::New();
610 const Actor& constParent = parent;
612 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
613 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
614 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
618 int UtcDaliActorGetParent01(void)
620 TestApplication application;
622 Actor parent = Actor::New();
623 Actor child = Actor::New();
627 DALI_TEST_CHECK(child.GetParent() == parent);
631 int UtcDaliActorGetParent02(void)
633 TestApplication application;
635 Actor actor = Actor::New();
637 DALI_TEST_CHECK(!actor.GetParent());
641 int UtcDaliActorCustomProperty(void)
643 TestApplication application;
645 Actor actor = Actor::New();
646 Stage::GetCurrent().Add( actor );
648 float startValue(1.0f);
649 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
650 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
652 application.SendNotification();
653 application.Render(0);
654 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
656 actor.SetProperty( index, 5.0f );
658 application.SendNotification();
659 application.Render(0);
660 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
664 int UtcDaliActorCustomPropertyIntToFloat(void)
666 TestApplication application;
668 Actor actor = Actor::New();
669 Stage::GetCurrent().Add( actor );
671 float startValue(5.0f);
672 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
673 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
675 application.SendNotification();
676 application.Render(0);
677 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
679 actor.SetProperty( index, int(1) );
681 application.SendNotification();
682 application.Render(0);
683 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
687 int UtcDaliActorCustomPropertyFloatToInt(void)
689 TestApplication application;
691 Actor actor = Actor::New();
692 Stage::GetCurrent().Add( actor );
695 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
696 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
698 application.SendNotification();
699 application.Render(0);
700 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
702 actor.SetProperty( index, float(1.5) );
704 application.SendNotification();
705 application.Render(0);
706 DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
710 int UtcDaliActorSetParentOrigin(void)
712 TestApplication application;
714 Actor actor = Actor::New();
716 Vector3 vector(0.7f, 0.8f, 0.9f);
717 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
719 actor.SetParentOrigin(vector);
721 // flush the queue and render once
722 application.SendNotification();
723 application.Render();
725 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
727 Stage::GetCurrent().Add( actor );
729 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
731 // flush the queue and render once
732 application.SendNotification();
733 application.Render();
735 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
737 Stage::GetCurrent().Remove( actor );
741 int UtcDaliActorSetParentOriginIndividual(void)
743 TestApplication application;
745 Actor actor = Actor::New();
747 Vector3 vector(0.7f, 0.8f, 0.9f);
748 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
750 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
752 // flush the queue and render once
753 application.SendNotification();
754 application.Render();
756 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
758 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
760 // flush the queue and render once
761 application.SendNotification();
762 application.Render();
764 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
766 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
768 // flush the queue and render once
769 application.SendNotification();
770 application.Render();
772 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
777 int UtcDaliActorGetCurrentParentOrigin(void)
779 TestApplication application;
781 Actor actor = Actor::New();
783 Vector3 vector(0.7f, 0.8f, 0.9f);
784 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
786 actor.SetParentOrigin(vector);
788 // flush the queue and render once
789 application.SendNotification();
790 application.Render();
792 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
796 int UtcDaliActorSetAnchorPoint(void)
798 TestApplication application;
800 Actor actor = Actor::New();
802 Vector3 vector(0.7f, 0.8f, 0.9f);
803 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
805 actor.SetAnchorPoint(vector);
807 // flush the queue and render once
808 application.SendNotification();
809 application.Render();
811 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
813 Stage::GetCurrent().Add( actor );
815 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
816 // flush the queue and render once
817 application.SendNotification();
818 application.Render();
820 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
822 Stage::GetCurrent().Remove( actor );
826 int UtcDaliActorSetAnchorPointIndividual(void)
828 TestApplication application;
830 Actor actor = Actor::New();
832 Vector3 vector(0.7f, 0.8f, 0.9f);
833 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
835 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
837 // flush the queue and render once
838 application.SendNotification();
839 application.Render();
841 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
843 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
845 // flush the queue and render once
846 application.SendNotification();
847 application.Render();
849 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
851 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
853 // flush the queue and render once
854 application.SendNotification();
855 application.Render();
857 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
862 int UtcDaliActorGetCurrentAnchorPoint(void)
864 TestApplication application;
866 Actor actor = Actor::New();
868 Vector3 vector(0.7f, 0.8f, 0.9f);
869 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
871 actor.SetAnchorPoint(vector);
873 // flush the queue and render once
874 application.SendNotification();
875 application.Render();
877 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
881 // SetSize(float width, float height)
882 int UtcDaliActorSetSize01(void)
884 TestApplication application;
886 Actor actor = Actor::New();
887 Vector3 vector(100.0f, 100.0f, 0.0f);
889 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
891 actor.SetSize(vector.x, vector.y);
893 // Immediately retrieve the size after setting
894 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
895 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
896 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
897 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
898 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
900 // Flush the queue and render once
901 application.SendNotification();
902 application.Render();
904 // Check the size in the new frame
905 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
907 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
908 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
909 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
910 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
911 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
913 // Check async behaviour
914 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
915 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
916 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
917 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
918 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
920 // Change the resize policy and check whether the size stays the same
921 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
923 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
924 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
926 // Set a new size after resize policy is changed and check the new size
927 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
929 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
930 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
932 // Change the resize policy again and check whether the new size stays the same
933 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
935 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
936 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
938 // Set another new size after resize policy is changed and check the new size
939 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
941 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
942 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
947 // SetSize(float width, float height, float depth)
948 int UtcDaliActorSetSize02(void)
950 TestApplication application;
952 Actor actor = Actor::New();
953 Vector3 vector(100.0f, 100.0f, 100.0f);
955 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
957 actor.SetSize(vector.x, vector.y, vector.z);
959 // Immediately check the size after setting
960 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
961 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
963 // flush the queue and render once
964 application.SendNotification();
965 application.Render();
967 // Check the size in the new frame
968 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
970 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
971 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
976 // SetSize(Vector2 size)
977 int UtcDaliActorSetSize03(void)
979 TestApplication application;
981 Actor actor = Actor::New();
982 Vector3 vector(100.0f, 100.0f, 0.0f);
984 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
986 actor.SetSize(Vector2(vector.x, vector.y));
988 // Immediately check the size after setting
989 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
990 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
992 // flush the queue and render once
993 application.SendNotification();
994 application.Render();
996 // Check the size in the new frame
997 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
999 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1000 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1005 // SetSize(Vector3 size)
1006 int UtcDaliActorSetSize04(void)
1008 TestApplication application;
1010 Actor actor = Actor::New();
1011 Vector3 vector(100.0f, 100.0f, 100.0f);
1013 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1015 actor.SetSize(vector);
1017 // Immediately check the size after setting
1018 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1019 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1021 // flush the queue and render once
1022 application.SendNotification();
1023 application.Render();
1025 // Check the size in the new frame
1026 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1028 Stage::GetCurrent().Add( actor );
1029 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
1031 // Immediately check the size after setting
1032 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1033 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1035 // flush the queue and render once
1036 application.SendNotification();
1037 application.Render();
1039 // Check the size in the new frame
1040 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
1042 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1043 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1045 Stage::GetCurrent().Remove( actor );
1049 int UtcDaliActorSetSizeIndividual(void)
1051 TestApplication application;
1053 Actor actor = Actor::New();
1055 Vector3 vector(0.7f, 0.8f, 0.9f);
1056 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1058 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1060 // Immediately check the width after setting
1061 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1062 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1064 // flush the queue and render once
1065 application.SendNotification();
1066 application.Render();
1068 // Check the width in the new frame
1069 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1071 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1072 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1074 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1076 // Immediately check the height after setting
1077 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1078 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1080 // flush the queue and render once
1081 application.SendNotification();
1082 application.Render();
1084 // Check the height in the new frame
1085 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1087 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1088 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1090 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1092 // Immediately check the depth after setting
1093 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1094 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1096 // flush the queue and render once
1097 application.SendNotification();
1098 application.Render();
1100 // Check the depth in the new frame
1101 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1103 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1104 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1106 // Change the resize policy and check whether the size stays the same
1107 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1109 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1110 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1112 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1113 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1115 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1116 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1118 // Change the resize policy again and check whether the size stays the same
1119 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1121 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1122 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1124 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1125 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1127 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1128 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1133 int UtcDaliActorSetSizeIndividual02(void)
1135 TestApplication application;
1137 Actor actor = Actor::New();
1138 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1139 Stage::GetCurrent().Add( actor );
1141 Vector3 vector( 100.0f, 200.0f, 400.0f );
1142 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1144 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1145 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1147 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1148 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1150 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1151 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1153 // flush the queue and render once
1154 application.SendNotification();
1155 application.Render();
1157 // Check the width in the new frame
1158 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1159 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1165 int UtcDaliActorGetCurrentSize(void)
1167 TestApplication application;
1169 Actor actor = Actor::New();
1170 Vector3 vector(100.0f, 100.0f, 20.0f);
1172 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1174 actor.SetSize(vector);
1176 // flush the queue and render once
1177 application.SendNotification();
1178 application.Render();
1180 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1184 int UtcDaliActorGetNaturalSize(void)
1186 TestApplication application;
1188 Actor actor = Actor::New();
1189 Vector3 vector( 0.0f, 0.0f, 0.0f );
1191 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1196 int UtcDaliActorGetCurrentSizeImmediate(void)
1198 TestApplication application;
1200 Actor actor = Actor::New();
1201 Vector3 vector(100.0f, 100.0f, 20.0f);
1203 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1204 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1206 actor.SetSize(vector);
1208 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1209 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1211 // flush the queue and render once
1212 application.SendNotification();
1213 application.Render();
1215 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1216 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1219 // Build the animation
1220 const float durationSeconds = 2.0f;
1221 Animation animation = Animation::New( durationSeconds );
1222 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1223 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1225 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1227 // Start the animation
1230 application.SendNotification();
1231 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1233 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1238 // SetPosition(float x, float y)
1239 int UtcDaliActorSetPosition01(void)
1241 TestApplication application;
1243 Actor actor = Actor::New();
1245 // Set to random to start off with
1246 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1248 Vector3 vector(100.0f, 100.0f, 0.0f);
1250 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1252 actor.SetPosition(vector.x, vector.y);
1253 // flush the queue and render once
1254 application.SendNotification();
1255 application.Render();
1256 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1258 Stage::GetCurrent().Add( actor );
1259 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1260 // flush the queue and render once
1261 application.SendNotification();
1262 application.Render();
1263 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1268 // flush the queue and render once
1269 application.SendNotification();
1270 application.Render();
1271 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1273 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1274 // flush the queue and render once
1275 application.SendNotification();
1276 application.Render();
1277 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1279 Stage::GetCurrent().Remove( actor );
1283 // SetPosition(float x, float y, float z)
1284 int UtcDaliActorSetPosition02(void)
1286 TestApplication application;
1288 Actor actor = Actor::New();
1290 // Set to random to start off with
1291 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1293 Vector3 vector(100.0f, 100.0f, 100.0f);
1295 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1297 actor.SetPosition(vector.x, vector.y, vector.z);
1299 // flush the queue and render once
1300 application.SendNotification();
1301 application.Render();
1303 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1307 // SetPosition(Vector3 position)
1308 int UtcDaliActorSetPosition03(void)
1310 TestApplication application;
1312 Actor actor = Actor::New();
1314 // Set to random to start off with
1315 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1317 Vector3 vector(100.0f, 100.0f, 100.0f);
1319 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1321 actor.SetPosition(vector);
1323 // flush the queue and render once
1324 application.SendNotification();
1325 application.Render();
1327 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1331 int UtcDaliActorSetX(void)
1333 TestApplication application;
1335 Actor actor = Actor::New();
1337 Vector3 vector(100.0f, 0.0f, 0.0f);
1339 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1343 // flush the queue and render once
1344 application.SendNotification();
1345 application.Render();
1347 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1351 int UtcDaliActorSetY(void)
1353 TestApplication application;
1355 Actor actor = Actor::New();
1357 Vector3 vector(0.0f, 100.0f, 0.0f);
1359 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1363 // flush the queue and render once
1364 application.SendNotification();
1365 application.Render();
1367 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1371 int UtcDaliActorSetZ(void)
1373 TestApplication application;
1375 Actor actor = Actor::New();
1377 Vector3 vector(0.0f, 0.0f, 100.0f);
1379 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1383 // flush the queue and render once
1384 application.SendNotification();
1385 application.Render();
1387 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1391 int UtcDaliActorSetPositionProperties(void)
1393 TestApplication application;
1395 Actor actor = Actor::New();
1397 Vector3 vector(0.7f, 0.8f, 0.9f);
1398 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1400 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1401 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1402 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1404 // flush the queue and render once
1405 application.SendNotification();
1406 application.Render();
1408 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1409 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1410 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1411 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1412 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1414 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1415 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1416 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1418 // flush the queue and render once
1419 application.SendNotification();
1420 application.Render();
1422 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1423 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1424 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1425 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1426 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1428 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1429 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1430 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1432 // flush the queue and render once
1433 application.SendNotification();
1434 application.Render();
1436 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1437 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1438 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1439 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1440 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1445 int UtcDaliActorTranslateBy(void)
1447 TestApplication application;
1449 Actor actor = Actor::New();
1450 Vector3 vector(100.0f, 100.0f, 100.0f);
1452 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1454 actor.SetPosition(vector);
1456 // flush the queue and render once
1457 application.SendNotification();
1458 application.Render();
1460 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1462 actor.TranslateBy(vector);
1464 // flush the queue and render once
1465 application.SendNotification();
1466 application.Render();
1468 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1472 int UtcDaliActorGetCurrentPosition(void)
1474 TestApplication application;
1476 Actor actor = Actor::New();
1477 Vector3 setVector(100.0f, 100.0f, 0.0f);
1478 actor.SetPosition(setVector);
1480 // flush the queue and render once
1481 application.SendNotification();
1482 application.Render();
1484 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1488 int UtcDaliActorGetCurrentWorldPosition(void)
1490 TestApplication application;
1492 Actor parent = Actor::New();
1493 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1494 parent.SetPosition( parentPosition );
1495 parent.SetParentOrigin( ParentOrigin::CENTER );
1496 parent.SetAnchorPoint( AnchorPoint::CENTER );
1497 Stage::GetCurrent().Add( parent );
1499 Actor child = Actor::New();
1500 child.SetParentOrigin( ParentOrigin::CENTER );
1501 child.SetAnchorPoint( AnchorPoint::CENTER );
1502 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1503 child.SetPosition( childPosition );
1504 parent.Add( child );
1506 // The actors should not have a world position yet
1507 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1508 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1510 application.SendNotification();
1511 application.Render(0);
1513 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1514 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1516 // The actors should have a world position now
1517 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1518 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1522 int UtcDaliActorInheritPosition(void)
1524 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1525 TestApplication application;
1527 Actor parent = Actor::New();
1528 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1529 parent.SetPosition( parentPosition );
1530 parent.SetParentOrigin( ParentOrigin::CENTER );
1531 parent.SetAnchorPoint( AnchorPoint::CENTER );
1532 Stage::GetCurrent().Add( parent );
1534 Actor child = Actor::New();
1535 child.SetParentOrigin( ParentOrigin::CENTER );
1536 child.SetAnchorPoint( AnchorPoint::CENTER );
1537 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1538 child.SetPosition( childPosition );
1539 parent.Add( child );
1541 // The actors should not have a world position yet
1542 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1543 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1545 // first test default, which is to inherit position
1546 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1547 application.SendNotification();
1548 application.Render(0); // should only really call Update as Render is not required to update scene
1549 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1550 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1551 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1552 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1555 //Change child position
1556 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1557 child.SetPosition( childOffset );
1559 // Change inheritance mode to not inherit
1560 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1561 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1562 application.SendNotification();
1563 application.Render(0); // should only really call Update as Render is not required to update scene
1564 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1565 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1566 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1567 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1571 int UtcDaliActorSetInheritPosition(void)
1573 tet_infoline("Testing Actor::SetInheritPosition");
1574 TestApplication application;
1576 Actor parent = Actor::New();
1577 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1578 parent.SetPosition( parentPosition );
1579 parent.SetParentOrigin( ParentOrigin::CENTER );
1580 parent.SetAnchorPoint( AnchorPoint::CENTER );
1581 Stage::GetCurrent().Add( parent );
1583 Actor child = Actor::New();
1584 child.SetParentOrigin( ParentOrigin::CENTER );
1585 child.SetAnchorPoint( AnchorPoint::CENTER );
1586 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1587 child.SetPosition( childPosition );
1588 parent.Add( child );
1590 // The actors should not have a world position yet
1591 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1592 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1594 // first test default, which is to inherit position
1595 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1596 application.SendNotification();
1597 application.Render(0); // should only really call Update as Render is not required to update scene
1598 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1599 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1600 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1601 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1603 //Change child position
1604 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1605 child.SetPosition( childOffset );
1607 // Use local position as world postion
1608 child.SetInheritPosition( false );
1609 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1610 application.SendNotification();
1611 application.Render(0); // should only really call Update as Render is not required to update scene
1612 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1613 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1614 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1615 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1617 //Change back to inherit position from parent
1618 child.SetInheritPosition( true );
1619 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1620 application.SendNotification();
1621 application.Render(0); // should only really call Update as Render is not required to update scene
1622 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1623 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1624 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1625 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1629 // SetOrientation(float angleRadians, Vector3 axis)
1630 int UtcDaliActorSetOrientation01(void)
1632 TestApplication application;
1634 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1635 Actor actor = Actor::New();
1637 actor.SetOrientation(rotation);
1639 // flush the queue and render once
1640 application.SendNotification();
1641 application.Render();
1643 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1647 int UtcDaliActorSetOrientation02(void)
1649 TestApplication application;
1651 Actor actor = Actor::New();
1653 Radian angle( 0.785f );
1654 Vector3 axis(1.0f, 1.0f, 0.0f);
1656 actor.SetOrientation( angle, axis);
1657 Quaternion rotation( angle, axis );
1658 // flush the queue and render once
1659 application.SendNotification();
1660 application.Render();
1661 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1663 Stage::GetCurrent().Add( actor );
1664 actor.RotateBy( Degree( 360 ), axis);
1665 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1667 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1668 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1669 // flush the queue and render once
1670 application.SendNotification();
1671 application.Render();
1672 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1674 actor.SetOrientation( 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().Remove( actor );
1684 // SetOrientation(float angleRadians, Vector3 axis)
1685 int UtcDaliActorSetOrientationProperty(void)
1687 TestApplication application;
1689 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1690 Actor actor = Actor::New();
1692 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1693 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1695 // flush the queue and render once
1696 application.SendNotification();
1697 application.Render();
1699 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1700 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1701 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1705 // RotateBy(float angleRadians, Vector3 axis)
1706 int UtcDaliActorRotateBy01(void)
1708 TestApplication application;
1710 Actor actor = Actor::New();
1712 Radian angle( M_PI * 0.25f );
1713 actor.RotateBy(( angle ), Vector3::ZAXIS);
1714 // flush the queue and render once
1715 application.SendNotification();
1716 application.Render();
1717 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1719 Stage::GetCurrent().Add( actor );
1721 actor.RotateBy( angle, Vector3::ZAXIS);
1722 // flush the queue and render once
1723 application.SendNotification();
1724 application.Render();
1725 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1727 Stage::GetCurrent().Remove( actor );
1731 // RotateBy(Quaternion relativeRotation)
1732 int UtcDaliActorRotateBy02(void)
1734 TestApplication application;
1736 Actor actor = Actor::New();
1738 Radian angle( M_PI * 0.25f );
1739 Quaternion rotation(angle, Vector3::ZAXIS);
1740 actor.RotateBy(rotation);
1741 // flush the queue and render once
1742 application.SendNotification();
1743 application.Render();
1744 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1746 actor.RotateBy(rotation);
1747 // flush the queue and render once
1748 application.SendNotification();
1749 application.Render();
1750 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1754 int UtcDaliActorGetCurrentOrientation(void)
1756 TestApplication application;
1757 Actor actor = Actor::New();
1759 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1760 actor.SetOrientation(rotation);
1761 // flush the queue and render once
1762 application.SendNotification();
1763 application.Render();
1764 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1768 int UtcDaliActorGetCurrentWorldOrientation(void)
1770 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1771 TestApplication application;
1773 Actor parent = Actor::New();
1774 Radian rotationAngle( Degree(90.0f) );
1775 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1776 parent.SetOrientation( rotation );
1777 Stage::GetCurrent().Add( parent );
1779 Actor child = Actor::New();
1780 child.SetOrientation( rotation );
1781 parent.Add( child );
1783 // The actors should not have a world rotation yet
1784 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1785 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1787 application.SendNotification();
1788 application.Render(0);
1790 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1791 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1793 // The actors should have a world rotation now
1794 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1795 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1797 // turn off child rotation inheritance
1798 child.SetInheritOrientation( false );
1799 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1800 application.SendNotification();
1801 application.Render(0);
1803 // The actors should have a world rotation now
1804 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1805 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1809 // SetScale(float scale)
1810 int UtcDaliActorSetScale01(void)
1812 TestApplication application;
1814 Actor actor = Actor::New();
1816 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1817 actor.SetScale(0.25f);
1819 Vector3 scale(10.0f, 10.0f, 10.0f);
1820 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1822 actor.SetScale(scale.x);
1824 // flush the queue and render once
1825 application.SendNotification();
1826 application.Render();
1828 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1832 // SetScale(float scaleX, float scaleY, float scaleZ)
1833 int UtcDaliActorSetScale02(void)
1835 TestApplication application;
1836 Vector3 scale(10.0f, 10.0f, 10.0f);
1838 Actor actor = Actor::New();
1840 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1841 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1843 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1845 actor.SetScale(scale.x, scale.y, scale.z);
1846 // flush the queue and render once
1847 application.SendNotification();
1848 application.Render();
1849 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1851 // add to stage and test
1852 Stage::GetCurrent().Add( actor );
1853 actor.SetScale( 2.0f, 2.0f, 2.0f );
1854 // flush the queue and render once
1855 application.SendNotification();
1856 application.Render();
1857 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1859 Stage::GetCurrent().Remove( actor );
1864 // SetScale(Vector3 scale)
1865 int UtcDaliActorSetScale03(void)
1867 TestApplication application;
1868 Vector3 scale(10.0f, 10.0f, 10.0f);
1870 Actor actor = Actor::New();
1872 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1873 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1875 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1877 actor.SetScale(scale);
1879 // flush the queue and render once
1880 application.SendNotification();
1881 application.Render();
1883 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1887 int UtcDaliActorSetScaleIndividual(void)
1889 TestApplication application;
1891 Actor actor = Actor::New();
1893 Vector3 vector(0.7f, 0.8f, 0.9f);
1894 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1896 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1897 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1899 // flush the queue and render once
1900 application.SendNotification();
1901 application.Render();
1903 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1904 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1905 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1907 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1908 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1910 // flush the queue and render once
1911 application.SendNotification();
1912 application.Render();
1914 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1915 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1916 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1918 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1919 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1921 // flush the queue and render once
1922 application.SendNotification();
1923 application.Render();
1925 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1926 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1927 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1929 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1930 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1935 int UtcDaliActorScaleBy(void)
1937 TestApplication application;
1938 Actor actor = Actor::New();
1939 Vector3 vector(100.0f, 100.0f, 100.0f);
1941 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1943 actor.SetScale(vector);
1945 // flush the queue and render once
1946 application.SendNotification();
1947 application.Render();
1949 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1951 actor.ScaleBy(vector);
1953 // flush the queue and render once
1954 application.SendNotification();
1955 application.Render();
1957 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1961 int UtcDaliActorGetCurrentScale(void)
1963 TestApplication application;
1964 Vector3 scale(12.0f, 1.0f, 2.0f);
1966 Actor actor = Actor::New();
1968 actor.SetScale(scale);
1970 // flush the queue and render once
1971 application.SendNotification();
1972 application.Render();
1974 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1978 int UtcDaliActorGetCurrentWorldScale(void)
1980 TestApplication application;
1982 Actor parent = Actor::New();
1983 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1984 parent.SetScale( parentScale );
1985 Stage::GetCurrent().Add( parent );
1987 Actor child = Actor::New();
1988 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1989 child.SetScale( childScale );
1990 parent.Add( child );
1992 // The actors should not have a scale yet
1993 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1994 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1996 // The actors should not have a world scale yet
1997 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1998 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
2000 application.SendNotification();
2001 application.Render(0);
2003 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
2004 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
2006 // The actors should have a world scale now
2007 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
2008 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2012 int UtcDaliActorInheritScale(void)
2014 tet_infoline("Testing Actor::SetInheritScale");
2015 TestApplication application;
2017 Actor parent = Actor::New();
2018 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2019 parent.SetScale( parentScale );
2020 Stage::GetCurrent().Add( parent );
2022 Actor child = Actor::New();
2023 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2024 child.SetScale( childScale );
2025 parent.Add( child );
2027 application.SendNotification();
2028 application.Render(0);
2030 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2031 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2033 child.SetInheritScale( false );
2034 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2036 application.SendNotification();
2037 application.Render(0);
2039 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2043 int UtcDaliActorSetVisible(void)
2045 TestApplication application;
2047 Actor actor = Actor::New();
2048 actor.SetVisible(false);
2049 // flush the queue and render once
2050 application.SendNotification();
2051 application.Render();
2052 DALI_TEST_CHECK(actor.IsVisible() == false);
2054 actor.SetVisible(true);
2055 // flush the queue and render once
2056 application.SendNotification();
2057 application.Render();
2058 DALI_TEST_CHECK(actor.IsVisible() == true);
2060 // put actor on stage
2061 Stage::GetCurrent().Add( actor );
2062 actor.SetVisible(false);
2063 // flush the queue and render once
2064 application.SendNotification();
2065 application.Render();
2066 DALI_TEST_CHECK(actor.IsVisible() == false);
2070 int UtcDaliActorIsVisible(void)
2072 TestApplication application;
2074 Actor actor = Actor::New();
2076 DALI_TEST_CHECK(actor.IsVisible() == true);
2080 int UtcDaliActorSetOpacity(void)
2082 TestApplication application;
2084 Actor actor = Actor::New();
2085 // initial opacity is 1
2086 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2088 actor.SetOpacity( 0.4f);
2089 // flush the queue and render once
2090 application.SendNotification();
2091 application.Render();
2092 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2094 // change opacity, actor is on stage to change is not immediate
2095 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2096 // flush the queue and render once
2097 application.SendNotification();
2098 application.Render();
2099 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2101 // put actor on stage
2102 Stage::GetCurrent().Add( actor );
2104 // change opacity, actor is on stage to change is not immediate
2105 actor.SetOpacity( 0.9f );
2106 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2107 // flush the queue and render once
2108 application.SendNotification();
2109 application.Render();
2110 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2112 // change opacity, actor is on stage to change is not immediate
2113 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2114 // flush the queue and render once
2115 application.SendNotification();
2116 application.Render();
2117 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2121 int UtcDaliActorGetCurrentOpacity(void)
2123 TestApplication application;
2125 Actor actor = Actor::New();
2126 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2128 actor.SetOpacity(0.5f);
2129 // flush the queue and render once
2130 application.SendNotification();
2131 application.Render();
2132 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2136 int UtcDaliActorSetSensitive(void)
2138 TestApplication application;
2139 Actor actor = Actor::New();
2141 bool sensitive = !actor.IsSensitive();
2143 actor.SetSensitive(sensitive);
2145 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2149 int UtcDaliActorIsSensitive(void)
2151 TestApplication application;
2152 Actor actor = Actor::New();
2153 actor.SetSensitive(false);
2155 DALI_TEST_CHECK(false == actor.IsSensitive());
2159 int UtcDaliActorSetColor(void)
2161 TestApplication application;
2162 Actor actor = Actor::New();
2163 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2165 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2167 actor.SetColor(color);
2168 // flush the queue and render once
2169 application.SendNotification();
2170 application.Render();
2171 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2173 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2174 // flush the queue and render once
2175 application.SendNotification();
2176 application.Render();
2177 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2179 Stage::GetCurrent().Add( actor );
2180 actor.SetColor( color );
2181 // flush the queue and render once
2182 application.SendNotification();
2183 application.Render();
2184 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2186 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2187 // flush the queue and render once
2188 application.SendNotification();
2189 application.Render();
2190 // Actor color is not clamped
2191 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2192 // world color is clamped
2193 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2195 Stage::GetCurrent().Remove( actor );
2199 int UtcDaliActorSetColorIndividual(void)
2201 TestApplication application;
2203 Actor actor = Actor::New();
2205 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2206 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2208 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2209 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2211 // flush the queue and render once
2212 application.SendNotification();
2213 application.Render();
2215 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2216 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2217 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2219 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2220 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2222 // flush the queue and render once
2223 application.SendNotification();
2224 application.Render();
2226 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2227 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2228 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2230 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2231 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2233 // flush the queue and render once
2234 application.SendNotification();
2235 application.Render();
2237 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2238 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2239 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2242 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2243 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2245 // flush the queue and render once
2246 application.SendNotification();
2247 application.Render();
2249 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2250 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2251 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2253 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2254 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2256 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2259 // flush the queue and render once
2260 application.SendNotification();
2261 application.Render();
2263 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2269 int UtcDaliActorGetCurrentColor(void)
2271 TestApplication application;
2272 Actor actor = Actor::New();
2273 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2275 actor.SetColor(color);
2276 // flush the queue and render once
2277 application.SendNotification();
2278 application.Render();
2279 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2283 int UtcDaliActorGetCurrentWorldColor(void)
2285 tet_infoline("Actor::GetCurrentWorldColor");
2286 TestApplication application;
2288 Actor parent = Actor::New();
2289 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2290 parent.SetColor( parentColor );
2291 Stage::GetCurrent().Add( parent );
2293 Actor child = Actor::New();
2294 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2295 child.SetColor( childColor );
2296 parent.Add( child );
2298 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2299 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2301 // verify the default color mode
2302 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2304 // The actors should not have a world color yet
2305 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2306 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2308 application.SendNotification();
2309 application.Render(0);
2311 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2312 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2314 // The actors should have a world color now
2315 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2316 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2319 child.SetColorMode( USE_OWN_COLOR );
2320 application.SendNotification();
2321 application.Render(0);
2322 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2325 child.SetColorMode( USE_PARENT_COLOR );
2326 application.SendNotification();
2327 application.Render(0);
2328 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2329 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2332 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2333 application.SendNotification();
2334 application.Render(0);
2335 Vector4 expectedColor( childColor );
2336 expectedColor.a *= parentColor.a;
2337 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2338 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2342 int UtcDaliActorSetColorMode(void)
2344 tet_infoline("Actor::SetColorMode");
2345 TestApplication application;
2346 Actor actor = Actor::New();
2347 Actor child = Actor::New();
2350 actor.SetColorMode( USE_OWN_COLOR );
2351 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2353 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2354 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2356 actor.SetColorMode( USE_PARENT_COLOR );
2357 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2359 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2360 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2364 int UtcDaliActorScreenToLocal(void)
2366 TestApplication application;
2367 Actor actor = Actor::New();
2368 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2369 actor.SetSize(100.0f, 100.0f);
2370 actor.SetPosition(10.0f, 10.0f);
2371 Stage::GetCurrent().Add(actor);
2373 // flush the queue and render once
2374 application.SendNotification();
2375 application.Render();
2380 application.SendNotification();
2381 application.Render();
2383 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2385 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2386 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2390 int UtcDaliActorSetLeaveRequired(void)
2392 TestApplication application;
2394 Actor actor = Actor::New();
2396 actor.SetLeaveRequired(false);
2397 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2399 actor.SetLeaveRequired(true);
2400 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2404 int UtcDaliActorGetLeaveRequired(void)
2406 TestApplication application;
2408 Actor actor = Actor::New();
2410 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2414 int UtcDaliActorSetKeyboardFocusable(void)
2416 TestApplication application;
2418 Actor actor = Actor::New();
2420 actor.SetKeyboardFocusable(true);
2421 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2423 actor.SetKeyboardFocusable(false);
2424 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2428 int UtcDaliActorIsKeyboardFocusable(void)
2430 TestApplication application;
2432 Actor actor = Actor::New();
2434 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2438 int UtcDaliActorRemoveConstraints(void)
2440 tet_infoline(" UtcDaliActorRemoveConstraints");
2441 TestApplication application;
2443 gTestConstraintCalled = false;
2445 Actor actor = Actor::New();
2447 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2449 actor.RemoveConstraints();
2451 DALI_TEST_CHECK( gTestConstraintCalled == false );
2453 Stage::GetCurrent().Add( actor );
2456 // flush the queue and render once
2457 application.SendNotification();
2458 application.Render();
2460 actor.RemoveConstraints();
2462 DALI_TEST_CHECK( gTestConstraintCalled == true );
2466 int UtcDaliActorRemoveConstraintTag(void)
2468 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2469 TestApplication application;
2471 Actor actor = Actor::New();
2473 // 1. Apply Constraint1 and Constraint2, and test...
2474 unsigned int result1 = 0u;
2475 unsigned int result2 = 0u;
2477 unsigned constraint1Tag = 1u;
2478 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2479 constraint1.SetTag( constraint1Tag );
2480 constraint1.Apply();
2482 unsigned constraint2Tag = 2u;
2483 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2484 constraint2.SetTag( constraint2Tag );
2485 constraint2.Apply();
2487 Stage::GetCurrent().Add( actor );
2488 // flush the queue and render once
2489 application.SendNotification();
2490 application.Render();
2492 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2493 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2495 // 2. Remove Constraint1 and test...
2498 actor.RemoveConstraints(constraint1Tag);
2499 // make color property dirty, which will trigger constraints to be reapplied.
2500 actor.SetColor( Color::WHITE );
2501 // flush the queue and render once
2502 application.SendNotification();
2503 application.Render();
2505 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2506 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2508 // 3. Re-Apply Constraint1 and test...
2511 constraint1.Apply();
2512 // make color property dirty, which will trigger constraints to be reapplied.
2513 actor.SetColor( Color::WHITE );
2514 // flush the queue and render once
2515 application.SendNotification();
2516 application.Render();
2518 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2519 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2521 // 2. Remove Constraint2 and test...
2524 actor.RemoveConstraints(constraint2Tag);
2525 // make color property dirty, which will trigger constraints to be reapplied.
2526 actor.SetColor( Color::WHITE );
2527 // flush the queue and render once
2528 application.SendNotification();
2529 application.Render();
2531 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2532 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2534 // 2. Remove Constraint1 as well and test...
2537 actor.RemoveConstraints(constraint1Tag);
2538 // make color property dirty, which will trigger constraints to be reapplied.
2539 actor.SetColor( Color::WHITE );
2540 // flush the queue and render once
2541 application.SendNotification();
2542 application.Render();
2544 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2545 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2549 int UtcDaliActorTouchedSignal(void)
2551 TestApplication application;
2553 ResetTouchCallbacks();
2555 // get the root layer
2556 Actor actor = Stage::GetCurrent().GetRootLayer();
2557 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2559 application.SendNotification();
2560 application.Render();
2562 // connect to its touch signal
2563 actor.TouchedSignal().Connect( TestCallback );
2565 // simulate a touch event in the middle of the screen
2566 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2567 Dali::Integration::Point point;
2568 point.SetDeviceId( 1 );
2569 point.SetState( PointState::DOWN );
2570 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2571 Dali::Integration::TouchEvent touchEvent;
2572 touchEvent.AddPoint( point );
2573 application.ProcessEvent( touchEvent );
2575 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2579 int UtcDaliActorHoveredSignal(void)
2581 TestApplication application;
2583 gHoverCallBackCalled = false;
2585 // get the root layer
2586 Actor actor = Stage::GetCurrent().GetRootLayer();
2587 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2589 application.SendNotification();
2590 application.Render();
2592 // connect to its hover signal
2593 actor.HoveredSignal().Connect( TestCallback3 );
2595 // simulate a hover event in the middle of the screen
2596 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2597 Dali::Integration::Point point;
2598 point.SetDeviceId( 1 );
2599 point.SetState( PointState::MOTION );
2600 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2601 Dali::Integration::HoverEvent hoverEvent;
2602 hoverEvent.AddPoint( point );
2603 application.ProcessEvent( hoverEvent );
2605 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2609 int UtcDaliActorOnOffStageSignal(void)
2611 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2613 TestApplication application;
2616 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2617 gActorNamesOnOffStage.clear();
2619 Actor parent = Actor::New();
2620 parent.SetName( "parent" );
2621 parent.OnStageSignal().Connect( OnStageCallback );
2622 parent.OffStageSignal().Connect( OffStageCallback );
2624 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2625 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2627 // add parent to stage
2628 Stage::GetCurrent().Add( parent );
2629 // onstage emitted, offstage not
2630 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2631 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2632 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2634 // test adding a child, should get onstage emitted
2636 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2637 gActorNamesOnOffStage.clear();
2639 Actor child = Actor::New();
2640 child.SetName( "child" );
2641 child.OnStageSignal().Connect( OnStageCallback );
2642 child.OffStageSignal().Connect( OffStageCallback );
2643 parent.Add( child ); // add child
2644 // onstage emitted, offstage not
2645 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2646 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2647 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2649 // test removing parent from stage
2651 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2652 gActorNamesOnOffStage.clear();
2654 Stage::GetCurrent().Remove( parent );
2655 // onstage not emitted, offstage is
2656 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2657 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2658 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2659 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2661 // test adding parent back to stage
2663 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2664 gActorNamesOnOffStage.clear();
2666 Stage::GetCurrent().Add( parent );
2667 // onstage emitted, offstage not
2668 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2669 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2670 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2671 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2673 // test removing child
2675 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2676 gActorNamesOnOffStage.clear();
2678 parent.Remove( child );
2679 // onstage not emitted, offstage is
2680 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2681 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2682 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2684 // test removing parent
2686 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2687 gActorNamesOnOffStage.clear();
2689 Stage::GetCurrent().Remove( parent );
2690 // onstage not emitted, offstage is
2691 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2692 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2693 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2697 int UtcDaliActorFindChildByName(void)
2699 tet_infoline("Testing Dali::Actor::FindChildByName()");
2700 TestApplication application;
2702 Actor parent = Actor::New();
2703 parent.SetName( "parent" );
2704 Actor first = Actor::New();
2705 first .SetName( "first" );
2706 Actor second = Actor::New();
2707 second.SetName( "second" );
2712 Actor found = parent.FindChildByName( "foo" );
2713 DALI_TEST_CHECK( !found );
2715 found = parent.FindChildByName( "parent" );
2716 DALI_TEST_CHECK( found == parent );
2718 found = parent.FindChildByName( "first" );
2719 DALI_TEST_CHECK( found == first );
2721 found = parent.FindChildByName( "second" );
2722 DALI_TEST_CHECK( found == second );
2726 int UtcDaliActorFindChildById(void)
2728 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2729 TestApplication application;
2731 Actor parent = Actor::New();
2732 Actor first = Actor::New();
2733 Actor second = Actor::New();
2738 Actor found = parent.FindChildById( 100000 );
2739 DALI_TEST_CHECK( !found );
2741 found = parent.FindChildById( parent.GetId() );
2742 DALI_TEST_CHECK( found == parent );
2744 found = parent.FindChildById( first.GetId() );
2745 DALI_TEST_CHECK( found == first );
2747 found = parent.FindChildById( second.GetId() );
2748 DALI_TEST_CHECK( found == second );
2752 int UtcDaliActorHitTest(void)
2757 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2759 mTouchPoint( touchPoint ),
2764 Vector2 mTouchPoint;
2768 TestApplication application;
2769 tet_infoline(" UtcDaliActorHitTest");
2771 // Fill a vector with different hit tests.
2772 struct HitTestData* hitTestData[] = {
2773 // scale touch point result
2774 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2775 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2776 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.
2777 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2778 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.
2782 // get the root layer
2783 Actor actor = Actor::New();
2784 actor.SetAnchorPoint( AnchorPoint::CENTER );
2785 actor.SetParentOrigin( ParentOrigin::CENTER );
2787 Stage::GetCurrent().Add( actor );
2789 ResetTouchCallbacks();
2791 unsigned int index = 0;
2792 while( NULL != hitTestData[index] )
2794 actor.SetSize( 1.f, 1.f );
2795 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2797 // flush the queue and render once
2798 application.SendNotification();
2799 application.Render();
2801 DALI_TEST_CHECK( !gTouchCallBackCalled );
2803 // connect to its touch signal
2804 actor.TouchedSignal().Connect(TestCallback);
2806 Dali::Integration::Point point;
2807 point.SetState( PointState::DOWN );
2808 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2809 Dali::Integration::TouchEvent event;
2810 event.AddPoint( point );
2812 // flush the queue and render once
2813 application.SendNotification();
2814 application.Render();
2815 application.ProcessEvent( event );
2817 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2819 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2820 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2821 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2822 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2823 hitTestData[index]->mResult );
2825 ResetTouchCallbacks();
2831 int UtcDaliActorSetDrawMode(void)
2833 TestApplication app;
2834 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2836 Actor a = Actor::New();
2838 Stage::GetCurrent().Add(a);
2839 app.SendNotification();
2841 app.SendNotification();
2844 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2846 a.SetDrawMode( DrawMode::OVERLAY_2D );
2847 app.SendNotification();
2850 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2852 a.SetDrawMode( DrawMode::NORMAL );
2853 app.SendNotification();
2856 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2860 int UtcDaliActorSetDrawModeOverlayRender(void)
2862 TestApplication app;
2863 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2865 app.SendNotification();
2868 std::vector<GLuint> ids;
2869 ids.push_back( 8 ); // first rendered actor
2870 ids.push_back( 9 ); // second rendered actor
2871 ids.push_back( 10 ); // third rendered actor
2872 app.GetGlAbstraction().SetNextTextureIds( ids );
2874 BufferImage imageA = BufferImage::New(16, 16);
2875 BufferImage imageB = BufferImage::New(16, 16);
2876 BufferImage imageC = BufferImage::New(16, 16);
2877 Actor a = CreateRenderableActor( imageA );
2878 Actor b = CreateRenderableActor( imageB );
2879 Actor c = CreateRenderableActor( imageC );
2881 app.SendNotification();
2884 //Textures are bound when first created. Clear bound textures vector
2885 app.GetGlAbstraction().ClearBoundTextures();
2887 // Render a,b,c as regular non-overlays. so order will be:
2891 Stage::GetCurrent().Add(a);
2892 Stage::GetCurrent().Add(b);
2893 Stage::GetCurrent().Add(c);
2895 app.SendNotification();
2898 // Should be 3 textures changes.
2899 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2900 typedef std::vector<GLuint>::size_type TextureSize;
2901 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2902 if( boundTextures.size() == 3 )
2904 DALI_TEST_CHECK( boundTextures[0] == 8u );
2905 DALI_TEST_CHECK( boundTextures[1] == 9u );
2906 DALI_TEST_CHECK( boundTextures[2] == 10u );
2909 // Now texture ids have been set, we can monitor their render order.
2910 // render a as an overlay (last), so order will be:
2914 a.SetDrawMode( DrawMode::OVERLAY_2D );
2915 app.GetGlAbstraction().ClearBoundTextures();
2917 app.SendNotification();
2920 // Should be 3 texture changes.
2921 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2922 if( boundTextures.size() == 3 )
2924 DALI_TEST_CHECK( boundTextures[0] == 9u );
2925 DALI_TEST_CHECK( boundTextures[1] == 10u );
2926 DALI_TEST_CHECK( boundTextures[2] == 8u );
2931 int UtcDaliActorGetCurrentWorldMatrix(void)
2933 TestApplication app;
2934 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2936 Actor parent = Actor::New();
2937 parent.SetParentOrigin(ParentOrigin::CENTER);
2938 parent.SetAnchorPoint(AnchorPoint::CENTER);
2939 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2940 Radian rotationAngle(Degree(85.0f));
2941 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2942 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2943 parent.SetPosition( parentPosition );
2944 parent.SetOrientation( parentRotation );
2945 parent.SetScale( parentScale );
2946 Stage::GetCurrent().Add( parent );
2948 Actor child = Actor::New();
2949 child.SetParentOrigin(ParentOrigin::CENTER);
2950 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2951 Radian childRotationAngle(Degree(23.0f));
2952 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2953 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2954 child.SetPosition( childPosition );
2955 child.SetOrientation( childRotation );
2956 child.SetScale( childScale );
2957 parent.Add( child );
2959 app.SendNotification();
2962 app.SendNotification();
2964 Matrix parentMatrix(false);
2965 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2967 Matrix childMatrix(false);
2968 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2970 //Child matrix should be the composition of child and parent
2971 Matrix childWorldMatrix(false);
2972 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2974 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2975 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2981 int UtcDaliActorConstrainedToWorldMatrix(void)
2983 TestApplication app;
2984 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2986 Actor parent = Actor::New();
2987 parent.SetParentOrigin(ParentOrigin::CENTER);
2988 parent.SetAnchorPoint(AnchorPoint::CENTER);
2989 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2990 Radian rotationAngle(Degree(85.0f));
2991 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2992 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2993 parent.SetPosition( parentPosition );
2994 parent.SetOrientation( parentRotation );
2995 parent.SetScale( parentScale );
2996 Stage::GetCurrent().Add( parent );
2998 Actor child = Actor::New();
2999 child.SetParentOrigin(ParentOrigin::CENTER);
3000 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3001 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3002 posConstraint.Apply();
3004 Stage::GetCurrent().Add( child );
3006 app.SendNotification();
3009 app.SendNotification();
3011 Matrix parentMatrix(false);
3012 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3014 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3015 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3019 int UtcDaliActorConstrainedToOrientation(void)
3021 TestApplication app;
3022 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3024 Actor parent = Actor::New();
3025 parent.SetParentOrigin(ParentOrigin::CENTER);
3026 parent.SetAnchorPoint(AnchorPoint::CENTER);
3027 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3028 Radian rotationAngle(Degree(85.0f));
3029 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3030 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3031 parent.SetPosition( parentPosition );
3032 parent.SetOrientation( parentRotation );
3033 parent.SetScale( parentScale );
3034 Stage::GetCurrent().Add( parent );
3036 Actor child = Actor::New();
3037 child.SetParentOrigin(ParentOrigin::CENTER);
3038 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3039 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3040 posConstraint.Apply();
3042 Stage::GetCurrent().Add( child );
3044 app.SendNotification();
3047 app.SendNotification();
3049 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3053 int UtcDaliActorConstrainedToOpacity(void)
3055 TestApplication app;
3056 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3058 Actor parent = Actor::New();
3059 parent.SetOpacity( 0.7f );
3060 Stage::GetCurrent().Add( parent );
3062 Actor child = Actor::New();
3063 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3064 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3065 opacityConstraint.Apply();
3067 Stage::GetCurrent().Add( child );
3069 app.SendNotification();
3072 app.SendNotification();
3074 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3076 parent.SetOpacity( 0.3f );
3078 app.SendNotification();
3081 app.SendNotification();
3083 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3088 int UtcDaliActorUnparent(void)
3090 TestApplication app;
3091 tet_infoline(" UtcDaliActorUnparent");
3093 Actor parent = Actor::New();
3094 Stage::GetCurrent().Add( parent );
3096 Actor child = Actor::New();
3098 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3099 DALI_TEST_CHECK( !child.GetParent() );
3101 // Test that calling Unparent with no parent is a NOOP
3104 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3105 DALI_TEST_CHECK( !child.GetParent() );
3107 // Test that Unparent works
3108 parent.Add( child );
3110 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3111 DALI_TEST_CHECK( parent == child.GetParent() );
3115 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3116 DALI_TEST_CHECK( !child.GetParent() );
3118 // Test that UnparentAndReset works
3119 parent.Add( child );
3121 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3122 DALI_TEST_CHECK( parent == child.GetParent() );
3124 UnparentAndReset( child );
3126 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3127 DALI_TEST_CHECK( !child );
3129 // Test that UnparentAndReset is a NOOP with empty handle
3130 UnparentAndReset( child );
3132 DALI_TEST_CHECK( !child );
3136 int UtcDaliActorGetChildAt(void)
3138 TestApplication app;
3139 tet_infoline(" UtcDaliActorGetChildAt");
3141 Actor parent = Actor::New();
3142 Stage::GetCurrent().Add( parent );
3144 Actor child0 = Actor::New();
3145 parent.Add( child0 );
3147 Actor child1 = Actor::New();
3148 parent.Add( child1 );
3150 Actor child2 = Actor::New();
3151 parent.Add( child2 );
3153 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3154 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3155 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3159 int UtcDaliActorSetGetOverlay(void)
3161 TestApplication app;
3162 tet_infoline(" UtcDaliActorSetGetOverlay");
3164 Actor parent = Actor::New();
3165 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3166 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3171 int UtcDaliActorCreateDestroy(void)
3173 Actor* actor = new Actor;
3174 DALI_TEST_CHECK( actor );
3181 struct PropertyStringIndex
3183 const char * const name;
3184 const Property::Index index;
3185 const Property::Type type;
3188 const PropertyStringIndex PROPERTY_TABLE[] =
3190 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3191 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3192 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3193 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3194 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3195 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3196 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3197 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3198 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3199 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3200 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3201 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3202 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3203 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3204 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3205 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3206 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3207 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3208 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3209 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3210 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3211 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3212 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3213 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3214 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3215 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3216 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3217 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3218 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3219 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3220 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3221 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3222 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3223 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3224 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3225 { "name", Actor::Property::NAME, Property::STRING },
3226 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3227 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3228 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3229 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3230 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3231 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3232 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3233 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3234 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3235 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3236 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3237 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3238 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3239 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3240 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3241 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3242 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3243 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3244 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3246 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3247 } // unnamed namespace
3249 int UtcDaliActorProperties(void)
3251 TestApplication app;
3253 Actor actor = Actor::New();
3255 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3257 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3258 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3259 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3260 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3265 int UtcDaliRelayoutProperties_ResizePolicies(void)
3267 TestApplication app;
3269 Actor actor = Actor::New();
3272 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3273 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3275 // Set resize policy for all dimensions
3276 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3277 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3279 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3282 // Set individual dimensions
3283 const char* const widthPolicy = "FILL_TO_PARENT";
3284 const char* const heightPolicy = "FIXED";
3286 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3287 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3289 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3290 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3292 // Set individual dimensions using enums
3293 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3294 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3296 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3297 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3299 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3300 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3305 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3307 TestApplication app;
3309 Actor actor = Actor::New();
3312 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3313 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3315 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3316 actor.SetSizeScalePolicy( policy );
3317 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3320 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3321 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3323 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3324 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3326 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3327 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3332 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3334 TestApplication app;
3336 Actor actor = Actor::New();
3339 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3340 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3342 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3343 actor.SetSizeModeFactor( sizeMode );
3344 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3347 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3349 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3350 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3355 int UtcDaliRelayoutProperties_DimensionDependency(void)
3357 TestApplication app;
3359 Actor actor = Actor::New();
3362 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3363 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3366 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3367 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3369 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3370 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3372 // Test setting another resize policy
3373 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3374 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3379 int UtcDaliRelayoutProperties_Padding(void)
3381 TestApplication app;
3383 Actor actor = Actor::New();
3386 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3389 actor.SetProperty( Actor::Property::PADDING, padding );
3390 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3392 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3397 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3399 TestApplication app;
3401 Actor actor = Actor::New();
3404 Vector2 minSize( 1.0f, 2.0f );
3406 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3407 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3409 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3411 Vector2 maxSize( 3.0f, 4.0f );
3413 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3414 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3416 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3421 int UtcDaliActorGetHeightForWidth(void)
3423 TestApplication app;
3425 Actor actor = Actor::New();
3427 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3432 int UtcDaliActorGetWidthForHeight(void)
3434 TestApplication app;
3436 Actor actor = Actor::New();
3438 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3443 int UtcDaliActorGetRelayoutSize(void)
3445 TestApplication app;
3447 Actor actor = Actor::New();
3449 // Add actor to stage
3450 Stage::GetCurrent().Add( actor );
3452 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3454 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3455 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3457 // Flush the queue and render once
3458 app.SendNotification();
3461 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3466 int UtcDaliActorSetPadding(void)
3468 TestApplication app;
3470 Actor actor = Actor::New();
3473 actor.GetPadding( padding );
3475 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3476 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3477 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3478 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3480 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3481 actor.SetPadding( padding2 );
3483 actor.GetPadding( padding );
3485 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3486 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3487 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3488 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3493 int UtcDaliActorSetMinimumSize(void)
3495 TestApplication app;
3497 Actor actor = Actor::New();
3499 Vector2 size = actor.GetMinimumSize();
3501 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3502 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3504 Vector2 size2( 1.0f, 2.0f );
3505 actor.SetMinimumSize( size2 );
3507 size = actor.GetMinimumSize();
3509 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3510 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3515 int UtcDaliActorSetMaximumSize(void)
3517 TestApplication app;
3519 Actor actor = Actor::New();
3521 Vector2 size = actor.GetMaximumSize();
3523 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3524 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3526 Vector2 size2( 1.0f, 2.0f );
3527 actor.SetMaximumSize( size2 );
3529 size = actor.GetMaximumSize();
3531 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3532 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3537 int UtcDaliActorOnRelayoutSignal(void)
3539 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3541 TestApplication application;
3544 gOnRelayoutCallBackCalled = false;
3545 gActorNamesRelayout.clear();
3547 Actor actor = Actor::New();
3548 actor.SetName( "actor" );
3549 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3552 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3554 // Add actor to stage
3555 Stage::GetCurrent().Add( actor );
3557 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3558 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3560 // Flush the queue and render once
3561 application.SendNotification();
3562 application.Render();
3564 // OnRelayout emitted
3565 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3566 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3571 int UtcDaliActorGetHierachyDepth(void)
3573 TestApplication application;
3574 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3577 /* Build tree of actors:
3587 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3589 Stage stage( Stage::GetCurrent() );
3591 Actor actorA = Actor::New();
3592 Actor actorB = Actor::New();
3593 Actor actorC = Actor::New();
3594 Actor actorD = Actor::New();
3595 Actor actorE = Actor::New();
3596 Actor actorF = Actor::New();
3598 //Test that root actor has depth equal 0
3599 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3601 //Test actors return depth -1 when not connected to the tree
3602 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3603 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3604 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3605 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3606 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3607 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3609 //Create the hierarchy
3610 stage.Add( actorA );
3611 actorA.Add( actorB );
3612 actorA.Add( actorC );
3613 actorB.Add( actorD );
3614 actorB.Add( actorE );
3615 actorC.Add( actorF );
3617 //Test actors return correct depth
3618 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3619 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3620 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3621 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3622 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3623 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3625 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3626 actorA.Remove( actorB );
3628 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3629 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3630 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3632 //Removing actorA from the stage. All actors should have depth equal -1
3633 stage.Remove( actorA );
3635 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3636 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3637 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3638 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3639 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3640 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3645 int UtcDaliActorAnchorPointPropertyAsString(void)
3647 TestApplication application;
3649 Actor actor = Actor::New();
3651 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3652 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3654 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3655 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3657 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3658 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3660 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3661 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3663 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3664 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3666 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3667 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3669 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3670 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3672 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3673 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3675 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3676 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3678 // Invalid should not change anything
3679 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3680 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3685 int UtcDaliActorParentOriginPropertyAsString(void)
3687 TestApplication application;
3689 Actor actor = Actor::New();
3691 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3692 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3694 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3695 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3697 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3698 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3700 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3701 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3703 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3704 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3706 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3707 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3709 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3710 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3712 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3713 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3715 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3716 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3718 // Invalid should not change anything
3719 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3720 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3725 int UtcDaliActorColorModePropertyAsString(void)
3727 TestApplication application;
3729 Actor actor = Actor::New();
3731 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3732 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3734 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3735 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3737 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3738 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3740 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3741 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3743 // Invalid should not change anything
3744 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3745 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3750 int UtcDaliActorPositionInheritancePropertyAsString(void)
3752 TestApplication application;
3754 Actor actor = Actor::New();
3756 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3757 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3759 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3760 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3762 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3763 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3765 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3766 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3768 // Invalid should not change anything
3769 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3770 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3775 int UtcDaliActorDrawModePropertyAsString(void)
3777 TestApplication application;
3779 Actor actor = Actor::New();
3781 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3782 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3784 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3785 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3787 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3788 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3790 // Invalid should not change anything
3791 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3792 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3797 int UtcDaliActorColorModePropertyAsEnum(void)
3799 TestApplication application;
3801 Actor actor = Actor::New();
3803 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3804 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3806 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3807 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3809 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3810 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3812 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3813 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3818 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3820 TestApplication application;
3822 Actor actor = Actor::New();
3824 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3825 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3827 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3828 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3830 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3831 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3833 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3834 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3839 int UtcDaliActorDrawModePropertyAsEnum(void)
3841 TestApplication application;
3843 Actor actor = Actor::New();
3845 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3846 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3848 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3849 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3851 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3852 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3857 int UtcDaliActorAddRendererP(void)
3859 tet_infoline("Testing Actor::AddRenderer");
3860 TestApplication application;
3862 Actor actor = Actor::New();
3864 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3866 Geometry geometry = CreateQuadGeometry();
3867 Shader shader = CreateShader();
3868 Renderer renderer = Renderer::New(geometry, shader);
3870 actor.AddRenderer( renderer );
3871 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3872 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3877 int UtcDaliActorAddRendererN(void)
3879 tet_infoline("Testing Actor::AddRenderer");
3880 TestApplication application;
3882 Actor actor = Actor::New();
3888 actor.AddRenderer( renderer );
3889 tet_printf("Assertion test failed - no Exception\n" );
3890 tet_result(TET_FAIL);
3892 catch(Dali::DaliException& e)
3894 DALI_TEST_PRINT_ASSERT( e );
3895 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3896 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3900 tet_printf("Assertion test failed - wrong Exception\n" );
3901 tet_result(TET_FAIL);
3907 int UtcDaliActorAddRendererOnStage(void)
3909 tet_infoline("Testing Actor::AddRenderer");
3910 TestApplication application;
3912 Actor actor = Actor::New();
3913 Stage::GetCurrent().Add(actor);
3915 application.SendNotification();
3916 application.Render(0);
3918 Geometry geometry = CreateQuadGeometry();
3919 Shader shader = CreateShader();
3920 Renderer renderer = Renderer::New(geometry, shader);
3922 application.SendNotification();
3923 application.Render(0);
3927 actor.AddRenderer( renderer );
3928 tet_result(TET_PASS);
3932 tet_result(TET_FAIL);
3938 int UtcDaliActorRemoveRendererP1(void)
3940 tet_infoline("Testing Actor::RemoveRenderer");
3941 TestApplication application;
3943 Actor actor = Actor::New();
3945 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3948 Geometry geometry = CreateQuadGeometry();
3949 Shader shader = CreateShader();
3950 Renderer renderer = Renderer::New(geometry, shader);
3952 actor.AddRenderer( renderer );
3953 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3954 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3956 application.SendNotification();
3957 application.Render();
3961 Renderer renderer = actor.GetRendererAt(0);
3962 actor.RemoveRenderer(renderer);
3963 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3965 application.SendNotification();
3966 application.Render();
3969 // Call one final time to ensure that the renderer is actually removed after
3970 // the handle goes out of scope, and excercises the deletion code path in
3971 // scene graph and render.
3972 application.SendNotification();
3973 application.Render();
3978 int UtcDaliActorRemoveRendererP2(void)
3980 tet_infoline("Testing Actor::RemoveRenderer");
3981 TestApplication application;
3983 Actor actor = Actor::New();
3985 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3987 Geometry geometry = CreateQuadGeometry();
3988 Shader shader = CreateShader();
3989 Renderer renderer = Renderer::New(geometry, shader);
3991 actor.AddRenderer( renderer );
3992 application.SendNotification();
3993 application.Render();
3995 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3996 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3998 actor.RemoveRenderer(0);
3999 application.SendNotification();
4000 application.Render();
4002 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4004 // Shut down whilst holding onto the renderer handle.
4009 int UtcDaliActorRemoveRendererN(void)
4011 tet_infoline("Testing Actor::RemoveRenderer");
4012 TestApplication application;
4014 Actor actor = Actor::New();
4016 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4018 Geometry geometry = CreateQuadGeometry();
4019 Shader shader = CreateShader();
4020 Renderer renderer = Renderer::New(geometry, shader);
4022 actor.AddRenderer( renderer );
4023 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4024 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4026 actor.RemoveRenderer(10);
4027 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4028 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4033 // Clipping test helper functions:
4034 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4036 BufferImage image = BufferImage::New( width, height );
4037 Actor actor = CreateRenderableActor( image );
4039 // Setup dimensions and position so actor is not skipped by culling.
4040 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4041 actor.SetSize( width, height );
4042 actor.SetParentOrigin( ParentOrigin::CENTER );
4043 actor.SetAnchorPoint( AnchorPoint::CENTER );
4048 Actor CreateActorWithContent16x16()
4050 return CreateActorWithContent( 16, 16 );
4053 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4055 enabledDisableTrace.Reset();
4056 stencilTrace.Reset();
4057 enabledDisableTrace.Enable( true );
4058 stencilTrace.Enable( true );
4060 application.SendNotification();
4061 application.Render();
4063 enabledDisableTrace.Enable( false );
4064 stencilTrace.Enable( false );
4067 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4069 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4071 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4072 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4073 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4074 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4077 int UtcDaliActorPropertyClippingP(void)
4079 // This test checks the clippingMode property.
4080 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4081 TestApplication application;
4083 Actor actor = Actor::New();
4085 // Check default clippingEnabled value.
4086 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4089 bool getValueResult = getValue.Get( value );
4090 DALI_TEST_CHECK( getValueResult );
4092 if( getValueResult )
4094 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4097 // Check setting the property to the stencil mode.
4098 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4100 // Check the new value was set.
4101 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4102 getValueResult = getValue.Get( value );
4103 DALI_TEST_CHECK( getValueResult );
4105 if( getValueResult )
4107 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4110 // Check setting the property to the scissor mode.
4111 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4113 // Check the new value was set.
4114 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4115 getValueResult = getValue.Get( value );
4116 DALI_TEST_CHECK( getValueResult );
4118 if( getValueResult )
4120 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4125 int UtcDaliActorPropertyClippingN(void)
4127 // Negative test case for Clipping.
4128 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4129 TestApplication application;
4131 Actor actor = Actor::New();
4133 // Check default clippingEnabled value.
4134 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4137 bool getValueResult = getValue.Get( value );
4138 DALI_TEST_CHECK( getValueResult );
4140 if( getValueResult )
4142 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4145 // Check setting an invalid property value won't change the current property value.
4146 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4148 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4149 getValueResult = getValue.Get( value );
4150 DALI_TEST_CHECK( getValueResult );
4152 if( getValueResult )
4154 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4160 int UtcDaliActorPropertyClippingActor(void)
4162 // This test checks that an actor is correctly setup for clipping.
4163 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4164 TestApplication application;
4166 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4167 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4168 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4169 size_t startIndex = 0u;
4171 // Create a clipping actor.
4172 Actor actorDepth1Clip = CreateActorWithContent16x16();
4173 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4174 Stage::GetCurrent().Add( actorDepth1Clip );
4176 // Gather the call trace.
4177 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4179 // Check we are writing to the color buffer.
4180 CheckColorMask( glAbstraction, true );
4182 // Check the stencil buffer was enabled.
4183 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4185 // Check the stencil buffer was cleared.
4186 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4188 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4189 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4190 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4191 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4196 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4198 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4199 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4200 TestApplication application;
4202 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4203 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4204 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4205 size_t startIndex = 0u;
4207 // Create a clipping actor.
4208 Actor actorDepth1Clip = CreateActorWithContent16x16();
4209 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4210 Stage::GetCurrent().Add( actorDepth1Clip );
4212 // Gather the call trace.
4213 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4215 // Check we are writing to the color buffer.
4216 CheckColorMask( glAbstraction, true );
4218 // Check the stencil buffer was enabled.
4219 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4221 // Check the stencil buffer was cleared.
4222 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4224 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4225 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4226 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4227 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4229 // Now disable the clipping
4230 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4232 // Gather the call trace.
4233 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4235 // Check the stencil buffer was disabled.
4236 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4238 // Ensure all values in stencil-mask are set to 1.
4240 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4245 int UtcDaliActorPropertyClippingNestedChildren(void)
4247 // This test checks that a hierarchy of actors are clipped correctly by
4248 // writing to and reading from the correct bit-planes of the stencil buffer.
4249 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4250 TestApplication application;
4251 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4252 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4253 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4255 // Create a clipping actor.
4256 Actor actorDepth1Clip = CreateActorWithContent16x16();
4257 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4258 Stage::GetCurrent().Add( actorDepth1Clip );
4260 // Create a child actor.
4261 Actor childDepth2 = CreateActorWithContent16x16();
4262 actorDepth1Clip.Add( childDepth2 );
4264 // Create another clipping actor.
4265 Actor childDepth2Clip = CreateActorWithContent16x16();
4266 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4267 childDepth2.Add( childDepth2Clip );
4269 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4270 // This tests the sort algorithm.
4271 Actor childDepth3 = CreateActorWithContent16x16();
4272 childDepth2Clip.Add( childDepth3 );
4273 Actor childDepth4 = CreateActorWithContent16x16();
4274 childDepth3.Add( childDepth4 );
4276 // Gather the call trace.
4277 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4279 // Check we are writing to the color buffer.
4280 CheckColorMask( glAbstraction, true );
4282 // Check the stencil buffer was enabled.
4283 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4285 // Perform the test twice, once for 2D layer, and once for 3D.
4286 for( unsigned int i = 0u ; i < 2u; ++i )
4288 size_t startIndex = 0u;
4290 // Check the stencil buffer was cleared.
4291 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4293 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4294 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4295 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4296 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4298 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4299 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4300 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4302 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4303 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4304 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4305 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4307 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4308 // (Both must be set to pass the check).
4309 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4310 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4312 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4315 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4316 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4323 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4325 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4326 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4327 TestApplication application;
4328 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4329 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4331 /* We create a small tree of actors as follows:
4335 Clipping enabled -> B D
4339 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4342 for( int i = 0; i < 5; ++i )
4344 BufferImage image = BufferImage::New( 16u, 16u );
4345 Actor actor = CreateRenderableActor( image );
4347 // Setup dimensions and position so actor is not skipped by culling.
4348 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4349 actor.SetSize( 16.0f, 16.0f );
4353 actor.SetParentOrigin( ParentOrigin::CENTER );
4357 float b = i > 2 ? 1.0f : -1.0f;
4358 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4364 // Enable clipping on the actor at the top of the left branch.
4365 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4367 // Build the scene graph.
4368 Stage::GetCurrent().Add( actors[0] );
4371 actors[0].Add( actors[1] );
4372 actors[1].Add( actors[2] );
4375 actors[0].Add( actors[3] );
4376 actors[3].Add( actors[4] );
4378 // Gather the call trace.
4379 enabledDisableTrace.Reset();
4380 enabledDisableTrace.Enable( true );
4381 application.SendNotification();
4382 application.Render();
4383 enabledDisableTrace.Enable( false );
4385 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4387 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
4388 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4390 size_t startIndex = 0u;
4391 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4392 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4393 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4395 // Swap the clipping actor from top of left branch to top of right branch.
4396 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4397 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4399 // Gather the call trace.
4400 enabledDisableTrace.Reset();
4401 enabledDisableTrace.Enable( true );
4402 application.SendNotification();
4403 application.Render();
4404 enabledDisableTrace.Enable( false );
4406 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4407 // This proves the draw order has remained the same.
4409 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4410 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4415 int UtcDaliActorPropertyScissorClippingActor(void)
4417 // This test checks that an actor is correctly setup for clipping.
4418 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4419 TestApplication application;
4421 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4422 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4423 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4425 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4426 const Vector2 imageSize( 16.0f, 16.0f );
4428 // Create a clipping actor.
4429 Actor clippingActorA = CreateActorWithContent16x16();
4430 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4431 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4432 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4433 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4434 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4435 Stage::GetCurrent().Add( clippingActorA );
4437 // Gather the call trace.
4438 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4440 // Check we are writing to the color buffer.
4441 CheckColorMask( glAbstraction, true );
4443 // Check scissor test was enabled.
4444 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4446 // Check the scissor was set, and the coordinates are correct.
4447 std::stringstream compareParametersString;
4448 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4449 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4451 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4452 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4454 // Gather the call trace.
4455 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4457 // Check the scissor was set, and the coordinates are correct.
4458 compareParametersString.str( std::string() );
4459 compareParametersString.clear();
4460 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4461 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4466 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4468 // This test checks that an actor is correctly setup for clipping.
4469 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4470 TestApplication application;
4473 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4474 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4475 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4477 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4478 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4479 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4481 // Create a clipping actors.
4482 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4483 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4485 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4486 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4487 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4489 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4490 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4491 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4493 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4494 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4496 Stage::GetCurrent().Add( clippingActorA );
4497 Stage::GetCurrent().Add( clippingActorB );
4499 // Gather the call trace.
4500 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4502 // Check we are writing to the color buffer.
4503 CheckColorMask( glAbstraction, true );
4505 // Check scissor test was enabled.
4506 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4508 // Check the scissor was set, and the coordinates are correct.
4509 std::stringstream compareParametersString;
4511 std::string clipA( "0, 500, 480, 200" );
4512 std::string clipB( "0, 380, 480, 40" );
4514 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4515 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4520 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4522 // This test checks that an actor is correctly setup for clipping.
4523 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4524 TestApplication application;
4526 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4527 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4528 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4530 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4531 const Vector2 imageSize( 16.0f, 16.0f );
4533 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4535 A is drawn first - with scissor clipping on
4536 B is drawn second - also with scissor clipping on
4537 C is the generated clipping region, the intersection ( A ∩ B )
4541 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4542 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4543 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4547 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4550 // Create a clipping actor.
4551 Actor clippingActorA = CreateActorWithContent16x16();
4552 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4553 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4554 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4555 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4556 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4557 Stage::GetCurrent().Add( clippingActorA );
4559 // Create a child clipping actor.
4560 Actor clippingActorB = CreateActorWithContent16x16();
4561 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4562 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4563 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4564 clippingActorA.Add( clippingActorB );
4566 // positionModifiers is an array of positions to position B around.
4567 // expect is an array of expected scissor clip coordinate results.
4568 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4569 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4571 // Loop through each overlap combination.
4572 for( unsigned int test = 0u; test < 4u; ++test )
4574 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4575 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4576 clippingActorB.SetPosition( position.x, position.y );
4578 // Gather the call trace.
4579 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4581 // Check we are writing to the color buffer.
4582 CheckColorMask( glAbstraction, true );
4584 // Check scissor test was enabled.
4585 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4587 // Check the scissor was set, and the coordinates are correct.
4588 const Vector4& expectResults( expect[test] );
4589 std::stringstream compareParametersString;
4590 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4591 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4597 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4599 // This test checks that an actor is correctly setup for clipping.
4600 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4601 TestApplication application;
4603 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4604 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4605 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4607 /* Create a nest of 2 scissors and siblings of the parent.
4617 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4618 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4619 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4620 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4621 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4622 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4624 // Create a clipping actors.
4625 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4626 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4627 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4628 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4629 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4631 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4632 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4633 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4635 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4636 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4637 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4639 clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4640 clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4641 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4643 clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4644 clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4645 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4647 clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4648 clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4650 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4651 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4652 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4653 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4654 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4656 Stage::GetCurrent().Add( clippingActorA );
4657 clippingActorA.Add( clippingActorB );
4658 Stage::GetCurrent().Add( clippingActorC );
4659 Stage::GetCurrent().Add( clippingActorD );
4660 clippingActorD.Add( clippingActorE );
4662 // Gather the call trace.
4663 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4665 // Check we are writing to the color buffer.
4666 CheckColorMask( glAbstraction, true );
4668 // Check scissor test was enabled.
4669 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4671 // Check the scissor was set, and the coordinates are correct.
4672 std::string clipA( "0, 500, 480, 200" );
4673 std::string clipB( "0, 580, 480, 40" );
4674 std::string clipC( "0, 200, 480, 200" );
4675 std::string clipD( "0, 300, 480, 200" );
4677 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4678 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4679 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4680 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4681 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4686 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4688 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4689 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4690 TestApplication application;
4692 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4693 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4694 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4696 // Create a clipping actor.
4697 Actor actorDepth1Clip = CreateActorWithContent16x16();
4698 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4699 Stage::GetCurrent().Add( actorDepth1Clip );
4701 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4702 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4704 // Gather the call trace.
4705 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4707 // Check we are writing to the color buffer.
4708 CheckColorMask( glAbstraction, true );
4710 // Check the stencil buffer was not enabled.
4711 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4713 // Check stencil functions are not called.
4714 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4715 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4716 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4718 // Check that scissor clipping is overriden by the renderer properties.
4719 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4721 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4723 // Gather the call trace.
4724 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4726 // Check the stencil buffer was not enabled.
4727 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4729 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4734 int UtcDaliGetPropertyN(void)
4736 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4737 TestApplication app;
4739 Actor actor = Actor::New();
4741 unsigned int propertyCount = actor.GetPropertyCount();
4742 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4746 int UtcDaliActorRaiseLower(void)
4748 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4750 TestApplication application;
4752 Stage stage( Stage::GetCurrent() );
4754 Actor actorA = Actor::New();
4755 Actor actorB = Actor::New();
4756 Actor actorC = Actor::New();
4758 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4759 actorA.SetParentOrigin( ParentOrigin::CENTER );
4761 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4762 actorB.SetParentOrigin( ParentOrigin::CENTER );
4764 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4765 actorC.SetParentOrigin( ParentOrigin::CENTER );
4767 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4768 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4770 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4771 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4773 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4774 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4776 stage.Add( actorA );
4777 stage.Add( actorB );
4778 stage.Add( actorC );
4780 ResetTouchCallbacks();
4782 application.SendNotification();
4783 application.Render();
4785 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4786 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4787 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4789 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4790 // Only top actor will get touched.
4791 actorA.TouchSignal().Connect( TestTouchCallback );
4792 actorB.TouchSignal().Connect( TestTouchCallback2 );
4793 actorC.TouchSignal().Connect( TestTouchCallback3 );
4795 Dali::Integration::Point point;
4796 point.SetDeviceId( 1 );
4797 point.SetState( PointState::DOWN );
4798 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4799 Dali::Integration::TouchEvent touchEvent;
4800 touchEvent.AddPoint( point );
4802 application.ProcessEvent( touchEvent );
4804 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4805 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4806 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4808 ResetTouchCallbacks();
4810 tet_printf( "Testing Raising of Actor\n" );
4812 int preActorOrder( 0 );
4813 int postActorOrder( 0 );
4815 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4816 value.Get( preActorOrder );
4819 // Ensure sort order is calculated before next touch event
4820 application.SendNotification();
4822 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4823 value.Get( postActorOrder );
4825 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4827 application.ProcessEvent( touchEvent );
4829 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4830 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4831 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4833 ResetTouchCallbacks();
4835 tet_printf( "Testing Lowering of Actor\n" );
4837 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4838 value.Get( preActorOrder );
4841 application.SendNotification(); // ensure sort order calculated before next touch event
4843 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4844 value.Get( postActorOrder );
4846 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4848 application.ProcessEvent( touchEvent );
4850 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4851 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4852 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4854 ResetTouchCallbacks();
4859 int UtcDaliActorRaiseToTopLowerToBottom(void)
4861 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4863 TestApplication application;
4865 Stage stage( Stage::GetCurrent() );
4867 Actor actorA = Actor::New();
4868 Actor actorB = Actor::New();
4869 Actor actorC = Actor::New();
4871 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4872 // enables checking of which actor the uniform is assigned too
4873 Shader shaderA = CreateShader();
4874 shaderA.RegisterProperty( "uRendererColor",1.f);
4876 Shader shaderB = CreateShader();
4877 shaderB.RegisterProperty( "uRendererColor", 2.f );
4879 Shader shaderC = CreateShader();
4880 shaderC.RegisterProperty( "uRendererColor", 3.f );
4882 Geometry geometry = CreateQuadGeometry();
4884 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4885 Renderer rendererA = Renderer::New(geometry, shaderA);
4886 actorA.AddRenderer(rendererA);
4888 Renderer rendererB = Renderer::New(geometry, shaderB);
4889 actorB.AddRenderer(rendererB);
4891 Renderer rendererC = Renderer::New(geometry, shaderC);
4892 actorC.AddRenderer(rendererC);
4894 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4895 actorA.SetParentOrigin( ParentOrigin::CENTER );
4897 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4898 actorB.SetParentOrigin( ParentOrigin::CENTER );
4900 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4901 actorC.SetParentOrigin( ParentOrigin::CENTER );
4903 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4904 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4906 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4907 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4909 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4910 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4912 stage.Add( actorA );
4913 stage.Add( actorB );
4914 stage.Add( actorC );
4916 ResetTouchCallbacks();
4918 // Set up gl abstraction trace so can query the set uniform order
4919 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4920 glAbstraction.EnableSetUniformCallTrace(true);
4921 glAbstraction.ResetSetUniformCallStack();
4923 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4925 application.SendNotification();
4926 application.Render();
4928 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4931 // Test order of uniforms in stack
4932 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4933 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4934 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4936 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4938 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4940 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4941 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4942 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4944 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4945 // Only top actor will get touched.
4946 actorA.TouchSignal().Connect( TestTouchCallback );
4947 actorB.TouchSignal().Connect( TestTouchCallback2 );
4948 actorC.TouchSignal().Connect( TestTouchCallback3 );
4950 Dali::Integration::Point point;
4951 point.SetDeviceId( 1 );
4952 point.SetState( PointState::DOWN );
4953 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4954 Dali::Integration::TouchEvent touchEvent;
4955 touchEvent.AddPoint( point );
4957 application.ProcessEvent( touchEvent );
4959 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4960 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4961 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4963 ResetTouchCallbacks();
4965 tet_printf( "RaiseToTop ActorA\n" );
4967 actorA.RaiseToTop();
4968 application.SendNotification(); // ensure sorting order is calculated before next touch event
4970 application.ProcessEvent( touchEvent );
4972 glAbstraction.ResetSetUniformCallStack();
4973 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4975 application.SendNotification();
4976 application.Render();
4978 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4980 // Test order of uniforms in stack
4981 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4982 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4983 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4985 tet_infoline( "Testing A above C and B at bottom\n" );
4986 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4988 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4990 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4991 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4992 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4994 ResetTouchCallbacks();
4996 tet_printf( "RaiseToTop ActorB\n" );
4998 actorB.RaiseToTop();
4999 application.SendNotification(); // Ensure sort order is calculated before next touch event
5001 application.ProcessEvent( touchEvent );
5003 glAbstraction.ResetSetUniformCallStack();
5004 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5006 application.SendNotification();
5007 application.Render();
5009 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5011 // Test order of uniforms in stack
5012 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5013 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5014 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5016 tet_infoline( "Testing B above A and C at bottom\n" );
5017 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5019 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5021 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5022 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5023 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5025 ResetTouchCallbacks();
5027 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5029 actorA.LowerToBottom();
5030 application.SendNotification();
5031 application.Render();
5033 actorB.LowerToBottom();
5034 application.SendNotification();
5035 application.Render();
5037 application.ProcessEvent( touchEvent );
5039 glAbstraction.ResetSetUniformCallStack();
5040 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5042 application.SendNotification();
5043 application.Render();
5045 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5047 // Test order of uniforms in stack
5048 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5049 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5050 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5052 tet_infoline( "Testing C above A and B at bottom\n" );
5053 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5055 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5057 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5058 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5059 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5061 ResetTouchCallbacks();
5066 int UtcDaliActorRaiseAbove(void)
5068 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5070 TestApplication application;
5072 Stage stage( Stage::GetCurrent() );
5074 Actor actorA = Actor::New();
5075 Actor actorB = Actor::New();
5076 Actor actorC = Actor::New();
5078 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5079 actorA.SetParentOrigin( ParentOrigin::CENTER );
5081 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5082 actorB.SetParentOrigin( ParentOrigin::CENTER );
5084 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5085 actorC.SetParentOrigin( ParentOrigin::CENTER );
5087 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5088 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5090 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5091 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5093 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5094 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5096 stage.Add( actorA );
5097 stage.Add( actorB );
5098 stage.Add( actorC );
5100 ResetTouchCallbacks();
5102 application.SendNotification();
5103 application.Render();
5105 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5106 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5107 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5109 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5110 // Only top actor will get touched.
5111 actorA.TouchSignal().Connect( TestTouchCallback );
5112 actorB.TouchSignal().Connect( TestTouchCallback2 );
5113 actorC.TouchSignal().Connect( TestTouchCallback3 );
5115 Dali::Integration::Point point;
5116 point.SetDeviceId( 1 );
5117 point.SetState( PointState::DOWN );
5118 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5119 Dali::Integration::TouchEvent touchEvent;
5120 touchEvent.AddPoint( point );
5122 application.ProcessEvent( touchEvent );
5124 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5125 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5126 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5128 ResetTouchCallbacks();
5130 tet_printf( "Raise actor B Above Actor C\n" );
5132 actorB.RaiseAbove( actorC );
5133 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5134 application.SendNotification();
5136 application.ProcessEvent( touchEvent );
5138 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5139 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5140 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5142 ResetTouchCallbacks();
5144 tet_printf( "Raise actor A Above Actor B\n" );
5146 actorA.RaiseAbove( actorB );
5148 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5149 application.SendNotification();
5151 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5153 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5154 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5155 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5157 ResetTouchCallbacks();
5162 int UtcDaliActorLowerBelow(void)
5164 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5166 TestApplication application;
5168 Stage stage( Stage::GetCurrent() );
5170 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5171 // enables checking of which actor the uniform is assigned too
5172 Shader shaderA = CreateShader();
5173 shaderA.RegisterProperty( "uRendererColor",1.f);
5175 Shader shaderB = CreateShader();
5176 shaderB.RegisterProperty( "uRendererColor", 2.f );
5178 Shader shaderC = CreateShader();
5179 shaderC.RegisterProperty( "uRendererColor", 3.f );
5181 Actor actorA = Actor::New();
5182 Actor actorB = Actor::New();
5183 Actor actorC = Actor::New();
5185 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5186 Geometry geometry = CreateQuadGeometry();
5188 Renderer rendererA = Renderer::New(geometry, shaderA);
5189 actorA.AddRenderer(rendererA);
5191 Renderer rendererB = Renderer::New(geometry, shaderB);
5192 actorB.AddRenderer(rendererB);
5194 Renderer rendererC = Renderer::New(geometry, shaderC);
5195 actorC.AddRenderer(rendererC);
5197 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5198 actorA.SetParentOrigin( ParentOrigin::CENTER );
5200 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5201 actorB.SetParentOrigin( ParentOrigin::CENTER );
5203 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5204 actorC.SetParentOrigin( ParentOrigin::CENTER );
5206 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5207 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5209 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5210 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5212 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5213 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5215 Actor container = Actor::New();
5216 container.SetParentOrigin( ParentOrigin::CENTER );
5217 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5218 stage.Add( container );
5220 container.Add( actorA );
5221 container.Add( actorB );
5222 container.Add( actorC );
5224 ResetTouchCallbacks();
5226 // Set up gl abstraction trace so can query the set uniform order
5227 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5228 glAbstraction.EnableSetUniformCallTrace(true);
5229 glAbstraction.ResetSetUniformCallStack();
5230 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5232 glAbstraction.ResetSetUniformCallStack();
5234 application.SendNotification();
5235 application.Render();
5237 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5239 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5241 // Test order of uniforms in stack
5242 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5243 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5244 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5246 tet_infoline( "Testing C above B and A at bottom\n" );
5247 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5249 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5251 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5252 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5253 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5255 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5256 // Only top actor will get touched.
5257 actorA.TouchSignal().Connect( TestTouchCallback );
5258 actorB.TouchSignal().Connect( TestTouchCallback2 );
5259 actorC.TouchSignal().Connect( TestTouchCallback3 );
5261 Dali::Integration::Point point;
5262 point.SetDeviceId( 1 );
5263 point.SetState( PointState::DOWN );
5264 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5265 Dali::Integration::TouchEvent touchEvent;
5266 touchEvent.AddPoint( point );
5268 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5270 application.ProcessEvent( touchEvent );
5272 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5273 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5274 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5276 ResetTouchCallbacks();
5278 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" );
5280 actorC.LowerBelow( actorB );
5281 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5282 application.SendNotification();
5283 application.Render();
5285 application.ProcessEvent( touchEvent ); // touch event
5287 glAbstraction.ResetSetUniformCallStack();
5288 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5290 application.SendNotification();
5291 application.Render();
5293 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5295 // Test order of uniforms in stack
5296 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5297 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5298 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5300 tet_infoline( "Testing render order is A, C, B" );
5301 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5302 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5304 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5305 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5306 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5308 ResetTouchCallbacks();
5310 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5312 actorC.LowerBelow( actorA );
5313 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5314 application.SendNotification();
5315 application.Render();
5317 application.ProcessEvent( touchEvent );
5319 glAbstraction.ResetSetUniformCallStack();
5320 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5322 application.Render();
5323 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5325 // Test order of uniforms in stack
5326 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5327 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5328 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5330 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5331 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5333 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5334 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5335 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5337 ResetTouchCallbacks();
5339 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5341 actorB.LowerBelow( actorC );
5342 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5343 application.SendNotification();
5344 application.Render();
5346 application.ProcessEvent( touchEvent );
5348 glAbstraction.ResetSetUniformCallStack();
5349 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5351 application.Render();
5352 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5354 // Test order of uniforms in stack
5355 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5356 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5357 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5359 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5360 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5366 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5368 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5370 TestApplication application;
5372 Stage stage( Stage::GetCurrent() );
5374 Actor parentA = Actor::New();
5375 Actor parentB = Actor::New();
5376 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5377 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5378 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5379 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5381 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5382 parentA.SetParentOrigin( ParentOrigin::CENTER );
5384 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5385 parentB.SetParentOrigin( ParentOrigin::CENTER );
5387 stage.Add( parentA );
5388 stage.Add( parentB );
5390 Actor actorA = Actor::New();
5391 Actor actorB = Actor::New();
5392 Actor actorC = Actor::New();
5394 parentA.Add( actorA );
5395 parentA.Add( actorB );
5397 tet_printf( "Actor C added to different parent from A and B \n" );
5398 parentB.Add( actorC );
5400 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5401 actorA.SetParentOrigin( ParentOrigin::CENTER );
5403 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5404 actorB.SetParentOrigin( ParentOrigin::CENTER );
5406 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5407 actorC.SetParentOrigin( ParentOrigin::CENTER );
5409 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5410 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5412 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5413 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5415 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5416 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5418 ResetTouchCallbacks();
5420 application.SendNotification();
5421 application.Render();
5423 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5424 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5425 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5427 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5428 // Only top actor will get touched.
5429 actorA.TouchSignal().Connect( TestTouchCallback );
5430 actorB.TouchSignal().Connect( TestTouchCallback2 );
5431 actorC.TouchSignal().Connect( TestTouchCallback3 );
5433 Dali::Integration::Point point;
5434 point.SetDeviceId( 1 );
5435 point.SetState( PointState::DOWN );
5436 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5437 Dali::Integration::TouchEvent touchEvent;
5438 touchEvent.AddPoint( point );
5440 application.ProcessEvent( touchEvent );
5442 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5443 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5444 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5446 ResetTouchCallbacks();
5448 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5450 actorA.RaiseAbove( actorC );
5451 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5452 application.SendNotification();
5454 application.ProcessEvent( touchEvent ); // touch event
5456 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5457 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5458 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5460 ResetTouchCallbacks();
5465 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5467 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5469 TestApplication application;
5471 Stage stage( Stage::GetCurrent() );
5473 Actor actorA = Actor::New();
5474 Actor actorB = Actor::New();
5475 Actor actorC = Actor::New();
5477 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5478 actorA.SetParentOrigin( ParentOrigin::CENTER );
5480 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5481 actorB.SetParentOrigin( ParentOrigin::CENTER );
5483 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5484 actorC.SetParentOrigin( ParentOrigin::CENTER );
5486 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5487 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5489 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5490 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5492 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5493 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5495 ResetTouchCallbacks();
5497 application.SendNotification();
5498 application.Render();
5500 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5501 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5502 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5504 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5505 // Only top actor will get touched.
5506 actorA.TouchSignal().Connect( TestTouchCallback );
5507 actorB.TouchSignal().Connect( TestTouchCallback2 );
5508 actorC.TouchSignal().Connect( TestTouchCallback3 );
5510 Dali::Integration::Point point;
5511 point.SetDeviceId( 1 );
5512 point.SetState( PointState::DOWN );
5513 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5514 Dali::Integration::TouchEvent touchEvent;
5515 touchEvent.AddPoint( point );
5517 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5519 actorA.RaiseAbove( actorC );
5520 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5521 application.SendNotification();
5523 application.ProcessEvent( touchEvent );
5525 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5527 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5528 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5529 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5531 ResetTouchCallbacks();
5533 stage.Add ( actorB );
5534 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5535 actorA.LowerBelow( actorC );
5537 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5538 application.SendNotification();
5539 application.Render();
5541 application.ProcessEvent( touchEvent );
5543 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5544 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5545 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5546 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5548 ResetTouchCallbacks();
5550 tet_printf( "Adding Actor A to stage, will be on top\n" );
5552 stage.Add ( actorA );
5553 application.SendNotification();
5554 application.Render();
5556 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5557 actorB.RaiseAbove( actorC );
5558 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5559 application.SendNotification();
5561 application.ProcessEvent( touchEvent );
5563 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5564 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5565 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5566 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5568 ResetTouchCallbacks();
5570 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5571 actorA.LowerBelow( actorC );
5572 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5573 application.SendNotification();
5575 application.ProcessEvent( touchEvent );
5577 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5578 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5579 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5580 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5582 ResetTouchCallbacks();
5584 stage.Add ( actorC );
5585 actorA.RaiseAbove( actorC );
5586 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5587 application.SendNotification();
5588 application.Render();
5590 application.ProcessEvent( touchEvent );
5592 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5593 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5594 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5595 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5600 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5602 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5604 TestApplication application;
5606 Stage stage( Stage::GetCurrent() );
5608 Actor actorA = Actor::New();
5609 Actor actorB = Actor::New();
5610 Actor actorC = Actor::New();
5612 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5613 actorA.SetParentOrigin( ParentOrigin::CENTER );
5615 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5616 actorB.SetParentOrigin( ParentOrigin::CENTER );
5618 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5619 actorC.SetParentOrigin( ParentOrigin::CENTER );
5621 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5622 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5624 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5625 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5627 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5628 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5630 ResetTouchCallbacks();
5632 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5633 // Only top actor will get touched.
5634 actorA.TouchSignal().Connect( TestTouchCallback );
5635 actorB.TouchSignal().Connect( TestTouchCallback2 );
5636 actorC.TouchSignal().Connect( TestTouchCallback3 );
5638 Dali::Integration::Point point;
5639 point.SetDeviceId( 1 );
5640 point.SetState( PointState::DOWN );
5641 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5642 Dali::Integration::TouchEvent touchEvent;
5643 touchEvent.AddPoint( point );
5645 stage.Add ( actorA );
5646 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5649 application.SendNotification();
5650 application.Render();
5652 application.ProcessEvent( touchEvent );
5654 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5656 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5657 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5658 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5660 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5661 ResetTouchCallbacks();
5664 // Sort actor tree before next touch event
5665 application.SendNotification();
5666 application.Render();
5668 application.ProcessEvent( touchEvent );
5670 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5672 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5673 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5674 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5675 ResetTouchCallbacks();
5677 tet_printf( "Lower actor C below B but C not parented\n" );
5680 // Sort actor tree before next touch event
5681 application.SendNotification();
5682 application.Render();
5684 application.ProcessEvent( touchEvent );
5686 tet_printf( "Not parented so Lower should show no effect\n" );
5688 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5689 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5690 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5691 ResetTouchCallbacks();
5693 tet_printf( "Raise actor B to top\n" );
5695 actorB.RaiseToTop();
5696 // Sort actor tree before next touch event
5697 application.SendNotification();
5698 application.Render();
5700 application.ProcessEvent( touchEvent );
5702 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5704 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5705 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5706 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5707 ResetTouchCallbacks();
5709 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5711 stage.Add ( actorB );
5713 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5715 actorC.LowerToBottom();
5716 application.SendNotification();
5717 application.Render();
5719 application.ProcessEvent( touchEvent );
5721 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5723 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5724 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5725 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5726 ResetTouchCallbacks();
5732 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5734 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5736 TestApplication application;
5738 Stage stage( Stage::GetCurrent() );
5740 Actor actorA = Actor::New();
5741 Actor actorB = Actor::New();
5742 Actor actorC = Actor::New();
5744 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5745 actorA.SetParentOrigin( ParentOrigin::CENTER );
5747 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5748 actorB.SetParentOrigin( ParentOrigin::CENTER );
5750 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5751 actorC.SetParentOrigin( ParentOrigin::CENTER );
5753 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5754 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5756 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5757 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5759 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5760 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5762 stage.Add( actorA );
5763 stage.Add( actorB );
5764 stage.Add( actorC );
5766 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5767 // Only top actor will get touched.
5768 actorA.TouchSignal().Connect( TestTouchCallback );
5769 actorB.TouchSignal().Connect( TestTouchCallback2 );
5770 actorC.TouchSignal().Connect( TestTouchCallback3 );
5772 ResetTouchCallbacks();
5774 application.SendNotification();
5775 application.Render();
5777 Dali::Integration::Point point;
5778 point.SetDeviceId( 1 );
5779 point.SetState( PointState::DOWN );
5780 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5781 Dali::Integration::TouchEvent touchEvent;
5782 touchEvent.AddPoint( point );
5784 application.ProcessEvent( touchEvent );
5786 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5787 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5788 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5790 ResetTouchCallbacks();
5792 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5794 actorA.RaiseAbove( actorA );
5795 application.SendNotification();
5796 application.Render();
5798 application.ProcessEvent( touchEvent );
5800 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5802 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5803 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5804 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5806 ResetTouchCallbacks();
5808 actorA.RaiseAbove( actorC );
5809 application.SendNotification();
5810 application.Render();
5812 application.ProcessEvent( touchEvent );
5814 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5815 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5816 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5817 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5822 int UtcDaliActorGetScreenPosition(void)
5824 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5826 TestApplication application;
5828 Stage stage( Stage::GetCurrent() );
5830 Actor actorA = Actor::New();
5831 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5833 Vector2 size2( 10.0f, 20.0f );
5834 actorA.SetSize( size2 );
5836 actorA.SetPosition( 0.f, 0.f );
5838 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5840 stage.Add( actorA );
5842 application.SendNotification();
5843 application.Render();
5845 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5846 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5848 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5849 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5851 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5852 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5854 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5856 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5858 application.SendNotification();
5859 application.Render();
5861 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5862 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5864 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5865 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5867 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5868 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5870 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5872 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5874 application.SendNotification();
5875 application.Render();
5877 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5878 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5880 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5881 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5883 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5884 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5886 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5888 actorA.SetPosition( 30.0, 0.0 );
5890 application.SendNotification();
5891 application.Render();
5893 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5894 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5896 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5897 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5899 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5900 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5902 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5904 actorA.SetPosition( 30.0, 420.0 );
5906 application.SendNotification();
5907 application.Render();
5909 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5910 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5912 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5913 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5915 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5916 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5918 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
5920 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5921 actorA.SetPosition( 30.0, 30.0 );
5923 Actor actorB = Actor::New();
5924 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5925 actorB.SetSize( size2 );
5926 actorB.SetPosition( 10.f, 10.f );
5927 actorA.Add( actorB );
5929 actorA.SetScale( 2.0f );
5931 application.SendNotification();
5932 application.Render();
5934 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5936 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
5937 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
5942 int UtcDaliActorGetScreenPositionAfterScaling(void)
5944 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5946 TestApplication application;
5948 Stage stage( Stage::GetCurrent() );
5950 Actor actorA = Actor::New();
5951 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5953 Vector2 size2( 10.0f, 20.0f );
5954 actorA.SetSize( size2 );
5955 actorA.SetScale( 1.5f );
5956 actorA.SetPosition( 0.f, 0.f );
5958 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5960 stage.Add( actorA );
5962 application.SendNotification();
5963 application.Render();
5965 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5966 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5968 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5969 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5971 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5972 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5974 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5976 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5978 application.SendNotification();
5979 application.Render();
5981 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5982 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5984 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5985 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5987 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5988 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5993 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5995 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5997 TestApplication application;
5999 Stage stage( Stage::GetCurrent() );
6001 Actor actorA = Actor::New();
6002 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6003 actorA.SetParentOrigin( ParentOrigin::CENTER );
6004 Vector2 size2( 10.0f, 20.0f );
6005 actorA.SetSize( size2 );
6006 actorA.SetPosition( 0.f, 0.f );
6008 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6010 stage.Add( actorA );
6012 application.SendNotification();
6013 application.Render();
6015 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6016 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6018 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6019 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6021 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6022 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6024 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6026 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6027 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6029 application.SendNotification();
6030 application.Render();
6032 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6033 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6035 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6036 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6038 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6039 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6045 int UtcDaliActorGetScreenPositionWithChildActors(void)
6047 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6049 TestApplication application;
6051 Stage stage( Stage::GetCurrent() );
6053 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6055 Actor actorA = Actor::New();
6056 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6057 actorA.SetParentOrigin( ParentOrigin::CENTER );
6058 Vector2 size1( 10.0f, 20.0f );
6059 actorA.SetSize( size1 );
6060 actorA.SetPosition( 0.f, 0.f );
6062 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6064 Actor parentActorA = Actor::New();
6065 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6066 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6067 Vector2 size2( 30.0f, 60.0f );
6068 parentActorA.SetSize( size2 );
6069 parentActorA.SetPosition( 0.f, 0.f );
6071 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6073 stage.Add( parentActorA );
6074 parentActorA.Add ( actorA );
6076 application.SendNotification();
6077 application.Render();
6079 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6080 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6082 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6083 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6085 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6086 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6088 tet_infoline( "Test 2\n");
6090 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6092 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6093 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6095 application.SendNotification();
6096 application.Render();
6098 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6099 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6101 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6102 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6104 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6105 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6110 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6112 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6114 TestApplication application;
6116 Stage stage( Stage::GetCurrent() );
6118 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6120 Actor actorA = Actor::New();
6121 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6122 actorA.SetParentOrigin( ParentOrigin::CENTER );
6123 Vector2 size1( 10.0f, 20.0f );
6124 actorA.SetSize( size1 );
6125 actorA.SetPosition( 0.f, 0.f );
6127 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6129 Actor parentActorA = Actor::New();
6130 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6131 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6132 Vector2 size2( 30.0f, 60.0f );
6133 parentActorA.SetSize( size2 );
6134 parentActorA.SetPosition( 0.f, 0.f );
6136 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6138 Actor grandParentActorA = Actor::New();
6139 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6140 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6141 Vector2 size3( 60.0f, 120.0f );
6142 grandParentActorA.SetSize( size3 );
6143 grandParentActorA.SetPosition( 0.f, 0.f );
6145 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6147 stage.Add( grandParentActorA );
6148 grandParentActorA.Add ( parentActorA );
6150 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6152 parentActorA.Add ( actorA );
6154 application.SendNotification();
6155 application.Render();
6157 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6158 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6160 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6161 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6163 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6164 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6169 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6171 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6173 TestApplication application;
6175 Stage stage( Stage::GetCurrent() );
6177 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6179 Actor actorA = Actor::New();
6180 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6181 actorA.SetParentOrigin( ParentOrigin::CENTER );
6182 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6183 actorA.SetSize( 10.0f, 20.0f );
6184 stage.Add( actorA );
6186 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6188 Actor actorB = Actor::New();
6189 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6190 actorB.SetParentOrigin( ParentOrigin::CENTER );
6191 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6192 Vector2 actorBSize( 30.0f, 60.0f );
6193 actorB.SetSize( actorBSize );
6194 stage.Add( actorB );
6196 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6198 Actor actorC = Actor::New();
6199 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6200 actorC.SetParentOrigin( ParentOrigin::CENTER );
6201 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6202 Vector2 actorCSize( 60.0f, 120.0f );
6203 actorC.SetSize( actorCSize );
6204 stage.Add( actorC );
6206 application.SendNotification();
6207 application.Render();
6209 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6211 Vector2 center( stage.GetSize() * 0.5f );
6213 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6214 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6215 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6217 tet_infoline( "Add scale to all actors" );
6219 actorA.SetScale( 2.0f );
6220 actorB.SetScale( 2.0f );
6221 actorC.SetScale( 2.0f );
6223 application.SendNotification();
6224 application.Render();
6226 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6227 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6228 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6233 int utcDaliActorPositionUsesAnchorPoint(void)
6235 TestApplication application;
6236 tet_infoline( "Check default behaviour\n" );
6238 Actor actor = Actor::New();
6239 actor.SetParentOrigin( ParentOrigin::CENTER );
6240 actor.SetAnchorPoint( AnchorPoint::CENTER );
6241 actor.SetSize( 100.0f, 100.0f );
6242 Stage::GetCurrent().Add( actor );
6244 application.SendNotification();
6245 application.Render();
6247 tet_infoline( "Check that the world position is in the center\n" );
6248 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6250 tet_infoline( "Set the position uses anchor point property to false\n" );
6251 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6253 application.SendNotification();
6254 application.Render();
6256 tet_infoline( "Check that the world position has changed appropriately\n" );
6257 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6262 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6264 TestApplication application;
6265 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6267 Actor actor = Actor::New();
6268 actor.SetParentOrigin( ParentOrigin::CENTER );
6269 actor.SetAnchorPoint( AnchorPoint::CENTER );
6270 actor.SetSize( 100.0f, 100.0f );
6271 actor.SetScale( 2.0f );
6272 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6273 Stage::GetCurrent().Add( actor );
6275 application.SendNotification();
6276 application.Render();
6278 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6279 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6281 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6282 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6283 application.SendNotification();
6284 application.Render();
6285 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6287 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6288 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6289 application.SendNotification();
6290 application.Render();
6291 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6296 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6298 TestApplication application;
6299 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6301 Actor actor = Actor::New();
6302 actor.SetParentOrigin( ParentOrigin::CENTER );
6303 actor.SetAnchorPoint( AnchorPoint::CENTER );
6304 actor.SetSize( 100.0f, 100.0f );
6305 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6306 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6307 Stage::GetCurrent().Add( actor );
6309 application.SendNotification();
6310 application.Render();
6312 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6313 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6315 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6316 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6317 application.SendNotification();
6318 application.Render();
6319 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6321 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6322 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6323 application.SendNotification();
6324 application.Render();
6325 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6330 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6332 TestApplication application;
6333 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6335 Actor actor = Actor::New();
6336 actor.SetParentOrigin( ParentOrigin::CENTER );
6337 actor.SetAnchorPoint( AnchorPoint::CENTER );
6338 actor.SetSize( 100.0f, 100.0f );
6339 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6340 actor.SetScale( 2.0f );
6341 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6342 Stage::GetCurrent().Add( actor );
6344 application.SendNotification();
6345 application.Render();
6347 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6348 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6350 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6351 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6352 application.SendNotification();
6353 application.Render();
6354 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6356 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6357 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6358 application.SendNotification();
6359 application.Render();
6360 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6365 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6367 TestApplication application;
6368 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6370 Actor parent = Actor::New();
6372 Stage::GetCurrent().Add( parent );
6373 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6375 Actor actor = Actor::New();
6376 actor.SetParentOrigin( ParentOrigin::CENTER );
6377 actor.SetAnchorPoint( AnchorPoint::CENTER );
6378 actor.SetSize( 100.0f, 100.0f );
6379 actor.SetInheritScale( false );
6380 actor.SetInheritOrientation( false );
6381 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6382 parent.Add( actor );
6384 application.SendNotification();
6385 application.Render();
6387 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6389 tet_infoline( "Check the world position is in the right place\n" );
6390 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6392 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6393 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6394 application.SendNotification();
6395 application.Render();
6396 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6398 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6399 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6400 application.SendNotification();
6401 application.Render();
6402 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6407 int utcDaliActorVisibilityChangeSignalSelf(void)
6409 TestApplication application;
6410 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6412 Actor actor = Actor::New();
6414 VisibilityChangedFunctorData data;
6415 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6417 actor.SetVisible( false );
6419 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6421 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6424 actor.SetVisible( false );
6425 data.Check( false /* not called */, TEST_LOCATION );
6427 tet_infoline( "Change the visibility using properties, ensure called" );
6430 actor.SetProperty( Actor::Property::VISIBLE, true );
6431 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6433 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6436 actor.SetProperty( Actor::Property::VISIBLE, true );
6437 data.Check( false /* not called */, TEST_LOCATION );
6442 int utcDaliActorVisibilityChangeSignalChildren(void)
6444 TestApplication application;
6445 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6447 Actor parent = Actor::New();
6448 Actor child = Actor::New();
6449 parent.Add( child );
6451 Actor grandChild = Actor::New();
6452 child.Add( grandChild );
6454 VisibilityChangedFunctorData parentData;
6455 VisibilityChangedFunctorData childData;
6456 VisibilityChangedFunctorData grandChildData;
6458 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6459 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6460 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6462 parent.SetVisible( false );
6463 parentData.Check( false /* not called */, TEST_LOCATION );
6464 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6465 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6467 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6470 grandChildData.Reset();
6472 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6474 parent.SetVisible( true );
6475 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6476 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6477 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6479 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6482 grandChildData.Reset();
6484 parent.SetVisible( true );
6485 parentData.Check( false /* not called */, TEST_LOCATION );
6486 childData.Check( false /* not called */, TEST_LOCATION );
6487 grandChildData.Check( false /* not called */, TEST_LOCATION );
6492 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6494 TestApplication application;
6495 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6497 Actor actor = Actor::New();
6498 Stage::GetCurrent().Add( actor );
6500 application.SendNotification();
6501 application.Render();
6503 VisibilityChangedFunctorData data;
6504 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6506 Animation animation = Animation::New( 1.0f );
6507 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6509 data.Check( false, TEST_LOCATION );
6510 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6511 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6513 tet_infoline( "Play the animation and check the property value" );
6516 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6517 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6519 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6520 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6522 application.SendNotification();
6523 application.Render( 1100 ); // After the animation
6525 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6531 int utcDaliActorVisibilityChangeSignalByName(void)
6533 TestApplication application;
6534 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6536 Actor actor = Actor::New();
6538 bool signalCalled=false;
6539 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6540 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6541 actor.SetVisible( false );
6542 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6544 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6545 signalCalled = false;
6546 actor.SetVisible( false );
6547 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6549 tet_infoline( "Change the visibility using properties, ensure called" );
6550 actor.SetProperty( Actor::Property::VISIBLE, true );
6551 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6553 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6554 signalCalled = false;
6556 actor.SetProperty( Actor::Property::VISIBLE, true );
6557 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6563 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6565 gLayoutDirectionType = type;
6568 int UtcDaliActorLayoutDirectionProperty(void)
6570 TestApplication application;
6571 tet_infoline( "Check layout direction property" );
6573 Actor actor0 = Actor::New();
6574 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6575 Stage::GetCurrent().Add( actor0 );
6577 application.SendNotification();
6578 application.Render();
6580 Actor actor1 = Actor::New();
6581 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6582 Actor actor2 = Actor::New();
6583 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6584 Actor actor3 = Actor::New();
6585 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6586 Actor actor4 = Actor::New();
6587 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6588 Actor actor5 = Actor::New();
6589 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6590 Actor actor6 = Actor::New();
6591 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6592 Actor actor7 = Actor::New();
6593 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6594 Actor actor8 = Actor::New();
6595 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6596 Actor actor9 = Actor::New();
6597 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6599 actor1.Add( actor2 );
6600 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6601 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6603 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6604 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6605 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6607 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6608 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6609 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6611 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6612 actor0.Add( actor1 );
6613 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6614 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6616 Stage::GetCurrent().Add( actor3 );
6617 actor3.Add( actor4 );
6618 actor4.Add( actor5 );
6619 actor5.Add( actor6 );
6620 actor5.Add( actor7 );
6621 actor7.Add( actor8 );
6622 actor8.Add( actor9 );
6623 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6624 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6626 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6627 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6628 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6630 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6632 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6633 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6634 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6635 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6636 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6637 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6638 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6640 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6641 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6642 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6644 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6645 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6646 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6647 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6649 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6650 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6651 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6657 struct LayoutDirectionFunctor
6659 LayoutDirectionFunctor(bool& signalCalled)
6660 : mSignalCalled( signalCalled )
6664 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6665 : mSignalCalled( rhs.mSignalCalled )
6671 mSignalCalled = true;
6674 bool& mSignalCalled;
6677 int UtcDaliActorLayoutDirectionSignal(void)
6679 TestApplication application;
6680 tet_infoline( "Check changing layout direction property sends a signal" );
6682 Actor actor = Actor::New();
6683 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6684 Stage::GetCurrent().Add( actor );
6685 bool signalCalled = false;
6686 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6688 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6689 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6691 // Test that writing the same value doesn't send a signal
6692 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6693 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6695 // Test that writing a different value sends the signal
6696 signalCalled = false;
6697 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6698 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6700 signalCalled = false;
6701 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6702 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6707 struct ChildAddedSignalCheck
6709 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6710 : mSignalReceived( signalReceived ),
6711 mChildHandle( childHandle )
6715 void operator() ( Actor childHandle )
6717 mSignalReceived = true;
6718 mChildHandle = childHandle;
6722 mSignalReceived = true;
6723 mChildHandle = Actor();
6726 bool& mSignalReceived;
6727 Actor& mChildHandle;
6730 int UtcDaliChildAddedSignalP1(void)
6732 TestApplication application;
6733 auto stage = Stage::GetCurrent();
6735 bool signalReceived=false;
6738 ChildAddedSignalCheck signal( signalReceived, childActor );
6739 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6740 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6742 auto actorA = Actor::New();
6743 stage.Add( actorA );
6744 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6745 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6746 signalReceived = false;
6748 auto actorB = Actor::New();
6749 stage.Add( actorB );
6750 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6751 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6757 int UtcDaliChildAddedSignalP2(void)
6759 TestApplication application;
6760 auto stage = Stage::GetCurrent();
6762 bool signalReceived=false;
6765 ChildAddedSignalCheck signal( signalReceived, childActor );
6766 tet_infoline( "Connect to childAdded signal by name" );
6768 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6769 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6771 auto actorA = Actor::New();
6772 stage.Add( actorA );
6773 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6775 // Can't test which actor was added; signal signature is void() when connecting via name.
6776 signalReceived = false;
6778 auto actorB = Actor::New();
6779 stage.Add( actorB );
6780 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6785 int UtcDaliChildAddedSignalN(void)
6787 TestApplication application;
6788 auto stage = Stage::GetCurrent();
6790 bool signalReceived=false;
6793 ChildAddedSignalCheck signal( signalReceived, childActor );
6794 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6795 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6797 auto actorA = Actor::New();
6798 stage.Add( actorA );
6799 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6800 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6801 signalReceived = false;
6803 auto actorB = Actor::New();
6804 actorA.Add( actorB );
6805 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6810 struct ChildRemovedSignalCheck
6812 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
6813 : mSignalReceived( signalReceived ),
6814 mChildHandle( childHandle )
6818 void operator() ( Actor childHandle )
6820 mSignalReceived = true;
6821 mChildHandle = childHandle;
6826 mSignalReceived = true;
6829 bool& mSignalReceived;
6830 Actor& mChildHandle;
6833 int UtcDaliChildRemovedSignalP1(void)
6835 TestApplication application;
6836 auto stage = Stage::GetCurrent();
6838 bool signalReceived=false;
6841 ChildRemovedSignalCheck signal( signalReceived, childActor );
6842 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6843 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6845 auto actorA = Actor::New();
6846 stage.Add( actorA );
6847 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6848 DALI_TEST_CHECK( !childActor );
6850 stage.Remove( actorA );
6851 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6852 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6854 signalReceived = false;
6855 auto actorB = Actor::New();
6856 stage.Add( actorB );
6857 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6859 stage.Remove( actorB );
6860 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6861 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6866 int UtcDaliChildRemovedSignalP2(void)
6868 TestApplication application;
6869 auto stage = Stage::GetCurrent();
6871 bool signalReceived=false;
6874 ChildAddedSignalCheck signal( signalReceived, childActor );
6875 tet_infoline( "Connect to childRemoved signal by name" );
6877 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
6878 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6880 auto actorA = Actor::New();
6881 stage.Add( actorA );
6882 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6884 stage.Remove( actorA );
6885 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6887 signalReceived = false;
6888 auto actorB = Actor::New();
6889 stage.Add( actorB );
6890 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6892 stage.Remove( actorB );
6893 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6899 int UtcDaliChildRemovedSignalN(void)
6901 TestApplication application;
6902 auto stage = Stage::GetCurrent();
6904 bool signalReceived=false;
6907 ChildRemovedSignalCheck signal( signalReceived, childActor );
6908 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6909 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6911 auto actorA = Actor::New();
6912 stage.Add( actorA );
6914 auto actorB = Actor::New();
6915 actorA.Add( actorB );
6917 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6918 DALI_TEST_CHECK( ! childActor );
6920 actorA.Remove( actorB );
6921 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6926 int UtcDaliChildMovedSignalP(void)
6928 TestApplication application;
6929 auto stage = Stage::GetCurrent();
6931 bool addedASignalReceived = false;
6932 bool removedASignalReceived = false;
6933 bool addedBSignalReceived = false;
6934 bool removedBSignalReceived = false;
6937 auto actorA = Actor::New();
6938 auto actorB = Actor::New();
6939 stage.Add( actorA );
6940 stage.Add( actorB );
6942 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
6943 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
6944 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
6945 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
6947 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
6948 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
6949 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
6950 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
6952 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
6953 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
6954 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
6955 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
6957 // Create a child of A
6959 auto child = Actor::New();
6960 actorA.Add( child );
6962 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
6963 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
6964 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
6965 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
6966 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
6969 addedASignalReceived = false;
6970 addedBSignalReceived = false;
6971 removedASignalReceived = false;
6972 removedBSignalReceived = false;
6974 actorB.Add( child ); // Expect this child to be re-parented
6975 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
6976 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
6977 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
6978 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
6980 // Move child back to A:
6981 addedASignalReceived = false;
6982 addedBSignalReceived = false;
6983 removedASignalReceived = false;
6984 removedBSignalReceived = false;
6986 actorA.Add( child ); // Expect this child to be re-parented
6987 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
6988 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
6989 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
6990 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );