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 UtcDaliActorSetParentOrigin(void)
643 TestApplication application;
645 Actor actor = Actor::New();
647 Vector3 vector(0.7f, 0.8f, 0.9f);
648 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
650 actor.SetParentOrigin(vector);
652 // flush the queue and render once
653 application.SendNotification();
654 application.Render();
656 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
658 Stage::GetCurrent().Add( actor );
660 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
662 // flush the queue and render once
663 application.SendNotification();
664 application.Render();
666 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
668 Stage::GetCurrent().Remove( actor );
672 int UtcDaliActorSetParentOriginIndividual(void)
674 TestApplication application;
676 Actor actor = Actor::New();
678 Vector3 vector(0.7f, 0.8f, 0.9f);
679 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
681 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
683 // flush the queue and render once
684 application.SendNotification();
685 application.Render();
687 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
689 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
691 // flush the queue and render once
692 application.SendNotification();
693 application.Render();
695 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
697 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
699 // flush the queue and render once
700 application.SendNotification();
701 application.Render();
703 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
708 int UtcDaliActorGetCurrentParentOrigin(void)
710 TestApplication application;
712 Actor actor = Actor::New();
714 Vector3 vector(0.7f, 0.8f, 0.9f);
715 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
717 actor.SetParentOrigin(vector);
719 // flush the queue and render once
720 application.SendNotification();
721 application.Render();
723 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
727 int UtcDaliActorSetAnchorPoint(void)
729 TestApplication application;
731 Actor actor = Actor::New();
733 Vector3 vector(0.7f, 0.8f, 0.9f);
734 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
736 actor.SetAnchorPoint(vector);
738 // flush the queue and render once
739 application.SendNotification();
740 application.Render();
742 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
744 Stage::GetCurrent().Add( actor );
746 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
747 // flush the queue and render once
748 application.SendNotification();
749 application.Render();
751 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
753 Stage::GetCurrent().Remove( actor );
757 int UtcDaliActorSetAnchorPointIndividual(void)
759 TestApplication application;
761 Actor actor = Actor::New();
763 Vector3 vector(0.7f, 0.8f, 0.9f);
764 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
766 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
768 // flush the queue and render once
769 application.SendNotification();
770 application.Render();
772 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
774 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
776 // flush the queue and render once
777 application.SendNotification();
778 application.Render();
780 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
782 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
784 // flush the queue and render once
785 application.SendNotification();
786 application.Render();
788 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
793 int UtcDaliActorGetCurrentAnchorPoint(void)
795 TestApplication application;
797 Actor actor = Actor::New();
799 Vector3 vector(0.7f, 0.8f, 0.9f);
800 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
802 actor.SetAnchorPoint(vector);
804 // flush the queue and render once
805 application.SendNotification();
806 application.Render();
808 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
812 // SetSize(float width, float height)
813 int UtcDaliActorSetSize01(void)
815 TestApplication application;
817 Actor actor = Actor::New();
818 Vector3 vector(100.0f, 100.0f, 0.0f);
820 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
822 actor.SetSize(vector.x, vector.y);
824 // Immediately retrieve the size after setting
825 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
826 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
827 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
828 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
829 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
831 // Flush the queue and render once
832 application.SendNotification();
833 application.Render();
835 // Check the size in the new frame
836 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
838 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
839 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
840 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
841 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
842 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
844 // Check async behaviour
845 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
846 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
847 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
848 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
849 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
851 // Change the resize policy and check whether the size stays the same
852 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
854 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
855 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
857 // Set a new size after resize policy is changed and check the new size
858 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
860 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
861 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
863 // Change the resize policy again and check whether the new size stays the same
864 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
866 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
867 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
869 // Set another new size after resize policy is changed and check the new size
870 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
872 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
873 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
878 // SetSize(float width, float height, float depth)
879 int UtcDaliActorSetSize02(void)
881 TestApplication application;
883 Actor actor = Actor::New();
884 Vector3 vector(100.0f, 100.0f, 100.0f);
886 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
888 actor.SetSize(vector.x, vector.y, vector.z);
890 // Immediately check the size after setting
891 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
892 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
894 // flush the queue and render once
895 application.SendNotification();
896 application.Render();
898 // Check the size in the new frame
899 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
901 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
902 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
907 // SetSize(Vector2 size)
908 int UtcDaliActorSetSize03(void)
910 TestApplication application;
912 Actor actor = Actor::New();
913 Vector3 vector(100.0f, 100.0f, 0.0f);
915 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
917 actor.SetSize(Vector2(vector.x, vector.y));
919 // Immediately check the size after setting
920 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
921 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
923 // flush the queue and render once
924 application.SendNotification();
925 application.Render();
927 // Check the size in the new frame
928 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
930 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
931 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
936 // SetSize(Vector3 size)
937 int UtcDaliActorSetSize04(void)
939 TestApplication application;
941 Actor actor = Actor::New();
942 Vector3 vector(100.0f, 100.0f, 100.0f);
944 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
946 actor.SetSize(vector);
948 // Immediately check the size after setting
949 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
950 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
952 // flush the queue and render once
953 application.SendNotification();
954 application.Render();
956 // Check the size in the new frame
957 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
959 Stage::GetCurrent().Add( actor );
960 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
962 // Immediately check the size after setting
963 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
964 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
966 // flush the queue and render once
967 application.SendNotification();
968 application.Render();
970 // Check the size in the new frame
971 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
973 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
974 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
976 Stage::GetCurrent().Remove( actor );
980 int UtcDaliActorSetSizeIndividual(void)
982 TestApplication application;
984 Actor actor = Actor::New();
986 Vector3 vector(0.7f, 0.8f, 0.9f);
987 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
989 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
991 // Immediately check the width after setting
992 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
993 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
995 // flush the queue and render once
996 application.SendNotification();
997 application.Render();
999 // Check the width in the new frame
1000 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1002 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1003 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1005 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1007 // Immediately check the height after setting
1008 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1009 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1011 // flush the queue and render once
1012 application.SendNotification();
1013 application.Render();
1015 // Check the height in the new frame
1016 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1018 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1019 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1021 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1023 // Immediately check the depth after setting
1024 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1025 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1027 // flush the queue and render once
1028 application.SendNotification();
1029 application.Render();
1031 // Check the depth in the new frame
1032 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1034 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1035 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1037 // Change the resize policy and check whether the size stays the same
1038 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1040 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1041 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1043 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1044 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1046 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1047 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1049 // Change the resize policy again and check whether the size stays the same
1050 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1052 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1053 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1055 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1056 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1058 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1059 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1064 int UtcDaliActorSetSizeIndividual02(void)
1066 TestApplication application;
1068 Actor actor = Actor::New();
1069 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1070 Stage::GetCurrent().Add( actor );
1072 Vector3 vector( 100.0f, 200.0f, 400.0f );
1073 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1075 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1076 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1078 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1079 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1081 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1082 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1084 // flush the queue and render once
1085 application.SendNotification();
1086 application.Render();
1088 // Check the width in the new frame
1089 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1090 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1096 int UtcDaliActorGetCurrentSize(void)
1098 TestApplication application;
1100 Actor actor = Actor::New();
1101 Vector3 vector(100.0f, 100.0f, 20.0f);
1103 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1105 actor.SetSize(vector);
1107 // flush the queue and render once
1108 application.SendNotification();
1109 application.Render();
1111 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1115 int UtcDaliActorGetNaturalSize(void)
1117 TestApplication application;
1119 Actor actor = Actor::New();
1120 Vector3 vector( 0.0f, 0.0f, 0.0f );
1122 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1127 int UtcDaliActorGetCurrentSizeImmediate(void)
1129 TestApplication application;
1131 Actor actor = Actor::New();
1132 Vector3 vector(100.0f, 100.0f, 20.0f);
1134 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1135 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1137 actor.SetSize(vector);
1139 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1140 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1142 // flush the queue and render once
1143 application.SendNotification();
1144 application.Render();
1146 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1147 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1150 // Build the animation
1151 const float durationSeconds = 2.0f;
1152 Animation animation = Animation::New( durationSeconds );
1153 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1154 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1156 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1158 // Start the animation
1161 application.SendNotification();
1162 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1164 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1169 // SetPosition(float x, float y)
1170 int UtcDaliActorSetPosition01(void)
1172 TestApplication application;
1174 Actor actor = Actor::New();
1176 // Set to random to start off with
1177 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1179 Vector3 vector(100.0f, 100.0f, 0.0f);
1181 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1183 actor.SetPosition(vector.x, vector.y);
1184 // flush the queue and render once
1185 application.SendNotification();
1186 application.Render();
1187 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1189 Stage::GetCurrent().Add( actor );
1190 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1191 // flush the queue and render once
1192 application.SendNotification();
1193 application.Render();
1194 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1199 // flush the queue and render once
1200 application.SendNotification();
1201 application.Render();
1202 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1204 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1205 // flush the queue and render once
1206 application.SendNotification();
1207 application.Render();
1208 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1210 Stage::GetCurrent().Remove( actor );
1214 // SetPosition(float x, float y, float z)
1215 int UtcDaliActorSetPosition02(void)
1217 TestApplication application;
1219 Actor actor = Actor::New();
1221 // Set to random to start off with
1222 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1224 Vector3 vector(100.0f, 100.0f, 100.0f);
1226 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1228 actor.SetPosition(vector.x, vector.y, vector.z);
1230 // flush the queue and render once
1231 application.SendNotification();
1232 application.Render();
1234 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1238 // SetPosition(Vector3 position)
1239 int UtcDaliActorSetPosition03(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, 120.0f));
1248 Vector3 vector(100.0f, 100.0f, 100.0f);
1250 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1252 actor.SetPosition(vector);
1254 // flush the queue and render once
1255 application.SendNotification();
1256 application.Render();
1258 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1262 int UtcDaliActorSetX(void)
1264 TestApplication application;
1266 Actor actor = Actor::New();
1268 Vector3 vector(100.0f, 0.0f, 0.0f);
1270 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1274 // flush the queue and render once
1275 application.SendNotification();
1276 application.Render();
1278 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1282 int UtcDaliActorSetY(void)
1284 TestApplication application;
1286 Actor actor = Actor::New();
1288 Vector3 vector(0.0f, 100.0f, 0.0f);
1290 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1294 // flush the queue and render once
1295 application.SendNotification();
1296 application.Render();
1298 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1302 int UtcDaliActorSetZ(void)
1304 TestApplication application;
1306 Actor actor = Actor::New();
1308 Vector3 vector(0.0f, 0.0f, 100.0f);
1310 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1314 // flush the queue and render once
1315 application.SendNotification();
1316 application.Render();
1318 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1322 int UtcDaliActorSetPositionProperties(void)
1324 TestApplication application;
1326 Actor actor = Actor::New();
1328 Vector3 vector(0.7f, 0.8f, 0.9f);
1329 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1331 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1332 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1333 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1335 // flush the queue and render once
1336 application.SendNotification();
1337 application.Render();
1339 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1340 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1341 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1342 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1343 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1345 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1346 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1347 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1349 // flush the queue and render once
1350 application.SendNotification();
1351 application.Render();
1353 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1354 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1355 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1356 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1357 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1359 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1360 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1361 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1363 // flush the queue and render once
1364 application.SendNotification();
1365 application.Render();
1367 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1368 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1369 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1370 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1371 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1376 int UtcDaliActorTranslateBy(void)
1378 TestApplication application;
1380 Actor actor = Actor::New();
1381 Vector3 vector(100.0f, 100.0f, 100.0f);
1383 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1385 actor.SetPosition(vector);
1387 // flush the queue and render once
1388 application.SendNotification();
1389 application.Render();
1391 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1393 actor.TranslateBy(vector);
1395 // flush the queue and render once
1396 application.SendNotification();
1397 application.Render();
1399 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1403 int UtcDaliActorGetCurrentPosition(void)
1405 TestApplication application;
1407 Actor actor = Actor::New();
1408 Vector3 setVector(100.0f, 100.0f, 0.0f);
1409 actor.SetPosition(setVector);
1411 // flush the queue and render once
1412 application.SendNotification();
1413 application.Render();
1415 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1419 int UtcDaliActorGetCurrentWorldPosition(void)
1421 TestApplication application;
1423 Actor parent = Actor::New();
1424 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1425 parent.SetPosition( parentPosition );
1426 parent.SetParentOrigin( ParentOrigin::CENTER );
1427 parent.SetAnchorPoint( AnchorPoint::CENTER );
1428 Stage::GetCurrent().Add( parent );
1430 Actor child = Actor::New();
1431 child.SetParentOrigin( ParentOrigin::CENTER );
1432 child.SetAnchorPoint( AnchorPoint::CENTER );
1433 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1434 child.SetPosition( childPosition );
1435 parent.Add( child );
1437 // The actors should not have a world position yet
1438 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1439 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1441 application.SendNotification();
1442 application.Render(0);
1444 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1445 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1447 // The actors should have a world position now
1448 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1449 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1453 int UtcDaliActorInheritPosition(void)
1455 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1456 TestApplication application;
1458 Actor parent = Actor::New();
1459 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1460 parent.SetPosition( parentPosition );
1461 parent.SetParentOrigin( ParentOrigin::CENTER );
1462 parent.SetAnchorPoint( AnchorPoint::CENTER );
1463 Stage::GetCurrent().Add( parent );
1465 Actor child = Actor::New();
1466 child.SetParentOrigin( ParentOrigin::CENTER );
1467 child.SetAnchorPoint( AnchorPoint::CENTER );
1468 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1469 child.SetPosition( childPosition );
1470 parent.Add( child );
1472 // The actors should not have a world position yet
1473 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1474 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1476 // first test default, which is to inherit position
1477 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1478 application.SendNotification();
1479 application.Render(0); // should only really call Update as Render is not required to update scene
1480 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1481 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1482 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1483 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1486 //Change child position
1487 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1488 child.SetPosition( childOffset );
1490 // Change inheritance mode to not inherit
1491 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1492 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1493 application.SendNotification();
1494 application.Render(0); // should only really call Update as Render is not required to update scene
1495 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1496 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1497 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1498 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1502 int UtcDaliActorSetInheritPosition(void)
1504 tet_infoline("Testing Actor::SetInheritPosition");
1505 TestApplication application;
1507 Actor parent = Actor::New();
1508 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1509 parent.SetPosition( parentPosition );
1510 parent.SetParentOrigin( ParentOrigin::CENTER );
1511 parent.SetAnchorPoint( AnchorPoint::CENTER );
1512 Stage::GetCurrent().Add( parent );
1514 Actor child = Actor::New();
1515 child.SetParentOrigin( ParentOrigin::CENTER );
1516 child.SetAnchorPoint( AnchorPoint::CENTER );
1517 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1518 child.SetPosition( childPosition );
1519 parent.Add( child );
1521 // The actors should not have a world position yet
1522 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1523 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1525 // first test default, which is to inherit position
1526 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1527 application.SendNotification();
1528 application.Render(0); // should only really call Update as Render is not required to update scene
1529 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1530 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1531 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1532 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1534 //Change child position
1535 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1536 child.SetPosition( childOffset );
1538 // Use local position as world postion
1539 child.SetInheritPosition( false );
1540 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1541 application.SendNotification();
1542 application.Render(0); // should only really call Update as Render is not required to update scene
1543 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1544 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1545 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1546 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1548 //Change back to inherit position from parent
1549 child.SetInheritPosition( true );
1550 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1551 application.SendNotification();
1552 application.Render(0); // should only really call Update as Render is not required to update scene
1553 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1554 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1555 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1556 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1560 // SetOrientation(float angleRadians, Vector3 axis)
1561 int UtcDaliActorSetOrientation01(void)
1563 TestApplication application;
1565 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1566 Actor actor = Actor::New();
1568 actor.SetOrientation(rotation);
1570 // flush the queue and render once
1571 application.SendNotification();
1572 application.Render();
1574 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1578 int UtcDaliActorSetOrientation02(void)
1580 TestApplication application;
1582 Actor actor = Actor::New();
1584 Radian angle( 0.785f );
1585 Vector3 axis(1.0f, 1.0f, 0.0f);
1587 actor.SetOrientation( angle, axis);
1588 Quaternion rotation( angle, axis );
1589 // flush the queue and render once
1590 application.SendNotification();
1591 application.Render();
1592 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1594 Stage::GetCurrent().Add( actor );
1595 actor.RotateBy( Degree( 360 ), axis);
1596 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1598 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1599 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1600 // flush the queue and render once
1601 application.SendNotification();
1602 application.Render();
1603 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1605 actor.SetOrientation( angle, axis);
1606 // flush the queue and render once
1607 application.SendNotification();
1608 application.Render();
1609 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1611 Stage::GetCurrent().Remove( actor );
1615 // SetOrientation(float angleRadians, Vector3 axis)
1616 int UtcDaliActorSetOrientationProperty(void)
1618 TestApplication application;
1620 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1621 Actor actor = Actor::New();
1623 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1624 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1626 // flush the queue and render once
1627 application.SendNotification();
1628 application.Render();
1630 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1631 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1632 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1636 // RotateBy(float angleRadians, Vector3 axis)
1637 int UtcDaliActorRotateBy01(void)
1639 TestApplication application;
1641 Actor actor = Actor::New();
1643 Radian angle( M_PI * 0.25f );
1644 actor.RotateBy(( angle ), Vector3::ZAXIS);
1645 // flush the queue and render once
1646 application.SendNotification();
1647 application.Render();
1648 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1650 Stage::GetCurrent().Add( actor );
1652 actor.RotateBy( angle, Vector3::ZAXIS);
1653 // flush the queue and render once
1654 application.SendNotification();
1655 application.Render();
1656 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1658 Stage::GetCurrent().Remove( actor );
1662 // RotateBy(Quaternion relativeRotation)
1663 int UtcDaliActorRotateBy02(void)
1665 TestApplication application;
1667 Actor actor = Actor::New();
1669 Radian angle( M_PI * 0.25f );
1670 Quaternion rotation(angle, Vector3::ZAXIS);
1671 actor.RotateBy(rotation);
1672 // flush the queue and render once
1673 application.SendNotification();
1674 application.Render();
1675 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1677 actor.RotateBy(rotation);
1678 // flush the queue and render once
1679 application.SendNotification();
1680 application.Render();
1681 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1685 int UtcDaliActorGetCurrentOrientation(void)
1687 TestApplication application;
1688 Actor actor = Actor::New();
1690 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1691 actor.SetOrientation(rotation);
1692 // flush the queue and render once
1693 application.SendNotification();
1694 application.Render();
1695 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1699 int UtcDaliActorGetCurrentWorldOrientation(void)
1701 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1702 TestApplication application;
1704 Actor parent = Actor::New();
1705 Radian rotationAngle( Degree(90.0f) );
1706 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1707 parent.SetOrientation( rotation );
1708 Stage::GetCurrent().Add( parent );
1710 Actor child = Actor::New();
1711 child.SetOrientation( rotation );
1712 parent.Add( child );
1714 // The actors should not have a world rotation yet
1715 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1716 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1718 application.SendNotification();
1719 application.Render(0);
1721 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1722 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1724 // The actors should have a world rotation now
1725 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1726 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1728 // turn off child rotation inheritance
1729 child.SetInheritOrientation( false );
1730 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1731 application.SendNotification();
1732 application.Render(0);
1734 // The actors should have a world rotation now
1735 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1736 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1740 // SetScale(float scale)
1741 int UtcDaliActorSetScale01(void)
1743 TestApplication application;
1745 Actor actor = Actor::New();
1747 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1748 actor.SetScale(0.25f);
1750 Vector3 scale(10.0f, 10.0f, 10.0f);
1751 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1753 actor.SetScale(scale.x);
1755 // flush the queue and render once
1756 application.SendNotification();
1757 application.Render();
1759 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1763 // SetScale(float scaleX, float scaleY, float scaleZ)
1764 int UtcDaliActorSetScale02(void)
1766 TestApplication application;
1767 Vector3 scale(10.0f, 10.0f, 10.0f);
1769 Actor actor = Actor::New();
1771 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1772 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1774 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1776 actor.SetScale(scale.x, scale.y, scale.z);
1777 // flush the queue and render once
1778 application.SendNotification();
1779 application.Render();
1780 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1782 // add to stage and test
1783 Stage::GetCurrent().Add( actor );
1784 actor.SetScale( 2.0f, 2.0f, 2.0f );
1785 // flush the queue and render once
1786 application.SendNotification();
1787 application.Render();
1788 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1790 Stage::GetCurrent().Remove( actor );
1795 // SetScale(Vector3 scale)
1796 int UtcDaliActorSetScale03(void)
1798 TestApplication application;
1799 Vector3 scale(10.0f, 10.0f, 10.0f);
1801 Actor actor = Actor::New();
1803 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1804 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1806 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1808 actor.SetScale(scale);
1810 // flush the queue and render once
1811 application.SendNotification();
1812 application.Render();
1814 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1818 int UtcDaliActorSetScaleIndividual(void)
1820 TestApplication application;
1822 Actor actor = Actor::New();
1824 Vector3 vector(0.7f, 0.8f, 0.9f);
1825 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1827 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1828 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1830 // flush the queue and render once
1831 application.SendNotification();
1832 application.Render();
1834 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1835 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1836 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1838 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1839 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1841 // flush the queue and render once
1842 application.SendNotification();
1843 application.Render();
1845 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1846 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1847 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1849 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1850 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1852 // flush the queue and render once
1853 application.SendNotification();
1854 application.Render();
1856 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1857 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1858 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1860 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1861 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1866 int UtcDaliActorScaleBy(void)
1868 TestApplication application;
1869 Actor actor = Actor::New();
1870 Vector3 vector(100.0f, 100.0f, 100.0f);
1872 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1874 actor.SetScale(vector);
1876 // flush the queue and render once
1877 application.SendNotification();
1878 application.Render();
1880 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1882 actor.ScaleBy(vector);
1884 // flush the queue and render once
1885 application.SendNotification();
1886 application.Render();
1888 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1892 int UtcDaliActorGetCurrentScale(void)
1894 TestApplication application;
1895 Vector3 scale(12.0f, 1.0f, 2.0f);
1897 Actor actor = Actor::New();
1899 actor.SetScale(scale);
1901 // flush the queue and render once
1902 application.SendNotification();
1903 application.Render();
1905 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1909 int UtcDaliActorGetCurrentWorldScale(void)
1911 TestApplication application;
1913 Actor parent = Actor::New();
1914 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1915 parent.SetScale( parentScale );
1916 Stage::GetCurrent().Add( parent );
1918 Actor child = Actor::New();
1919 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1920 child.SetScale( childScale );
1921 parent.Add( child );
1923 // The actors should not have a scale yet
1924 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1925 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1927 // The actors should not have a world scale yet
1928 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1929 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1931 application.SendNotification();
1932 application.Render(0);
1934 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1935 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1937 // The actors should have a world scale now
1938 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1939 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1943 int UtcDaliActorInheritScale(void)
1945 tet_infoline("Testing Actor::SetInheritScale");
1946 TestApplication application;
1948 Actor parent = Actor::New();
1949 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1950 parent.SetScale( parentScale );
1951 Stage::GetCurrent().Add( parent );
1953 Actor child = Actor::New();
1954 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1955 child.SetScale( childScale );
1956 parent.Add( child );
1958 application.SendNotification();
1959 application.Render(0);
1961 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1962 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1964 child.SetInheritScale( false );
1965 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1967 application.SendNotification();
1968 application.Render(0);
1970 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1974 int UtcDaliActorSetVisible(void)
1976 TestApplication application;
1978 Actor actor = Actor::New();
1979 actor.SetVisible(false);
1980 // flush the queue and render once
1981 application.SendNotification();
1982 application.Render();
1983 DALI_TEST_CHECK(actor.IsVisible() == false);
1985 actor.SetVisible(true);
1986 // flush the queue and render once
1987 application.SendNotification();
1988 application.Render();
1989 DALI_TEST_CHECK(actor.IsVisible() == true);
1991 // put actor on stage
1992 Stage::GetCurrent().Add( actor );
1993 actor.SetVisible(false);
1994 // flush the queue and render once
1995 application.SendNotification();
1996 application.Render();
1997 DALI_TEST_CHECK(actor.IsVisible() == false);
2001 int UtcDaliActorIsVisible(void)
2003 TestApplication application;
2005 Actor actor = Actor::New();
2007 DALI_TEST_CHECK(actor.IsVisible() == true);
2011 int UtcDaliActorSetOpacity(void)
2013 TestApplication application;
2015 Actor actor = Actor::New();
2016 // initial opacity is 1
2017 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2019 actor.SetOpacity( 0.4f);
2020 // flush the queue and render once
2021 application.SendNotification();
2022 application.Render();
2023 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2025 // change opacity, actor is on stage to change is not immediate
2026 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2027 // flush the queue and render once
2028 application.SendNotification();
2029 application.Render();
2030 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2032 // put actor on stage
2033 Stage::GetCurrent().Add( actor );
2035 // change opacity, actor is on stage to change is not immediate
2036 actor.SetOpacity( 0.9f );
2037 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2038 // flush the queue and render once
2039 application.SendNotification();
2040 application.Render();
2041 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2043 // change opacity, actor is on stage to change is not immediate
2044 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2045 // flush the queue and render once
2046 application.SendNotification();
2047 application.Render();
2048 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2052 int UtcDaliActorGetCurrentOpacity(void)
2054 TestApplication application;
2056 Actor actor = Actor::New();
2057 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2059 actor.SetOpacity(0.5f);
2060 // flush the queue and render once
2061 application.SendNotification();
2062 application.Render();
2063 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2067 int UtcDaliActorSetSensitive(void)
2069 TestApplication application;
2070 Actor actor = Actor::New();
2072 bool sensitive = !actor.IsSensitive();
2074 actor.SetSensitive(sensitive);
2076 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2080 int UtcDaliActorIsSensitive(void)
2082 TestApplication application;
2083 Actor actor = Actor::New();
2084 actor.SetSensitive(false);
2086 DALI_TEST_CHECK(false == actor.IsSensitive());
2090 int UtcDaliActorSetColor(void)
2092 TestApplication application;
2093 Actor actor = Actor::New();
2094 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2096 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2098 actor.SetColor(color);
2099 // flush the queue and render once
2100 application.SendNotification();
2101 application.Render();
2102 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2104 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2105 // flush the queue and render once
2106 application.SendNotification();
2107 application.Render();
2108 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2110 Stage::GetCurrent().Add( actor );
2111 actor.SetColor( color );
2112 // flush the queue and render once
2113 application.SendNotification();
2114 application.Render();
2115 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2117 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2118 // flush the queue and render once
2119 application.SendNotification();
2120 application.Render();
2121 // Actor color is not clamped
2122 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2123 // world color is clamped
2124 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2126 Stage::GetCurrent().Remove( actor );
2130 int UtcDaliActorSetColorIndividual(void)
2132 TestApplication application;
2134 Actor actor = Actor::New();
2136 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2137 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2139 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2140 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2142 // flush the queue and render once
2143 application.SendNotification();
2144 application.Render();
2146 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2147 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2148 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2150 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2151 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2153 // flush the queue and render once
2154 application.SendNotification();
2155 application.Render();
2157 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2158 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2159 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2161 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2162 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2164 // flush the queue and render once
2165 application.SendNotification();
2166 application.Render();
2168 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2169 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2170 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2173 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2174 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2176 // flush the queue and render once
2177 application.SendNotification();
2178 application.Render();
2180 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2181 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2182 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2184 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2185 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2187 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2190 // flush the queue and render once
2191 application.SendNotification();
2192 application.Render();
2194 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2200 int UtcDaliActorGetCurrentColor(void)
2202 TestApplication application;
2203 Actor actor = Actor::New();
2204 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2206 actor.SetColor(color);
2207 // flush the queue and render once
2208 application.SendNotification();
2209 application.Render();
2210 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2214 int UtcDaliActorGetCurrentWorldColor(void)
2216 tet_infoline("Actor::GetCurrentWorldColor");
2217 TestApplication application;
2219 Actor parent = Actor::New();
2220 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2221 parent.SetColor( parentColor );
2222 Stage::GetCurrent().Add( parent );
2224 Actor child = Actor::New();
2225 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2226 child.SetColor( childColor );
2227 parent.Add( child );
2229 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2230 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2232 // verify the default color mode
2233 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2235 // The actors should not have a world color yet
2236 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2237 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2239 application.SendNotification();
2240 application.Render(0);
2242 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2243 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2245 // The actors should have a world color now
2246 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2247 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2250 child.SetColorMode( USE_OWN_COLOR );
2251 application.SendNotification();
2252 application.Render(0);
2253 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2256 child.SetColorMode( USE_PARENT_COLOR );
2257 application.SendNotification();
2258 application.Render(0);
2259 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2260 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2263 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2264 application.SendNotification();
2265 application.Render(0);
2266 Vector4 expectedColor( childColor );
2267 expectedColor.a *= parentColor.a;
2268 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2269 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2273 int UtcDaliActorSetColorMode(void)
2275 tet_infoline("Actor::SetColorMode");
2276 TestApplication application;
2277 Actor actor = Actor::New();
2278 Actor child = Actor::New();
2281 actor.SetColorMode( USE_OWN_COLOR );
2282 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2284 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2285 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2287 actor.SetColorMode( USE_PARENT_COLOR );
2288 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2290 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2291 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2295 int UtcDaliActorScreenToLocal(void)
2297 TestApplication application;
2298 Actor actor = Actor::New();
2299 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2300 actor.SetSize(100.0f, 100.0f);
2301 actor.SetPosition(10.0f, 10.0f);
2302 Stage::GetCurrent().Add(actor);
2304 // flush the queue and render once
2305 application.SendNotification();
2306 application.Render();
2311 application.SendNotification();
2312 application.Render();
2314 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2316 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2317 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2321 int UtcDaliActorSetLeaveRequired(void)
2323 TestApplication application;
2325 Actor actor = Actor::New();
2327 actor.SetLeaveRequired(false);
2328 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2330 actor.SetLeaveRequired(true);
2331 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2335 int UtcDaliActorGetLeaveRequired(void)
2337 TestApplication application;
2339 Actor actor = Actor::New();
2341 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2345 int UtcDaliActorSetKeyboardFocusable(void)
2347 TestApplication application;
2349 Actor actor = Actor::New();
2351 actor.SetKeyboardFocusable(true);
2352 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2354 actor.SetKeyboardFocusable(false);
2355 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2359 int UtcDaliActorIsKeyboardFocusable(void)
2361 TestApplication application;
2363 Actor actor = Actor::New();
2365 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2369 int UtcDaliActorRemoveConstraints(void)
2371 tet_infoline(" UtcDaliActorRemoveConstraints");
2372 TestApplication application;
2374 gTestConstraintCalled = false;
2376 Actor actor = Actor::New();
2378 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2380 actor.RemoveConstraints();
2382 DALI_TEST_CHECK( gTestConstraintCalled == false );
2384 Stage::GetCurrent().Add( actor );
2387 // flush the queue and render once
2388 application.SendNotification();
2389 application.Render();
2391 actor.RemoveConstraints();
2393 DALI_TEST_CHECK( gTestConstraintCalled == true );
2397 int UtcDaliActorRemoveConstraintTag(void)
2399 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2400 TestApplication application;
2402 Actor actor = Actor::New();
2404 // 1. Apply Constraint1 and Constraint2, and test...
2405 unsigned int result1 = 0u;
2406 unsigned int result2 = 0u;
2408 unsigned constraint1Tag = 1u;
2409 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2410 constraint1.SetTag( constraint1Tag );
2411 constraint1.Apply();
2413 unsigned constraint2Tag = 2u;
2414 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2415 constraint2.SetTag( constraint2Tag );
2416 constraint2.Apply();
2418 Stage::GetCurrent().Add( actor );
2419 // flush the queue and render once
2420 application.SendNotification();
2421 application.Render();
2423 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2424 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2426 // 2. Remove Constraint1 and test...
2429 actor.RemoveConstraints(constraint1Tag);
2430 // make color property dirty, which will trigger constraints to be reapplied.
2431 actor.SetColor( Color::WHITE );
2432 // flush the queue and render once
2433 application.SendNotification();
2434 application.Render();
2436 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2437 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2439 // 3. Re-Apply Constraint1 and test...
2442 constraint1.Apply();
2443 // make color property dirty, which will trigger constraints to be reapplied.
2444 actor.SetColor( Color::WHITE );
2445 // flush the queue and render once
2446 application.SendNotification();
2447 application.Render();
2449 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2450 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2452 // 2. Remove Constraint2 and test...
2455 actor.RemoveConstraints(constraint2Tag);
2456 // make color property dirty, which will trigger constraints to be reapplied.
2457 actor.SetColor( Color::WHITE );
2458 // flush the queue and render once
2459 application.SendNotification();
2460 application.Render();
2462 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2463 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2465 // 2. Remove Constraint1 as well and test...
2468 actor.RemoveConstraints(constraint1Tag);
2469 // make color property dirty, which will trigger constraints to be reapplied.
2470 actor.SetColor( Color::WHITE );
2471 // flush the queue and render once
2472 application.SendNotification();
2473 application.Render();
2475 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2476 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2480 int UtcDaliActorTouchedSignal(void)
2482 TestApplication application;
2484 ResetTouchCallbacks();
2486 // get the root layer
2487 Actor actor = Stage::GetCurrent().GetRootLayer();
2488 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2490 application.SendNotification();
2491 application.Render();
2493 // connect to its touch signal
2494 actor.TouchedSignal().Connect( TestCallback );
2496 // simulate a touch event in the middle of the screen
2497 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2498 Dali::Integration::Point point;
2499 point.SetDeviceId( 1 );
2500 point.SetState( PointState::DOWN );
2501 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2502 Dali::Integration::TouchEvent touchEvent;
2503 touchEvent.AddPoint( point );
2504 application.ProcessEvent( touchEvent );
2506 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2510 int UtcDaliActorHoveredSignal(void)
2512 TestApplication application;
2514 gHoverCallBackCalled = false;
2516 // get the root layer
2517 Actor actor = Stage::GetCurrent().GetRootLayer();
2518 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2520 application.SendNotification();
2521 application.Render();
2523 // connect to its hover signal
2524 actor.HoveredSignal().Connect( TestCallback3 );
2526 // simulate a hover event in the middle of the screen
2527 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2528 Dali::Integration::Point point;
2529 point.SetDeviceId( 1 );
2530 point.SetState( PointState::MOTION );
2531 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2532 Dali::Integration::HoverEvent hoverEvent;
2533 hoverEvent.AddPoint( point );
2534 application.ProcessEvent( hoverEvent );
2536 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2540 int UtcDaliActorOnOffStageSignal(void)
2542 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2544 TestApplication application;
2547 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2548 gActorNamesOnOffStage.clear();
2550 Actor parent = Actor::New();
2551 parent.SetName( "parent" );
2552 parent.OnStageSignal().Connect( OnStageCallback );
2553 parent.OffStageSignal().Connect( OffStageCallback );
2555 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2556 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2558 // add parent to stage
2559 Stage::GetCurrent().Add( parent );
2560 // onstage emitted, offstage not
2561 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2562 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2563 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2565 // test adding a child, should get onstage emitted
2567 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2568 gActorNamesOnOffStage.clear();
2570 Actor child = Actor::New();
2571 child.SetName( "child" );
2572 child.OnStageSignal().Connect( OnStageCallback );
2573 child.OffStageSignal().Connect( OffStageCallback );
2574 parent.Add( child ); // add child
2575 // onstage emitted, offstage not
2576 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2577 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2578 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2580 // test removing parent from stage
2582 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2583 gActorNamesOnOffStage.clear();
2585 Stage::GetCurrent().Remove( parent );
2586 // onstage not emitted, offstage is
2587 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2588 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2589 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2590 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2592 // test adding parent back to stage
2594 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2595 gActorNamesOnOffStage.clear();
2597 Stage::GetCurrent().Add( parent );
2598 // onstage emitted, offstage not
2599 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2600 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2601 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2602 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2604 // test removing child
2606 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2607 gActorNamesOnOffStage.clear();
2609 parent.Remove( child );
2610 // onstage not emitted, offstage is
2611 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2612 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2613 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2615 // test removing parent
2617 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2618 gActorNamesOnOffStage.clear();
2620 Stage::GetCurrent().Remove( parent );
2621 // onstage not emitted, offstage is
2622 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2623 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2624 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2628 int UtcDaliActorFindChildByName(void)
2630 tet_infoline("Testing Dali::Actor::FindChildByName()");
2631 TestApplication application;
2633 Actor parent = Actor::New();
2634 parent.SetName( "parent" );
2635 Actor first = Actor::New();
2636 first .SetName( "first" );
2637 Actor second = Actor::New();
2638 second.SetName( "second" );
2643 Actor found = parent.FindChildByName( "foo" );
2644 DALI_TEST_CHECK( !found );
2646 found = parent.FindChildByName( "parent" );
2647 DALI_TEST_CHECK( found == parent );
2649 found = parent.FindChildByName( "first" );
2650 DALI_TEST_CHECK( found == first );
2652 found = parent.FindChildByName( "second" );
2653 DALI_TEST_CHECK( found == second );
2657 int UtcDaliActorFindChildById(void)
2659 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2660 TestApplication application;
2662 Actor parent = Actor::New();
2663 Actor first = Actor::New();
2664 Actor second = Actor::New();
2669 Actor found = parent.FindChildById( 100000 );
2670 DALI_TEST_CHECK( !found );
2672 found = parent.FindChildById( parent.GetId() );
2673 DALI_TEST_CHECK( found == parent );
2675 found = parent.FindChildById( first.GetId() );
2676 DALI_TEST_CHECK( found == first );
2678 found = parent.FindChildById( second.GetId() );
2679 DALI_TEST_CHECK( found == second );
2683 int UtcDaliActorHitTest(void)
2688 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2690 mTouchPoint( touchPoint ),
2695 Vector2 mTouchPoint;
2699 TestApplication application;
2700 tet_infoline(" UtcDaliActorHitTest");
2702 // Fill a vector with different hit tests.
2703 struct HitTestData* hitTestData[] = {
2704 // scale touch point result
2705 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2706 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2707 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.
2708 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2709 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.
2713 // get the root layer
2714 Actor actor = Actor::New();
2715 actor.SetAnchorPoint( AnchorPoint::CENTER );
2716 actor.SetParentOrigin( ParentOrigin::CENTER );
2718 Stage::GetCurrent().Add( actor );
2720 ResetTouchCallbacks();
2722 unsigned int index = 0;
2723 while( NULL != hitTestData[index] )
2725 actor.SetSize( 1.f, 1.f );
2726 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2728 // flush the queue and render once
2729 application.SendNotification();
2730 application.Render();
2732 DALI_TEST_CHECK( !gTouchCallBackCalled );
2734 // connect to its touch signal
2735 actor.TouchedSignal().Connect(TestCallback);
2737 Dali::Integration::Point point;
2738 point.SetState( PointState::DOWN );
2739 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2740 Dali::Integration::TouchEvent event;
2741 event.AddPoint( point );
2743 // flush the queue and render once
2744 application.SendNotification();
2745 application.Render();
2746 application.ProcessEvent( event );
2748 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2750 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2751 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2752 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2753 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2754 hitTestData[index]->mResult );
2756 ResetTouchCallbacks();
2762 int UtcDaliActorSetDrawMode(void)
2764 TestApplication app;
2765 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2767 Actor a = Actor::New();
2769 Stage::GetCurrent().Add(a);
2770 app.SendNotification();
2772 app.SendNotification();
2775 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2777 a.SetDrawMode( DrawMode::OVERLAY_2D );
2778 app.SendNotification();
2781 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2783 a.SetDrawMode( DrawMode::NORMAL );
2784 app.SendNotification();
2787 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2791 int UtcDaliActorSetDrawModeOverlayRender(void)
2793 TestApplication app;
2794 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2796 app.SendNotification();
2799 std::vector<GLuint> ids;
2800 ids.push_back( 8 ); // first rendered actor
2801 ids.push_back( 9 ); // second rendered actor
2802 ids.push_back( 10 ); // third rendered actor
2803 app.GetGlAbstraction().SetNextTextureIds( ids );
2805 BufferImage imageA = BufferImage::New(16, 16);
2806 BufferImage imageB = BufferImage::New(16, 16);
2807 BufferImage imageC = BufferImage::New(16, 16);
2808 Actor a = CreateRenderableActor( imageA );
2809 Actor b = CreateRenderableActor( imageB );
2810 Actor c = CreateRenderableActor( imageC );
2812 app.SendNotification();
2815 //Textures are bound when first created. Clear bound textures vector
2816 app.GetGlAbstraction().ClearBoundTextures();
2818 // Render a,b,c as regular non-overlays. so order will be:
2822 Stage::GetCurrent().Add(a);
2823 Stage::GetCurrent().Add(b);
2824 Stage::GetCurrent().Add(c);
2826 app.SendNotification();
2829 // Should be 3 textures changes.
2830 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2831 typedef std::vector<GLuint>::size_type TextureSize;
2832 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2833 if( boundTextures.size() == 3 )
2835 DALI_TEST_CHECK( boundTextures[0] == 8u );
2836 DALI_TEST_CHECK( boundTextures[1] == 9u );
2837 DALI_TEST_CHECK( boundTextures[2] == 10u );
2840 // Now texture ids have been set, we can monitor their render order.
2841 // render a as an overlay (last), so order will be:
2845 a.SetDrawMode( DrawMode::OVERLAY_2D );
2846 app.GetGlAbstraction().ClearBoundTextures();
2848 app.SendNotification();
2851 // Should be 3 texture changes.
2852 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2853 if( boundTextures.size() == 3 )
2855 DALI_TEST_CHECK( boundTextures[0] == 9u );
2856 DALI_TEST_CHECK( boundTextures[1] == 10u );
2857 DALI_TEST_CHECK( boundTextures[2] == 8u );
2862 int UtcDaliActorGetCurrentWorldMatrix(void)
2864 TestApplication app;
2865 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2867 Actor parent = Actor::New();
2868 parent.SetParentOrigin(ParentOrigin::CENTER);
2869 parent.SetAnchorPoint(AnchorPoint::CENTER);
2870 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2871 Radian rotationAngle(Degree(85.0f));
2872 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2873 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2874 parent.SetPosition( parentPosition );
2875 parent.SetOrientation( parentRotation );
2876 parent.SetScale( parentScale );
2877 Stage::GetCurrent().Add( parent );
2879 Actor child = Actor::New();
2880 child.SetParentOrigin(ParentOrigin::CENTER);
2881 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2882 Radian childRotationAngle(Degree(23.0f));
2883 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2884 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2885 child.SetPosition( childPosition );
2886 child.SetOrientation( childRotation );
2887 child.SetScale( childScale );
2888 parent.Add( child );
2890 app.SendNotification();
2893 app.SendNotification();
2895 Matrix parentMatrix(false);
2896 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2898 Matrix childMatrix(false);
2899 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2901 //Child matrix should be the composition of child and parent
2902 Matrix childWorldMatrix(false);
2903 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2905 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2906 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2912 int UtcDaliActorConstrainedToWorldMatrix(void)
2914 TestApplication app;
2915 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2917 Actor parent = Actor::New();
2918 parent.SetParentOrigin(ParentOrigin::CENTER);
2919 parent.SetAnchorPoint(AnchorPoint::CENTER);
2920 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2921 Radian rotationAngle(Degree(85.0f));
2922 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2923 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2924 parent.SetPosition( parentPosition );
2925 parent.SetOrientation( parentRotation );
2926 parent.SetScale( parentScale );
2927 Stage::GetCurrent().Add( parent );
2929 Actor child = Actor::New();
2930 child.SetParentOrigin(ParentOrigin::CENTER);
2931 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2932 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2933 posConstraint.Apply();
2935 Stage::GetCurrent().Add( child );
2937 app.SendNotification();
2940 app.SendNotification();
2942 Matrix parentMatrix(false);
2943 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2945 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2946 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2950 int UtcDaliActorConstrainedToOrientation(void)
2952 TestApplication app;
2953 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2955 Actor parent = Actor::New();
2956 parent.SetParentOrigin(ParentOrigin::CENTER);
2957 parent.SetAnchorPoint(AnchorPoint::CENTER);
2958 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2959 Radian rotationAngle(Degree(85.0f));
2960 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2961 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2962 parent.SetPosition( parentPosition );
2963 parent.SetOrientation( parentRotation );
2964 parent.SetScale( parentScale );
2965 Stage::GetCurrent().Add( parent );
2967 Actor child = Actor::New();
2968 child.SetParentOrigin(ParentOrigin::CENTER);
2969 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2970 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2971 posConstraint.Apply();
2973 Stage::GetCurrent().Add( child );
2975 app.SendNotification();
2978 app.SendNotification();
2980 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2984 int UtcDaliActorConstrainedToOpacity(void)
2986 TestApplication app;
2987 tet_infoline(" UtcDaliActorConstrainedToOpacity");
2989 Actor parent = Actor::New();
2990 parent.SetOpacity( 0.7f );
2991 Stage::GetCurrent().Add( parent );
2993 Actor child = Actor::New();
2994 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2995 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2996 opacityConstraint.Apply();
2998 Stage::GetCurrent().Add( child );
3000 app.SendNotification();
3003 app.SendNotification();
3005 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3007 parent.SetOpacity( 0.3f );
3009 app.SendNotification();
3012 app.SendNotification();
3014 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3019 int UtcDaliActorUnparent(void)
3021 TestApplication app;
3022 tet_infoline(" UtcDaliActorUnparent");
3024 Actor parent = Actor::New();
3025 Stage::GetCurrent().Add( parent );
3027 Actor child = Actor::New();
3029 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3030 DALI_TEST_CHECK( !child.GetParent() );
3032 // Test that calling Unparent with no parent is a NOOP
3035 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3036 DALI_TEST_CHECK( !child.GetParent() );
3038 // Test that Unparent works
3039 parent.Add( child );
3041 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3042 DALI_TEST_CHECK( parent == child.GetParent() );
3046 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3047 DALI_TEST_CHECK( !child.GetParent() );
3049 // Test that UnparentAndReset works
3050 parent.Add( child );
3052 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3053 DALI_TEST_CHECK( parent == child.GetParent() );
3055 UnparentAndReset( child );
3057 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3058 DALI_TEST_CHECK( !child );
3060 // Test that UnparentAndReset is a NOOP with empty handle
3061 UnparentAndReset( child );
3063 DALI_TEST_CHECK( !child );
3067 int UtcDaliActorGetChildAt(void)
3069 TestApplication app;
3070 tet_infoline(" UtcDaliActorGetChildAt");
3072 Actor parent = Actor::New();
3073 Stage::GetCurrent().Add( parent );
3075 Actor child0 = Actor::New();
3076 parent.Add( child0 );
3078 Actor child1 = Actor::New();
3079 parent.Add( child1 );
3081 Actor child2 = Actor::New();
3082 parent.Add( child2 );
3084 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3085 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3086 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3090 int UtcDaliActorSetGetOverlay(void)
3092 TestApplication app;
3093 tet_infoline(" UtcDaliActorSetGetOverlay");
3095 Actor parent = Actor::New();
3096 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3097 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3102 int UtcDaliActorCreateDestroy(void)
3104 Actor* actor = new Actor;
3105 DALI_TEST_CHECK( actor );
3112 struct PropertyStringIndex
3114 const char * const name;
3115 const Property::Index index;
3116 const Property::Type type;
3119 const PropertyStringIndex PROPERTY_TABLE[] =
3121 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3122 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3123 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3124 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3125 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3126 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3127 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3128 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3129 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3130 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3131 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3132 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3133 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3134 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3135 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3136 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3137 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3138 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3139 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3140 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3141 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3142 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3143 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3144 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3145 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3146 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3147 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3148 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3149 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3150 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3151 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3152 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3153 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3154 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3155 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3156 { "name", Actor::Property::NAME, Property::STRING },
3157 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3158 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3159 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3160 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3161 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3162 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3163 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3164 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3165 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3166 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3167 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3168 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3169 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3170 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3171 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3172 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3173 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3174 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3175 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3177 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3178 } // unnamed namespace
3180 int UtcDaliActorProperties(void)
3182 TestApplication app;
3184 Actor actor = Actor::New();
3186 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3188 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3189 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3190 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3191 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3196 int UtcDaliRelayoutProperties_ResizePolicies(void)
3198 TestApplication app;
3200 Actor actor = Actor::New();
3203 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3204 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3206 // Set resize policy for all dimensions
3207 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3208 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3210 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3213 // Set individual dimensions
3214 const char* const widthPolicy = "FILL_TO_PARENT";
3215 const char* const heightPolicy = "FIXED";
3217 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3218 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3220 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3221 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3223 // Set individual dimensions using enums
3224 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3225 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3227 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3228 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3230 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3231 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3236 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3238 TestApplication app;
3240 Actor actor = Actor::New();
3243 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3244 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3246 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3247 actor.SetSizeScalePolicy( policy );
3248 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3251 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3252 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3254 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3255 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3257 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3258 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3263 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3265 TestApplication app;
3267 Actor actor = Actor::New();
3270 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3271 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3273 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3274 actor.SetSizeModeFactor( sizeMode );
3275 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3278 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3280 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3281 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3286 int UtcDaliRelayoutProperties_DimensionDependency(void)
3288 TestApplication app;
3290 Actor actor = Actor::New();
3293 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3294 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3297 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3298 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3300 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3301 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3303 // Test setting another resize policy
3304 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3305 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3310 int UtcDaliRelayoutProperties_Padding(void)
3312 TestApplication app;
3314 Actor actor = Actor::New();
3317 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3320 actor.SetProperty( Actor::Property::PADDING, padding );
3321 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3323 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3328 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3330 TestApplication app;
3332 Actor actor = Actor::New();
3335 Vector2 minSize( 1.0f, 2.0f );
3337 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3338 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3340 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3342 Vector2 maxSize( 3.0f, 4.0f );
3344 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3345 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3347 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3352 int UtcDaliActorGetHeightForWidth(void)
3354 TestApplication app;
3356 Actor actor = Actor::New();
3358 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3363 int UtcDaliActorGetWidthForHeight(void)
3365 TestApplication app;
3367 Actor actor = Actor::New();
3369 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3374 int UtcDaliActorGetRelayoutSize(void)
3376 TestApplication app;
3378 Actor actor = Actor::New();
3380 // Add actor to stage
3381 Stage::GetCurrent().Add( actor );
3383 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3385 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3386 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3388 // Flush the queue and render once
3389 app.SendNotification();
3392 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3397 int UtcDaliActorSetPadding(void)
3399 TestApplication app;
3401 Actor actor = Actor::New();
3404 actor.GetPadding( padding );
3406 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3407 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3408 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3409 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3411 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3412 actor.SetPadding( padding2 );
3414 actor.GetPadding( padding );
3416 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3417 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3418 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3419 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3424 int UtcDaliActorSetMinimumSize(void)
3426 TestApplication app;
3428 Actor actor = Actor::New();
3430 Vector2 size = actor.GetMinimumSize();
3432 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3433 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3435 Vector2 size2( 1.0f, 2.0f );
3436 actor.SetMinimumSize( size2 );
3438 size = actor.GetMinimumSize();
3440 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3441 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3446 int UtcDaliActorSetMaximumSize(void)
3448 TestApplication app;
3450 Actor actor = Actor::New();
3452 Vector2 size = actor.GetMaximumSize();
3454 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3455 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3457 Vector2 size2( 1.0f, 2.0f );
3458 actor.SetMaximumSize( size2 );
3460 size = actor.GetMaximumSize();
3462 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3463 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3468 int UtcDaliActorOnRelayoutSignal(void)
3470 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3472 TestApplication application;
3475 gOnRelayoutCallBackCalled = false;
3476 gActorNamesRelayout.clear();
3478 Actor actor = Actor::New();
3479 actor.SetName( "actor" );
3480 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3483 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3485 // Add actor to stage
3486 Stage::GetCurrent().Add( actor );
3488 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3489 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3491 // Flush the queue and render once
3492 application.SendNotification();
3493 application.Render();
3495 // OnRelayout emitted
3496 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3497 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3502 int UtcDaliActorGetHierachyDepth(void)
3504 TestApplication application;
3505 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3508 /* Build tree of actors:
3518 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3520 Stage stage( Stage::GetCurrent() );
3522 Actor actorA = Actor::New();
3523 Actor actorB = Actor::New();
3524 Actor actorC = Actor::New();
3525 Actor actorD = Actor::New();
3526 Actor actorE = Actor::New();
3527 Actor actorF = Actor::New();
3529 //Test that root actor has depth equal 0
3530 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3532 //Test actors return depth -1 when not connected to the tree
3533 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3534 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3535 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3536 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3537 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3538 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3540 //Create the hierarchy
3541 stage.Add( actorA );
3542 actorA.Add( actorB );
3543 actorA.Add( actorC );
3544 actorB.Add( actorD );
3545 actorB.Add( actorE );
3546 actorC.Add( actorF );
3548 //Test actors return correct depth
3549 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3550 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3551 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3552 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3553 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3554 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3556 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3557 actorA.Remove( actorB );
3559 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3560 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3561 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3563 //Removing actorA from the stage. All actors should have depth equal -1
3564 stage.Remove( actorA );
3566 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3567 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3568 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3569 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3570 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3571 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3576 int UtcDaliActorAnchorPointPropertyAsString(void)
3578 TestApplication application;
3580 Actor actor = Actor::New();
3582 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3583 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3585 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3586 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3588 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3589 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3591 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3592 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3594 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3595 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3597 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3598 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3600 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3601 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3603 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3604 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3606 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3607 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3609 // Invalid should not change anything
3610 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3611 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3616 int UtcDaliActorParentOriginPropertyAsString(void)
3618 TestApplication application;
3620 Actor actor = Actor::New();
3622 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3623 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3625 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3626 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3628 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3629 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3631 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3632 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3634 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3635 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3637 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3638 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3640 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3641 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3643 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3644 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3646 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3647 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3649 // Invalid should not change anything
3650 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3651 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3656 int UtcDaliActorColorModePropertyAsString(void)
3658 TestApplication application;
3660 Actor actor = Actor::New();
3662 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3663 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3665 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3666 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3668 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3669 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3671 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3672 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3674 // Invalid should not change anything
3675 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3676 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3681 int UtcDaliActorPositionInheritancePropertyAsString(void)
3683 TestApplication application;
3685 Actor actor = Actor::New();
3687 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3688 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3690 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3691 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3693 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3694 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3696 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3697 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3699 // Invalid should not change anything
3700 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3701 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3706 int UtcDaliActorDrawModePropertyAsString(void)
3708 TestApplication application;
3710 Actor actor = Actor::New();
3712 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3713 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3715 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3716 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3718 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3719 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3721 // Invalid should not change anything
3722 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3723 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3728 int UtcDaliActorColorModePropertyAsEnum(void)
3730 TestApplication application;
3732 Actor actor = Actor::New();
3734 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3735 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3737 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3738 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3740 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3741 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3743 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3744 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3749 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3751 TestApplication application;
3753 Actor actor = Actor::New();
3755 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3756 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3758 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3759 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3761 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3762 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3764 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3765 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3770 int UtcDaliActorDrawModePropertyAsEnum(void)
3772 TestApplication application;
3774 Actor actor = Actor::New();
3776 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3777 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3779 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3780 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3782 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3783 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3788 int UtcDaliActorAddRendererP(void)
3790 tet_infoline("Testing Actor::AddRenderer");
3791 TestApplication application;
3793 Actor actor = Actor::New();
3795 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3797 Geometry geometry = CreateQuadGeometry();
3798 Shader shader = CreateShader();
3799 Renderer renderer = Renderer::New(geometry, shader);
3801 actor.AddRenderer( renderer );
3802 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3803 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3808 int UtcDaliActorAddRendererN(void)
3810 tet_infoline("Testing Actor::AddRenderer");
3811 TestApplication application;
3813 Actor actor = Actor::New();
3819 actor.AddRenderer( renderer );
3820 tet_printf("Assertion test failed - no Exception\n" );
3821 tet_result(TET_FAIL);
3823 catch(Dali::DaliException& e)
3825 DALI_TEST_PRINT_ASSERT( e );
3826 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3827 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3831 tet_printf("Assertion test failed - wrong Exception\n" );
3832 tet_result(TET_FAIL);
3838 int UtcDaliActorAddRendererOnStage(void)
3840 tet_infoline("Testing Actor::AddRenderer");
3841 TestApplication application;
3843 Actor actor = Actor::New();
3844 Stage::GetCurrent().Add(actor);
3846 application.SendNotification();
3847 application.Render(0);
3849 Geometry geometry = CreateQuadGeometry();
3850 Shader shader = CreateShader();
3851 Renderer renderer = Renderer::New(geometry, shader);
3853 application.SendNotification();
3854 application.Render(0);
3858 actor.AddRenderer( renderer );
3859 tet_result(TET_PASS);
3863 tet_result(TET_FAIL);
3869 int UtcDaliActorRemoveRendererP1(void)
3871 tet_infoline("Testing Actor::RemoveRenderer");
3872 TestApplication application;
3874 Actor actor = Actor::New();
3876 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3879 Geometry geometry = CreateQuadGeometry();
3880 Shader shader = CreateShader();
3881 Renderer renderer = Renderer::New(geometry, shader);
3883 actor.AddRenderer( renderer );
3884 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3885 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3887 application.SendNotification();
3888 application.Render();
3892 Renderer renderer = actor.GetRendererAt(0);
3893 actor.RemoveRenderer(renderer);
3894 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3896 application.SendNotification();
3897 application.Render();
3900 // Call one final time to ensure that the renderer is actually removed after
3901 // the handle goes out of scope, and excercises the deletion code path in
3902 // scene graph and render.
3903 application.SendNotification();
3904 application.Render();
3909 int UtcDaliActorRemoveRendererP2(void)
3911 tet_infoline("Testing Actor::RemoveRenderer");
3912 TestApplication application;
3914 Actor actor = Actor::New();
3916 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3918 Geometry geometry = CreateQuadGeometry();
3919 Shader shader = CreateShader();
3920 Renderer renderer = Renderer::New(geometry, shader);
3922 actor.AddRenderer( renderer );
3923 application.SendNotification();
3924 application.Render();
3926 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3927 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3929 actor.RemoveRenderer(0);
3930 application.SendNotification();
3931 application.Render();
3933 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3935 // Shut down whilst holding onto the renderer handle.
3940 int UtcDaliActorRemoveRendererN(void)
3942 tet_infoline("Testing Actor::RemoveRenderer");
3943 TestApplication application;
3945 Actor actor = Actor::New();
3947 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3949 Geometry geometry = CreateQuadGeometry();
3950 Shader shader = CreateShader();
3951 Renderer renderer = Renderer::New(geometry, shader);
3953 actor.AddRenderer( renderer );
3954 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3955 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3957 actor.RemoveRenderer(10);
3958 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3959 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3964 // Clipping test helper functions:
3965 Actor CreateActorWithContent( uint32_t width, uint32_t height)
3967 BufferImage image = BufferImage::New( width, height );
3968 Actor actor = CreateRenderableActor( image );
3970 // Setup dimensions and position so actor is not skipped by culling.
3971 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3972 actor.SetSize( width, height );
3973 actor.SetParentOrigin( ParentOrigin::CENTER );
3974 actor.SetAnchorPoint( AnchorPoint::CENTER );
3979 Actor CreateActorWithContent16x16()
3981 return CreateActorWithContent( 16, 16 );
3984 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3986 enabledDisableTrace.Reset();
3987 stencilTrace.Reset();
3988 enabledDisableTrace.Enable( true );
3989 stencilTrace.Enable( true );
3991 application.SendNotification();
3992 application.Render();
3994 enabledDisableTrace.Enable( false );
3995 stencilTrace.Enable( false );
3998 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4000 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4002 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4003 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4004 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4005 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4008 int UtcDaliActorPropertyClippingP(void)
4010 // This test checks the clippingMode property.
4011 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4012 TestApplication application;
4014 Actor actor = Actor::New();
4016 // Check default clippingEnabled value.
4017 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4020 bool getValueResult = getValue.Get( value );
4021 DALI_TEST_CHECK( getValueResult );
4023 if( getValueResult )
4025 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4028 // Check setting the property to the stencil mode.
4029 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4031 // Check the new value was set.
4032 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4033 getValueResult = getValue.Get( value );
4034 DALI_TEST_CHECK( getValueResult );
4036 if( getValueResult )
4038 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4041 // Check setting the property to the scissor mode.
4042 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4044 // Check the new value was set.
4045 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4046 getValueResult = getValue.Get( value );
4047 DALI_TEST_CHECK( getValueResult );
4049 if( getValueResult )
4051 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4056 int UtcDaliActorPropertyClippingN(void)
4058 // Negative test case for Clipping.
4059 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4060 TestApplication application;
4062 Actor actor = Actor::New();
4064 // Check default clippingEnabled value.
4065 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4068 bool getValueResult = getValue.Get( value );
4069 DALI_TEST_CHECK( getValueResult );
4071 if( getValueResult )
4073 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4076 // Check setting an invalid property value won't change the current property value.
4077 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4079 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4080 getValueResult = getValue.Get( value );
4081 DALI_TEST_CHECK( getValueResult );
4083 if( getValueResult )
4085 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4091 int UtcDaliActorPropertyClippingActor(void)
4093 // This test checks that an actor is correctly setup for clipping.
4094 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4095 TestApplication application;
4097 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4098 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4099 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4100 size_t startIndex = 0u;
4102 // Create a clipping actor.
4103 Actor actorDepth1Clip = CreateActorWithContent16x16();
4104 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4105 Stage::GetCurrent().Add( actorDepth1Clip );
4107 // Gather the call trace.
4108 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4110 // Check we are writing to the color buffer.
4111 CheckColorMask( glAbstraction, true );
4113 // Check the stencil buffer was enabled.
4114 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4116 // Check the stencil buffer was cleared.
4117 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4119 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4120 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4121 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4122 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4127 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4129 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4130 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4131 TestApplication application;
4133 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4134 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4135 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4136 size_t startIndex = 0u;
4138 // Create a clipping actor.
4139 Actor actorDepth1Clip = CreateActorWithContent16x16();
4140 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4141 Stage::GetCurrent().Add( actorDepth1Clip );
4143 // Gather the call trace.
4144 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4146 // Check we are writing to the color buffer.
4147 CheckColorMask( glAbstraction, true );
4149 // Check the stencil buffer was enabled.
4150 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4152 // Check the stencil buffer was cleared.
4153 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4155 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4156 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4157 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4158 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4160 // Now disable the clipping
4161 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4163 // Gather the call trace.
4164 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4166 // Check the stencil buffer was disabled.
4167 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4169 // Ensure all values in stencil-mask are set to 1.
4171 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4176 int UtcDaliActorPropertyClippingNestedChildren(void)
4178 // This test checks that a hierarchy of actors are clipped correctly by
4179 // writing to and reading from the correct bit-planes of the stencil buffer.
4180 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4181 TestApplication application;
4182 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4183 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4184 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4186 // Create a clipping actor.
4187 Actor actorDepth1Clip = CreateActorWithContent16x16();
4188 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4189 Stage::GetCurrent().Add( actorDepth1Clip );
4191 // Create a child actor.
4192 Actor childDepth2 = CreateActorWithContent16x16();
4193 actorDepth1Clip.Add( childDepth2 );
4195 // Create another clipping actor.
4196 Actor childDepth2Clip = CreateActorWithContent16x16();
4197 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4198 childDepth2.Add( childDepth2Clip );
4200 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4201 // This tests the sort algorithm.
4202 Actor childDepth3 = CreateActorWithContent16x16();
4203 childDepth2Clip.Add( childDepth3 );
4204 Actor childDepth4 = CreateActorWithContent16x16();
4205 childDepth3.Add( childDepth4 );
4207 // Gather the call trace.
4208 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4210 // Check we are writing to the color buffer.
4211 CheckColorMask( glAbstraction, true );
4213 // Check the stencil buffer was enabled.
4214 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4216 // Perform the test twice, once for 2D layer, and once for 3D.
4217 for( unsigned int i = 0u ; i < 2u; ++i )
4219 size_t startIndex = 0u;
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 ) ); // Write to the first bit-plane
4227 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4229 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4230 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4231 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4233 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4234 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4235 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4236 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4238 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4239 // (Both must be set to pass the check).
4240 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4241 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4243 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4246 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4247 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4254 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4256 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4257 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4258 TestApplication application;
4259 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4260 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4262 /* We create a small tree of actors as follows:
4266 Clipping enabled -> B D
4270 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4273 for( int i = 0; i < 5; ++i )
4275 BufferImage image = BufferImage::New( 16u, 16u );
4276 Actor actor = CreateRenderableActor( image );
4278 // Setup dimensions and position so actor is not skipped by culling.
4279 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4280 actor.SetSize( 16.0f, 16.0f );
4284 actor.SetParentOrigin( ParentOrigin::CENTER );
4288 float b = i > 2 ? 1.0f : -1.0f;
4289 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4295 // Enable clipping on the actor at the top of the left branch.
4296 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4298 // Build the scene graph.
4299 Stage::GetCurrent().Add( actors[0] );
4302 actors[0].Add( actors[1] );
4303 actors[1].Add( actors[2] );
4306 actors[0].Add( actors[3] );
4307 actors[3].Add( actors[4] );
4309 // Gather the call trace.
4310 enabledDisableTrace.Reset();
4311 enabledDisableTrace.Enable( true );
4312 application.SendNotification();
4313 application.Render();
4314 enabledDisableTrace.Enable( false );
4316 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4318 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
4319 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4321 size_t startIndex = 0u;
4322 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4323 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4324 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4326 // Swap the clipping actor from top of left branch to top of right branch.
4327 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4328 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4330 // Gather the call trace.
4331 enabledDisableTrace.Reset();
4332 enabledDisableTrace.Enable( true );
4333 application.SendNotification();
4334 application.Render();
4335 enabledDisableTrace.Enable( false );
4337 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4338 // This proves the draw order has remained the same.
4340 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4341 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4346 int UtcDaliActorPropertyScissorClippingActor(void)
4348 // This test checks that an actor is correctly setup for clipping.
4349 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4350 TestApplication application;
4352 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4353 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4354 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4356 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4357 const Vector2 imageSize( 16.0f, 16.0f );
4359 // Create a clipping actor.
4360 Actor clippingActorA = CreateActorWithContent16x16();
4361 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4362 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4363 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4364 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4365 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4366 Stage::GetCurrent().Add( clippingActorA );
4368 // Gather the call trace.
4369 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4371 // Check we are writing to the color buffer.
4372 CheckColorMask( glAbstraction, true );
4374 // Check scissor test was enabled.
4375 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4377 // Check the scissor was set, and the coordinates are correct.
4378 std::stringstream compareParametersString;
4379 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4380 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4382 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4383 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4385 // Gather the call trace.
4386 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4388 // Check the scissor was set, and the coordinates are correct.
4389 compareParametersString.str( std::string() );
4390 compareParametersString.clear();
4391 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4392 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4397 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4399 // This test checks that an actor is correctly setup for clipping.
4400 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4401 TestApplication application;
4404 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4405 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4406 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4408 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4409 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4410 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4412 // Create a clipping actors.
4413 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4414 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4416 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4417 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4418 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4420 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4421 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4422 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4424 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4425 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4427 Stage::GetCurrent().Add( clippingActorA );
4428 Stage::GetCurrent().Add( clippingActorB );
4430 // Gather the call trace.
4431 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4433 // Check we are writing to the color buffer.
4434 CheckColorMask( glAbstraction, true );
4436 // Check scissor test was enabled.
4437 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4439 // Check the scissor was set, and the coordinates are correct.
4440 std::stringstream compareParametersString;
4442 std::string clipA( "0, 500, 480, 200" );
4443 std::string clipB( "0, 380, 480, 40" );
4445 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4446 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4451 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4453 // This test checks that an actor is correctly setup for clipping.
4454 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4455 TestApplication application;
4457 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4458 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4459 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4461 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4462 const Vector2 imageSize( 16.0f, 16.0f );
4464 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4466 A is drawn first - with scissor clipping on
4467 B is drawn second - also with scissor clipping on
4468 C is the generated clipping region, the intersection ( A ∩ B )
4472 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4473 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4474 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4478 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4481 // Create a clipping actor.
4482 Actor clippingActorA = CreateActorWithContent16x16();
4483 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4484 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4485 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4486 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4487 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4488 Stage::GetCurrent().Add( clippingActorA );
4490 // Create a child clipping actor.
4491 Actor clippingActorB = CreateActorWithContent16x16();
4492 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4493 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4494 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4495 clippingActorA.Add( clippingActorB );
4497 // positionModifiers is an array of positions to position B around.
4498 // expect is an array of expected scissor clip coordinate results.
4499 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4500 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4502 // Loop through each overlap combination.
4503 for( unsigned int test = 0u; test < 4u; ++test )
4505 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4506 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4507 clippingActorB.SetPosition( position.x, position.y );
4509 // Gather the call trace.
4510 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4512 // Check we are writing to the color buffer.
4513 CheckColorMask( glAbstraction, true );
4515 // Check scissor test was enabled.
4516 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4518 // Check the scissor was set, and the coordinates are correct.
4519 const Vector4& expectResults( expect[test] );
4520 std::stringstream compareParametersString;
4521 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4522 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4528 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4530 // This test checks that an actor is correctly setup for clipping.
4531 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4532 TestApplication application;
4534 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4535 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4536 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4538 /* Create a nest of 2 scissors and siblings of the parent.
4548 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4549 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4550 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4551 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4552 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4553 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4555 // Create a clipping actors.
4556 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4557 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4558 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4559 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4560 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4562 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4563 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4564 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4566 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4567 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4568 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4570 clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4571 clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4572 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4574 clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4575 clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4576 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4578 clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4579 clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4581 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4582 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4583 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4584 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4585 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4587 Stage::GetCurrent().Add( clippingActorA );
4588 clippingActorA.Add( clippingActorB );
4589 Stage::GetCurrent().Add( clippingActorC );
4590 Stage::GetCurrent().Add( clippingActorD );
4591 clippingActorD.Add( clippingActorE );
4593 // Gather the call trace.
4594 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4596 // Check we are writing to the color buffer.
4597 CheckColorMask( glAbstraction, true );
4599 // Check scissor test was enabled.
4600 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4602 // Check the scissor was set, and the coordinates are correct.
4603 std::string clipA( "0, 500, 480, 200" );
4604 std::string clipB( "0, 580, 480, 40" );
4605 std::string clipC( "0, 200, 480, 200" );
4606 std::string clipD( "0, 300, 480, 200" );
4608 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4609 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4610 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4611 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4612 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4617 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4619 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4620 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4621 TestApplication application;
4623 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4624 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4625 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4627 // Create a clipping actor.
4628 Actor actorDepth1Clip = CreateActorWithContent16x16();
4629 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4630 Stage::GetCurrent().Add( actorDepth1Clip );
4632 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4633 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4635 // Gather the call trace.
4636 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4638 // Check we are writing to the color buffer.
4639 CheckColorMask( glAbstraction, true );
4641 // Check the stencil buffer was not enabled.
4642 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4644 // Check stencil functions are not called.
4645 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4646 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4647 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4649 // Check that scissor clipping is overriden by the renderer properties.
4650 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4652 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4654 // Gather the call trace.
4655 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4657 // Check the stencil buffer was not enabled.
4658 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4660 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4665 int UtcDaliGetPropertyN(void)
4667 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4668 TestApplication app;
4670 Actor actor = Actor::New();
4672 unsigned int propertyCount = actor.GetPropertyCount();
4673 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4677 int UtcDaliActorRaiseLower(void)
4679 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4681 TestApplication application;
4683 Stage stage( Stage::GetCurrent() );
4685 Actor actorA = Actor::New();
4686 Actor actorB = Actor::New();
4687 Actor actorC = Actor::New();
4689 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4690 actorA.SetParentOrigin( ParentOrigin::CENTER );
4692 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4693 actorB.SetParentOrigin( ParentOrigin::CENTER );
4695 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4696 actorC.SetParentOrigin( ParentOrigin::CENTER );
4698 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4699 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4701 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4702 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4704 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4705 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4707 stage.Add( actorA );
4708 stage.Add( actorB );
4709 stage.Add( actorC );
4711 ResetTouchCallbacks();
4713 application.SendNotification();
4714 application.Render();
4716 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4717 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4718 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4720 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4721 // Only top actor will get touched.
4722 actorA.TouchSignal().Connect( TestTouchCallback );
4723 actorB.TouchSignal().Connect( TestTouchCallback2 );
4724 actorC.TouchSignal().Connect( TestTouchCallback3 );
4726 Dali::Integration::Point point;
4727 point.SetDeviceId( 1 );
4728 point.SetState( PointState::DOWN );
4729 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4730 Dali::Integration::TouchEvent touchEvent;
4731 touchEvent.AddPoint( point );
4733 application.ProcessEvent( touchEvent );
4735 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4736 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4737 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4739 ResetTouchCallbacks();
4741 tet_printf( "Testing Raising of Actor\n" );
4743 int preActorOrder( 0 );
4744 int postActorOrder( 0 );
4746 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4747 value.Get( preActorOrder );
4750 // Ensure sort order is calculated before next touch event
4751 application.SendNotification();
4753 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4754 value.Get( postActorOrder );
4756 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4758 application.ProcessEvent( touchEvent );
4760 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4761 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4762 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4764 ResetTouchCallbacks();
4766 tet_printf( "Testing Lowering of Actor\n" );
4768 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4769 value.Get( preActorOrder );
4772 application.SendNotification(); // ensure sort order calculated before next touch event
4774 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4775 value.Get( postActorOrder );
4777 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4779 application.ProcessEvent( touchEvent );
4781 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4782 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4783 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4785 ResetTouchCallbacks();
4790 int UtcDaliActorRaiseToTopLowerToBottom(void)
4792 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4794 TestApplication application;
4796 Stage stage( Stage::GetCurrent() );
4798 Actor actorA = Actor::New();
4799 Actor actorB = Actor::New();
4800 Actor actorC = Actor::New();
4802 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4803 // enables checking of which actor the uniform is assigned too
4804 Shader shaderA = CreateShader();
4805 shaderA.RegisterProperty( "uRendererColor",1.f);
4807 Shader shaderB = CreateShader();
4808 shaderB.RegisterProperty( "uRendererColor", 2.f );
4810 Shader shaderC = CreateShader();
4811 shaderC.RegisterProperty( "uRendererColor", 3.f );
4813 Geometry geometry = CreateQuadGeometry();
4815 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4816 Renderer rendererA = Renderer::New(geometry, shaderA);
4817 actorA.AddRenderer(rendererA);
4819 Renderer rendererB = Renderer::New(geometry, shaderB);
4820 actorB.AddRenderer(rendererB);
4822 Renderer rendererC = Renderer::New(geometry, shaderC);
4823 actorC.AddRenderer(rendererC);
4825 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4826 actorA.SetParentOrigin( ParentOrigin::CENTER );
4828 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4829 actorB.SetParentOrigin( ParentOrigin::CENTER );
4831 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4832 actorC.SetParentOrigin( ParentOrigin::CENTER );
4834 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4835 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4837 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4838 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4840 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4841 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4843 stage.Add( actorA );
4844 stage.Add( actorB );
4845 stage.Add( actorC );
4847 ResetTouchCallbacks();
4849 // Set up gl abstraction trace so can query the set uniform order
4850 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4851 glAbstraction.EnableSetUniformCallTrace(true);
4852 glAbstraction.ResetSetUniformCallStack();
4854 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4856 application.SendNotification();
4857 application.Render();
4859 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4862 // Test order of uniforms in stack
4863 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4864 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4865 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4867 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4869 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4871 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4872 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4873 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4875 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4876 // Only top actor will get touched.
4877 actorA.TouchSignal().Connect( TestTouchCallback );
4878 actorB.TouchSignal().Connect( TestTouchCallback2 );
4879 actorC.TouchSignal().Connect( TestTouchCallback3 );
4881 Dali::Integration::Point point;
4882 point.SetDeviceId( 1 );
4883 point.SetState( PointState::DOWN );
4884 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4885 Dali::Integration::TouchEvent touchEvent;
4886 touchEvent.AddPoint( point );
4888 application.ProcessEvent( touchEvent );
4890 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4891 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4892 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4894 ResetTouchCallbacks();
4896 tet_printf( "RaiseToTop ActorA\n" );
4898 actorA.RaiseToTop();
4899 application.SendNotification(); // ensure sorting order is calculated before next touch event
4901 application.ProcessEvent( touchEvent );
4903 glAbstraction.ResetSetUniformCallStack();
4904 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4906 application.SendNotification();
4907 application.Render();
4909 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4911 // Test order of uniforms in stack
4912 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4913 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4914 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4916 tet_infoline( "Testing A above C and B at bottom\n" );
4917 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4919 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4921 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4922 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4923 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4925 ResetTouchCallbacks();
4927 tet_printf( "RaiseToTop ActorB\n" );
4929 actorB.RaiseToTop();
4930 application.SendNotification(); // Ensure sort order is calculated before next touch event
4932 application.ProcessEvent( touchEvent );
4934 glAbstraction.ResetSetUniformCallStack();
4935 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4937 application.SendNotification();
4938 application.Render();
4940 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4942 // Test order of uniforms in stack
4943 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4944 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4945 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4947 tet_infoline( "Testing B above A and C at bottom\n" );
4948 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4950 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4952 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4953 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4954 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4956 ResetTouchCallbacks();
4958 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4960 actorA.LowerToBottom();
4961 application.SendNotification();
4962 application.Render();
4964 actorB.LowerToBottom();
4965 application.SendNotification();
4966 application.Render();
4968 application.ProcessEvent( touchEvent );
4970 glAbstraction.ResetSetUniformCallStack();
4971 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4973 application.SendNotification();
4974 application.Render();
4976 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4978 // Test order of uniforms in stack
4979 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4980 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4981 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4983 tet_infoline( "Testing C above A and B at bottom\n" );
4984 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4986 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4988 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4989 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4990 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4992 ResetTouchCallbacks();
4997 int UtcDaliActorRaiseAbove(void)
4999 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5001 TestApplication application;
5003 Stage stage( Stage::GetCurrent() );
5005 Actor actorA = Actor::New();
5006 Actor actorB = Actor::New();
5007 Actor actorC = Actor::New();
5009 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5010 actorA.SetParentOrigin( ParentOrigin::CENTER );
5012 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5013 actorB.SetParentOrigin( ParentOrigin::CENTER );
5015 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5016 actorC.SetParentOrigin( ParentOrigin::CENTER );
5018 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5019 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5021 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5022 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5024 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5025 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5027 stage.Add( actorA );
5028 stage.Add( actorB );
5029 stage.Add( actorC );
5031 ResetTouchCallbacks();
5033 application.SendNotification();
5034 application.Render();
5036 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5037 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5038 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5040 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5041 // Only top actor will get touched.
5042 actorA.TouchSignal().Connect( TestTouchCallback );
5043 actorB.TouchSignal().Connect( TestTouchCallback2 );
5044 actorC.TouchSignal().Connect( TestTouchCallback3 );
5046 Dali::Integration::Point point;
5047 point.SetDeviceId( 1 );
5048 point.SetState( PointState::DOWN );
5049 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5050 Dali::Integration::TouchEvent touchEvent;
5051 touchEvent.AddPoint( point );
5053 application.ProcessEvent( touchEvent );
5055 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5056 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5057 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5059 ResetTouchCallbacks();
5061 tet_printf( "Raise actor B Above Actor C\n" );
5063 actorB.RaiseAbove( actorC );
5064 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5065 application.SendNotification();
5067 application.ProcessEvent( touchEvent );
5069 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5070 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5071 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5073 ResetTouchCallbacks();
5075 tet_printf( "Raise actor A Above Actor B\n" );
5077 actorA.RaiseAbove( actorB );
5079 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5080 application.SendNotification();
5082 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5084 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5085 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5086 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5088 ResetTouchCallbacks();
5093 int UtcDaliActorLowerBelow(void)
5095 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5097 TestApplication application;
5099 Stage stage( Stage::GetCurrent() );
5101 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5102 // enables checking of which actor the uniform is assigned too
5103 Shader shaderA = CreateShader();
5104 shaderA.RegisterProperty( "uRendererColor",1.f);
5106 Shader shaderB = CreateShader();
5107 shaderB.RegisterProperty( "uRendererColor", 2.f );
5109 Shader shaderC = CreateShader();
5110 shaderC.RegisterProperty( "uRendererColor", 3.f );
5112 Actor actorA = Actor::New();
5113 Actor actorB = Actor::New();
5114 Actor actorC = Actor::New();
5116 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5117 Geometry geometry = CreateQuadGeometry();
5119 Renderer rendererA = Renderer::New(geometry, shaderA);
5120 actorA.AddRenderer(rendererA);
5122 Renderer rendererB = Renderer::New(geometry, shaderB);
5123 actorB.AddRenderer(rendererB);
5125 Renderer rendererC = Renderer::New(geometry, shaderC);
5126 actorC.AddRenderer(rendererC);
5128 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5129 actorA.SetParentOrigin( ParentOrigin::CENTER );
5131 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5132 actorB.SetParentOrigin( ParentOrigin::CENTER );
5134 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5135 actorC.SetParentOrigin( ParentOrigin::CENTER );
5137 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5138 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5140 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5141 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5143 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5144 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5146 Actor container = Actor::New();
5147 container.SetParentOrigin( ParentOrigin::CENTER );
5148 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5149 stage.Add( container );
5151 container.Add( actorA );
5152 container.Add( actorB );
5153 container.Add( actorC );
5155 ResetTouchCallbacks();
5157 // Set up gl abstraction trace so can query the set uniform order
5158 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5159 glAbstraction.EnableSetUniformCallTrace(true);
5160 glAbstraction.ResetSetUniformCallStack();
5161 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5163 glAbstraction.ResetSetUniformCallStack();
5165 application.SendNotification();
5166 application.Render();
5168 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5170 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5172 // Test order of uniforms in stack
5173 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5174 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5175 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5177 tet_infoline( "Testing C above B and A at bottom\n" );
5178 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5180 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5182 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5183 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5184 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5186 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5187 // Only top actor will get touched.
5188 actorA.TouchSignal().Connect( TestTouchCallback );
5189 actorB.TouchSignal().Connect( TestTouchCallback2 );
5190 actorC.TouchSignal().Connect( TestTouchCallback3 );
5192 Dali::Integration::Point point;
5193 point.SetDeviceId( 1 );
5194 point.SetState( PointState::DOWN );
5195 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5196 Dali::Integration::TouchEvent touchEvent;
5197 touchEvent.AddPoint( point );
5199 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5201 application.ProcessEvent( touchEvent );
5203 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5204 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5205 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5207 ResetTouchCallbacks();
5209 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" );
5211 actorC.LowerBelow( actorB );
5212 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5213 application.SendNotification();
5214 application.Render();
5216 application.ProcessEvent( touchEvent ); // touch event
5218 glAbstraction.ResetSetUniformCallStack();
5219 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5221 application.SendNotification();
5222 application.Render();
5224 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5226 // Test order of uniforms in stack
5227 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5228 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5229 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5231 tet_infoline( "Testing render order is A, C, B" );
5232 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5233 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5235 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5236 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5237 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5239 ResetTouchCallbacks();
5241 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5243 actorC.LowerBelow( actorA );
5244 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5245 application.SendNotification();
5246 application.Render();
5248 application.ProcessEvent( touchEvent );
5250 glAbstraction.ResetSetUniformCallStack();
5251 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5253 application.Render();
5254 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5256 // Test order of uniforms in stack
5257 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5258 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5259 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5261 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5262 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5264 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5265 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5266 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5268 ResetTouchCallbacks();
5270 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5272 actorB.LowerBelow( actorC );
5273 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5274 application.SendNotification();
5275 application.Render();
5277 application.ProcessEvent( touchEvent );
5279 glAbstraction.ResetSetUniformCallStack();
5280 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5282 application.Render();
5283 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5285 // Test order of uniforms in stack
5286 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5287 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5288 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5290 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5291 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5297 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5299 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5301 TestApplication application;
5303 Stage stage( Stage::GetCurrent() );
5305 Actor parentA = Actor::New();
5306 Actor parentB = Actor::New();
5307 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5308 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5309 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5310 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5312 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5313 parentA.SetParentOrigin( ParentOrigin::CENTER );
5315 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5316 parentB.SetParentOrigin( ParentOrigin::CENTER );
5318 stage.Add( parentA );
5319 stage.Add( parentB );
5321 Actor actorA = Actor::New();
5322 Actor actorB = Actor::New();
5323 Actor actorC = Actor::New();
5325 parentA.Add( actorA );
5326 parentA.Add( actorB );
5328 tet_printf( "Actor C added to different parent from A and B \n" );
5329 parentB.Add( actorC );
5331 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5332 actorA.SetParentOrigin( ParentOrigin::CENTER );
5334 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5335 actorB.SetParentOrigin( ParentOrigin::CENTER );
5337 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5338 actorC.SetParentOrigin( ParentOrigin::CENTER );
5340 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5341 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5343 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5344 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5346 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5347 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5349 ResetTouchCallbacks();
5351 application.SendNotification();
5352 application.Render();
5354 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5355 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5356 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5358 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5359 // Only top actor will get touched.
5360 actorA.TouchSignal().Connect( TestTouchCallback );
5361 actorB.TouchSignal().Connect( TestTouchCallback2 );
5362 actorC.TouchSignal().Connect( TestTouchCallback3 );
5364 Dali::Integration::Point point;
5365 point.SetDeviceId( 1 );
5366 point.SetState( PointState::DOWN );
5367 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5368 Dali::Integration::TouchEvent touchEvent;
5369 touchEvent.AddPoint( point );
5371 application.ProcessEvent( touchEvent );
5373 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5374 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5375 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5377 ResetTouchCallbacks();
5379 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5381 actorA.RaiseAbove( actorC );
5382 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5383 application.SendNotification();
5385 application.ProcessEvent( touchEvent ); // touch event
5387 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5388 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5389 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5391 ResetTouchCallbacks();
5396 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5398 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5400 TestApplication application;
5402 Stage stage( Stage::GetCurrent() );
5404 Actor actorA = Actor::New();
5405 Actor actorB = Actor::New();
5406 Actor actorC = Actor::New();
5408 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5409 actorA.SetParentOrigin( ParentOrigin::CENTER );
5411 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5412 actorB.SetParentOrigin( ParentOrigin::CENTER );
5414 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5415 actorC.SetParentOrigin( ParentOrigin::CENTER );
5417 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5418 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5420 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5421 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5423 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5424 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5426 ResetTouchCallbacks();
5428 application.SendNotification();
5429 application.Render();
5431 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5432 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5433 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5435 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5436 // Only top actor will get touched.
5437 actorA.TouchSignal().Connect( TestTouchCallback );
5438 actorB.TouchSignal().Connect( TestTouchCallback2 );
5439 actorC.TouchSignal().Connect( TestTouchCallback3 );
5441 Dali::Integration::Point point;
5442 point.SetDeviceId( 1 );
5443 point.SetState( PointState::DOWN );
5444 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5445 Dali::Integration::TouchEvent touchEvent;
5446 touchEvent.AddPoint( point );
5448 tet_printf( "Raise actor A Above Actor C which have no 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 );
5456 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5458 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5459 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5460 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5462 ResetTouchCallbacks();
5464 stage.Add ( actorB );
5465 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5466 actorA.LowerBelow( actorC );
5468 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5469 application.SendNotification();
5470 application.Render();
5472 application.ProcessEvent( touchEvent );
5474 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5475 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5476 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5477 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5479 ResetTouchCallbacks();
5481 tet_printf( "Adding Actor A to stage, will be on top\n" );
5483 stage.Add ( actorA );
5484 application.SendNotification();
5485 application.Render();
5487 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5488 actorB.RaiseAbove( actorC );
5489 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5490 application.SendNotification();
5492 application.ProcessEvent( touchEvent );
5494 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5495 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5496 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5497 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5499 ResetTouchCallbacks();
5501 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5502 actorA.LowerBelow( actorC );
5503 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5504 application.SendNotification();
5506 application.ProcessEvent( touchEvent );
5508 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5509 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5510 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5511 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5513 ResetTouchCallbacks();
5515 stage.Add ( actorC );
5516 actorA.RaiseAbove( actorC );
5517 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5518 application.SendNotification();
5519 application.Render();
5521 application.ProcessEvent( touchEvent );
5523 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5524 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5525 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5526 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5531 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5533 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5535 TestApplication application;
5537 Stage stage( Stage::GetCurrent() );
5539 Actor actorA = Actor::New();
5540 Actor actorB = Actor::New();
5541 Actor actorC = Actor::New();
5543 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5544 actorA.SetParentOrigin( ParentOrigin::CENTER );
5546 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5547 actorB.SetParentOrigin( ParentOrigin::CENTER );
5549 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5550 actorC.SetParentOrigin( ParentOrigin::CENTER );
5552 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5553 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5555 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5556 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5558 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5559 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5561 ResetTouchCallbacks();
5563 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5564 // Only top actor will get touched.
5565 actorA.TouchSignal().Connect( TestTouchCallback );
5566 actorB.TouchSignal().Connect( TestTouchCallback2 );
5567 actorC.TouchSignal().Connect( TestTouchCallback3 );
5569 Dali::Integration::Point point;
5570 point.SetDeviceId( 1 );
5571 point.SetState( PointState::DOWN );
5572 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5573 Dali::Integration::TouchEvent touchEvent;
5574 touchEvent.AddPoint( point );
5576 stage.Add ( actorA );
5577 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5580 application.SendNotification();
5581 application.Render();
5583 application.ProcessEvent( touchEvent );
5585 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5587 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5588 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5589 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5591 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5592 ResetTouchCallbacks();
5595 // Sort actor tree before next touch event
5596 application.SendNotification();
5597 application.Render();
5599 application.ProcessEvent( touchEvent );
5601 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5603 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5604 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5605 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5606 ResetTouchCallbacks();
5608 tet_printf( "Lower actor C below B but C not parented\n" );
5611 // Sort actor tree before next touch event
5612 application.SendNotification();
5613 application.Render();
5615 application.ProcessEvent( touchEvent );
5617 tet_printf( "Not parented so Lower should show no effect\n" );
5619 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5620 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5621 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5622 ResetTouchCallbacks();
5624 tet_printf( "Raise actor B to top\n" );
5626 actorB.RaiseToTop();
5627 // Sort actor tree before next touch event
5628 application.SendNotification();
5629 application.Render();
5631 application.ProcessEvent( touchEvent );
5633 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5635 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5636 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5637 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5638 ResetTouchCallbacks();
5640 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5642 stage.Add ( actorB );
5644 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5646 actorC.LowerToBottom();
5647 application.SendNotification();
5648 application.Render();
5650 application.ProcessEvent( touchEvent );
5652 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5654 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5655 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5656 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5657 ResetTouchCallbacks();
5663 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5665 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5667 TestApplication application;
5669 Stage stage( Stage::GetCurrent() );
5671 Actor actorA = Actor::New();
5672 Actor actorB = Actor::New();
5673 Actor actorC = Actor::New();
5675 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5676 actorA.SetParentOrigin( ParentOrigin::CENTER );
5678 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5679 actorB.SetParentOrigin( ParentOrigin::CENTER );
5681 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5682 actorC.SetParentOrigin( ParentOrigin::CENTER );
5684 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5685 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5687 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5688 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5690 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5691 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5693 stage.Add( actorA );
5694 stage.Add( actorB );
5695 stage.Add( actorC );
5697 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5698 // Only top actor will get touched.
5699 actorA.TouchSignal().Connect( TestTouchCallback );
5700 actorB.TouchSignal().Connect( TestTouchCallback2 );
5701 actorC.TouchSignal().Connect( TestTouchCallback3 );
5703 ResetTouchCallbacks();
5705 application.SendNotification();
5706 application.Render();
5708 Dali::Integration::Point point;
5709 point.SetDeviceId( 1 );
5710 point.SetState( PointState::DOWN );
5711 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5712 Dali::Integration::TouchEvent touchEvent;
5713 touchEvent.AddPoint( point );
5715 application.ProcessEvent( touchEvent );
5717 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5718 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5719 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5721 ResetTouchCallbacks();
5723 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5725 actorA.RaiseAbove( actorA );
5726 application.SendNotification();
5727 application.Render();
5729 application.ProcessEvent( touchEvent );
5731 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5733 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5734 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5735 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5737 ResetTouchCallbacks();
5739 actorA.RaiseAbove( actorC );
5740 application.SendNotification();
5741 application.Render();
5743 application.ProcessEvent( touchEvent );
5745 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5746 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5747 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5748 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5753 int UtcDaliActorGetScreenPosition(void)
5755 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5757 TestApplication application;
5759 Stage stage( Stage::GetCurrent() );
5761 Actor actorA = Actor::New();
5762 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5764 Vector2 size2( 10.0f, 20.0f );
5765 actorA.SetSize( size2 );
5767 actorA.SetPosition( 0.f, 0.f );
5769 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5771 stage.Add( actorA );
5773 application.SendNotification();
5774 application.Render();
5776 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5777 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5779 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5780 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5782 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5783 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5785 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5787 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5789 application.SendNotification();
5790 application.Render();
5792 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5793 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5795 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5796 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5798 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5799 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5801 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5803 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5805 application.SendNotification();
5806 application.Render();
5808 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5809 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5811 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5812 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5814 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5815 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5817 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5819 actorA.SetPosition( 30.0, 0.0 );
5821 application.SendNotification();
5822 application.Render();
5824 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5825 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5827 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5828 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5830 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5831 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5833 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5835 actorA.SetPosition( 30.0, 420.0 );
5837 application.SendNotification();
5838 application.Render();
5840 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5841 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5843 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5844 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5846 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5847 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5849 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
5851 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5852 actorA.SetPosition( 30.0, 30.0 );
5854 Actor actorB = Actor::New();
5855 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5856 actorB.SetSize( size2 );
5857 actorB.SetPosition( 10.f, 10.f );
5858 actorA.Add( actorB );
5860 actorA.SetScale( 2.0f );
5862 application.SendNotification();
5863 application.Render();
5865 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5867 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
5868 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
5873 int UtcDaliActorGetScreenPositionAfterScaling(void)
5875 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5877 TestApplication application;
5879 Stage stage( Stage::GetCurrent() );
5881 Actor actorA = Actor::New();
5882 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5884 Vector2 size2( 10.0f, 20.0f );
5885 actorA.SetSize( size2 );
5886 actorA.SetScale( 1.5f );
5887 actorA.SetPosition( 0.f, 0.f );
5889 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5891 stage.Add( actorA );
5893 application.SendNotification();
5894 application.Render();
5896 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5897 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5899 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5900 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5902 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5903 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5905 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5907 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5909 application.SendNotification();
5910 application.Render();
5912 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5913 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5915 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5916 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5918 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5919 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5924 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5926 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5928 TestApplication application;
5930 Stage stage( Stage::GetCurrent() );
5932 Actor actorA = Actor::New();
5933 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5934 actorA.SetParentOrigin( ParentOrigin::CENTER );
5935 Vector2 size2( 10.0f, 20.0f );
5936 actorA.SetSize( size2 );
5937 actorA.SetPosition( 0.f, 0.f );
5939 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5941 stage.Add( actorA );
5943 application.SendNotification();
5944 application.Render();
5946 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5947 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5949 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5950 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5952 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
5953 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
5955 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5957 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5958 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5960 application.SendNotification();
5961 application.Render();
5963 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5964 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5966 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5967 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5969 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5970 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5976 int UtcDaliActorGetScreenPositionWithChildActors(void)
5978 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5980 TestApplication application;
5982 Stage stage( Stage::GetCurrent() );
5984 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5986 Actor actorA = Actor::New();
5987 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5988 actorA.SetParentOrigin( ParentOrigin::CENTER );
5989 Vector2 size1( 10.0f, 20.0f );
5990 actorA.SetSize( size1 );
5991 actorA.SetPosition( 0.f, 0.f );
5993 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5995 Actor parentActorA = Actor::New();
5996 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5997 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5998 Vector2 size2( 30.0f, 60.0f );
5999 parentActorA.SetSize( size2 );
6000 parentActorA.SetPosition( 0.f, 0.f );
6002 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6004 stage.Add( parentActorA );
6005 parentActorA.Add ( actorA );
6007 application.SendNotification();
6008 application.Render();
6010 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6011 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6013 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6014 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6016 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6017 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6019 tet_infoline( "Test 2\n");
6021 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6023 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6024 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6026 application.SendNotification();
6027 application.Render();
6029 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6030 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6032 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6033 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6035 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6036 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6041 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6043 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6045 TestApplication application;
6047 Stage stage( Stage::GetCurrent() );
6049 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6051 Actor actorA = Actor::New();
6052 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6053 actorA.SetParentOrigin( ParentOrigin::CENTER );
6054 Vector2 size1( 10.0f, 20.0f );
6055 actorA.SetSize( size1 );
6056 actorA.SetPosition( 0.f, 0.f );
6058 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6060 Actor parentActorA = Actor::New();
6061 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6062 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6063 Vector2 size2( 30.0f, 60.0f );
6064 parentActorA.SetSize( size2 );
6065 parentActorA.SetPosition( 0.f, 0.f );
6067 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6069 Actor grandParentActorA = Actor::New();
6070 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6071 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6072 Vector2 size3( 60.0f, 120.0f );
6073 grandParentActorA.SetSize( size3 );
6074 grandParentActorA.SetPosition( 0.f, 0.f );
6076 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6078 stage.Add( grandParentActorA );
6079 grandParentActorA.Add ( parentActorA );
6081 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6083 parentActorA.Add ( actorA );
6085 application.SendNotification();
6086 application.Render();
6088 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6089 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6091 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6092 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6094 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6095 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6100 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6102 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6104 TestApplication application;
6106 Stage stage( Stage::GetCurrent() );
6108 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6110 Actor actorA = Actor::New();
6111 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6112 actorA.SetParentOrigin( ParentOrigin::CENTER );
6113 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6114 actorA.SetSize( 10.0f, 20.0f );
6115 stage.Add( actorA );
6117 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6119 Actor actorB = Actor::New();
6120 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6121 actorB.SetParentOrigin( ParentOrigin::CENTER );
6122 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6123 Vector2 actorBSize( 30.0f, 60.0f );
6124 actorB.SetSize( actorBSize );
6125 stage.Add( actorB );
6127 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6129 Actor actorC = Actor::New();
6130 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6131 actorC.SetParentOrigin( ParentOrigin::CENTER );
6132 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6133 Vector2 actorCSize( 60.0f, 120.0f );
6134 actorC.SetSize( actorCSize );
6135 stage.Add( actorC );
6137 application.SendNotification();
6138 application.Render();
6140 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6142 Vector2 center( stage.GetSize() * 0.5f );
6144 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6145 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6146 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6148 tet_infoline( "Add scale to all actors" );
6150 actorA.SetScale( 2.0f );
6151 actorB.SetScale( 2.0f );
6152 actorC.SetScale( 2.0f );
6154 application.SendNotification();
6155 application.Render();
6157 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6158 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6159 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6164 int utcDaliActorPositionUsesAnchorPoint(void)
6166 TestApplication application;
6167 tet_infoline( "Check default behaviour\n" );
6169 Actor actor = Actor::New();
6170 actor.SetParentOrigin( ParentOrigin::CENTER );
6171 actor.SetAnchorPoint( AnchorPoint::CENTER );
6172 actor.SetSize( 100.0f, 100.0f );
6173 Stage::GetCurrent().Add( actor );
6175 application.SendNotification();
6176 application.Render();
6178 tet_infoline( "Check that the world position is in the center\n" );
6179 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6181 tet_infoline( "Set the position uses anchor point property to false\n" );
6182 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6184 application.SendNotification();
6185 application.Render();
6187 tet_infoline( "Check that the world position has changed appropriately\n" );
6188 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6193 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6195 TestApplication application;
6196 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6198 Actor actor = Actor::New();
6199 actor.SetParentOrigin( ParentOrigin::CENTER );
6200 actor.SetAnchorPoint( AnchorPoint::CENTER );
6201 actor.SetSize( 100.0f, 100.0f );
6202 actor.SetScale( 2.0f );
6203 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6204 Stage::GetCurrent().Add( actor );
6206 application.SendNotification();
6207 application.Render();
6209 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6210 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6212 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6213 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6214 application.SendNotification();
6215 application.Render();
6216 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6218 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6219 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6220 application.SendNotification();
6221 application.Render();
6222 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6227 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6229 TestApplication application;
6230 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6232 Actor actor = Actor::New();
6233 actor.SetParentOrigin( ParentOrigin::CENTER );
6234 actor.SetAnchorPoint( AnchorPoint::CENTER );
6235 actor.SetSize( 100.0f, 100.0f );
6236 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6237 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6238 Stage::GetCurrent().Add( actor );
6240 application.SendNotification();
6241 application.Render();
6243 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6244 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6246 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6247 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6248 application.SendNotification();
6249 application.Render();
6250 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6252 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6253 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6254 application.SendNotification();
6255 application.Render();
6256 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6261 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6263 TestApplication application;
6264 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6266 Actor actor = Actor::New();
6267 actor.SetParentOrigin( ParentOrigin::CENTER );
6268 actor.SetAnchorPoint( AnchorPoint::CENTER );
6269 actor.SetSize( 100.0f, 100.0f );
6270 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
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 and rotation\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( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6296 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6298 TestApplication application;
6299 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6301 Actor parent = Actor::New();
6303 Stage::GetCurrent().Add( parent );
6304 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6306 Actor actor = Actor::New();
6307 actor.SetParentOrigin( ParentOrigin::CENTER );
6308 actor.SetAnchorPoint( AnchorPoint::CENTER );
6309 actor.SetSize( 100.0f, 100.0f );
6310 actor.SetInheritScale( false );
6311 actor.SetInheritOrientation( false );
6312 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6313 parent.Add( actor );
6315 application.SendNotification();
6316 application.Render();
6318 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6320 tet_infoline( "Check the world position is in the right place\n" );
6321 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6323 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6324 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6325 application.SendNotification();
6326 application.Render();
6327 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6329 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6330 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6331 application.SendNotification();
6332 application.Render();
6333 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6338 int utcDaliActorVisibilityChangeSignalSelf(void)
6340 TestApplication application;
6341 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6343 Actor actor = Actor::New();
6345 VisibilityChangedFunctorData data;
6346 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6348 actor.SetVisible( false );
6350 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6352 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6355 actor.SetVisible( false );
6356 data.Check( false /* not called */, TEST_LOCATION );
6358 tet_infoline( "Change the visibility using properties, ensure called" );
6361 actor.SetProperty( Actor::Property::VISIBLE, true );
6362 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6364 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6367 actor.SetProperty( Actor::Property::VISIBLE, true );
6368 data.Check( false /* not called */, TEST_LOCATION );
6373 int utcDaliActorVisibilityChangeSignalChildren(void)
6375 TestApplication application;
6376 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6378 Actor parent = Actor::New();
6379 Actor child = Actor::New();
6380 parent.Add( child );
6382 Actor grandChild = Actor::New();
6383 child.Add( grandChild );
6385 VisibilityChangedFunctorData parentData;
6386 VisibilityChangedFunctorData childData;
6387 VisibilityChangedFunctorData grandChildData;
6389 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6390 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6391 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6393 parent.SetVisible( false );
6394 parentData.Check( false /* not called */, TEST_LOCATION );
6395 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6396 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6398 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6401 grandChildData.Reset();
6403 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6405 parent.SetVisible( true );
6406 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6407 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6408 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6410 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6413 grandChildData.Reset();
6415 parent.SetVisible( true );
6416 parentData.Check( false /* not called */, TEST_LOCATION );
6417 childData.Check( false /* not called */, TEST_LOCATION );
6418 grandChildData.Check( false /* not called */, TEST_LOCATION );
6423 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6425 TestApplication application;
6426 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6428 Actor actor = Actor::New();
6429 Stage::GetCurrent().Add( actor );
6431 application.SendNotification();
6432 application.Render();
6434 VisibilityChangedFunctorData data;
6435 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6437 Animation animation = Animation::New( 1.0f );
6438 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6440 data.Check( false, TEST_LOCATION );
6441 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6442 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6444 tet_infoline( "Play the animation and check the property value" );
6447 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6448 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6450 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6451 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6453 application.SendNotification();
6454 application.Render( 1100 ); // After the animation
6456 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6462 int utcDaliActorVisibilityChangeSignalByName(void)
6464 TestApplication application;
6465 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6467 Actor actor = Actor::New();
6469 bool signalCalled=false;
6470 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6471 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6472 actor.SetVisible( false );
6473 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6475 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6476 signalCalled = false;
6477 actor.SetVisible( false );
6478 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6480 tet_infoline( "Change the visibility using properties, ensure called" );
6481 actor.SetProperty( Actor::Property::VISIBLE, true );
6482 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6484 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6485 signalCalled = false;
6487 actor.SetProperty( Actor::Property::VISIBLE, true );
6488 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6494 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6496 gLayoutDirectionType = type;
6499 int UtcDaliActorLayoutDirectionProperty(void)
6501 TestApplication application;
6502 tet_infoline( "Check layout direction property" );
6504 Actor actor0 = Actor::New();
6505 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6506 Stage::GetCurrent().Add( actor0 );
6508 application.SendNotification();
6509 application.Render();
6511 Actor actor1 = Actor::New();
6512 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6513 Actor actor2 = Actor::New();
6514 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6515 Actor actor3 = Actor::New();
6516 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6517 Actor actor4 = Actor::New();
6518 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6519 Actor actor5 = Actor::New();
6520 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6521 Actor actor6 = Actor::New();
6522 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6523 Actor actor7 = Actor::New();
6524 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6525 Actor actor8 = Actor::New();
6526 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6527 Actor actor9 = Actor::New();
6528 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6530 actor1.Add( actor2 );
6531 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6532 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6534 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6535 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6536 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6538 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6539 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6540 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6542 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6543 actor0.Add( actor1 );
6544 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6545 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6547 Stage::GetCurrent().Add( actor3 );
6548 actor3.Add( actor4 );
6549 actor4.Add( actor5 );
6550 actor5.Add( actor6 );
6551 actor5.Add( actor7 );
6552 actor7.Add( actor8 );
6553 actor8.Add( actor9 );
6554 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6555 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6557 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6558 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6559 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6561 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6563 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6564 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6565 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6566 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6567 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6568 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6569 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6571 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6572 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6573 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6575 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6576 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6577 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6578 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6580 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6581 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6582 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6588 struct LayoutDirectionFunctor
6590 LayoutDirectionFunctor(bool& signalCalled)
6591 : mSignalCalled( signalCalled )
6595 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6596 : mSignalCalled( rhs.mSignalCalled )
6602 mSignalCalled = true;
6605 bool& mSignalCalled;
6608 int UtcDaliActorLayoutDirectionSignal(void)
6610 TestApplication application;
6611 tet_infoline( "Check changing layout direction property sends a signal" );
6613 Actor actor = Actor::New();
6614 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6615 Stage::GetCurrent().Add( actor );
6616 bool signalCalled = false;
6617 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6619 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6620 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6622 // Test that writing the same value doesn't send a signal
6623 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6624 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6626 // Test that writing a different value sends the signal
6627 signalCalled = false;
6628 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6629 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6631 signalCalled = false;
6632 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6633 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6638 struct ChildAddedSignalCheck
6640 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6641 : mSignalReceived( signalReceived ),
6642 mChildHandle( childHandle )
6646 void operator() ( Actor childHandle )
6648 mSignalReceived = true;
6649 mChildHandle = childHandle;
6653 mSignalReceived = true;
6654 mChildHandle = Actor();
6657 bool& mSignalReceived;
6658 Actor& mChildHandle;
6661 int UtcDaliChildAddedSignalP1(void)
6663 TestApplication application;
6664 auto stage = Stage::GetCurrent();
6666 bool signalReceived=false;
6669 ChildAddedSignalCheck signal( signalReceived, childActor );
6670 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6671 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6673 auto actorA = Actor::New();
6674 stage.Add( actorA );
6675 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6676 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6677 signalReceived = false;
6679 auto actorB = Actor::New();
6680 stage.Add( actorB );
6681 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6682 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6688 int UtcDaliChildAddedSignalP2(void)
6690 TestApplication application;
6691 auto stage = Stage::GetCurrent();
6693 bool signalReceived=false;
6696 ChildAddedSignalCheck signal( signalReceived, childActor );
6697 tet_infoline( "Connect to childAdded signal by name" );
6699 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6700 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6702 auto actorA = Actor::New();
6703 stage.Add( actorA );
6704 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6706 // Can't test which actor was added; signal signature is void() when connecting via name.
6707 signalReceived = false;
6709 auto actorB = Actor::New();
6710 stage.Add( actorB );
6711 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6716 int UtcDaliChildAddedSignalN(void)
6718 TestApplication application;
6719 auto stage = Stage::GetCurrent();
6721 bool signalReceived=false;
6724 ChildAddedSignalCheck signal( signalReceived, childActor );
6725 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6726 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6728 auto actorA = Actor::New();
6729 stage.Add( actorA );
6730 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6731 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6732 signalReceived = false;
6734 auto actorB = Actor::New();
6735 actorA.Add( actorB );
6736 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6741 struct ChildRemovedSignalCheck
6743 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
6744 : mSignalReceived( signalReceived ),
6745 mChildHandle( childHandle )
6749 void operator() ( Actor childHandle )
6751 mSignalReceived = true;
6752 mChildHandle = childHandle;
6757 mSignalReceived = true;
6760 bool& mSignalReceived;
6761 Actor& mChildHandle;
6764 int UtcDaliChildRemovedSignalP1(void)
6766 TestApplication application;
6767 auto stage = Stage::GetCurrent();
6769 bool signalReceived=false;
6772 ChildRemovedSignalCheck signal( signalReceived, childActor );
6773 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6774 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6776 auto actorA = Actor::New();
6777 stage.Add( actorA );
6778 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6779 DALI_TEST_CHECK( !childActor );
6781 stage.Remove( actorA );
6782 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6783 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6785 signalReceived = false;
6786 auto actorB = Actor::New();
6787 stage.Add( actorB );
6788 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6790 stage.Remove( actorB );
6791 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6792 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6797 int UtcDaliChildRemovedSignalP2(void)
6799 TestApplication application;
6800 auto stage = Stage::GetCurrent();
6802 bool signalReceived=false;
6805 ChildAddedSignalCheck signal( signalReceived, childActor );
6806 tet_infoline( "Connect to childRemoved signal by name" );
6808 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
6809 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6811 auto actorA = Actor::New();
6812 stage.Add( actorA );
6813 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6815 stage.Remove( actorA );
6816 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6818 signalReceived = false;
6819 auto actorB = Actor::New();
6820 stage.Add( actorB );
6821 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6823 stage.Remove( actorB );
6824 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6830 int UtcDaliChildRemovedSignalN(void)
6832 TestApplication application;
6833 auto stage = Stage::GetCurrent();
6835 bool signalReceived=false;
6838 ChildRemovedSignalCheck signal( signalReceived, childActor );
6839 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6840 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6842 auto actorA = Actor::New();
6843 stage.Add( actorA );
6845 auto actorB = Actor::New();
6846 actorA.Add( actorB );
6848 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6849 DALI_TEST_CHECK( ! childActor );
6851 actorA.Remove( actorB );
6852 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6857 int UtcDaliChildMovedSignalP(void)
6859 TestApplication application;
6860 auto stage = Stage::GetCurrent();
6862 bool addedASignalReceived = false;
6863 bool removedASignalReceived = false;
6864 bool addedBSignalReceived = false;
6865 bool removedBSignalReceived = false;
6868 auto actorA = Actor::New();
6869 auto actorB = Actor::New();
6870 stage.Add( actorA );
6871 stage.Add( actorB );
6873 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
6874 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
6875 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
6876 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
6878 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
6879 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
6880 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
6881 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
6883 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
6884 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
6885 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
6886 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
6888 // Create a child of A
6890 auto child = Actor::New();
6891 actorA.Add( child );
6893 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
6894 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
6895 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
6896 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
6897 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
6900 addedASignalReceived = false;
6901 addedBSignalReceived = false;
6902 removedASignalReceived = false;
6903 removedBSignalReceived = false;
6905 actorB.Add( child ); // Expect this child to be re-parented
6906 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
6907 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
6908 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
6909 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
6911 // Move child back to A:
6912 addedASignalReceived = false;
6913 addedBSignalReceived = false;
6914 removedASignalReceived = false;
6915 removedBSignalReceived = false;
6917 actorA.Add( child ); // Expect this child to be re-parented
6918 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
6919 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
6920 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
6921 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );