2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
22 #include <dali/public-api/dali-core.h>
24 #include <cfloat> // For FLT_MAX
25 #include <dali/devel-api/actors/actor-devel.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali/integration-api/events/hover-event-integ.h>
28 #include <dali/integration-api/debug.h>
29 #include <dali-test-suite-utils.h>
30 #include <mesh-builder.h>
38 void utc_dali_actor_startup(void)
40 test_return_value = TET_UNDEF;
43 void utc_dali_actor_cleanup(void)
45 test_return_value = TET_PASS;
50 bool gTouchCallBackCalled=false;
51 bool gTouchCallBackCalled2=false;
52 bool gTouchCallBackCalled3=false;
54 bool gHoverCallBackCalled=false;
56 static bool gTestConstraintCalled;
58 LayoutDirection::Type gLayoutDirectionType;
62 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
64 gTestConstraintCalled = true;
69 * TestConstraint reference.
70 * When constraint is called, the resultRef is updated
71 * with the value supplied.
74 struct TestConstraintRef
76 TestConstraintRef(unsigned int& resultRef, unsigned int value)
77 : mResultRef(resultRef),
82 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
87 unsigned int& mResultRef;
91 static bool TestCallback(Actor actor, const TouchEvent& event)
93 gTouchCallBackCalled = true;
98 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
100 gTouchCallBackCalled = true;
105 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
107 gTouchCallBackCalled2 = true;
112 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
114 gTouchCallBackCalled3 = true;
119 static void ResetTouchCallbacks()
121 gTouchCallBackCalled = false;
122 gTouchCallBackCalled2 = false;
123 gTouchCallBackCalled3 = false;
126 static bool TestCallback3(Actor actor, const HoverEvent& event)
128 gHoverCallBackCalled = true;
133 // validation stuff for onstage & offstage signals
134 static std::vector< std::string > gActorNamesOnOffStage;
135 static int gOnStageCallBackCalled;
136 void OnStageCallback( Actor actor )
138 ++gOnStageCallBackCalled;
139 gActorNamesOnOffStage.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
140 DALI_TEST_CHECK( actor.OnStage() == true );
142 static int gOffStageCallBackCalled;
143 void OffStageCallback( Actor actor )
145 ++gOffStageCallBackCalled;
146 gActorNamesOnOffStage.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
147 DALI_TEST_CHECK( actor.OnStage() == false );
150 struct PositionComponentConstraint
152 PositionComponentConstraint(){}
154 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
156 const Matrix& m = inputs[0]->GetMatrix();
159 m.GetTransformComponents(pos, rot, scale);
163 struct OrientationComponentConstraint
165 OrientationComponentConstraint(){}
167 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
169 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
172 orientation = parentOrientation;
177 static bool gOnRelayoutCallBackCalled = false;
178 static std::vector< std::string > gActorNamesRelayout;
180 void OnRelayoutCallback( Actor actor )
182 gOnRelayoutCallBackCalled = true;
183 gActorNamesRelayout.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
186 struct VisibilityChangedFunctorData
188 VisibilityChangedFunctorData()
191 type( DevelActor::VisibilityChange::SELF ),
200 type = DevelActor::VisibilityChange::SELF;
204 void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
206 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
207 DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
208 DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
209 DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
212 void Check( bool compareCalled, const std::string& location )
214 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
219 DevelActor::VisibilityChange::Type type;
223 struct VisibilityChangedFunctor
225 VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
227 void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
230 data.visible = visible;
235 VisibilityChangedFunctorData& data;
239 struct VisibilityChangedVoidFunctor
241 VisibilityChangedVoidFunctor(bool& signalCalled)
242 : mSignalCalled( signalCalled )
247 mSignalCalled = true;
253 struct ChildOrderChangedFunctor
255 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
256 : mSignalCalled( signalCalled ),
260 void operator()( Actor actor )
262 mSignalCalled = true;
270 struct CulledPropertyNotificationFunctor
272 CulledPropertyNotificationFunctor( bool& signalCalled, PropertyNotification& propertyNotification )
273 : mSignalCalled( signalCalled ),
274 mPropertyNotification( propertyNotification )
277 void operator()( PropertyNotification& source )
279 mSignalCalled = true;
280 mPropertyNotification = source;
284 PropertyNotification& mPropertyNotification;
287 } // anonymous namespace
290 //& purpose: Testing New API
291 int UtcDaliActorNew(void)
293 TestApplication application;
295 Actor actor = Actor::New();
297 DALI_TEST_CHECK(actor);
301 //& purpose: Testing Dali::Actor::DownCast()
302 int UtcDaliActorDownCastP(void)
304 TestApplication application;
305 tet_infoline("Testing Dali::Actor::DownCast()");
307 Actor actor = Actor::New();
308 BaseHandle object(actor);
309 Actor actor2 = Actor::DownCast(object);
310 DALI_TEST_CHECK(actor2);
314 //& purpose: Testing Dali::Actor::DownCast()
315 int UtcDaliActorDownCastN(void)
317 TestApplication application;
318 tet_infoline("Testing Dali::Actor::DownCast()");
320 BaseHandle unInitializedObject;
321 Actor actor = Actor::DownCast(unInitializedObject);
322 DALI_TEST_CHECK(!actor);
326 //& purpose: Testing Dali::Actor::GetName()
327 int UtcDaliActorGetName(void)
329 TestApplication application;
331 Actor actor = Actor::New();
333 DALI_TEST_CHECK(actor.GetProperty< std::string >( Actor::Property::NAME ).empty());
337 //& purpose: Testing Dali::Actor::SetName()
338 int UtcDaliActorSetName(void)
340 TestApplication application;
342 string str("ActorName");
343 Actor actor = Actor::New();
345 actor.SetProperty( Actor::Property::NAME,str);
346 DALI_TEST_CHECK(actor.GetProperty< std::string >( Actor::Property::NAME ) == str);
350 int UtcDaliActorGetId(void)
352 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
353 TestApplication application;
355 Actor first = Actor::New();
356 Actor second = Actor::New();
357 Actor third = Actor::New();
359 DALI_TEST_CHECK(first.GetId() != second.GetId());
360 DALI_TEST_CHECK(second.GetId() != third.GetId());
364 int UtcDaliActorIsRoot(void)
366 TestApplication application;
368 Actor actor = Actor::New();
369 DALI_TEST_CHECK(!actor.IsRoot());
371 // get the root layer
372 actor = Stage::GetCurrent().GetLayer( 0 );
373 DALI_TEST_CHECK( actor.IsRoot() );
377 int UtcDaliActorOnStage(void)
379 TestApplication application;
381 Actor actor = Actor::New();
382 DALI_TEST_CHECK( !actor.OnStage() );
384 // get the root layer
385 actor = Stage::GetCurrent().GetLayer( 0 );
386 DALI_TEST_CHECK( actor.OnStage() );
390 int UtcDaliActorIsLayer(void)
392 TestApplication application;
394 Actor actor = Actor::New();
395 DALI_TEST_CHECK( !actor.IsLayer() );
397 // get the root layer
398 actor = Stage::GetCurrent().GetLayer( 0 );
399 DALI_TEST_CHECK( actor.IsLayer() );
403 int UtcDaliActorGetLayer(void)
405 TestApplication application;
407 Actor actor = Actor::New();
408 Stage::GetCurrent().Add(actor);
409 Layer layer = actor.GetLayer();
411 DALI_TEST_CHECK(layer);
413 // get the root layers layer
414 actor = Stage::GetCurrent().GetLayer( 0 );
415 DALI_TEST_CHECK( actor.GetLayer() );
419 int UtcDaliActorAddP(void)
421 tet_infoline("Testing Actor::Add");
422 TestApplication application;
424 Actor parent = Actor::New();
425 Actor child = Actor::New();
427 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
431 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
433 Actor parent2 = Actor::New();
434 parent2.Add( child );
436 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
437 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
439 // try Adding to same parent again, works
440 parent2.Add( child );
441 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
443 // try reparenting an orphaned child
445 Actor temporaryParent = Actor::New();
446 temporaryParent.Add( child );
447 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
449 // temporaryParent has now died, reparent the orphaned child
450 parent2.Add( child );
451 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
456 int UtcDaliActorAddN(void)
458 tet_infoline("Testing Actor::Add");
459 TestApplication application;
461 Actor child = Actor::New();
463 Actor parent2 = Actor::New();
464 parent2.Add( child );
469 parent2.Add( parent2 );
470 tet_printf("Assertion test failed - no Exception\n" );
471 tet_result(TET_FAIL);
473 catch(Dali::DaliException& e)
475 DALI_TEST_PRINT_ASSERT( e );
476 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
477 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
481 tet_printf("Assertion test failed - wrong Exception\n" );
482 tet_result(TET_FAIL);
485 // try reparenting root
488 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
489 tet_printf("Assertion test failed - no Exception\n" );
490 tet_result(TET_FAIL);
492 catch(Dali::DaliException& e)
494 DALI_TEST_PRINT_ASSERT( e );
495 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
496 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
500 tet_printf("Assertion test failed - wrong Exception\n" );
501 tet_result(TET_FAIL);
508 parent2.Add( empty );
509 tet_printf("Assertion test failed - no Exception\n" );
510 tet_result(TET_FAIL);
512 catch(Dali::DaliException& e)
514 DALI_TEST_PRINT_ASSERT( e );
515 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
516 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
520 tet_printf("Assertion test failed - wrong Exception\n" );
521 tet_result(TET_FAIL);
527 int UtcDaliActorRemoveN(void)
529 tet_infoline("Testing Actor::Remove");
530 TestApplication application;
532 Actor parent = Actor::New();
533 Actor child = Actor::New();
534 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
537 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
539 parent.Remove(child);
540 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
542 // remove again, no problem
543 parent.Remove(child);
544 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
548 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
549 // try Remove self, its a no-op
550 parent.Remove( parent );
551 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
557 parent.Remove( empty );
558 tet_printf("Assertion test failed - no Exception\n" );
559 tet_result(TET_FAIL);
561 catch(Dali::DaliException& e)
563 DALI_TEST_PRINT_ASSERT( e );
564 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
565 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
569 tet_printf("Assertion test failed - wrong Exception\n" );
570 tet_result(TET_FAIL);
575 int UtcDaliActorRemoveP(void)
577 TestApplication application;
579 Actor parent = Actor::New();
580 Actor child = Actor::New();
581 Actor random = Actor::New();
583 Stage::GetCurrent().Add( parent );
585 DALI_TEST_CHECK(parent.GetChildCount() == 0);
589 DALI_TEST_CHECK(parent.GetChildCount() == 1);
591 parent.Remove(random);
593 DALI_TEST_CHECK(parent.GetChildCount() == 1);
595 Stage::GetCurrent().Remove( parent );
597 DALI_TEST_CHECK(parent.GetChildCount() == 1);
601 int UtcDaliActorGetChildCount(void)
603 TestApplication application;
605 Actor parent = Actor::New();
606 Actor child = Actor::New();
608 DALI_TEST_CHECK(parent.GetChildCount() == 0);
612 DALI_TEST_CHECK(parent.GetChildCount() == 1);
616 int UtcDaliActorGetChildren01(void)
618 TestApplication application;
620 Actor parent = Actor::New();
621 Actor first = Actor::New();
622 Actor second = Actor::New();
623 Actor third = Actor::New();
629 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
630 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
631 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
635 int UtcDaliActorGetChildren02(void)
637 TestApplication application;
639 Actor parent = Actor::New();
640 Actor first = Actor::New();
641 Actor second = Actor::New();
642 Actor third = Actor::New();
648 const Actor& constParent = parent;
650 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
651 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
652 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
656 int UtcDaliActorGetParent01(void)
658 TestApplication application;
660 Actor parent = Actor::New();
661 Actor child = Actor::New();
665 DALI_TEST_CHECK(child.GetParent() == parent);
669 int UtcDaliActorGetParent02(void)
671 TestApplication application;
673 Actor actor = Actor::New();
675 DALI_TEST_CHECK(!actor.GetParent());
679 int UtcDaliActorCustomProperty(void)
681 TestApplication application;
683 Actor actor = Actor::New();
684 Stage::GetCurrent().Add( actor );
686 float startValue(1.0f);
687 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
688 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
690 application.SendNotification();
691 application.Render(0);
692 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
694 actor.SetProperty( index, 5.0f );
696 application.SendNotification();
697 application.Render(0);
698 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
702 int UtcDaliActorCustomPropertyIntToFloat(void)
704 TestApplication application;
706 Actor actor = Actor::New();
707 Stage::GetCurrent().Add( actor );
709 float startValue(5.0f);
710 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
711 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
713 application.SendNotification();
714 application.Render(0);
715 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
717 actor.SetProperty( index, int(1) );
719 application.SendNotification();
720 application.Render(0);
721 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
725 int UtcDaliActorCustomPropertyFloatToInt(void)
727 TestApplication application;
729 Actor actor = Actor::New();
730 Stage::GetCurrent().Add( actor );
733 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
734 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
736 application.SendNotification();
737 application.Render(0);
738 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
740 actor.SetProperty( index, float(1.5) );
742 application.SendNotification();
743 application.Render(0);
744 DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
748 int UtcDaliActorSetParentOrigin(void)
750 TestApplication application;
752 Actor actor = Actor::New();
754 Vector3 vector(0.7f, 0.8f, 0.9f);
755 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
757 actor.SetProperty( Actor::Property::PARENT_ORIGIN, vector );
759 // flush the queue and render once
760 application.SendNotification();
761 application.Render();
763 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
765 Stage::GetCurrent().Add( actor );
767 actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.1f, 0.2f, 0.3f ) );
769 // flush the queue and render once
770 application.SendNotification();
771 application.Render();
773 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), TEST_LOCATION );
775 Stage::GetCurrent().Remove( actor );
779 int UtcDaliActorSetParentOriginIndividual(void)
781 TestApplication application;
783 Actor actor = Actor::New();
785 Vector3 vector(0.7f, 0.8f, 0.9f);
786 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
788 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
790 // flush the queue and render once
791 application.SendNotification();
792 application.Render();
794 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).x, TEST_LOCATION );
796 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
798 // flush the queue and render once
799 application.SendNotification();
800 application.Render();
802 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).y, TEST_LOCATION );
804 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
806 // flush the queue and render once
807 application.SendNotification();
808 application.Render();
810 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).z, TEST_LOCATION );
815 int UtcDaliActorGetCurrentParentOrigin(void)
817 TestApplication application;
819 Actor actor = Actor::New();
821 Vector3 vector(0.7f, 0.8f, 0.9f);
822 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
824 actor.SetProperty( Actor::Property::PARENT_ORIGIN, vector );
826 // flush the queue and render once
827 application.SendNotification();
828 application.Render();
830 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
834 int UtcDaliActorSetAnchorPoint(void)
836 TestApplication application;
838 Actor actor = Actor::New();
840 Vector3 vector(0.7f, 0.8f, 0.9f);
841 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
843 actor.SetProperty( Actor::Property::ANCHOR_POINT, vector );
845 // flush the queue and render once
846 application.SendNotification();
847 application.Render();
849 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
851 Stage::GetCurrent().Add( actor );
853 actor.SetProperty( Actor::Property::ANCHOR_POINT, Vector3( 0.1f, 0.2f, 0.3f ) );
854 // flush the queue and render once
855 application.SendNotification();
856 application.Render();
858 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), TEST_LOCATION );
860 Stage::GetCurrent().Remove( actor );
864 int UtcDaliActorSetAnchorPointIndividual(void)
866 TestApplication application;
868 Actor actor = Actor::New();
870 Vector3 vector(0.7f, 0.8f, 0.9f);
871 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
873 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
875 // flush the queue and render once
876 application.SendNotification();
877 application.Render();
879 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).x, TEST_LOCATION );
881 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
883 // flush the queue and render once
884 application.SendNotification();
885 application.Render();
887 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).y, TEST_LOCATION );
889 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
891 // flush the queue and render once
892 application.SendNotification();
893 application.Render();
895 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).z, TEST_LOCATION );
900 int UtcDaliActorGetCurrentAnchorPoint(void)
902 TestApplication application;
904 Actor actor = Actor::New();
906 Vector3 vector(0.7f, 0.8f, 0.9f);
907 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
909 actor.SetProperty( Actor::Property::ANCHOR_POINT, vector);
911 // flush the queue and render once
912 application.SendNotification();
913 application.Render();
915 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
919 // SetSize(float width, float height)
920 int UtcDaliActorSetSize01(void)
922 TestApplication application;
924 Actor actor = Actor::New();
925 Vector3 vector(100.0f, 100.0f, 0.0f);
927 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
929 actor.SetSize(vector.x, vector.y);
931 // Immediately retrieve the size after setting
932 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
933 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
934 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
935 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
936 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
938 // Flush the queue and render once
939 application.SendNotification();
940 application.Render();
942 // Check the size in the new frame
943 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
945 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
946 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
947 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
948 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
949 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
951 // Check async behaviour
952 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
953 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
954 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
955 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
956 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
958 // Change the resize policy and check whether the size stays the same
959 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
961 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
962 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
964 // Set a new size after resize policy is changed and check the new size
965 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
967 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
968 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
970 // Change the resize policy again and check whether the new size stays the same
971 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
973 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
974 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
976 // Set another new size after resize policy is changed and check the new size
977 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
979 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
980 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
985 // SetSize(float width, float height, float depth)
986 int UtcDaliActorSetSize02(void)
988 TestApplication application;
990 Actor actor = Actor::New();
991 Vector3 vector(100.0f, 100.0f, 100.0f);
993 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
995 actor.SetSize(vector.x, vector.y, vector.z);
997 // Immediately check the size after setting
998 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
999 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1001 // flush the queue and render once
1002 application.SendNotification();
1003 application.Render();
1005 // Check the size in the new frame
1006 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1008 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1009 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1014 // SetSize(Vector2 size)
1015 int UtcDaliActorSetSize03(void)
1017 TestApplication application;
1019 Actor actor = Actor::New();
1020 Vector3 vector(100.0f, 100.0f, 0.0f);
1022 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1024 actor.SetSize(Vector2(vector.x, vector.y));
1026 // Immediately check the size after setting
1027 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1028 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1030 // flush the queue and render once
1031 application.SendNotification();
1032 application.Render();
1034 // Check the size in the new frame
1035 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1037 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1038 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1043 // SetSize(Vector3 size)
1044 int UtcDaliActorSetSize04(void)
1046 TestApplication application;
1048 Actor actor = Actor::New();
1049 Vector3 vector(100.0f, 100.0f, 100.0f);
1051 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1053 actor.SetSize(vector);
1055 // Immediately check the size after setting
1056 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1057 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1059 // flush the queue and render once
1060 application.SendNotification();
1061 application.Render();
1063 // Check the size in the new frame
1064 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1066 Stage::GetCurrent().Add( actor );
1067 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
1069 // Immediately check the size after setting
1070 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1071 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1073 // flush the queue and render once
1074 application.SendNotification();
1075 application.Render();
1077 // Check the size in the new frame
1078 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), TEST_LOCATION );
1080 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1081 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1083 Stage::GetCurrent().Remove( actor );
1087 int UtcDaliActorSetSizeIndividual(void)
1089 TestApplication application;
1091 Actor actor = Actor::New();
1093 Vector3 vector(0.7f, 0.8f, 0.9f);
1094 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1096 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1098 // Immediately check the width after setting
1099 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1100 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1102 // flush the queue and render once
1103 application.SendNotification();
1104 application.Render();
1106 // Check the width in the new frame
1107 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1109 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1110 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1112 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1114 // Immediately check the height after setting
1115 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1116 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1118 // flush the queue and render once
1119 application.SendNotification();
1120 application.Render();
1122 // Check the height in the new frame
1123 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1125 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1126 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1128 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1130 // Immediately check the depth after setting
1131 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1132 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1134 // flush the queue and render once
1135 application.SendNotification();
1136 application.Render();
1138 // Check the depth in the new frame
1139 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).depth, TEST_LOCATION );
1141 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1142 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1144 // Change the resize policy and check whether the size stays the same
1145 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1147 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1148 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1150 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1151 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1153 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1154 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1156 // Change the resize policy again and check whether the size stays the same
1157 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1159 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1160 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1162 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1163 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1165 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1166 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1171 int UtcDaliActorSetSizeIndividual02(void)
1173 TestApplication application;
1175 Actor actor = Actor::New();
1176 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1177 Stage::GetCurrent().Add( actor );
1179 Vector3 vector( 100.0f, 200.0f, 400.0f );
1180 DALI_TEST_CHECK( vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ) );
1182 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1183 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1185 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1186 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1188 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1189 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1191 // flush the queue and render once
1192 application.SendNotification();
1193 application.Render();
1195 // Check the width in the new frame
1196 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1197 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1203 int UtcDaliActorGetCurrentSize(void)
1205 TestApplication application;
1207 Actor actor = Actor::New();
1208 Vector3 vector(100.0f, 100.0f, 20.0f);
1210 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1212 actor.SetSize(vector);
1214 // flush the queue and render once
1215 application.SendNotification();
1216 application.Render();
1218 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1222 int UtcDaliActorGetNaturalSize(void)
1224 TestApplication application;
1226 Actor actor = Actor::New();
1227 Vector3 vector( 0.0f, 0.0f, 0.0f );
1229 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1234 int UtcDaliActorGetCurrentSizeImmediate(void)
1236 TestApplication application;
1238 Actor actor = Actor::New();
1239 Vector3 vector(100.0f, 100.0f, 20.0f);
1241 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1242 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1244 actor.SetSize(vector);
1246 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1247 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1249 // flush the queue and render once
1250 application.SendNotification();
1251 application.Render();
1253 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1254 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1257 // Build the animation
1258 const float durationSeconds = 2.0f;
1259 Animation animation = Animation::New( durationSeconds );
1260 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1261 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1263 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1265 // Start the animation
1268 application.SendNotification();
1269 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1271 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1276 int UtcDaliActorCalculateScreenExtents(void)
1278 TestApplication application;
1280 Actor actor = Actor::New();
1282 actor.SetPosition(Vector3(2.0f, 2.0f, 16.0f));
1283 actor.SetSize(Vector3{ 1.0f, 1.0f, 1.0f });
1285 application.SendNotification();
1286 application.Render();
1288 auto expectedExtent = Rect<>{ -0.5f, -0.5f, 1.0f, 1.0f };
1289 auto actualExtent = DevelActor::CalculateScreenExtents( actor );
1290 DALI_TEST_EQUALS( expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1291 DALI_TEST_EQUALS( expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1292 DALI_TEST_EQUALS( expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1293 DALI_TEST_EQUALS( expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1295 Stage::GetCurrent().Remove( actor );
1299 // SetPosition(float x, float y)
1300 int UtcDaliActorSetPosition01(void)
1302 TestApplication application;
1304 Actor actor = Actor::New();
1306 // Set to random to start off with
1307 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1309 Vector3 vector(100.0f, 100.0f, 0.0f);
1311 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1313 actor.SetPosition(vector.x, vector.y);
1314 // flush the queue and render once
1315 application.SendNotification();
1316 application.Render();
1317 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1319 Stage::GetCurrent().Add( actor );
1320 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1321 // flush the queue and render once
1322 application.SendNotification();
1323 application.Render();
1324 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1329 // flush the queue and render once
1330 application.SendNotification();
1331 application.Render();
1332 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1334 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1335 // flush the queue and render once
1336 application.SendNotification();
1337 application.Render();
1338 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1340 Stage::GetCurrent().Remove( actor );
1344 // SetPosition(float x, float y, float z)
1345 int UtcDaliActorSetPosition02(void)
1347 TestApplication application;
1349 Actor actor = Actor::New();
1351 // Set to random to start off with
1352 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1354 Vector3 vector(100.0f, 100.0f, 100.0f);
1356 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1358 actor.SetPosition(vector.x, vector.y, vector.z);
1360 // flush the queue and render once
1361 application.SendNotification();
1362 application.Render();
1364 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1368 // SetPosition(Vector3 position)
1369 int UtcDaliActorSetPosition03(void)
1371 TestApplication application;
1373 Actor actor = Actor::New();
1375 // Set to random to start off with
1376 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1378 Vector3 vector(100.0f, 100.0f, 100.0f);
1380 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1382 actor.SetPosition(vector);
1384 // flush the queue and render once
1385 application.SendNotification();
1386 application.Render();
1388 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1392 int UtcDaliActorSetX(void)
1394 TestApplication application;
1396 Actor actor = Actor::New();
1398 Vector3 vector(100.0f, 0.0f, 0.0f);
1400 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1404 // flush the queue and render once
1405 application.SendNotification();
1406 application.Render();
1408 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1412 int UtcDaliActorSetY(void)
1414 TestApplication application;
1416 Actor actor = Actor::New();
1418 Vector3 vector(0.0f, 100.0f, 0.0f);
1420 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1424 // flush the queue and render once
1425 application.SendNotification();
1426 application.Render();
1428 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1432 int UtcDaliActorSetZ(void)
1434 TestApplication application;
1436 Actor actor = Actor::New();
1438 Vector3 vector(0.0f, 0.0f, 100.0f);
1440 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1444 // flush the queue and render once
1445 application.SendNotification();
1446 application.Render();
1448 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1452 int UtcDaliActorSetPositionProperties(void)
1454 TestApplication application;
1456 Actor actor = Actor::New();
1458 Vector3 vector(0.7f, 0.8f, 0.9f);
1459 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1461 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1462 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1463 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1465 // flush the queue and render once
1466 application.SendNotification();
1467 application.Render();
1469 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1470 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1471 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1472 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1473 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1475 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1476 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1477 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1479 // flush the queue and render once
1480 application.SendNotification();
1481 application.Render();
1483 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1484 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1485 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1486 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1487 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1489 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1490 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1491 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1493 // flush the queue and render once
1494 application.SendNotification();
1495 application.Render();
1497 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1498 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1499 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1500 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1501 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1506 int UtcDaliActorTranslateBy(void)
1508 TestApplication application;
1510 Actor actor = Actor::New();
1511 Vector3 vector(100.0f, 100.0f, 100.0f);
1513 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1515 actor.SetPosition(vector);
1517 // flush the queue and render once
1518 application.SendNotification();
1519 application.Render();
1521 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1523 actor.TranslateBy(vector);
1525 // flush the queue and render once
1526 application.SendNotification();
1527 application.Render();
1529 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1533 int UtcDaliActorGetCurrentPosition(void)
1535 TestApplication application;
1537 Actor actor = Actor::New();
1538 Vector3 setVector(100.0f, 100.0f, 0.0f);
1539 actor.SetPosition(setVector);
1541 // flush the queue and render once
1542 application.SendNotification();
1543 application.Render();
1545 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ) == setVector);
1549 int UtcDaliActorGetCurrentWorldPosition(void)
1551 TestApplication application;
1553 Actor parent = Actor::New();
1554 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1555 parent.SetPosition( parentPosition );
1556 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1557 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1558 Stage::GetCurrent().Add( parent );
1560 Actor child = Actor::New();
1561 child.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1562 child.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1563 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1564 child.SetPosition( childPosition );
1565 parent.Add( child );
1567 // The actors should not have a world position yet
1568 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1569 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1571 application.SendNotification();
1572 application.Render(0);
1574 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1575 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1577 // The actors should have a world position now
1578 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1579 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1583 int UtcDaliActorSetInheritPosition(void)
1585 tet_infoline("Testing Actor::SetInheritPosition");
1586 TestApplication application;
1588 Actor parent = Actor::New();
1589 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1590 parent.SetPosition( parentPosition );
1591 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1592 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1593 Stage::GetCurrent().Add( parent );
1595 Actor child = Actor::New();
1596 child.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1597 child.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1598 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1599 child.SetPosition( childPosition );
1600 parent.Add( child );
1602 // The actors should not have a world position yet
1603 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1604 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1606 // first test default, which is to inherit position
1607 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1608 application.SendNotification();
1609 application.Render(0); // should only really call Update as Render is not required to update scene
1610 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1611 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1612 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1613 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1615 //Change child position
1616 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1617 child.SetPosition( childOffset );
1619 // Use local position as world postion
1620 child.SetProperty( Actor::Property::INHERIT_POSITION, false );
1621 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), false, TEST_LOCATION );
1622 application.SendNotification();
1623 application.Render(0); // should only really call Update as Render is not required to update scene
1624 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1625 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1626 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1627 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), childOffset, TEST_LOCATION );
1629 //Change back to inherit position from parent
1630 child.SetProperty( Actor::Property::INHERIT_POSITION, true );
1631 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1632 application.SendNotification();
1633 application.Render(0); // should only really call Update as Render is not required to update scene
1634 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1635 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1636 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1637 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childOffset, TEST_LOCATION );
1641 int UtcDaliActorInheritOpacity(void)
1643 tet_infoline("Testing Actor::Inherit Opacity");
1644 TestApplication application;
1646 Actor parent = Actor::New();
1647 Actor child = Actor::New();
1648 parent.Add( child );
1649 Stage::GetCurrent().Add( parent );
1651 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1652 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1654 // flush the queue and render once
1655 application.SendNotification();
1656 application.Render();
1658 parent.SetProperty( DevelActor::Property::OPACITY, 0.1f );
1660 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1661 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1663 application.SendNotification();
1664 application.Render();
1666 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1667 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1668 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1669 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1670 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1671 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1676 // SetOrientation(float angleRadians, Vector3 axis)
1677 int UtcDaliActorSetOrientation01(void)
1679 TestApplication application;
1681 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1682 Actor actor = Actor::New();
1684 actor.SetProperty( Actor::Property::ORIENTATION, rotation);
1686 // flush the queue and render once
1687 application.SendNotification();
1688 application.Render();
1690 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1694 int UtcDaliActorSetOrientation02(void)
1696 TestApplication application;
1698 Actor actor = Actor::New();
1700 Radian angle( 0.785f );
1701 Vector3 axis(1.0f, 1.0f, 0.0f);
1703 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1704 Quaternion rotation( angle, axis );
1705 // flush the queue and render once
1706 application.SendNotification();
1707 application.Render();
1708 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1710 Stage::GetCurrent().Add( actor );
1711 actor.RotateBy( Degree( 360 ), axis);
1712 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1714 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) ) );
1715 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1716 // flush the queue and render once
1717 application.SendNotification();
1718 application.Render();
1719 DALI_TEST_EQUALS( result, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1721 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1722 // flush the queue and render once
1723 application.SendNotification();
1724 application.Render();
1725 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1727 Stage::GetCurrent().Remove( actor );
1731 // SetOrientation(float angleRadians, Vector3 axis)
1732 int UtcDaliActorSetOrientationProperty(void)
1734 TestApplication application;
1736 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1737 Actor actor = Actor::New();
1739 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1740 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1742 // flush the queue and render once
1743 application.SendNotification();
1744 application.Render();
1746 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1747 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1748 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1752 // RotateBy(float angleRadians, Vector3 axis)
1753 int UtcDaliActorRotateBy01(void)
1755 TestApplication application;
1757 Actor actor = Actor::New();
1759 Radian angle( M_PI * 0.25f );
1760 actor.RotateBy(( angle ), Vector3::ZAXIS);
1761 // flush the queue and render once
1762 application.SendNotification();
1763 application.Render();
1764 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1766 Stage::GetCurrent().Add( actor );
1768 actor.RotateBy( angle, Vector3::ZAXIS);
1769 // flush the queue and render once
1770 application.SendNotification();
1771 application.Render();
1772 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1774 Stage::GetCurrent().Remove( actor );
1778 // RotateBy(Quaternion relativeRotation)
1779 int UtcDaliActorRotateBy02(void)
1781 TestApplication application;
1783 Actor actor = Actor::New();
1785 Radian angle( M_PI * 0.25f );
1786 Quaternion rotation(angle, Vector3::ZAXIS);
1787 actor.RotateBy(rotation);
1788 // flush the queue and render once
1789 application.SendNotification();
1790 application.Render();
1791 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1793 actor.RotateBy(rotation);
1794 // flush the queue and render once
1795 application.SendNotification();
1796 application.Render();
1797 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1801 int UtcDaliActorGetCurrentOrientation(void)
1803 TestApplication application;
1804 Actor actor = Actor::New();
1806 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1807 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1808 // flush the queue and render once
1809 application.SendNotification();
1810 application.Render();
1811 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1815 int UtcDaliActorGetCurrentWorldOrientation(void)
1817 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1818 TestApplication application;
1820 Actor parent = Actor::New();
1821 Radian rotationAngle( Degree(90.0f) );
1822 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1823 parent.SetProperty( Actor::Property::ORIENTATION, rotation );
1824 Stage::GetCurrent().Add( parent );
1826 Actor child = Actor::New();
1827 child.SetProperty( Actor::Property::ORIENTATION, rotation );
1828 parent.Add( child );
1830 // The actors should not have a world rotation yet
1831 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1832 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1834 application.SendNotification();
1835 application.Render(0);
1837 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1838 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1840 // The actors should have a world rotation now
1841 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1842 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1844 // turn off child rotation inheritance
1845 child.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
1846 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_ORIENTATION ), false, TEST_LOCATION );
1847 application.SendNotification();
1848 application.Render(0);
1850 // The actors should have a world rotation now
1851 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1852 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1856 // SetScale(float scale)
1857 int UtcDaliActorSetScale01(void)
1859 TestApplication application;
1861 Actor actor = Actor::New();
1863 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1864 actor.SetScale(0.25f);
1866 Vector3 scale(10.0f, 10.0f, 10.0f);
1867 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1869 actor.SetScale(scale.x);
1871 // flush the queue and render once
1872 application.SendNotification();
1873 application.Render();
1875 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1879 // SetScale(float scaleX, float scaleY, float scaleZ)
1880 int UtcDaliActorSetScale02(void)
1882 TestApplication application;
1883 Vector3 scale(10.0f, 10.0f, 10.0f);
1885 Actor actor = Actor::New();
1887 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1888 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1890 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1892 actor.SetScale(scale.x, scale.y, scale.z);
1893 // flush the queue and render once
1894 application.SendNotification();
1895 application.Render();
1896 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1898 // add to stage and test
1899 Stage::GetCurrent().Add( actor );
1900 actor.SetScale( 2.0f, 2.0f, 2.0f );
1901 // flush the queue and render once
1902 application.SendNotification();
1903 application.Render();
1904 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), 0.001, TEST_LOCATION);
1906 Stage::GetCurrent().Remove( actor );
1911 // SetScale(Vector3 scale)
1912 int UtcDaliActorSetScale03(void)
1914 TestApplication application;
1915 Vector3 scale(10.0f, 10.0f, 10.0f);
1917 Actor actor = Actor::New();
1919 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1920 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1922 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1924 actor.SetScale(scale);
1926 // flush the queue and render once
1927 application.SendNotification();
1928 application.Render();
1930 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1934 int UtcDaliActorSetScaleIndividual(void)
1936 TestApplication application;
1938 Actor actor = Actor::New();
1940 Vector3 vector(0.7f, 0.8f, 0.9f);
1941 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1943 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1944 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1946 // flush the queue and render once
1947 application.SendNotification();
1948 application.Render();
1950 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x, TEST_LOCATION );
1951 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1952 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1954 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1955 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1957 // flush the queue and render once
1958 application.SendNotification();
1959 application.Render();
1961 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).y, TEST_LOCATION );
1962 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1963 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1965 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1966 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1968 // flush the queue and render once
1969 application.SendNotification();
1970 application.Render();
1972 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).z, TEST_LOCATION );
1973 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1974 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1976 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1977 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1982 int UtcDaliActorScaleBy(void)
1984 TestApplication application;
1985 Actor actor = Actor::New();
1986 Vector3 vector(100.0f, 100.0f, 100.0f);
1988 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1990 actor.SetScale(vector);
1992 // flush the queue and render once
1993 application.SendNotification();
1994 application.Render();
1996 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1998 actor.ScaleBy(vector);
2000 // flush the queue and render once
2001 application.SendNotification();
2002 application.Render();
2004 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
2008 int UtcDaliActorGetCurrentScale(void)
2010 TestApplication application;
2011 Vector3 scale(12.0f, 1.0f, 2.0f);
2013 Actor actor = Actor::New();
2015 actor.SetScale(scale);
2017 // flush the queue and render once
2018 application.SendNotification();
2019 application.Render();
2021 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
2025 int UtcDaliActorGetCurrentWorldScale(void)
2027 TestApplication application;
2029 Actor parent = Actor::New();
2030 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2031 parent.SetScale( parentScale );
2032 Stage::GetCurrent().Add( parent );
2034 Actor child = Actor::New();
2035 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2036 child.SetScale( childScale );
2037 parent.Add( child );
2039 // The actors should not have a scale yet
2040 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2041 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2043 // The actors should not have a world scale yet
2044 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2045 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2047 application.SendNotification();
2048 application.Render(0);
2050 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), parentScale, TEST_LOCATION );
2051 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), childScale, TEST_LOCATION );
2053 // The actors should have a world scale now
2054 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale, TEST_LOCATION );
2055 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2059 int UtcDaliActorInheritScale(void)
2061 tet_infoline("Testing Actor::SetInheritScale");
2062 TestApplication application;
2064 Actor parent = Actor::New();
2065 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2066 parent.SetScale( parentScale );
2067 Stage::GetCurrent().Add( parent );
2069 Actor child = Actor::New();
2070 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2071 child.SetScale( childScale );
2072 parent.Add( child );
2074 application.SendNotification();
2075 application.Render(0);
2077 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), true, TEST_LOCATION );
2078 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2080 child.SetProperty( Actor::Property::INHERIT_SCALE, false );
2081 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), false, TEST_LOCATION );
2083 application.SendNotification();
2084 application.Render(0);
2086 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), childScale, TEST_LOCATION );
2090 int UtcDaliActorSetVisible(void)
2092 TestApplication application;
2094 Actor actor = Actor::New();
2095 actor.SetProperty( Actor::Property::VISIBLE,false);
2096 // flush the queue and render once
2097 application.SendNotification();
2098 application.Render();
2099 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2101 actor.SetProperty( Actor::Property::VISIBLE,true);
2102 // flush the queue and render once
2103 application.SendNotification();
2104 application.Render();
2105 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2107 // put actor on stage
2108 Stage::GetCurrent().Add( actor );
2109 actor.SetProperty( Actor::Property::VISIBLE,false);
2110 // flush the queue and render once
2111 application.SendNotification();
2112 application.Render();
2113 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2117 int UtcDaliActorIsVisible(void)
2119 TestApplication application;
2121 Actor actor = Actor::New();
2123 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2127 int UtcDaliActorSetOpacity(void)
2129 TestApplication application;
2131 Actor actor = Actor::New();
2132 // initial opacity is 1
2133 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
2135 actor.SetProperty( DevelActor::Property::OPACITY, 0.4f);
2136 // flush the queue and render once
2137 application.SendNotification();
2138 application.Render();
2139 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.4f, TEST_LOCATION );
2141 // change opacity, actor is on stage to change is not immediate
2142 actor.SetProperty( DevelActor::Property::OPACITY, actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) + 0.1f );
2143 // flush the queue and render once
2144 application.SendNotification();
2145 application.Render();
2146 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2148 // put actor on stage
2149 Stage::GetCurrent().Add( actor );
2151 // change opacity, actor is on stage to change is not immediate
2152 actor.SetProperty( DevelActor::Property::OPACITY, 0.9f );
2153 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2154 // flush the queue and render once
2155 application.SendNotification();
2156 application.Render();
2157 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.9f, TEST_LOCATION );
2159 // change opacity, actor is on stage to change is not immediate
2160 actor.SetProperty( DevelActor::Property::OPACITY, actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) - 0.9f );
2161 // flush the queue and render once
2162 application.SendNotification();
2163 application.Render();
2164 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
2168 int UtcDaliActorGetCurrentOpacity(void)
2170 TestApplication application;
2172 Actor actor = Actor::New();
2173 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) != 0.5f);
2175 actor.SetProperty( DevelActor::Property::OPACITY,0.5f);
2176 // flush the queue and render once
2177 application.SendNotification();
2178 application.Render();
2179 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) == 0.5f);
2183 int UtcDaliActorSetSensitive(void)
2185 TestApplication application;
2186 Actor actor = Actor::New();
2188 bool sensitive = !actor.GetProperty< bool >( Actor::Property::SENSITIVE );
2190 actor.SetProperty( Actor::Property::SENSITIVE,sensitive);
2192 DALI_TEST_CHECK(sensitive == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2196 int UtcDaliActorIsSensitive(void)
2198 TestApplication application;
2199 Actor actor = Actor::New();
2200 actor.SetProperty( Actor::Property::SENSITIVE,false);
2202 DALI_TEST_CHECK(false == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2206 int UtcDaliActorSetColor(void)
2208 TestApplication application;
2209 Actor actor = Actor::New();
2210 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2212 DALI_TEST_CHECK(color != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2214 actor.SetProperty( Actor::Property::COLOR,color);
2215 // flush the queue and render once
2216 application.SendNotification();
2217 application.Render();
2218 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2220 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2221 // flush the queue and render once
2222 application.SendNotification();
2223 application.Render();
2224 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2226 Stage::GetCurrent().Add( actor );
2227 actor.SetProperty( Actor::Property::COLOR, color );
2228 // flush the queue and render once
2229 application.SendNotification();
2230 application.Render();
2231 DALI_TEST_EQUALS( color, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2233 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2234 // flush the queue and render once
2235 application.SendNotification();
2236 application.Render();
2237 // Actor color is not clamped
2238 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2239 // world color is clamped
2240 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), TEST_LOCATION );
2242 actor.SetProperty( Actor::Property::COLOR, color );
2243 DALI_TEST_EQUALS( color, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2245 Vector3 newColor( 1.0f, 0.0f, 0.0f );
2246 actor.SetProperty( Actor::Property::COLOR, newColor );
2247 DALI_TEST_EQUALS( Vector4( newColor.r, newColor.g, newColor.b, 1.0f ), actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2249 Stage::GetCurrent().Remove( actor );
2253 int UtcDaliActorSetColorIndividual(void)
2255 TestApplication application;
2257 Actor actor = Actor::New();
2259 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2260 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2262 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2263 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2265 // flush the queue and render once
2266 application.SendNotification();
2267 application.Render();
2269 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).r, TEST_LOCATION );
2270 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2271 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2273 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2274 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2276 // flush the queue and render once
2277 application.SendNotification();
2278 application.Render();
2280 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).g, TEST_LOCATION );
2281 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2282 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2284 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2285 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2287 // flush the queue and render once
2288 application.SendNotification();
2289 application.Render();
2291 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).b, TEST_LOCATION );
2292 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2293 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2296 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2297 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2299 // flush the queue and render once
2300 application.SendNotification();
2301 application.Render();
2303 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2304 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2305 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2307 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2308 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2310 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2313 // flush the queue and render once
2314 application.SendNotification();
2315 application.Render();
2317 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2323 int UtcDaliActorGetCurrentColor(void)
2325 TestApplication application;
2326 Actor actor = Actor::New();
2327 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2329 actor.SetProperty( Actor::Property::COLOR,color);
2330 // flush the queue and render once
2331 application.SendNotification();
2332 application.Render();
2333 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2337 int UtcDaliActorGetCurrentWorldColor(void)
2339 tet_infoline("Actor::GetCurrentWorldColor");
2340 TestApplication application;
2342 Actor parent = Actor::New();
2343 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2344 parent.SetProperty( Actor::Property::COLOR, parentColor );
2345 Stage::GetCurrent().Add( parent );
2347 Actor child = Actor::New();
2348 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2349 child.SetProperty( Actor::Property::COLOR, childColor );
2350 parent.Add( child );
2352 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2353 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2355 // verify the default color mode
2356 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2358 // The actors should not have a world color yet
2359 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2360 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2362 application.SendNotification();
2363 application.Render(0);
2365 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), parentColor, TEST_LOCATION );
2366 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2368 // The actors should have a world color now
2369 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2370 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2373 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2374 application.SendNotification();
2375 application.Render(0);
2376 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), childColor, TEST_LOCATION );
2379 child.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2380 application.SendNotification();
2381 application.Render(0);
2382 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2383 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2386 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2387 application.SendNotification();
2388 application.Render(0);
2389 Vector4 expectedColor( childColor );
2390 expectedColor.a *= parentColor.a;
2391 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2392 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), expectedColor, TEST_LOCATION );
2396 int UtcDaliActorSetColorMode(void)
2398 tet_infoline("Actor::SetColorMode");
2399 TestApplication application;
2400 Actor actor = Actor::New();
2401 Actor child = Actor::New();
2404 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2405 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2407 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
2408 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2410 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2411 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2413 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2414 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2418 int UtcDaliActorScreenToLocal(void)
2420 TestApplication application;
2421 Actor actor = Actor::New();
2422 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2423 actor.SetSize(100.0f, 100.0f);
2424 actor.SetPosition(10.0f, 10.0f);
2425 Stage::GetCurrent().Add(actor);
2427 // flush the queue and render once
2428 application.SendNotification();
2429 application.Render();
2434 application.SendNotification();
2435 application.Render();
2437 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2439 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2440 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2444 int UtcDaliActorSetLeaveRequired(void)
2446 TestApplication application;
2448 Actor actor = Actor::New();
2450 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,false);
2451 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2453 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,true);
2454 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == true);
2458 int UtcDaliActorGetLeaveRequired(void)
2460 TestApplication application;
2462 Actor actor = Actor::New();
2464 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2468 int UtcDaliActorSetKeyboardFocusable(void)
2470 TestApplication application;
2472 Actor actor = Actor::New();
2474 actor.SetKeyboardFocusable(true);
2475 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2477 actor.SetKeyboardFocusable(false);
2478 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2482 int UtcDaliActorIsKeyboardFocusable(void)
2484 TestApplication application;
2486 Actor actor = Actor::New();
2488 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2492 int UtcDaliActorRemoveConstraints(void)
2494 tet_infoline(" UtcDaliActorRemoveConstraints");
2495 TestApplication application;
2497 gTestConstraintCalled = false;
2499 Actor actor = Actor::New();
2501 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2503 actor.RemoveConstraints();
2505 DALI_TEST_CHECK( gTestConstraintCalled == false );
2507 Stage::GetCurrent().Add( actor );
2510 // flush the queue and render once
2511 application.SendNotification();
2512 application.Render();
2514 actor.RemoveConstraints();
2516 DALI_TEST_CHECK( gTestConstraintCalled == true );
2520 int UtcDaliActorRemoveConstraintTag(void)
2522 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2523 TestApplication application;
2525 Actor actor = Actor::New();
2527 // 1. Apply Constraint1 and Constraint2, and test...
2528 unsigned int result1 = 0u;
2529 unsigned int result2 = 0u;
2531 unsigned constraint1Tag = 1u;
2532 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2533 constraint1.SetTag( constraint1Tag );
2534 constraint1.Apply();
2536 unsigned constraint2Tag = 2u;
2537 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2538 constraint2.SetTag( constraint2Tag );
2539 constraint2.Apply();
2541 Stage::GetCurrent().Add( actor );
2542 // flush the queue and render once
2543 application.SendNotification();
2544 application.Render();
2546 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2547 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2549 // 2. Remove Constraint1 and test...
2552 actor.RemoveConstraints(constraint1Tag);
2553 // make color property dirty, which will trigger constraints to be reapplied.
2554 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2555 // flush the queue and render once
2556 application.SendNotification();
2557 application.Render();
2559 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2560 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2562 // 3. Re-Apply Constraint1 and test...
2565 constraint1.Apply();
2566 // make color property dirty, which will trigger constraints to be reapplied.
2567 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2568 // flush the queue and render once
2569 application.SendNotification();
2570 application.Render();
2572 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2573 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2575 // 2. Remove Constraint2 and test...
2578 actor.RemoveConstraints(constraint2Tag);
2579 // make color property dirty, which will trigger constraints to be reapplied.
2580 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2581 // flush the queue and render once
2582 application.SendNotification();
2583 application.Render();
2585 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2586 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2588 // 2. Remove Constraint1 as well and test...
2591 actor.RemoveConstraints(constraint1Tag);
2592 // make color property dirty, which will trigger constraints to be reapplied.
2593 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2594 // flush the queue and render once
2595 application.SendNotification();
2596 application.Render();
2598 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2599 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2603 int UtcDaliActorTouchedSignal(void)
2605 TestApplication application;
2607 ResetTouchCallbacks();
2609 // get the root layer
2610 Actor actor = Stage::GetCurrent().GetRootLayer();
2611 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2613 application.SendNotification();
2614 application.Render();
2616 // connect to its touch signal
2617 actor.TouchedSignal().Connect( TestCallback );
2619 // simulate a touch event in the middle of the screen
2620 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2621 Dali::Integration::Point point;
2622 point.SetDeviceId( 1 );
2623 point.SetState( PointState::DOWN );
2624 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2625 Dali::Integration::TouchEvent touchEvent;
2626 touchEvent.AddPoint( point );
2627 application.ProcessEvent( touchEvent );
2629 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2633 int UtcDaliActorHoveredSignal(void)
2635 TestApplication application;
2637 gHoverCallBackCalled = false;
2639 // get the root layer
2640 Actor actor = Stage::GetCurrent().GetRootLayer();
2641 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2643 application.SendNotification();
2644 application.Render();
2646 // connect to its hover signal
2647 actor.HoveredSignal().Connect( TestCallback3 );
2649 // simulate a hover event in the middle of the screen
2650 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2651 Dali::Integration::Point point;
2652 point.SetDeviceId( 1 );
2653 point.SetState( PointState::MOTION );
2654 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2655 Dali::Integration::HoverEvent hoverEvent;
2656 hoverEvent.AddPoint( point );
2657 application.ProcessEvent( hoverEvent );
2659 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2663 int UtcDaliActorOnOffStageSignal(void)
2665 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2667 TestApplication application;
2670 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2671 gActorNamesOnOffStage.clear();
2673 Actor parent = Actor::New();
2674 parent.SetProperty( Actor::Property::NAME, "parent" );
2675 parent.OnStageSignal().Connect( OnStageCallback );
2676 parent.OffStageSignal().Connect( OffStageCallback );
2678 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2679 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2681 // add parent to stage
2682 Stage::GetCurrent().Add( parent );
2683 // onstage emitted, offstage not
2684 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2685 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2686 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2688 // test adding a child, should get onstage emitted
2690 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2691 gActorNamesOnOffStage.clear();
2693 Actor child = Actor::New();
2694 child.SetProperty( Actor::Property::NAME, "child" );
2695 child.OnStageSignal().Connect( OnStageCallback );
2696 child.OffStageSignal().Connect( OffStageCallback );
2697 parent.Add( child ); // add child
2698 // onstage emitted, offstage not
2699 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2700 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2701 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2703 // test removing parent from stage
2705 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2706 gActorNamesOnOffStage.clear();
2708 Stage::GetCurrent().Remove( parent );
2709 // onstage not emitted, offstage is
2710 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2711 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2712 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2713 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2715 // test adding parent back to stage
2717 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2718 gActorNamesOnOffStage.clear();
2720 Stage::GetCurrent().Add( parent );
2721 // onstage emitted, offstage not
2722 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2723 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2724 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2725 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2727 // test removing child
2729 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2730 gActorNamesOnOffStage.clear();
2732 parent.Remove( child );
2733 // onstage not emitted, offstage is
2734 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2735 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2736 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2738 // test removing parent
2740 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2741 gActorNamesOnOffStage.clear();
2743 Stage::GetCurrent().Remove( parent );
2744 // onstage not emitted, offstage is
2745 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2746 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2747 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2751 int UtcDaliActorFindChildByName(void)
2753 tet_infoline("Testing Dali::Actor::FindChildByName()");
2754 TestApplication application;
2756 Actor parent = Actor::New();
2757 parent.SetProperty( Actor::Property::NAME, "parent" );
2758 Actor first = Actor::New();
2759 first .SetProperty( Actor::Property::NAME, "first" );
2760 Actor second = Actor::New();
2761 second.SetProperty( Actor::Property::NAME, "second" );
2766 Actor found = parent.FindChildByName( "foo" );
2767 DALI_TEST_CHECK( !found );
2769 found = parent.FindChildByName( "parent" );
2770 DALI_TEST_CHECK( found == parent );
2772 found = parent.FindChildByName( "first" );
2773 DALI_TEST_CHECK( found == first );
2775 found = parent.FindChildByName( "second" );
2776 DALI_TEST_CHECK( found == second );
2780 int UtcDaliActorFindChildById(void)
2782 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2783 TestApplication application;
2785 Actor parent = Actor::New();
2786 Actor first = Actor::New();
2787 Actor second = Actor::New();
2792 Actor found = parent.FindChildById( 100000 );
2793 DALI_TEST_CHECK( !found );
2795 found = parent.FindChildById( parent.GetId() );
2796 DALI_TEST_CHECK( found == parent );
2798 found = parent.FindChildById( first.GetId() );
2799 DALI_TEST_CHECK( found == first );
2801 found = parent.FindChildById( second.GetId() );
2802 DALI_TEST_CHECK( found == second );
2806 int UtcDaliActorHitTest(void)
2811 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2813 mTouchPoint( touchPoint ),
2818 Vector2 mTouchPoint;
2822 TestApplication application;
2823 tet_infoline(" UtcDaliActorHitTest");
2825 // Fill a vector with different hit tests.
2826 struct HitTestData* hitTestData[] = {
2827 // scale touch point result
2828 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2829 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2830 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.
2831 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2832 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.
2836 // get the root layer
2837 Actor actor = Actor::New();
2838 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2839 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2841 Stage::GetCurrent().Add( actor );
2843 ResetTouchCallbacks();
2845 unsigned int index = 0;
2846 while( NULL != hitTestData[index] )
2848 actor.SetSize( 1.f, 1.f );
2849 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2851 // flush the queue and render once
2852 application.SendNotification();
2853 application.Render();
2855 DALI_TEST_CHECK( !gTouchCallBackCalled );
2857 // connect to its touch signal
2858 actor.TouchedSignal().Connect(TestCallback);
2860 Dali::Integration::Point point;
2861 point.SetState( PointState::DOWN );
2862 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2863 Dali::Integration::TouchEvent event;
2864 event.AddPoint( point );
2866 // flush the queue and render once
2867 application.SendNotification();
2868 application.Render();
2869 application.ProcessEvent( event );
2871 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2873 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2874 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2875 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2876 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2877 hitTestData[index]->mResult );
2879 ResetTouchCallbacks();
2885 int UtcDaliActorSetDrawMode(void)
2887 TestApplication app;
2888 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2890 Actor a = Actor::New();
2892 Stage::GetCurrent().Add(a);
2893 app.SendNotification();
2895 app.SendNotification();
2898 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Ensure overlay is off by default
2900 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
2901 app.SendNotification();
2904 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is overlay
2906 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
2907 app.SendNotification();
2910 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is normal
2914 int UtcDaliActorSetDrawModeOverlayRender(void)
2916 TestApplication app;
2917 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2919 app.SendNotification();
2922 std::vector<GLuint> ids;
2923 ids.push_back( 8 ); // first rendered actor
2924 ids.push_back( 9 ); // second rendered actor
2925 ids.push_back( 10 ); // third rendered actor
2926 app.GetGlAbstraction().SetNextTextureIds( ids );
2928 BufferImage imageA = BufferImage::New(16, 16);
2929 BufferImage imageB = BufferImage::New(16, 16);
2930 BufferImage imageC = BufferImage::New(16, 16);
2931 Actor a = CreateRenderableActor( imageA );
2932 Actor b = CreateRenderableActor( imageB );
2933 Actor c = CreateRenderableActor( imageC );
2935 app.SendNotification();
2938 //Textures are bound when first created. Clear bound textures vector
2939 app.GetGlAbstraction().ClearBoundTextures();
2941 // Render a,b,c as regular non-overlays. so order will be:
2945 Stage::GetCurrent().Add(a);
2946 Stage::GetCurrent().Add(b);
2947 Stage::GetCurrent().Add(c);
2949 app.SendNotification();
2952 // Should be 3 textures changes.
2953 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2954 typedef std::vector<GLuint>::size_type TextureSize;
2955 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2956 if( boundTextures.size() == 3 )
2958 DALI_TEST_CHECK( boundTextures[0] == 8u );
2959 DALI_TEST_CHECK( boundTextures[1] == 9u );
2960 DALI_TEST_CHECK( boundTextures[2] == 10u );
2963 // Now texture ids have been set, we can monitor their render order.
2964 // render a as an overlay (last), so order will be:
2968 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
2969 app.GetGlAbstraction().ClearBoundTextures();
2971 app.SendNotification();
2974 // Should be 3 texture changes.
2975 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2976 if( boundTextures.size() == 3 )
2978 DALI_TEST_CHECK( boundTextures[0] == 9u );
2979 DALI_TEST_CHECK( boundTextures[1] == 10u );
2980 DALI_TEST_CHECK( boundTextures[2] == 8u );
2985 int UtcDaliActorGetCurrentWorldMatrix(void)
2987 TestApplication app;
2988 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2990 Actor parent = Actor::New();
2991 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
2992 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
2993 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2994 Radian rotationAngle(Degree(85.0f));
2995 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2996 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2997 parent.SetPosition( parentPosition );
2998 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
2999 parent.SetScale( parentScale );
3000 Stage::GetCurrent().Add( parent );
3002 Actor child = Actor::New();
3003 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3004 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
3005 Radian childRotationAngle(Degree(23.0f));
3006 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
3007 Vector3 childScale( 2.0f, 2.0f, 2.0f );
3008 child.SetPosition( childPosition );
3009 child.SetProperty( Actor::Property::ORIENTATION, childRotation );
3010 child.SetScale( childScale );
3011 parent.Add( child );
3013 app.SendNotification();
3016 app.SendNotification();
3018 Matrix parentMatrix(false);
3019 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3021 Matrix childMatrix(false);
3022 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
3024 //Child matrix should be the composition of child and parent
3025 Matrix childWorldMatrix(false);
3026 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
3028 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3029 DALI_TEST_EQUALS( child.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), childWorldMatrix, 0.001, TEST_LOCATION );
3035 int UtcDaliActorConstrainedToWorldMatrix(void)
3037 TestApplication app;
3038 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3040 Actor parent = Actor::New();
3041 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3042 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3043 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3044 Radian rotationAngle(Degree(85.0f));
3045 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3046 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3047 parent.SetPosition( parentPosition );
3048 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3049 parent.SetScale( parentScale );
3050 Stage::GetCurrent().Add( parent );
3052 Actor child = Actor::New();
3053 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3054 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3055 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3056 posConstraint.Apply();
3058 Stage::GetCurrent().Add( child );
3060 app.SendNotification();
3063 app.SendNotification();
3065 Matrix parentMatrix(false);
3066 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3068 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3069 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), 0.001, TEST_LOCATION );
3073 int UtcDaliActorConstrainedToOrientation(void)
3075 TestApplication app;
3076 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3078 Actor parent = Actor::New();
3079 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3080 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3081 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3082 Radian rotationAngle(Degree(85.0f));
3083 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3084 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3085 parent.SetPosition( parentPosition );
3086 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3087 parent.SetScale( parentScale );
3088 Stage::GetCurrent().Add( parent );
3090 Actor child = Actor::New();
3091 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3092 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3093 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3094 posConstraint.Apply();
3096 Stage::GetCurrent().Add( child );
3098 app.SendNotification();
3101 app.SendNotification();
3103 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION );
3107 int UtcDaliActorConstrainedToOpacity(void)
3109 TestApplication app;
3110 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3112 Actor parent = Actor::New();
3113 parent.SetProperty( DevelActor::Property::OPACITY, 0.7f );
3114 Stage::GetCurrent().Add( parent );
3116 Actor child = Actor::New();
3117 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3118 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3119 opacityConstraint.Apply();
3121 Stage::GetCurrent().Add( child );
3123 app.SendNotification();
3126 app.SendNotification();
3128 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), parent.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3130 parent.SetProperty( DevelActor::Property::OPACITY, 0.3f );
3132 app.SendNotification();
3135 app.SendNotification();
3137 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), parent.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3142 int UtcDaliActorUnparent(void)
3144 TestApplication app;
3145 tet_infoline(" UtcDaliActorUnparent");
3147 Actor parent = Actor::New();
3148 Stage::GetCurrent().Add( parent );
3150 Actor child = Actor::New();
3152 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3153 DALI_TEST_CHECK( !child.GetParent() );
3155 // Test that calling Unparent with no parent is a NOOP
3158 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3159 DALI_TEST_CHECK( !child.GetParent() );
3161 // Test that Unparent works
3162 parent.Add( child );
3164 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3165 DALI_TEST_CHECK( parent == child.GetParent() );
3169 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3170 DALI_TEST_CHECK( !child.GetParent() );
3172 // Test that UnparentAndReset works
3173 parent.Add( child );
3175 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3176 DALI_TEST_CHECK( parent == child.GetParent() );
3178 UnparentAndReset( child );
3180 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3181 DALI_TEST_CHECK( !child );
3183 // Test that UnparentAndReset is a NOOP with empty handle
3184 UnparentAndReset( child );
3186 DALI_TEST_CHECK( !child );
3190 int UtcDaliActorGetChildAt(void)
3192 TestApplication app;
3193 tet_infoline(" UtcDaliActorGetChildAt");
3195 Actor parent = Actor::New();
3196 Stage::GetCurrent().Add( parent );
3198 Actor child0 = Actor::New();
3199 parent.Add( child0 );
3201 Actor child1 = Actor::New();
3202 parent.Add( child1 );
3204 Actor child2 = Actor::New();
3205 parent.Add( child2 );
3207 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3208 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3209 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3213 int UtcDaliActorSetGetOverlay(void)
3215 TestApplication app;
3216 tet_infoline(" UtcDaliActorSetGetOverlay");
3218 Actor parent = Actor::New();
3219 parent.SetProperty( Actor::Property::DRAW_MODE,DrawMode::OVERLAY_2D );
3220 DALI_TEST_CHECK( parent.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) == DrawMode::OVERLAY_2D );
3225 int UtcDaliActorCreateDestroy(void)
3227 Actor* actor = new Actor;
3228 DALI_TEST_CHECK( actor );
3235 struct PropertyStringIndex
3237 const char * const name;
3238 const Property::Index index;
3239 const Property::Type type;
3242 const PropertyStringIndex PROPERTY_TABLE[] =
3244 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3245 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3246 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3247 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3248 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3249 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3250 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3251 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3252 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3253 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3254 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3255 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3256 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3257 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3258 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3259 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3260 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3261 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3262 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3263 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3264 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3265 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3266 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3267 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3268 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3269 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3270 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3271 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3272 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3273 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3274 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3275 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3276 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3277 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3278 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3279 { "name", Actor::Property::NAME, Property::STRING },
3280 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3281 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3282 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3283 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3284 { "colorMode", Actor::Property::COLOR_MODE, Property::INTEGER },
3285 { "drawMode", Actor::Property::DRAW_MODE, Property::INTEGER },
3286 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3287 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3288 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3289 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER },
3290 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3291 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3292 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3293 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3294 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3295 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3296 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3297 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3299 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3300 } // unnamed namespace
3302 int UtcDaliActorProperties(void)
3304 TestApplication app;
3306 Actor actor = Actor::New();
3308 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3310 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3311 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3312 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3313 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3318 int UtcDaliRelayoutProperties_ResizePolicies(void)
3320 TestApplication app;
3322 Actor actor = Actor::New();
3325 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3326 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3328 // Set resize policy for all dimensions
3329 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3330 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3332 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3335 // Set individual dimensions
3336 const char* const widthPolicy = "FILL_TO_PARENT";
3337 const char* const heightPolicy = "FIXED";
3339 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3340 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3342 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3343 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3345 // Set individual dimensions using enums
3346 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3347 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3349 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3350 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3352 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3353 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3358 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3360 TestApplication app;
3362 Actor actor = Actor::New();
3365 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3367 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3368 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy );
3369 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy, TEST_LOCATION );
3372 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3373 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3375 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3376 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy1, TEST_LOCATION );
3378 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3379 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy2, TEST_LOCATION );
3384 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3386 TestApplication app;
3388 Actor actor = Actor::New();
3391 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3392 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3394 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3395 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode );
3396 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), sizeMode, TEST_LOCATION );
3399 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3401 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3402 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3407 int UtcDaliRelayoutProperties_DimensionDependency(void)
3409 TestApplication app;
3411 Actor actor = Actor::New();
3414 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3415 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3418 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3419 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3421 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3422 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3424 // Test setting another resize policy
3425 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3426 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3431 int UtcDaliRelayoutProperties_Padding(void)
3433 TestApplication app;
3435 Actor actor = Actor::New();
3438 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3441 actor.SetProperty( Actor::Property::PADDING, padding );
3442 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3444 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3449 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3451 TestApplication app;
3453 Actor actor = Actor::New();
3456 Vector2 minSize( 1.0f, 2.0f );
3458 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3459 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3461 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3463 Vector2 maxSize( 3.0f, 4.0f );
3465 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3466 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3468 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3473 int UtcDaliActorGetHeightForWidth(void)
3475 TestApplication app;
3477 Actor actor = Actor::New();
3479 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3484 int UtcDaliActorGetWidthForHeight(void)
3486 TestApplication app;
3488 Actor actor = Actor::New();
3490 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3495 int UtcDaliActorGetRelayoutSize(void)
3497 TestApplication app;
3499 Actor actor = Actor::New();
3501 // Add actor to stage
3502 Stage::GetCurrent().Add( actor );
3504 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3506 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3507 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3509 // Flush the queue and render once
3510 app.SendNotification();
3513 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3518 int UtcDaliActorSetPadding(void)
3520 TestApplication app;
3522 Actor actor = Actor::New();
3525 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3527 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3528 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3529 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3530 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3532 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3533 actor.SetProperty( Actor::Property::PADDING, padding2 );
3535 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3537 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3538 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3539 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3540 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3545 int UtcDaliActorSetMinimumSize(void)
3547 TestApplication app;
3549 Actor actor = Actor::New();
3551 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3553 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3554 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3556 Vector2 size2( 1.0f, 2.0f );
3557 actor.SetProperty( Actor::Property::MINIMUM_SIZE, size2 );
3559 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3561 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3562 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3567 int UtcDaliActorSetMaximumSize(void)
3569 TestApplication app;
3571 Actor actor = Actor::New();
3573 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3575 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3576 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3578 Vector2 size2( 1.0f, 2.0f );
3579 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, size2 );
3581 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3583 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3584 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3589 int UtcDaliActorOnRelayoutSignal(void)
3591 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3593 TestApplication application;
3596 gOnRelayoutCallBackCalled = false;
3597 gActorNamesRelayout.clear();
3599 Actor actor = Actor::New();
3600 actor.SetProperty( Actor::Property::NAME, "actor" );
3601 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3604 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3606 // Add actor to stage
3607 Stage::GetCurrent().Add( actor );
3609 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3610 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3612 // Flush the queue and render once
3613 application.SendNotification();
3614 application.Render();
3616 // OnRelayout emitted
3617 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3618 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3623 int UtcDaliActorGetHierachyDepth(void)
3625 TestApplication application;
3626 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3629 /* Build tree of actors:
3639 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3641 Stage stage( Stage::GetCurrent() );
3643 Actor actorA = Actor::New();
3644 Actor actorB = Actor::New();
3645 Actor actorC = Actor::New();
3646 Actor actorD = Actor::New();
3647 Actor actorE = Actor::New();
3648 Actor actorF = Actor::New();
3650 //Test that root actor has depth equal 0
3651 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3653 //Test actors return depth -1 when not connected to the tree
3654 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3655 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3656 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3657 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3658 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3659 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3661 //Create the hierarchy
3662 stage.Add( actorA );
3663 actorA.Add( actorB );
3664 actorA.Add( actorC );
3665 actorB.Add( actorD );
3666 actorB.Add( actorE );
3667 actorC.Add( actorF );
3669 //Test actors return correct depth
3670 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3671 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3672 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3673 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3674 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3675 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3677 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3678 actorA.Remove( actorB );
3680 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3681 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3682 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3684 //Removing actorA from the stage. All actors should have depth equal -1
3685 stage.Remove( actorA );
3687 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3688 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3689 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3690 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3691 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3692 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3697 int UtcDaliActorAnchorPointPropertyAsString(void)
3699 TestApplication application;
3701 Actor actor = Actor::New();
3703 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3704 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3706 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3707 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3709 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3710 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3712 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3713 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3715 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3716 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER, TEST_LOCATION );
3718 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3719 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3721 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3722 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3724 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3725 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3727 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3728 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3730 // Invalid should not change anything
3731 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3732 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3737 int UtcDaliActorParentOriginPropertyAsString(void)
3739 TestApplication application;
3741 Actor actor = Actor::New();
3743 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3744 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3746 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3747 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3749 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3750 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3752 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3753 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3755 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3756 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER, TEST_LOCATION );
3758 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3759 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3761 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3762 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3764 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3765 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3767 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3768 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3770 // Invalid should not change anything
3771 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3772 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3777 int UtcDaliActorColorModePropertyAsString(void)
3779 TestApplication application;
3781 Actor actor = Actor::New();
3783 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3784 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3786 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3787 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3789 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3790 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3792 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3793 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3795 // Invalid should not change anything
3796 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3797 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3802 int UtcDaliActorDrawModePropertyAsString(void)
3804 TestApplication application;
3806 Actor actor = Actor::New();
3808 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3809 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3811 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3812 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3814 // Invalid should not change anything
3815 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3816 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3821 int UtcDaliActorColorModePropertyAsEnum(void)
3823 TestApplication application;
3825 Actor actor = Actor::New();
3827 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3828 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3830 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3831 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3833 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3834 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3836 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3837 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3842 int UtcDaliActorDrawModePropertyAsEnum(void)
3844 TestApplication application;
3846 Actor actor = Actor::New();
3848 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3849 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3851 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3852 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3857 int UtcDaliActorAddRendererP(void)
3859 tet_infoline("Testing Actor::AddRenderer");
3860 TestApplication application;
3862 Actor actor = Actor::New();
3864 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3866 Geometry geometry = CreateQuadGeometry();
3867 Shader shader = CreateShader();
3868 Renderer renderer = Renderer::New(geometry, shader);
3870 actor.AddRenderer( renderer );
3871 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3872 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3877 int UtcDaliActorAddRendererN(void)
3879 tet_infoline("Testing Actor::AddRenderer");
3880 TestApplication application;
3882 Actor actor = Actor::New();
3888 actor.AddRenderer( renderer );
3889 tet_printf("Assertion test failed - no Exception\n" );
3890 tet_result(TET_FAIL);
3892 catch(Dali::DaliException& e)
3894 DALI_TEST_PRINT_ASSERT( e );
3895 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3896 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3900 tet_printf("Assertion test failed - wrong Exception\n" );
3901 tet_result(TET_FAIL);
3907 int UtcDaliActorAddRendererOnStage(void)
3909 tet_infoline("Testing Actor::AddRenderer");
3910 TestApplication application;
3912 Actor actor = Actor::New();
3913 Stage::GetCurrent().Add(actor);
3915 application.SendNotification();
3916 application.Render(0);
3918 Geometry geometry = CreateQuadGeometry();
3919 Shader shader = CreateShader();
3920 Renderer renderer = Renderer::New(geometry, shader);
3922 application.SendNotification();
3923 application.Render(0);
3927 actor.AddRenderer( renderer );
3928 tet_result(TET_PASS);
3932 tet_result(TET_FAIL);
3938 int UtcDaliActorRemoveRendererP1(void)
3940 tet_infoline("Testing Actor::RemoveRenderer");
3941 TestApplication application;
3943 Actor actor = Actor::New();
3945 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3948 Geometry geometry = CreateQuadGeometry();
3949 Shader shader = CreateShader();
3950 Renderer renderer = Renderer::New(geometry, shader);
3952 actor.AddRenderer( renderer );
3953 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3954 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3956 application.SendNotification();
3957 application.Render();
3961 Renderer renderer = actor.GetRendererAt(0);
3962 actor.RemoveRenderer(renderer);
3963 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3965 application.SendNotification();
3966 application.Render();
3969 // Call one final time to ensure that the renderer is actually removed after
3970 // the handle goes out of scope, and excercises the deletion code path in
3971 // scene graph and render.
3972 application.SendNotification();
3973 application.Render();
3978 int UtcDaliActorRemoveRendererP2(void)
3980 tet_infoline("Testing Actor::RemoveRenderer");
3981 TestApplication application;
3983 Actor actor = Actor::New();
3985 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3987 Geometry geometry = CreateQuadGeometry();
3988 Shader shader = CreateShader();
3989 Renderer renderer = Renderer::New(geometry, shader);
3991 actor.AddRenderer( renderer );
3992 application.SendNotification();
3993 application.Render();
3995 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3996 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3998 actor.RemoveRenderer(0);
3999 application.SendNotification();
4000 application.Render();
4002 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4004 // Shut down whilst holding onto the renderer handle.
4009 int UtcDaliActorRemoveRendererN(void)
4011 tet_infoline("Testing Actor::RemoveRenderer");
4012 TestApplication application;
4014 Actor actor = Actor::New();
4016 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4018 Geometry geometry = CreateQuadGeometry();
4019 Shader shader = CreateShader();
4020 Renderer renderer = Renderer::New(geometry, shader);
4022 actor.AddRenderer( renderer );
4023 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4024 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4026 actor.RemoveRenderer(10);
4027 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4028 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4033 // Clipping test helper functions:
4034 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4036 BufferImage image = BufferImage::New( width, height );
4037 Actor actor = CreateRenderableActor( image );
4039 // Setup dimensions and position so actor is not skipped by culling.
4040 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4041 actor.SetSize( width, height );
4042 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4043 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4048 Actor CreateActorWithContent16x16()
4050 return CreateActorWithContent( 16, 16 );
4053 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4055 enabledDisableTrace.Reset();
4056 stencilTrace.Reset();
4057 enabledDisableTrace.Enable( true );
4058 stencilTrace.Enable( true );
4060 application.SendNotification();
4061 application.Render();
4063 enabledDisableTrace.Enable( false );
4064 stencilTrace.Enable( false );
4067 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4069 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4071 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4072 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4073 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4074 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4077 int UtcDaliActorPropertyClippingP(void)
4079 // This test checks the clippingMode property.
4080 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4081 TestApplication application;
4083 Actor actor = Actor::New();
4085 // Check default clippingEnabled value.
4086 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4089 bool getValueResult = getValue.Get( value );
4090 DALI_TEST_CHECK( getValueResult );
4092 if( getValueResult )
4094 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4097 // Check setting the property to the stencil mode.
4098 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4100 // Check the new value was set.
4101 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4102 getValueResult = getValue.Get( value );
4103 DALI_TEST_CHECK( getValueResult );
4105 if( getValueResult )
4107 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4110 // Check setting the property to the scissor mode.
4111 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4113 // Check the new value was set.
4114 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4115 getValueResult = getValue.Get( value );
4116 DALI_TEST_CHECK( getValueResult );
4118 if( getValueResult )
4120 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4125 int UtcDaliActorPropertyClippingN(void)
4127 // Negative test case for Clipping.
4128 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4129 TestApplication application;
4131 Actor actor = Actor::New();
4133 // Check default clippingEnabled value.
4134 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4137 bool getValueResult = getValue.Get( value );
4138 DALI_TEST_CHECK( getValueResult );
4140 if( getValueResult )
4142 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4145 // Check setting an invalid property value won't change the current property value.
4146 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4148 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4149 getValueResult = getValue.Get( value );
4150 DALI_TEST_CHECK( getValueResult );
4152 if( getValueResult )
4154 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4160 int UtcDaliActorPropertyClippingActor(void)
4162 // This test checks that an actor is correctly setup for clipping.
4163 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4164 TestApplication application;
4166 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4167 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4168 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4169 size_t startIndex = 0u;
4171 // Create a clipping actor.
4172 Actor actorDepth1Clip = CreateActorWithContent16x16();
4173 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4174 Stage::GetCurrent().Add( actorDepth1Clip );
4176 // Gather the call trace.
4177 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4179 // Check we are writing to the color buffer.
4180 CheckColorMask( glAbstraction, true );
4182 // Check the stencil buffer was enabled.
4183 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4185 // Check the stencil buffer was cleared.
4186 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4188 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4189 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4190 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4191 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4196 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4198 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4199 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4200 TestApplication application;
4202 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4203 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4204 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4205 size_t startIndex = 0u;
4207 // Create a clipping actor.
4208 Actor actorDepth1Clip = CreateActorWithContent16x16();
4209 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4210 Stage::GetCurrent().Add( actorDepth1Clip );
4212 // Gather the call trace.
4213 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4215 // Check we are writing to the color buffer.
4216 CheckColorMask( glAbstraction, true );
4218 // Check the stencil buffer was enabled.
4219 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4221 // Check the stencil buffer was cleared.
4222 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4224 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4225 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4226 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4227 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4229 // Now disable the clipping
4230 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4232 // Gather the call trace.
4233 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4235 // Check the stencil buffer was disabled.
4236 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4238 // Ensure all values in stencil-mask are set to 1.
4240 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4245 int UtcDaliActorPropertyClippingNestedChildren(void)
4247 // This test checks that a hierarchy of actors are clipped correctly by
4248 // writing to and reading from the correct bit-planes of the stencil buffer.
4249 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4250 TestApplication application;
4251 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4252 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4253 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4255 // Create a clipping actor.
4256 Actor actorDepth1Clip = CreateActorWithContent16x16();
4257 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4258 Stage::GetCurrent().Add( actorDepth1Clip );
4260 // Create a child actor.
4261 Actor childDepth2 = CreateActorWithContent16x16();
4262 actorDepth1Clip.Add( childDepth2 );
4264 // Create another clipping actor.
4265 Actor childDepth2Clip = CreateActorWithContent16x16();
4266 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4267 childDepth2.Add( childDepth2Clip );
4269 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4270 // This tests the sort algorithm.
4271 Actor childDepth3 = CreateActorWithContent16x16();
4272 childDepth2Clip.Add( childDepth3 );
4273 Actor childDepth4 = CreateActorWithContent16x16();
4274 childDepth3.Add( childDepth4 );
4276 // Gather the call trace.
4277 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4279 // Check we are writing to the color buffer.
4280 CheckColorMask( glAbstraction, true );
4282 // Check the stencil buffer was enabled.
4283 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4285 // Perform the test twice, once for 2D layer, and once for 3D.
4286 for( unsigned int i = 0u ; i < 2u; ++i )
4288 size_t startIndex = 0u;
4290 // Check the stencil buffer was cleared.
4291 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4293 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4294 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4295 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4296 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4298 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4299 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4300 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4302 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4303 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4304 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4305 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4307 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4308 // (Both must be set to pass the check).
4309 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4310 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4312 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4315 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4316 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4323 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4325 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4326 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4327 TestApplication application;
4328 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4329 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4331 /* We create a small tree of actors as follows:
4335 Clipping enabled -> B D
4339 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4342 for( int i = 0; i < 5; ++i )
4344 BufferImage image = BufferImage::New( 16u, 16u );
4345 Actor actor = CreateRenderableActor( image );
4347 // Setup dimensions and position so actor is not skipped by culling.
4348 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4349 actor.SetSize( 16.0f, 16.0f );
4353 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4357 float b = i > 2 ? 1.0f : -1.0f;
4358 actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4364 // Enable clipping on the actor at the top of the left branch.
4365 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4367 // Build the scene graph.
4368 Stage::GetCurrent().Add( actors[0] );
4371 actors[0].Add( actors[1] );
4372 actors[1].Add( actors[2] );
4375 actors[0].Add( actors[3] );
4376 actors[3].Add( actors[4] );
4378 // Gather the call trace.
4379 enabledDisableTrace.Reset();
4380 enabledDisableTrace.Enable( true );
4381 application.SendNotification();
4382 application.Render();
4383 enabledDisableTrace.Enable( false );
4385 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4387 Note: Correct enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
4388 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4390 size_t startIndex = 0u;
4391 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4392 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4393 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4395 // Swap the clipping actor from top of left branch to top of right branch.
4396 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4397 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4399 // Gather the call trace.
4400 enabledDisableTrace.Reset();
4401 enabledDisableTrace.Enable( true );
4402 application.SendNotification();
4403 application.Render();
4404 enabledDisableTrace.Enable( false );
4406 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4407 // This proves the draw order has remained the same.
4409 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4410 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4415 int UtcDaliActorPropertyScissorClippingActor(void)
4417 // This test checks that an actor is correctly setup for clipping.
4418 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4419 TestApplication application;
4421 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4422 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4423 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4425 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4426 const Vector2 imageSize( 16.0f, 16.0f );
4428 // Create a clipping actor.
4429 Actor clippingActorA = CreateActorWithContent16x16();
4430 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4431 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4432 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
4433 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
4434 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4435 Stage::GetCurrent().Add( clippingActorA );
4437 // Gather the call trace.
4438 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4440 // Check we are writing to the color buffer.
4441 CheckColorMask( glAbstraction, true );
4443 // Check scissor test was enabled.
4444 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4446 // Check the scissor was set, and the coordinates are correct.
4447 std::stringstream compareParametersString;
4448 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4449 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4451 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
4452 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT );
4454 // Gather the call trace.
4455 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4457 // Check the scissor was set, and the coordinates are correct.
4458 compareParametersString.str( std::string() );
4459 compareParametersString.clear();
4460 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4461 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4466 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4468 // This test checks that an actor is correctly setup for clipping.
4469 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4470 TestApplication application;
4473 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4474 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4475 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4477 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4478 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4479 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4481 // Create a clipping actors.
4482 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4483 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4485 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4486 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4487 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4489 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4490 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4491 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4493 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4494 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4496 Stage::GetCurrent().Add( clippingActorA );
4497 Stage::GetCurrent().Add( clippingActorB );
4499 // Gather the call trace.
4500 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4502 // Check we are writing to the color buffer.
4503 CheckColorMask( glAbstraction, true );
4505 // Check scissor test was enabled.
4506 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4508 // Check the scissor was set, and the coordinates are correct.
4509 std::stringstream compareParametersString;
4511 std::string clipA( "0, 500, 480, 200" );
4512 std::string clipB( "0, 380, 480, 40" );
4514 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4515 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4520 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4522 // This test checks that an actor is correctly setup for clipping.
4523 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4524 TestApplication application;
4526 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4527 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4528 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4530 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4531 const Vector2 imageSize( 16.0f, 16.0f );
4533 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4535 A is drawn first - with scissor clipping on
4536 B is drawn second - also with scissor clipping on
4537 C is the generated clipping region, the intersection ( A ∩ B )
4541 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4542 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4543 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4547 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4550 // Create a clipping actor.
4551 Actor clippingActorA = CreateActorWithContent16x16();
4552 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4553 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4554 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4555 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4556 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4557 Stage::GetCurrent().Add( clippingActorA );
4559 // Create a child clipping actor.
4560 Actor clippingActorB = CreateActorWithContent16x16();
4561 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4562 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4563 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4564 clippingActorA.Add( clippingActorB );
4566 // positionModifiers is an array of positions to position B around.
4567 // expect is an array of expected scissor clip coordinate results.
4568 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4569 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4571 // Loop through each overlap combination.
4572 for( unsigned int test = 0u; test < 4u; ++test )
4574 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4575 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4576 clippingActorB.SetPosition( position.x, position.y );
4578 // Gather the call trace.
4579 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4581 // Check we are writing to the color buffer.
4582 CheckColorMask( glAbstraction, true );
4584 // Check scissor test was enabled.
4585 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4587 // Check the scissor was set, and the coordinates are correct.
4588 const Vector4& expectResults( expect[test] );
4589 std::stringstream compareParametersString;
4590 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4591 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4597 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4599 // This test checks that an actor is correctly setup for clipping.
4600 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4601 TestApplication application;
4603 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4604 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4605 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4607 /* Create a nest of 2 scissors and siblings of the parent.
4617 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4618 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4619 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4620 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4621 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4622 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4624 // Create a clipping actors.
4625 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4626 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4627 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4628 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4629 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4631 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4632 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4633 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4635 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4636 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4637 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4639 clippingActorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4640 clippingActorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4641 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4643 clippingActorD.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4644 clippingActorD.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4645 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4647 clippingActorE.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4648 clippingActorE.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4650 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4651 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4652 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4653 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4654 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4656 Stage::GetCurrent().Add( clippingActorA );
4657 clippingActorA.Add( clippingActorB );
4658 Stage::GetCurrent().Add( clippingActorC );
4659 Stage::GetCurrent().Add( clippingActorD );
4660 clippingActorD.Add( clippingActorE );
4662 // Gather the call trace.
4663 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4665 // Check we are writing to the color buffer.
4666 CheckColorMask( glAbstraction, true );
4668 // Check scissor test was enabled.
4669 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4671 // Check the scissor was set, and the coordinates are correct.
4672 std::string clipA( "0, 500, 480, 200" );
4673 std::string clipB( "0, 580, 480, 40" );
4674 std::string clipC( "0, 200, 480, 200" );
4675 std::string clipD( "0, 300, 480, 200" );
4677 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4678 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4679 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4680 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4681 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4686 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4688 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4689 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4690 TestApplication application;
4692 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4693 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4694 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4696 // Create a clipping actor.
4697 Actor actorDepth1Clip = CreateActorWithContent16x16();
4698 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4699 Stage::GetCurrent().Add( actorDepth1Clip );
4701 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4702 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4704 // Gather the call trace.
4705 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4707 // Check we are writing to the color buffer.
4708 CheckColorMask( glAbstraction, true );
4710 // Check the stencil buffer was not enabled.
4711 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4713 // Check stencil functions are not called.
4714 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4715 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4716 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4718 // Check that scissor clipping is overriden by the renderer properties.
4719 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4721 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4723 // Gather the call trace.
4724 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4726 // Check the stencil buffer was not enabled.
4727 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4729 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4734 int UtcDaliGetPropertyN(void)
4736 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4737 TestApplication app;
4739 Actor actor = Actor::New();
4741 unsigned int propertyCount = actor.GetPropertyCount();
4742 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4746 int UtcDaliActorRaiseLower(void)
4748 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4750 TestApplication application;
4752 Debug::Filter::SetGlobalLogLevel( Debug::Verbose );
4754 Stage stage( Stage::GetCurrent() );
4756 Actor actorA = Actor::New();
4757 Actor actorB = Actor::New();
4758 Actor actorC = Actor::New();
4760 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4761 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4763 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4764 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4766 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4767 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4769 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4770 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4772 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4773 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4775 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4776 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4778 stage.Add( actorA );
4779 stage.Add( actorB );
4780 stage.Add( actorC );
4782 ResetTouchCallbacks();
4784 application.SendNotification();
4785 application.Render();
4787 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4788 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4789 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4791 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4792 // Only top actor will get touched.
4793 actorA.TouchSignal().Connect( TestTouchCallback );
4794 actorB.TouchSignal().Connect( TestTouchCallback2 );
4795 actorC.TouchSignal().Connect( TestTouchCallback3 );
4797 // Connect ChildOrderChangedSignal
4798 bool orderChangedSignal( false );
4799 Actor orderChangedActor;
4800 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4801 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4803 Dali::Integration::Point point;
4804 point.SetDeviceId( 1 );
4805 point.SetState( PointState::DOWN );
4806 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4807 Dali::Integration::TouchEvent touchEvent;
4808 touchEvent.AddPoint( point );
4810 application.ProcessEvent( touchEvent );
4812 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4813 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4814 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4816 ResetTouchCallbacks();
4818 tet_printf( "Testing Raising of Actor\n" );
4820 int preActorOrder( 0 );
4821 int postActorOrder( 0 );
4823 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4824 value.Get( preActorOrder );
4826 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4828 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4829 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4831 // Ensure sort order is calculated before next touch event
4832 application.SendNotification();
4834 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4835 value.Get( postActorOrder );
4837 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4839 application.ProcessEvent( touchEvent );
4841 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4842 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4843 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4845 ResetTouchCallbacks();
4847 tet_printf( "Testing Lowering of Actor\n" );
4849 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4850 value.Get( preActorOrder );
4852 orderChangedSignal = false;
4854 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4856 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4857 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4859 application.SendNotification(); // ensure sort order calculated before next touch event
4861 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4862 value.Get( postActorOrder );
4864 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4866 application.ProcessEvent( touchEvent );
4868 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4869 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4870 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4872 ResetTouchCallbacks();
4874 Debug::Filter::SetGlobalLogLevel( Debug::NoLogging );
4879 int UtcDaliActorRaiseToTopLowerToBottom(void)
4881 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4883 TestApplication application;
4885 Stage stage( Stage::GetCurrent() );
4887 Actor actorA = Actor::New();
4888 Actor actorB = Actor::New();
4889 Actor actorC = Actor::New();
4891 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4892 // enables checking of which actor the uniform is assigned too
4893 Shader shaderA = CreateShader();
4894 shaderA.RegisterProperty( "uRendererColor",1.f);
4896 Shader shaderB = CreateShader();
4897 shaderB.RegisterProperty( "uRendererColor", 2.f );
4899 Shader shaderC = CreateShader();
4900 shaderC.RegisterProperty( "uRendererColor", 3.f );
4902 Geometry geometry = CreateQuadGeometry();
4904 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4905 Renderer rendererA = Renderer::New(geometry, shaderA);
4906 actorA.AddRenderer(rendererA);
4908 Renderer rendererB = Renderer::New(geometry, shaderB);
4909 actorB.AddRenderer(rendererB);
4911 Renderer rendererC = Renderer::New(geometry, shaderC);
4912 actorC.AddRenderer(rendererC);
4914 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4915 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4917 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4918 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4920 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4921 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4923 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4924 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4926 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4927 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4929 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4930 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4932 stage.Add( actorA );
4933 stage.Add( actorB );
4934 stage.Add( actorC );
4936 ResetTouchCallbacks();
4938 // Connect ChildOrderChangedSignal
4939 bool orderChangedSignal( false );
4940 Actor orderChangedActor;
4941 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4942 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4944 // Set up gl abstraction trace so can query the set uniform order
4945 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4946 glAbstraction.EnableSetUniformCallTrace(true);
4947 glAbstraction.ResetSetUniformCallStack();
4949 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4951 application.SendNotification();
4952 application.Render();
4954 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4957 // Test order of uniforms in stack
4958 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4959 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4960 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4962 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4964 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4966 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4967 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4968 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4970 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4971 // Only top actor will get touched.
4972 actorA.TouchSignal().Connect( TestTouchCallback );
4973 actorB.TouchSignal().Connect( TestTouchCallback2 );
4974 actorC.TouchSignal().Connect( TestTouchCallback3 );
4976 Dali::Integration::Point point;
4977 point.SetDeviceId( 1 );
4978 point.SetState( PointState::DOWN );
4979 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4980 Dali::Integration::TouchEvent touchEvent;
4981 touchEvent.AddPoint( point );
4983 application.ProcessEvent( touchEvent );
4985 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4986 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4987 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4989 ResetTouchCallbacks();
4991 tet_printf( "RaiseToTop ActorA\n" );
4993 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4994 actorA.RaiseToTop();
4995 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4996 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
4998 application.SendNotification(); // ensure sorting order is calculated before next touch event
5000 application.ProcessEvent( touchEvent );
5002 glAbstraction.ResetSetUniformCallStack();
5003 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5005 application.SendNotification();
5006 application.Render();
5008 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5010 // Test order of uniforms in stack
5011 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5012 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5013 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5015 tet_infoline( "Testing A above C and B at bottom\n" );
5016 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5018 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5020 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5021 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5022 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5024 ResetTouchCallbacks();
5026 tet_printf( "RaiseToTop ActorB\n" );
5028 orderChangedSignal = false;
5030 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5031 actorB.RaiseToTop();
5032 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5033 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5035 application.SendNotification(); // Ensure sort order is calculated before next touch event
5037 application.ProcessEvent( touchEvent );
5039 glAbstraction.ResetSetUniformCallStack();
5040 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5042 application.SendNotification();
5043 application.Render();
5045 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5047 // Test order of uniforms in stack
5048 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5049 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5050 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5052 tet_infoline( "Testing B above A and C at bottom\n" );
5053 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5055 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5057 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5058 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5059 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5061 ResetTouchCallbacks();
5063 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5065 orderChangedSignal = false;
5067 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5068 actorA.LowerToBottom();
5069 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5070 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5072 application.SendNotification();
5073 application.Render();
5075 orderChangedSignal = false;
5077 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5078 actorB.LowerToBottom();
5079 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5080 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5082 application.SendNotification();
5083 application.Render();
5085 application.ProcessEvent( touchEvent );
5087 glAbstraction.ResetSetUniformCallStack();
5088 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5090 application.SendNotification();
5091 application.Render();
5093 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5095 // Test order of uniforms in stack
5096 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5097 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5098 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5100 tet_infoline( "Testing C above A and B at bottom\n" );
5101 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5103 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5105 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5106 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5107 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5109 ResetTouchCallbacks();
5114 int UtcDaliActorRaiseAbove(void)
5116 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5118 TestApplication application;
5120 Stage stage( Stage::GetCurrent() );
5122 Actor actorA = Actor::New();
5123 Actor actorB = Actor::New();
5124 Actor actorC = Actor::New();
5126 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5127 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5129 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5130 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5132 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5133 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5135 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5136 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5138 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5139 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5141 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5142 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5144 stage.Add( actorA );
5145 stage.Add( actorB );
5146 stage.Add( actorC );
5148 ResetTouchCallbacks();
5150 application.SendNotification();
5151 application.Render();
5153 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5154 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5155 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5157 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5158 // Only top actor will get touched.
5159 actorA.TouchSignal().Connect( TestTouchCallback );
5160 actorB.TouchSignal().Connect( TestTouchCallback2 );
5161 actorC.TouchSignal().Connect( TestTouchCallback3 );
5163 bool orderChangedSignal( false );
5164 Actor orderChangedActor;
5165 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5166 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5168 Dali::Integration::Point point;
5169 point.SetDeviceId( 1 );
5170 point.SetState( PointState::DOWN );
5171 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5172 Dali::Integration::TouchEvent touchEvent;
5173 touchEvent.AddPoint( point );
5175 application.ProcessEvent( touchEvent );
5177 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5178 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5179 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5181 ResetTouchCallbacks();
5183 tet_printf( "Raise actor B Above Actor C\n" );
5185 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5186 actorB.RaiseAbove( actorC );
5187 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5188 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5190 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5191 application.SendNotification();
5192 application.ProcessEvent( touchEvent );
5194 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5195 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5196 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5198 ResetTouchCallbacks();
5200 tet_printf( "Raise actor A Above Actor B\n" );
5202 orderChangedSignal = false;
5204 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5205 actorA.RaiseAbove( actorB );
5206 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5207 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5209 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5210 application.SendNotification();
5212 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5214 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5215 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5216 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5218 ResetTouchCallbacks();
5223 int UtcDaliActorLowerBelow(void)
5225 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5227 TestApplication application;
5229 Stage stage( Stage::GetCurrent() );
5231 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5232 // enables checking of which actor the uniform is assigned too
5233 Shader shaderA = CreateShader();
5234 shaderA.RegisterProperty( "uRendererColor",1.f);
5236 Shader shaderB = CreateShader();
5237 shaderB.RegisterProperty( "uRendererColor", 2.f );
5239 Shader shaderC = CreateShader();
5240 shaderC.RegisterProperty( "uRendererColor", 3.f );
5242 Actor actorA = Actor::New();
5243 Actor actorB = Actor::New();
5244 Actor actorC = Actor::New();
5246 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5247 Geometry geometry = CreateQuadGeometry();
5249 Renderer rendererA = Renderer::New(geometry, shaderA);
5250 actorA.AddRenderer(rendererA);
5252 Renderer rendererB = Renderer::New(geometry, shaderB);
5253 actorB.AddRenderer(rendererB);
5255 Renderer rendererC = Renderer::New(geometry, shaderC);
5256 actorC.AddRenderer(rendererC);
5258 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5259 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5261 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5262 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5264 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5265 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5267 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5268 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5270 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5271 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5273 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5274 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5276 Actor container = Actor::New();
5277 container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5278 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5279 stage.Add( container );
5281 container.Add( actorA );
5282 container.Add( actorB );
5283 container.Add( actorC );
5285 ResetTouchCallbacks();
5287 // Connect ChildOrderChangedSignal
5288 bool orderChangedSignal( false );
5289 Actor orderChangedActor;
5290 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5291 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5293 // Set up gl abstraction trace so can query the set uniform order
5294 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5295 glAbstraction.EnableSetUniformCallTrace(true);
5296 glAbstraction.ResetSetUniformCallStack();
5297 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5299 glAbstraction.ResetSetUniformCallStack();
5301 application.SendNotification();
5302 application.Render();
5304 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5306 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5308 // Test order of uniforms in stack
5309 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5310 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5311 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5313 tet_infoline( "Testing C above B and A at bottom\n" );
5314 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5316 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5318 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5319 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5320 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5322 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5323 // Only top actor will get touched.
5324 actorA.TouchSignal().Connect( TestTouchCallback );
5325 actorB.TouchSignal().Connect( TestTouchCallback2 );
5326 actorC.TouchSignal().Connect( TestTouchCallback3 );
5328 Dali::Integration::Point point;
5329 point.SetDeviceId( 1 );
5330 point.SetState( PointState::DOWN );
5331 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5332 Dali::Integration::TouchEvent touchEvent;
5333 touchEvent.AddPoint( point );
5335 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5337 application.ProcessEvent( touchEvent );
5339 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5340 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5341 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5343 ResetTouchCallbacks();
5345 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" );
5347 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5348 actorC.LowerBelow( actorB );
5349 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5350 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5352 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5353 application.SendNotification();
5354 application.Render();
5356 application.ProcessEvent( touchEvent ); // touch event
5358 glAbstraction.ResetSetUniformCallStack();
5359 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5361 application.SendNotification();
5362 application.Render();
5364 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5366 // Test order of uniforms in stack
5367 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5368 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5369 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5371 tet_infoline( "Testing render order is A, C, B" );
5372 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5373 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5375 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5376 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5377 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5379 ResetTouchCallbacks();
5381 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5383 orderChangedSignal = false;
5385 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5386 actorC.LowerBelow( actorA );
5387 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5388 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5390 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5391 application.SendNotification();
5392 application.Render();
5394 application.ProcessEvent( touchEvent );
5396 glAbstraction.ResetSetUniformCallStack();
5397 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5399 application.Render();
5400 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5402 // Test order of uniforms in stack
5403 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5404 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5405 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5407 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5408 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5410 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5411 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5412 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5414 ResetTouchCallbacks();
5416 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5418 orderChangedSignal = false;
5420 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5421 actorB.LowerBelow( actorC );
5422 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5423 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5425 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5426 application.SendNotification();
5427 application.Render();
5429 application.ProcessEvent( touchEvent );
5431 glAbstraction.ResetSetUniformCallStack();
5432 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5434 application.Render();
5435 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5437 // Test order of uniforms in stack
5438 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5439 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5440 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5442 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5443 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5449 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5451 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5453 TestApplication application;
5455 Stage stage( Stage::GetCurrent() );
5457 Actor parentA = Actor::New();
5458 Actor parentB = Actor::New();
5459 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5460 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5461 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5462 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5464 parentA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5465 parentA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5467 parentB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5468 parentB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5470 stage.Add( parentA );
5471 stage.Add( parentB );
5473 Actor actorA = Actor::New();
5474 Actor actorB = Actor::New();
5475 Actor actorC = Actor::New();
5477 parentA.Add( actorA );
5478 parentA.Add( actorB );
5480 tet_printf( "Actor C added to different parent from A and B \n" );
5481 parentB.Add( actorC );
5483 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5484 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5486 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5487 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5489 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5490 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5492 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5493 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5495 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5496 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5498 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5499 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5501 ResetTouchCallbacks();
5503 // Connect ChildOrderChangedSignal
5504 bool orderChangedSignal( false );
5505 Actor orderChangedActor;
5506 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5507 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5509 application.SendNotification();
5510 application.Render();
5512 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5513 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5514 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5516 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5517 // Only top actor will get touched.
5518 actorA.TouchSignal().Connect( TestTouchCallback );
5519 actorB.TouchSignal().Connect( TestTouchCallback2 );
5520 actorC.TouchSignal().Connect( TestTouchCallback3 );
5522 Dali::Integration::Point point;
5523 point.SetDeviceId( 1 );
5524 point.SetState( PointState::DOWN );
5525 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5526 Dali::Integration::TouchEvent touchEvent;
5527 touchEvent.AddPoint( point );
5529 application.ProcessEvent( touchEvent );
5531 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5532 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5533 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5535 ResetTouchCallbacks();
5537 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5539 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5540 actorA.RaiseAbove( actorC );
5541 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5543 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5544 application.SendNotification();
5546 application.ProcessEvent( touchEvent ); // touch event
5548 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5549 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5550 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5552 ResetTouchCallbacks();
5557 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5559 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5561 TestApplication application;
5563 Stage stage( Stage::GetCurrent() );
5565 Actor actorA = Actor::New();
5566 Actor actorB = Actor::New();
5567 Actor actorC = Actor::New();
5569 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5570 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5572 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5573 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5575 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5576 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5578 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5579 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5581 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5582 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5584 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5585 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5587 ResetTouchCallbacks();
5589 // Connect ChildOrderChangedSignal
5590 bool orderChangedSignal( false );
5591 Actor orderChangedActor;
5592 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5593 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5595 application.SendNotification();
5596 application.Render();
5598 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5599 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5600 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5602 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5603 // Only top actor will get touched.
5604 actorA.TouchSignal().Connect( TestTouchCallback );
5605 actorB.TouchSignal().Connect( TestTouchCallback2 );
5606 actorC.TouchSignal().Connect( TestTouchCallback3 );
5608 Dali::Integration::Point point;
5609 point.SetDeviceId( 1 );
5610 point.SetState( PointState::DOWN );
5611 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5612 Dali::Integration::TouchEvent touchEvent;
5613 touchEvent.AddPoint( point );
5615 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5617 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5618 actorA.RaiseAbove( actorC );
5619 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5621 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5622 application.SendNotification();
5624 application.ProcessEvent( touchEvent );
5626 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5628 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5629 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5630 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5632 ResetTouchCallbacks();
5634 orderChangedSignal = false;
5636 stage.Add ( actorB );
5637 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5639 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5640 actorA.LowerBelow( actorC );
5641 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5643 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5644 application.SendNotification();
5645 application.Render();
5647 application.ProcessEvent( touchEvent );
5649 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5650 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5651 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5652 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5654 ResetTouchCallbacks();
5656 orderChangedSignal = false;
5658 tet_printf( "Adding Actor A to stage, will be on top\n" );
5660 stage.Add ( actorA );
5661 application.SendNotification();
5662 application.Render();
5664 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5666 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5667 actorB.RaiseAbove( actorC );
5668 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5670 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5671 application.SendNotification();
5673 application.ProcessEvent( touchEvent );
5675 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5676 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5677 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5678 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5680 ResetTouchCallbacks();
5682 orderChangedSignal = false;
5684 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5686 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5687 actorA.LowerBelow( actorC );
5688 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5690 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5691 application.SendNotification();
5693 application.ProcessEvent( touchEvent );
5695 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5696 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5697 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5698 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5700 ResetTouchCallbacks();
5702 orderChangedSignal = false;
5704 stage.Add ( actorC );
5706 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5707 actorA.RaiseAbove( actorC );
5708 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5709 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5711 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5712 application.SendNotification();
5713 application.Render();
5715 application.ProcessEvent( touchEvent );
5717 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5718 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5719 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5720 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5725 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5727 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5729 TestApplication application;
5731 Stage stage( Stage::GetCurrent() );
5733 Actor actorA = Actor::New();
5734 Actor actorB = Actor::New();
5735 Actor actorC = Actor::New();
5737 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5738 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5740 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5741 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5743 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5744 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5746 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5747 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5749 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5750 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5752 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5753 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5755 ResetTouchCallbacks();
5757 // Connect ChildOrderChangedSignal
5758 bool orderChangedSignal( false );
5759 Actor orderChangedActor;
5760 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5761 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5763 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5764 // Only top actor will get touched.
5765 actorA.TouchSignal().Connect( TestTouchCallback );
5766 actorB.TouchSignal().Connect( TestTouchCallback2 );
5767 actorC.TouchSignal().Connect( TestTouchCallback3 );
5769 Dali::Integration::Point point;
5770 point.SetDeviceId( 1 );
5771 point.SetState( PointState::DOWN );
5772 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5773 Dali::Integration::TouchEvent touchEvent;
5774 touchEvent.AddPoint( point );
5776 stage.Add ( actorA );
5777 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5779 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5781 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5783 application.SendNotification();
5784 application.Render();
5786 application.ProcessEvent( touchEvent );
5788 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5790 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5791 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5792 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5794 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5795 ResetTouchCallbacks();
5797 orderChangedSignal = false;
5799 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5801 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5803 // Sort actor tree before next touch event
5804 application.SendNotification();
5805 application.Render();
5807 application.ProcessEvent( touchEvent );
5809 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5811 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5812 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5813 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5814 ResetTouchCallbacks();
5816 orderChangedSignal = false;
5818 tet_printf( "Lower actor C below B but C not parented\n" );
5820 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5822 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5824 // Sort actor tree before next touch event
5825 application.SendNotification();
5826 application.Render();
5828 application.ProcessEvent( touchEvent );
5830 tet_printf( "Not parented so Lower should show no effect\n" );
5832 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5833 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5834 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5835 ResetTouchCallbacks();
5837 orderChangedSignal = false;
5839 tet_printf( "Raise actor B to top\n" );
5841 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5842 actorB.RaiseToTop();
5843 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5845 // Sort actor tree before next touch event
5846 application.SendNotification();
5847 application.Render();
5849 application.ProcessEvent( touchEvent );
5851 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5853 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5854 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5855 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5856 ResetTouchCallbacks();
5858 orderChangedSignal = false;
5860 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5862 stage.Add ( actorB );
5864 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5866 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5867 actorC.LowerToBottom();
5868 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5870 application.SendNotification();
5871 application.Render();
5873 application.ProcessEvent( touchEvent );
5875 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5877 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5878 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5879 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5880 ResetTouchCallbacks();
5886 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5888 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5890 TestApplication application;
5892 Stage stage( Stage::GetCurrent() );
5894 Actor actorA = Actor::New();
5895 Actor actorB = Actor::New();
5896 Actor actorC = Actor::New();
5898 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5899 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5901 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5902 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5904 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5905 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5907 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5908 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5910 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5911 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5913 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5914 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5916 stage.Add( actorA );
5917 stage.Add( actorB );
5918 stage.Add( actorC );
5920 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5921 // Only top actor will get touched.
5922 actorA.TouchSignal().Connect( TestTouchCallback );
5923 actorB.TouchSignal().Connect( TestTouchCallback2 );
5924 actorC.TouchSignal().Connect( TestTouchCallback3 );
5926 ResetTouchCallbacks();
5928 // Connect ChildOrderChangedSignal
5929 bool orderChangedSignal( false );
5930 Actor orderChangedActor;
5931 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5932 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5934 application.SendNotification();
5935 application.Render();
5937 Dali::Integration::Point point;
5938 point.SetDeviceId( 1 );
5939 point.SetState( PointState::DOWN );
5940 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5941 Dali::Integration::TouchEvent touchEvent;
5942 touchEvent.AddPoint( point );
5944 application.ProcessEvent( touchEvent );
5946 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5947 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5948 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5950 ResetTouchCallbacks();
5952 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5954 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5955 actorA.RaiseAbove( actorA );
5956 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5957 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5959 application.SendNotification();
5960 application.Render();
5962 application.ProcessEvent( touchEvent );
5964 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5966 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5967 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5968 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5970 ResetTouchCallbacks();
5972 orderChangedSignal = false;
5974 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5975 actorA.RaiseAbove( actorC );
5976 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5977 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5979 application.SendNotification();
5980 application.Render();
5982 application.ProcessEvent( touchEvent );
5984 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5985 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5986 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5987 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5992 int UtcDaliActorGetScreenPosition(void)
5994 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5996 TestApplication application;
5998 Stage stage( Stage::GetCurrent() );
6000 Actor actorA = Actor::New();
6001 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6003 Vector2 size2( 10.0f, 20.0f );
6004 actorA.SetSize( size2 );
6006 actorA.SetPosition( 0.f, 0.f );
6008 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6010 stage.Add( actorA );
6012 application.SendNotification();
6013 application.Render();
6015 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6016 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6018 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6019 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6021 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6022 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6024 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6026 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6028 application.SendNotification();
6029 application.Render();
6031 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6032 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6034 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6035 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6037 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6038 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6040 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6042 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6044 application.SendNotification();
6045 application.Render();
6047 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6048 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6050 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6051 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6053 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6054 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6056 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6058 actorA.SetPosition( 30.0, 0.0 );
6060 application.SendNotification();
6061 application.Render();
6063 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6064 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6066 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6067 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6069 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6070 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6072 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6074 actorA.SetPosition( 30.0, 420.0 );
6076 application.SendNotification();
6077 application.Render();
6079 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6080 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6082 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6083 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6085 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6086 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6088 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6090 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6091 actorA.SetPosition( 30.0, 30.0 );
6093 Actor actorB = Actor::New();
6094 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6095 actorB.SetSize( size2 );
6096 actorB.SetPosition( 10.f, 10.f );
6097 actorA.Add( actorB );
6099 actorA.SetScale( 2.0f );
6101 application.SendNotification();
6102 application.Render();
6104 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6106 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6107 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6112 int UtcDaliActorGetScreenPositionAfterScaling(void)
6114 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6116 TestApplication application;
6118 Stage stage( Stage::GetCurrent() );
6120 Actor actorA = Actor::New();
6121 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6123 Vector2 size2( 10.0f, 20.0f );
6124 actorA.SetSize( size2 );
6125 actorA.SetScale( 1.5f );
6126 actorA.SetPosition( 0.f, 0.f );
6128 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6130 stage.Add( actorA );
6132 application.SendNotification();
6133 application.Render();
6135 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6136 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6138 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6139 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6141 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6142 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6144 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6146 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6148 application.SendNotification();
6149 application.Render();
6151 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6152 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6154 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6155 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6157 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6158 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6163 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6165 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6167 TestApplication application;
6169 Stage stage( Stage::GetCurrent() );
6171 Actor actorA = Actor::New();
6172 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6173 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6174 Vector2 size2( 10.0f, 20.0f );
6175 actorA.SetSize( size2 );
6176 actorA.SetPosition( 0.f, 0.f );
6178 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6180 stage.Add( actorA );
6182 application.SendNotification();
6183 application.Render();
6185 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6186 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6188 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6189 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6191 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6192 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6194 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6196 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
6197 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6199 application.SendNotification();
6200 application.Render();
6202 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6203 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6205 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6206 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6208 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6209 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6215 int UtcDaliActorGetScreenPositionWithChildActors(void)
6217 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6219 TestApplication application;
6221 Stage stage( Stage::GetCurrent() );
6223 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6225 Actor actorA = Actor::New();
6226 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6227 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6228 Vector2 size1( 10.0f, 20.0f );
6229 actorA.SetSize( size1 );
6230 actorA.SetPosition( 0.f, 0.f );
6232 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6234 Actor parentActorA = Actor::New();
6235 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6236 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6237 Vector2 size2( 30.0f, 60.0f );
6238 parentActorA.SetSize( size2 );
6239 parentActorA.SetPosition( 0.f, 0.f );
6241 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6243 stage.Add( parentActorA );
6244 parentActorA.Add ( actorA );
6246 application.SendNotification();
6247 application.Render();
6249 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6250 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6252 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6253 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6255 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6256 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6258 tet_infoline( "Test 2\n");
6260 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6262 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6263 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
6265 application.SendNotification();
6266 application.Render();
6268 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6269 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6271 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6272 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6274 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6275 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6280 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6282 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6284 TestApplication application;
6286 Stage stage( Stage::GetCurrent() );
6288 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6290 Actor actorA = Actor::New();
6291 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6292 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6293 Vector2 size1( 10.0f, 20.0f );
6294 actorA.SetSize( size1 );
6295 actorA.SetPosition( 0.f, 0.f );
6297 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6299 Actor parentActorA = Actor::New();
6300 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6301 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6302 Vector2 size2( 30.0f, 60.0f );
6303 parentActorA.SetSize( size2 );
6304 parentActorA.SetPosition( 0.f, 0.f );
6306 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6308 Actor grandParentActorA = Actor::New();
6309 grandParentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6310 grandParentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
6311 Vector2 size3( 60.0f, 120.0f );
6312 grandParentActorA.SetSize( size3 );
6313 grandParentActorA.SetPosition( 0.f, 0.f );
6315 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6317 stage.Add( grandParentActorA );
6318 grandParentActorA.Add ( parentActorA );
6320 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6322 parentActorA.Add ( actorA );
6324 application.SendNotification();
6325 application.Render();
6327 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6328 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6330 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6331 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6333 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6334 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6339 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6341 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6343 TestApplication application;
6345 Stage stage( Stage::GetCurrent() );
6347 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6349 Actor actorA = Actor::New();
6350 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6351 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6352 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6353 actorA.SetSize( 10.0f, 20.0f );
6354 stage.Add( actorA );
6356 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6358 Actor actorB = Actor::New();
6359 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6360 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6361 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6362 Vector2 actorBSize( 30.0f, 60.0f );
6363 actorB.SetSize( actorBSize );
6364 stage.Add( actorB );
6366 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6368 Actor actorC = Actor::New();
6369 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6370 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6371 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6372 Vector2 actorCSize( 60.0f, 120.0f );
6373 actorC.SetSize( actorCSize );
6374 stage.Add( actorC );
6376 application.SendNotification();
6377 application.Render();
6379 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6381 Vector2 center( stage.GetSize() * 0.5f );
6383 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6384 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6385 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6387 tet_infoline( "Add scale to all actors" );
6389 actorA.SetScale( 2.0f );
6390 actorB.SetScale( 2.0f );
6391 actorC.SetScale( 2.0f );
6393 application.SendNotification();
6394 application.Render();
6396 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6397 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6398 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6403 int utcDaliActorPositionUsesAnchorPoint(void)
6405 TestApplication application;
6406 tet_infoline( "Check default behaviour\n" );
6408 Actor actor = Actor::New();
6409 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6410 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6411 actor.SetSize( 100.0f, 100.0f );
6412 Stage::GetCurrent().Add( actor );
6414 application.SendNotification();
6415 application.Render();
6417 tet_infoline( "Check that the world position is in the center\n" );
6418 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6420 tet_infoline( "Set the position uses anchor point property to false\n" );
6421 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6423 application.SendNotification();
6424 application.Render();
6426 tet_infoline( "Check that the world position has changed appropriately\n" );
6427 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6432 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6434 TestApplication application;
6435 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6437 Actor actor = Actor::New();
6438 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6439 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6440 actor.SetSize( 100.0f, 100.0f );
6441 actor.SetScale( 2.0f );
6442 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6443 Stage::GetCurrent().Add( actor );
6445 application.SendNotification();
6446 application.Render();
6448 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6449 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6451 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6452 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6453 application.SendNotification();
6454 application.Render();
6455 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6457 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6458 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6459 application.SendNotification();
6460 application.Render();
6461 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6466 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6468 TestApplication application;
6469 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6471 Actor actor = Actor::New();
6472 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6473 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6474 actor.SetSize( 100.0f, 100.0f );
6475 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6476 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6477 Stage::GetCurrent().Add( actor );
6479 application.SendNotification();
6480 application.Render();
6482 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6483 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6485 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6486 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6487 application.SendNotification();
6488 application.Render();
6489 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6491 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6492 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6493 application.SendNotification();
6494 application.Render();
6495 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6500 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6502 TestApplication application;
6503 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6505 Actor actor = Actor::New();
6506 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6507 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6508 actor.SetSize( 100.0f, 100.0f );
6509 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6510 actor.SetScale( 2.0f );
6511 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6512 Stage::GetCurrent().Add( actor );
6514 application.SendNotification();
6515 application.Render();
6517 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6518 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6520 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6521 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6522 application.SendNotification();
6523 application.Render();
6524 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6526 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6527 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6528 application.SendNotification();
6529 application.Render();
6530 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6535 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6537 TestApplication application;
6538 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6540 Actor parent = Actor::New();
6542 Stage::GetCurrent().Add( parent );
6543 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6545 Actor actor = Actor::New();
6546 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6547 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6548 actor.SetSize( 100.0f, 100.0f );
6549 actor.SetProperty( Actor::Property::INHERIT_SCALE, false );
6550 actor.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
6551 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6552 parent.Add( actor );
6554 application.SendNotification();
6555 application.Render();
6557 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6559 tet_infoline( "Check the world position is in the right place\n" );
6560 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6562 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6563 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6564 application.SendNotification();
6565 application.Render();
6566 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6568 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6569 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6570 application.SendNotification();
6571 application.Render();
6572 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6577 int utcDaliActorVisibilityChangeSignalSelf(void)
6579 TestApplication application;
6580 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6582 Actor actor = Actor::New();
6584 VisibilityChangedFunctorData data;
6585 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6587 actor.SetProperty( Actor::Property::VISIBLE, false );
6589 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6591 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6594 actor.SetProperty( Actor::Property::VISIBLE, false );
6595 data.Check( false /* not called */, TEST_LOCATION );
6597 tet_infoline( "Change the visibility using properties, ensure called" );
6600 actor.SetProperty( Actor::Property::VISIBLE, true );
6601 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6603 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6606 actor.SetProperty( Actor::Property::VISIBLE, true );
6607 data.Check( false /* not called */, TEST_LOCATION );
6612 int utcDaliActorVisibilityChangeSignalChildren(void)
6614 TestApplication application;
6615 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6617 Actor parent = Actor::New();
6618 Actor child = Actor::New();
6619 parent.Add( child );
6621 Actor grandChild = Actor::New();
6622 child.Add( grandChild );
6624 VisibilityChangedFunctorData parentData;
6625 VisibilityChangedFunctorData childData;
6626 VisibilityChangedFunctorData grandChildData;
6628 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6629 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6630 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6632 parent.SetProperty( Actor::Property::VISIBLE, false );
6633 parentData.Check( false /* not called */, TEST_LOCATION );
6634 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6635 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6637 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6640 grandChildData.Reset();
6642 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6644 parent.SetProperty( Actor::Property::VISIBLE, true );
6645 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6646 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6647 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6649 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6652 grandChildData.Reset();
6654 parent.SetProperty( Actor::Property::VISIBLE, true );
6655 parentData.Check( false /* not called */, TEST_LOCATION );
6656 childData.Check( false /* not called */, TEST_LOCATION );
6657 grandChildData.Check( false /* not called */, TEST_LOCATION );
6662 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6664 TestApplication application;
6665 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6667 Actor actor = Actor::New();
6668 Stage::GetCurrent().Add( actor );
6670 application.SendNotification();
6671 application.Render();
6673 VisibilityChangedFunctorData data;
6674 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6676 Animation animation = Animation::New( 1.0f );
6677 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6679 data.Check( false, TEST_LOCATION );
6680 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6681 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6683 tet_infoline( "Play the animation and check the property value" );
6686 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6687 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6689 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6690 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6692 application.SendNotification();
6693 application.Render( 1100 ); // After the animation
6695 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6701 int utcDaliActorVisibilityChangeSignalByName(void)
6703 TestApplication application;
6704 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6706 Actor actor = Actor::New();
6708 bool signalCalled=false;
6709 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6710 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6711 actor.SetProperty( Actor::Property::VISIBLE, false );
6712 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6714 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6715 signalCalled = false;
6716 actor.SetProperty( Actor::Property::VISIBLE, false );
6717 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6719 tet_infoline( "Change the visibility using properties, ensure called" );
6720 actor.SetProperty( Actor::Property::VISIBLE, true );
6721 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6723 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6724 signalCalled = false;
6726 actor.SetProperty( Actor::Property::VISIBLE, true );
6727 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6733 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6735 gLayoutDirectionType = type;
6738 int UtcDaliActorLayoutDirectionProperty(void)
6740 TestApplication application;
6741 tet_infoline( "Check layout direction property" );
6743 Actor actor0 = Actor::New();
6744 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6745 Stage::GetCurrent().Add( actor0 );
6747 application.SendNotification();
6748 application.Render();
6750 Actor actor1 = Actor::New();
6751 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6752 Actor actor2 = Actor::New();
6753 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6754 Actor actor3 = Actor::New();
6755 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6756 Actor actor4 = Actor::New();
6757 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6758 Actor actor5 = Actor::New();
6759 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6760 Actor actor6 = Actor::New();
6761 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6762 Actor actor7 = Actor::New();
6763 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6764 Actor actor8 = Actor::New();
6765 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6766 Actor actor9 = Actor::New();
6767 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6769 actor1.Add( actor2 );
6770 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6771 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6773 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6774 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6775 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6777 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6778 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6779 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6781 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6782 actor0.Add( actor1 );
6783 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6784 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6786 Stage::GetCurrent().Add( actor3 );
6787 actor3.Add( actor4 );
6788 actor4.Add( actor5 );
6789 actor5.Add( actor6 );
6790 actor5.Add( actor7 );
6791 actor7.Add( actor8 );
6792 actor8.Add( actor9 );
6793 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6794 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6796 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6797 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6798 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6800 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6802 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6803 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6804 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6805 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6806 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6807 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6808 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6810 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6811 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6812 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6814 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6815 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6816 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6817 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6819 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6820 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6821 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6827 struct LayoutDirectionFunctor
6829 LayoutDirectionFunctor(bool& signalCalled)
6830 : mSignalCalled( signalCalled )
6834 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6835 : mSignalCalled( rhs.mSignalCalled )
6841 mSignalCalled = true;
6844 bool& mSignalCalled;
6847 int UtcDaliActorLayoutDirectionSignal(void)
6849 TestApplication application;
6850 tet_infoline( "Check changing layout direction property sends a signal" );
6852 Actor actor = Actor::New();
6853 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6854 Stage::GetCurrent().Add( actor );
6855 bool signalCalled = false;
6856 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6858 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6859 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6861 // Test that writing the same value doesn't send a signal
6862 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6863 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6865 // Test that writing a different value sends the signal
6866 signalCalled = false;
6867 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6868 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6870 signalCalled = false;
6871 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6872 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6877 struct ChildAddedSignalCheck
6879 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6880 : mSignalReceived( signalReceived ),
6881 mChildHandle( childHandle )
6885 void operator() ( Actor childHandle )
6887 mSignalReceived = true;
6888 mChildHandle = childHandle;
6892 mSignalReceived = true;
6893 mChildHandle = Actor();
6896 bool& mSignalReceived;
6897 Actor& mChildHandle;
6900 int UtcDaliChildAddedSignalP1(void)
6902 TestApplication application;
6903 auto stage = Stage::GetCurrent();
6905 bool signalReceived=false;
6908 ChildAddedSignalCheck signal( signalReceived, childActor );
6909 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6910 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6912 auto actorA = Actor::New();
6913 stage.Add( actorA );
6914 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6915 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6916 signalReceived = false;
6918 auto actorB = Actor::New();
6919 stage.Add( actorB );
6920 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6921 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6927 int UtcDaliChildAddedSignalP2(void)
6929 TestApplication application;
6930 auto stage = Stage::GetCurrent();
6932 bool signalReceived=false;
6935 ChildAddedSignalCheck signal( signalReceived, childActor );
6936 tet_infoline( "Connect to childAdded signal by name" );
6938 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6939 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6941 auto actorA = Actor::New();
6942 stage.Add( actorA );
6943 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6945 // Can't test which actor was added; signal signature is void() when connecting via name.
6946 signalReceived = false;
6948 auto actorB = Actor::New();
6949 stage.Add( actorB );
6950 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6955 int UtcDaliChildAddedSignalN(void)
6957 TestApplication application;
6958 auto stage = Stage::GetCurrent();
6960 bool signalReceived=false;
6963 ChildAddedSignalCheck signal( signalReceived, childActor );
6964 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6965 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6967 auto actorA = Actor::New();
6968 stage.Add( actorA );
6969 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6970 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6971 signalReceived = false;
6973 auto actorB = Actor::New();
6974 actorA.Add( actorB );
6975 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6980 struct ChildRemovedSignalCheck
6982 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
6983 : mSignalReceived( signalReceived ),
6984 mChildHandle( childHandle )
6988 void operator() ( Actor childHandle )
6990 mSignalReceived = true;
6991 mChildHandle = childHandle;
6996 mSignalReceived = true;
6999 bool& mSignalReceived;
7000 Actor& mChildHandle;
7003 int UtcDaliChildRemovedSignalP1(void)
7005 TestApplication application;
7006 auto stage = Stage::GetCurrent();
7008 bool signalReceived=false;
7011 ChildRemovedSignalCheck signal( signalReceived, childActor );
7012 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7013 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7015 auto actorA = Actor::New();
7016 stage.Add( actorA );
7017 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7018 DALI_TEST_CHECK( !childActor );
7020 stage.Remove( actorA );
7021 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7022 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7024 signalReceived = false;
7025 auto actorB = Actor::New();
7026 stage.Add( actorB );
7027 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7029 stage.Remove( actorB );
7030 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7031 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7036 int UtcDaliChildRemovedSignalP2(void)
7038 TestApplication application;
7039 auto stage = Stage::GetCurrent();
7041 bool signalReceived=false;
7044 ChildAddedSignalCheck signal( signalReceived, childActor );
7045 tet_infoline( "Connect to childRemoved signal by name" );
7047 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7048 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7050 auto actorA = Actor::New();
7051 stage.Add( actorA );
7052 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7054 stage.Remove( actorA );
7055 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7057 signalReceived = false;
7058 auto actorB = Actor::New();
7059 stage.Add( actorB );
7060 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7062 stage.Remove( actorB );
7063 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7069 int UtcDaliChildRemovedSignalN(void)
7071 TestApplication application;
7072 auto stage = Stage::GetCurrent();
7074 bool signalReceived=false;
7077 ChildRemovedSignalCheck signal( signalReceived, childActor );
7078 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7079 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7081 auto actorA = Actor::New();
7082 stage.Add( actorA );
7084 auto actorB = Actor::New();
7085 actorA.Add( actorB );
7087 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7088 DALI_TEST_CHECK( ! childActor );
7090 actorA.Remove( actorB );
7091 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7096 int UtcDaliChildMovedSignalP(void)
7098 TestApplication application;
7099 auto stage = Stage::GetCurrent();
7101 bool addedASignalReceived = false;
7102 bool removedASignalReceived = false;
7103 bool addedBSignalReceived = false;
7104 bool removedBSignalReceived = false;
7107 auto actorA = Actor::New();
7108 auto actorB = Actor::New();
7109 stage.Add( actorA );
7110 stage.Add( actorB );
7112 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7113 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7114 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7115 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7117 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7118 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7119 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7120 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7122 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7123 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7124 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7125 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7127 // Create a child of A
7129 auto child = Actor::New();
7130 actorA.Add( child );
7132 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7133 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7134 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7135 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7136 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7139 addedASignalReceived = false;
7140 addedBSignalReceived = false;
7141 removedASignalReceived = false;
7142 removedBSignalReceived = false;
7144 actorB.Add( child ); // Expect this child to be re-parented
7145 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7146 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7147 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7148 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7150 // Move child back to A:
7151 addedASignalReceived = false;
7152 addedBSignalReceived = false;
7153 removedASignalReceived = false;
7154 removedBSignalReceived = false;
7156 actorA.Add( child ); // Expect this child to be re-parented
7157 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7158 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7159 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7160 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7166 int utcDaliActorCulled(void)
7168 TestApplication application;
7169 auto stage = Stage::GetCurrent();
7171 tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7173 Actor actor = Actor::New();
7174 actor.SetSize( 10.0f, 10.0f );
7176 Geometry geometry = CreateQuadGeometry();
7177 Shader shader = CreateShader();
7178 Renderer renderer = Renderer::New(geometry, shader);
7179 actor.AddRenderer( renderer );
7183 application.SendNotification();
7184 application.Render( 0 );
7186 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), false, TEST_LOCATION );
7188 PropertyNotification notification = actor.AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) );
7189 notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7191 // Connect NotifySignal
7192 bool propertyNotificationSignal( false );
7193 PropertyNotification source;
7194 CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7195 notification.NotifySignal().Connect( &application, f ) ;
7197 actor.SetPosition( 1000.0f, 1000.0f );
7199 application.SendNotification();
7200 application.Render();
7202 application.SendNotification();
7204 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), true, TEST_LOCATION );
7206 DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7207 DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( DevelActor::Property::CULLED ), TEST_LOCATION );
7208 DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7213 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7215 TestApplication application;
7216 auto stage = Stage::GetCurrent();
7218 tet_infoline( "Ensure we clear the screen when the last actor is removed" );
7220 Actor actor = CreateRenderableActor();
7221 actor.SetSize( 100.0f, 100.0f );
7224 application.SendNotification();
7225 application.Render();
7227 auto& glAbstraction = application.GetGlAbstraction();
7228 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7232 application.SendNotification();
7233 application.Render();
7235 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7240 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7242 TestApplication application;
7243 auto stage = Stage::GetCurrent();
7245 tet_infoline( "Ensure we clear the screen when the last actor is made invisible" );
7247 Actor actor = CreateRenderableActor();
7248 actor.SetSize( 100.0f, 100.0f );
7251 application.SendNotification();
7252 application.Render();
7254 auto& glAbstraction = application.GetGlAbstraction();
7255 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7257 actor.SetProperty( Actor::Property::VISIBLE, false );
7259 application.SendNotification();
7260 application.Render();
7262 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7267 int utcDaliActorGetSizeAfterAnimation(void)
7269 TestApplication application;
7270 tet_infoline( "Check the actor size when an animation is finished" );
7272 Vector3 vector( 100.0f, 100.0f, 0.0f );
7274 Actor actor = Actor::New();
7275 actor.SetSize( vector.x, vector.y );
7276 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
7277 Stage::GetCurrent().Add( actor );
7279 application.SendNotification();
7280 application.Render();
7282 Vector3 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7283 DALI_TEST_EQUALS( size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7284 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7285 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7286 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7288 Vector3 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7289 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7290 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7291 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7292 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7294 Vector3 targetValue( 10.0f, 20.0f, 30.0f );
7296 Animation animation = Animation::New( 1.0f );
7297 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
7300 application.SendNotification();
7301 application.Render( 1100 ); // After the animation
7303 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7304 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7305 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7306 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7307 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7309 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7310 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7311 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7312 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7313 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7315 targetValue.width = 50.0f;
7318 animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetValue.width );
7321 application.SendNotification();
7322 application.Render( 1100 ); // After the animation
7324 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7325 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7326 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7327 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7328 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7330 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7331 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7332 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7333 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7334 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7336 targetValue.height = 70.0f;
7339 animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetValue.height );
7342 application.SendNotification();
7343 application.Render( 1100 ); // After the animation
7345 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7346 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7347 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7348 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7349 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7351 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7352 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7353 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7354 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7355 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7357 Vector3 offset( 10.0f, 20.0f, 30.0f );
7360 animation.AnimateBy( Property( actor, Actor::Property::SIZE ), offset );
7363 application.SendNotification();
7364 application.Render( 1100 ); // After the animation
7366 targetValue += offset;
7368 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7369 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7370 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7371 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7372 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7374 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7375 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7376 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7377 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7378 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7380 offset.width = 20.0f;
7383 animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), offset.width );
7386 application.SendNotification();
7387 application.Render( 1100 ); // After the animation
7389 targetValue.width += offset.width;
7391 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7392 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7393 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7394 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7395 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7397 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7398 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7399 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7400 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7401 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7403 offset.height = 10.0f;
7406 animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), offset.height );
7409 application.SendNotification();
7410 application.Render( 1100 ); // After the animation
7412 targetValue.height += offset.height;
7414 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7415 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7416 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7417 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7418 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7420 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7421 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7422 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7423 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7424 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );