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 int UtcDaliActorSetSize01(void)
921 TestApplication application;
923 Actor actor = Actor::New();
924 Vector3 vector(100.0f, 100.0f, 0.0f);
926 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
928 actor.SetProperty( Actor::Property::SIZE, Vector2( vector.x, vector.y ) );
930 // Immediately retrieve the size after setting
931 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
932 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
933 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
934 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
935 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
937 // Flush the queue and render once
938 application.SendNotification();
939 application.Render();
941 // Check the size in the new frame
942 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
944 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
945 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
946 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
947 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
948 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
950 // Check async behaviour
951 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
952 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
953 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
954 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
955 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
957 // Change the resize policy and check whether the size stays the same
958 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
960 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
961 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
963 // Set a new size after resize policy is changed and check the new size
964 actor.SetProperty( Actor::Property::SIZE, Vector3( 0.1f, 0.2f, 0.0f ) );
966 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
967 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
969 // Change the resize policy again and check whether the new size stays the same
970 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
972 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
973 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
975 // Set another new size after resize policy is changed and check the new size
976 actor.SetProperty( Actor::Property::SIZE, Vector3( 50.0f, 60.0f, 0.0f ) );
978 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
979 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
984 int UtcDaliActorSetSize02(void)
986 TestApplication application;
988 Actor actor = Actor::New();
989 Vector3 vector(100.0f, 100.0f, 100.0f);
991 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
993 actor.SetProperty( Actor::Property::SIZE, Vector3( vector.x, vector.y, vector.z ) );
995 // Immediately check the size after setting
996 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
997 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
999 // flush the queue and render once
1000 application.SendNotification();
1001 application.Render();
1003 // Check the size in the new frame
1004 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1006 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1007 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1012 // SetSize(Vector2 size)
1013 int UtcDaliActorSetSize03(void)
1015 TestApplication application;
1017 Actor actor = Actor::New();
1018 Vector3 vector(100.0f, 100.0f, 0.0f);
1020 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1022 actor.SetProperty( Actor::Property::SIZE,Vector2(vector.x, vector.y));
1024 // Immediately check the size after setting
1025 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1026 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1028 // flush the queue and render once
1029 application.SendNotification();
1030 application.Render();
1032 // Check the size in the new frame
1033 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1035 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1036 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1041 // SetSize(Vector3 size)
1042 int UtcDaliActorSetSize04(void)
1044 TestApplication application;
1046 Actor actor = Actor::New();
1047 Vector3 vector(100.0f, 100.0f, 100.0f);
1049 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1051 actor.SetProperty( Actor::Property::SIZE,vector);
1053 // Immediately check the size after setting
1054 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1055 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1057 // flush the queue and render once
1058 application.SendNotification();
1059 application.Render();
1061 // Check the size in the new frame
1062 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1064 Stage::GetCurrent().Add( actor );
1065 actor.SetProperty( Actor::Property::SIZE, Vector3( 0.1f, 0.2f, 0.3f ) );
1067 // Immediately check the size after setting
1068 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1069 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1071 // flush the queue and render once
1072 application.SendNotification();
1073 application.Render();
1075 // Check the size in the new frame
1076 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), TEST_LOCATION );
1078 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1079 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1081 Stage::GetCurrent().Remove( actor );
1085 int UtcDaliActorSetSizeIndividual(void)
1087 TestApplication application;
1089 Actor actor = Actor::New();
1091 Vector3 vector(0.7f, 0.8f, 0.9f);
1092 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1094 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1096 // Immediately check the width after setting
1097 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1098 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1100 // flush the queue and render once
1101 application.SendNotification();
1102 application.Render();
1104 // Check the width in the new frame
1105 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1107 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1108 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1110 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1112 // Immediately check the height after setting
1113 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1114 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1116 // flush the queue and render once
1117 application.SendNotification();
1118 application.Render();
1120 // Check the height in the new frame
1121 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1123 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1124 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1126 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1128 // Immediately check the depth after setting
1129 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1130 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1132 // flush the queue and render once
1133 application.SendNotification();
1134 application.Render();
1136 // Check the depth in the new frame
1137 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).depth, TEST_LOCATION );
1139 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1140 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1142 // Change the resize policy and check whether the size stays the same
1143 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1145 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1146 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1148 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1149 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1151 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1152 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1154 // Change the resize policy again and check whether the size stays the same
1155 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1157 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1158 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1160 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1161 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1163 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1164 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1169 int UtcDaliActorSetSizeIndividual02(void)
1171 TestApplication application;
1173 Actor actor = Actor::New();
1174 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1175 Stage::GetCurrent().Add( actor );
1177 Vector3 vector( 100.0f, 200.0f, 400.0f );
1178 DALI_TEST_CHECK( vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ) );
1180 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1181 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1183 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1184 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1186 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1187 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1189 // flush the queue and render once
1190 application.SendNotification();
1191 application.Render();
1193 // Check the width in the new frame
1194 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1195 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1201 int UtcDaliActorGetCurrentSize(void)
1203 TestApplication application;
1205 Actor actor = Actor::New();
1206 Vector3 vector(100.0f, 100.0f, 20.0f);
1208 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1210 actor.SetProperty( Actor::Property::SIZE,vector);
1212 // flush the queue and render once
1213 application.SendNotification();
1214 application.Render();
1216 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1220 int UtcDaliActorGetNaturalSize(void)
1222 TestApplication application;
1224 Actor actor = Actor::New();
1225 Vector3 vector( 0.0f, 0.0f, 0.0f );
1227 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1232 int UtcDaliActorGetCurrentSizeImmediate(void)
1234 TestApplication application;
1236 Actor actor = Actor::New();
1237 Vector3 vector(100.0f, 100.0f, 20.0f);
1239 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1240 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1242 actor.SetProperty( Actor::Property::SIZE,vector);
1244 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1245 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1247 // flush the queue and render once
1248 application.SendNotification();
1249 application.Render();
1251 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1252 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1255 // Build the animation
1256 const float durationSeconds = 2.0f;
1257 Animation animation = Animation::New( durationSeconds );
1258 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1259 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1261 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1263 // Start the animation
1266 application.SendNotification();
1267 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1269 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1274 int UtcDaliActorCalculateScreenExtents(void)
1276 TestApplication application;
1278 Actor actor = Actor::New();
1280 actor.SetProperty( Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1281 actor.SetProperty( Actor::Property::SIZE,Vector3{ 1.0f, 1.0f, 1.0f });
1283 application.SendNotification();
1284 application.Render();
1286 auto expectedExtent = Rect<>{ -0.5f, -0.5f, 1.0f, 1.0f };
1287 auto actualExtent = DevelActor::CalculateScreenExtents( actor );
1288 DALI_TEST_EQUALS( expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1289 DALI_TEST_EQUALS( expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1290 DALI_TEST_EQUALS( expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1291 DALI_TEST_EQUALS( expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1293 Stage::GetCurrent().Remove( actor );
1297 // SetPosition(float x, float y)
1298 int UtcDaliActorSetPosition01(void)
1300 TestApplication application;
1302 Actor actor = Actor::New();
1304 // Set to random to start off with
1305 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1307 Vector3 vector(100.0f, 100.0f, 0.0f);
1309 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1311 actor.SetProperty( Actor::Property::POSITION, Vector2(vector.x, vector.y));
1312 // flush the queue and render once
1313 application.SendNotification();
1314 application.Render();
1315 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1317 Stage::GetCurrent().Add( actor );
1318 actor.SetProperty( Actor::Property::POSITION, Vector3( 0.1f, 0.2f, 0.3f ) );
1319 // flush the queue and render once
1320 application.SendNotification();
1321 application.Render();
1322 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1324 actor.SetProperty( Actor::Property::POSITION_X, 1.0f );
1325 actor.SetProperty( Actor::Property::POSITION_Y, 1.1f );
1326 actor.SetProperty( Actor::Property::POSITION_Z, 1.2f );
1327 // flush the queue and render once
1328 application.SendNotification();
1329 application.Render();
1330 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1332 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1333 // flush the queue and render once
1334 application.SendNotification();
1335 application.Render();
1336 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1338 Stage::GetCurrent().Remove( actor );
1342 // SetPosition(float x, float y, float z)
1343 int UtcDaliActorSetPosition02(void)
1345 TestApplication application;
1347 Actor actor = Actor::New();
1349 // Set to random to start off with
1350 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1352 Vector3 vector(100.0f, 100.0f, 100.0f);
1354 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1356 actor.SetProperty( Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1358 // flush the queue and render once
1359 application.SendNotification();
1360 application.Render();
1362 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1366 // SetPosition(Vector3 position)
1367 int UtcDaliActorSetPosition03(void)
1369 TestApplication application;
1371 Actor actor = Actor::New();
1373 // Set to random to start off with
1374 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1376 Vector3 vector(100.0f, 100.0f, 100.0f);
1378 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1380 actor.SetProperty( Actor::Property::POSITION, vector);
1382 // flush the queue and render once
1383 application.SendNotification();
1384 application.Render();
1386 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1390 int UtcDaliActorSetX(void)
1392 TestApplication application;
1394 Actor actor = Actor::New();
1396 Vector3 vector(100.0f, 0.0f, 0.0f);
1398 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1400 actor.SetProperty( Actor::Property::POSITION_X, 100.0f);
1402 // flush the queue and render once
1403 application.SendNotification();
1404 application.Render();
1406 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1410 int UtcDaliActorSetY(void)
1412 TestApplication application;
1414 Actor actor = Actor::New();
1416 Vector3 vector(0.0f, 100.0f, 0.0f);
1418 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1420 actor.SetProperty( Actor::Property::POSITION_Y, 100.0f);
1422 // flush the queue and render once
1423 application.SendNotification();
1424 application.Render();
1426 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1430 int UtcDaliActorSetZ(void)
1432 TestApplication application;
1434 Actor actor = Actor::New();
1436 Vector3 vector(0.0f, 0.0f, 100.0f);
1438 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1440 actor.SetProperty( Actor::Property::POSITION_Z, 100.0f);
1442 // flush the queue and render once
1443 application.SendNotification();
1444 application.Render();
1446 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1450 int UtcDaliActorSetPositionProperties(void)
1452 TestApplication application;
1454 Actor actor = Actor::New();
1456 Vector3 vector(0.7f, 0.8f, 0.9f);
1457 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1459 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1460 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1461 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1463 // flush the queue and render once
1464 application.SendNotification();
1465 application.Render();
1467 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1468 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1469 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1470 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1471 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1473 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1474 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1475 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1477 // flush the queue and render once
1478 application.SendNotification();
1479 application.Render();
1481 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1482 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1483 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1484 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1485 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1487 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1488 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1489 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1491 // flush the queue and render once
1492 application.SendNotification();
1493 application.Render();
1495 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1496 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1497 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1498 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1499 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1504 int UtcDaliActorTranslateBy(void)
1506 TestApplication application;
1508 Actor actor = Actor::New();
1509 Vector3 vector(100.0f, 100.0f, 100.0f);
1511 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1513 actor.SetProperty( Actor::Property::POSITION, vector);
1515 // flush the queue and render once
1516 application.SendNotification();
1517 application.Render();
1519 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1521 actor.TranslateBy(vector);
1523 // flush the queue and render once
1524 application.SendNotification();
1525 application.Render();
1527 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1531 int UtcDaliActorGetCurrentPosition(void)
1533 TestApplication application;
1535 Actor actor = Actor::New();
1536 Vector3 setVector(100.0f, 100.0f, 0.0f);
1537 actor.SetProperty( Actor::Property::POSITION, setVector);
1539 // flush the queue and render once
1540 application.SendNotification();
1541 application.Render();
1543 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ) == setVector);
1547 int UtcDaliActorGetCurrentWorldPosition(void)
1549 TestApplication application;
1551 Actor parent = Actor::New();
1552 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1553 parent.SetProperty( Actor::Property::POSITION, parentPosition );
1554 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1555 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1556 Stage::GetCurrent().Add( parent );
1558 Actor child = Actor::New();
1559 child.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1560 child.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1561 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1562 child.SetProperty( Actor::Property::POSITION, childPosition );
1563 parent.Add( child );
1565 // The actors should not have a world position yet
1566 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1567 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1569 application.SendNotification();
1570 application.Render(0);
1572 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1573 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1575 // The actors should have a world position now
1576 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1577 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1581 int UtcDaliActorSetInheritPosition(void)
1583 tet_infoline("Testing Actor::SetInheritPosition");
1584 TestApplication application;
1586 Actor parent = Actor::New();
1587 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1588 parent.SetProperty( Actor::Property::POSITION, parentPosition );
1589 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1590 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1591 Stage::GetCurrent().Add( parent );
1593 Actor child = Actor::New();
1594 child.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1595 child.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1596 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1597 child.SetProperty( Actor::Property::POSITION, childPosition );
1598 parent.Add( child );
1600 // The actors should not have a world position yet
1601 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1602 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1604 // first test default, which is to inherit position
1605 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1606 application.SendNotification();
1607 application.Render(0); // should only really call Update as Render is not required to update scene
1608 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1609 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1610 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1611 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1613 //Change child position
1614 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1615 child.SetProperty( Actor::Property::POSITION, childOffset );
1617 // Use local position as world postion
1618 child.SetProperty( Actor::Property::INHERIT_POSITION, false );
1619 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), false, TEST_LOCATION );
1620 application.SendNotification();
1621 application.Render(0); // should only really call Update as Render is not required to update scene
1622 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1623 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1624 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1625 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), childOffset, TEST_LOCATION );
1627 //Change back to inherit position from parent
1628 child.SetProperty( Actor::Property::INHERIT_POSITION, true );
1629 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1630 application.SendNotification();
1631 application.Render(0); // should only really call Update as Render is not required to update scene
1632 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1633 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1634 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1635 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childOffset, TEST_LOCATION );
1639 int UtcDaliActorInheritOpacity(void)
1641 tet_infoline("Testing Actor::Inherit Opacity");
1642 TestApplication application;
1644 Actor parent = Actor::New();
1645 Actor child = Actor::New();
1646 parent.Add( child );
1647 Stage::GetCurrent().Add( parent );
1649 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1650 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1652 // flush the queue and render once
1653 application.SendNotification();
1654 application.Render();
1656 parent.SetProperty( DevelActor::Property::OPACITY, 0.1f );
1658 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1659 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1661 application.SendNotification();
1662 application.Render();
1664 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1665 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1666 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1667 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1668 DALI_TEST_EQUALS( child.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.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1674 // SetOrientation(float angleRadians, Vector3 axis)
1675 int UtcDaliActorSetOrientation01(void)
1677 TestApplication application;
1679 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1680 Actor actor = Actor::New();
1682 actor.SetProperty( Actor::Property::ORIENTATION, rotation);
1684 // flush the queue and render once
1685 application.SendNotification();
1686 application.Render();
1688 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1692 int UtcDaliActorSetOrientation02(void)
1694 TestApplication application;
1696 Actor actor = Actor::New();
1698 Radian angle( 0.785f );
1699 Vector3 axis(1.0f, 1.0f, 0.0f);
1701 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1702 Quaternion rotation( angle, axis );
1703 // flush the queue and render once
1704 application.SendNotification();
1705 application.Render();
1706 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1708 Stage::GetCurrent().Add( actor );
1709 actor.RotateBy( Degree( 360 ), axis);
1710 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1712 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) ) );
1713 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1714 // flush the queue and render once
1715 application.SendNotification();
1716 application.Render();
1717 DALI_TEST_EQUALS( result, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1719 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1720 // flush the queue and render once
1721 application.SendNotification();
1722 application.Render();
1723 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1725 Stage::GetCurrent().Remove( actor );
1729 // SetOrientation(float angleRadians, Vector3 axis)
1730 int UtcDaliActorSetOrientationProperty(void)
1732 TestApplication application;
1734 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1735 Actor actor = Actor::New();
1737 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1738 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1740 // flush the queue and render once
1741 application.SendNotification();
1742 application.Render();
1744 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1745 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1746 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1750 // RotateBy(float angleRadians, Vector3 axis)
1751 int UtcDaliActorRotateBy01(void)
1753 TestApplication application;
1755 Actor actor = Actor::New();
1757 Radian angle( M_PI * 0.25f );
1758 actor.RotateBy(( angle ), Vector3::ZAXIS);
1759 // flush the queue and render once
1760 application.SendNotification();
1761 application.Render();
1762 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1764 Stage::GetCurrent().Add( actor );
1766 actor.RotateBy( angle, Vector3::ZAXIS);
1767 // flush the queue and render once
1768 application.SendNotification();
1769 application.Render();
1770 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1772 Stage::GetCurrent().Remove( actor );
1776 // RotateBy(Quaternion relativeRotation)
1777 int UtcDaliActorRotateBy02(void)
1779 TestApplication application;
1781 Actor actor = Actor::New();
1783 Radian angle( M_PI * 0.25f );
1784 Quaternion rotation(angle, Vector3::ZAXIS);
1785 actor.RotateBy(rotation);
1786 // flush the queue and render once
1787 application.SendNotification();
1788 application.Render();
1789 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1791 actor.RotateBy(rotation);
1792 // flush the queue and render once
1793 application.SendNotification();
1794 application.Render();
1795 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1799 int UtcDaliActorGetCurrentOrientation(void)
1801 TestApplication application;
1802 Actor actor = Actor::New();
1804 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1805 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1806 // flush the queue and render once
1807 application.SendNotification();
1808 application.Render();
1809 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1813 int UtcDaliActorGetCurrentWorldOrientation(void)
1815 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1816 TestApplication application;
1818 Actor parent = Actor::New();
1819 Radian rotationAngle( Degree(90.0f) );
1820 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1821 parent.SetProperty( Actor::Property::ORIENTATION, rotation );
1822 Stage::GetCurrent().Add( parent );
1824 Actor child = Actor::New();
1825 child.SetProperty( Actor::Property::ORIENTATION, rotation );
1826 parent.Add( child );
1828 // The actors should not have a world rotation yet
1829 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1830 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1832 application.SendNotification();
1833 application.Render(0);
1835 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1836 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1838 // The actors should have a world rotation now
1839 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1840 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1842 // turn off child rotation inheritance
1843 child.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
1844 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_ORIENTATION ), false, TEST_LOCATION );
1845 application.SendNotification();
1846 application.Render(0);
1848 // The actors should have a world rotation now
1849 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1850 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1854 // SetScale(float scale)
1855 int UtcDaliActorSetScale01(void)
1857 TestApplication application;
1859 Actor actor = Actor::New();
1861 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1862 actor.SetProperty( Actor::Property::SCALE,0.25f);
1864 Vector3 scale(10.0f, 10.0f, 10.0f);
1865 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1867 actor.SetProperty( Actor::Property::SCALE,scale.x);
1869 // flush the queue and render once
1870 application.SendNotification();
1871 application.Render();
1873 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1877 // SetScale(float scaleX, float scaleY, float scaleZ)
1878 int UtcDaliActorSetScale02(void)
1880 TestApplication application;
1881 Vector3 scale(10.0f, 10.0f, 10.0f);
1883 Actor actor = Actor::New();
1885 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1886 actor.SetProperty( Actor::Property::SCALE, Vector3( 12.0f, 1.0f, 2.0f ) );
1888 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1890 actor.SetProperty( Actor::Property::SCALE, Vector3( scale.x, scale.y, scale.z ) );
1891 // flush the queue and render once
1892 application.SendNotification();
1893 application.Render();
1894 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1896 // add to stage and test
1897 Stage::GetCurrent().Add( actor );
1898 actor.SetProperty( Actor::Property::SCALE, Vector3( 2.0f, 2.0f, 2.0f ) );
1899 // flush the queue and render once
1900 application.SendNotification();
1901 application.Render();
1902 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), 0.001, TEST_LOCATION);
1904 Stage::GetCurrent().Remove( actor );
1909 // SetScale(Vector3 scale)
1910 int UtcDaliActorSetScale03(void)
1912 TestApplication application;
1913 Vector3 scale(10.0f, 10.0f, 10.0f);
1915 Actor actor = Actor::New();
1917 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1918 actor.SetProperty( Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1920 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1922 actor.SetProperty( Actor::Property::SCALE,scale);
1924 // flush the queue and render once
1925 application.SendNotification();
1926 application.Render();
1928 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1932 int UtcDaliActorSetScaleIndividual(void)
1934 TestApplication application;
1936 Actor actor = Actor::New();
1938 Vector3 vector(0.7f, 0.8f, 0.9f);
1939 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1941 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1942 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1944 // flush the queue and render once
1945 application.SendNotification();
1946 application.Render();
1948 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x, TEST_LOCATION );
1949 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1950 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1952 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1953 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1955 // flush the queue and render once
1956 application.SendNotification();
1957 application.Render();
1959 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).y, TEST_LOCATION );
1960 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1961 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1963 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1964 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1966 // flush the queue and render once
1967 application.SendNotification();
1968 application.Render();
1970 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).z, TEST_LOCATION );
1971 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1972 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1974 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1975 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1980 int UtcDaliActorScaleBy(void)
1982 TestApplication application;
1983 Actor actor = Actor::New();
1984 Vector3 vector(100.0f, 100.0f, 100.0f);
1986 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1988 actor.SetProperty( Actor::Property::SCALE,vector);
1990 // flush the queue and render once
1991 application.SendNotification();
1992 application.Render();
1994 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1996 actor.ScaleBy(vector);
1998 // flush the queue and render once
1999 application.SendNotification();
2000 application.Render();
2002 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
2006 int UtcDaliActorGetCurrentScale(void)
2008 TestApplication application;
2009 Vector3 scale(12.0f, 1.0f, 2.0f);
2011 Actor actor = Actor::New();
2013 actor.SetProperty( Actor::Property::SCALE,scale);
2015 // flush the queue and render once
2016 application.SendNotification();
2017 application.Render();
2019 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
2023 int UtcDaliActorGetCurrentWorldScale(void)
2025 TestApplication application;
2027 Actor parent = Actor::New();
2028 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2029 parent.SetProperty( Actor::Property::SCALE, parentScale );
2030 Stage::GetCurrent().Add( parent );
2032 Actor child = Actor::New();
2033 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2034 child.SetProperty( Actor::Property::SCALE, childScale );
2035 parent.Add( child );
2037 // The actors should not have a scale yet
2038 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2039 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2041 // The actors should not have a world scale yet
2042 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2043 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2045 application.SendNotification();
2046 application.Render(0);
2048 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), parentScale, TEST_LOCATION );
2049 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), childScale, TEST_LOCATION );
2051 // The actors should have a world scale now
2052 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale, TEST_LOCATION );
2053 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2057 int UtcDaliActorInheritScale(void)
2059 tet_infoline("Testing Actor::SetInheritScale");
2060 TestApplication application;
2062 Actor parent = Actor::New();
2063 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2064 parent.SetProperty( Actor::Property::SCALE, parentScale );
2065 Stage::GetCurrent().Add( parent );
2067 Actor child = Actor::New();
2068 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2069 child.SetProperty( Actor::Property::SCALE, childScale );
2070 parent.Add( child );
2072 application.SendNotification();
2073 application.Render(0);
2075 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), true, TEST_LOCATION );
2076 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2078 child.SetProperty( Actor::Property::INHERIT_SCALE, false );
2079 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), false, TEST_LOCATION );
2081 application.SendNotification();
2082 application.Render(0);
2084 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), childScale, TEST_LOCATION );
2088 int UtcDaliActorSetVisible(void)
2090 TestApplication application;
2092 Actor actor = Actor::New();
2093 actor.SetProperty( Actor::Property::VISIBLE,false);
2094 // flush the queue and render once
2095 application.SendNotification();
2096 application.Render();
2097 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2099 actor.SetProperty( Actor::Property::VISIBLE,true);
2100 // flush the queue and render once
2101 application.SendNotification();
2102 application.Render();
2103 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2105 // put actor on stage
2106 Stage::GetCurrent().Add( actor );
2107 actor.SetProperty( Actor::Property::VISIBLE,false);
2108 // flush the queue and render once
2109 application.SendNotification();
2110 application.Render();
2111 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2115 int UtcDaliActorIsVisible(void)
2117 TestApplication application;
2119 Actor actor = Actor::New();
2121 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2125 int UtcDaliActorSetOpacity(void)
2127 TestApplication application;
2129 Actor actor = Actor::New();
2130 // initial opacity is 1
2131 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
2133 actor.SetProperty( DevelActor::Property::OPACITY, 0.4f);
2134 // flush the queue and render once
2135 application.SendNotification();
2136 application.Render();
2137 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.4f, TEST_LOCATION );
2139 // change opacity, actor is on stage to change is not immediate
2140 actor.SetProperty( DevelActor::Property::OPACITY, actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) + 0.1f );
2141 // flush the queue and render once
2142 application.SendNotification();
2143 application.Render();
2144 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2146 // put actor on stage
2147 Stage::GetCurrent().Add( actor );
2149 // change opacity, actor is on stage to change is not immediate
2150 actor.SetProperty( DevelActor::Property::OPACITY, 0.9f );
2151 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2152 // flush the queue and render once
2153 application.SendNotification();
2154 application.Render();
2155 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.9f, TEST_LOCATION );
2157 // change opacity, actor is on stage to change is not immediate
2158 actor.SetProperty( DevelActor::Property::OPACITY, actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) - 0.9f );
2159 // flush the queue and render once
2160 application.SendNotification();
2161 application.Render();
2162 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
2166 int UtcDaliActorGetCurrentOpacity(void)
2168 TestApplication application;
2170 Actor actor = Actor::New();
2171 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) != 0.5f);
2173 actor.SetProperty( DevelActor::Property::OPACITY,0.5f);
2174 // flush the queue and render once
2175 application.SendNotification();
2176 application.Render();
2177 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) == 0.5f);
2181 int UtcDaliActorSetSensitive(void)
2183 TestApplication application;
2184 Actor actor = Actor::New();
2186 bool sensitive = !actor.GetProperty< bool >( Actor::Property::SENSITIVE );
2188 actor.SetProperty( Actor::Property::SENSITIVE,sensitive);
2190 DALI_TEST_CHECK(sensitive == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2194 int UtcDaliActorIsSensitive(void)
2196 TestApplication application;
2197 Actor actor = Actor::New();
2198 actor.SetProperty( Actor::Property::SENSITIVE,false);
2200 DALI_TEST_CHECK(false == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2204 int UtcDaliActorSetColor(void)
2206 TestApplication application;
2207 Actor actor = Actor::New();
2208 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2210 DALI_TEST_CHECK(color != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2212 actor.SetProperty( Actor::Property::COLOR,color);
2213 // flush the queue and render once
2214 application.SendNotification();
2215 application.Render();
2216 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2218 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2219 // flush the queue and render once
2220 application.SendNotification();
2221 application.Render();
2222 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2224 Stage::GetCurrent().Add( actor );
2225 actor.SetProperty( Actor::Property::COLOR, color );
2226 // flush the queue and render once
2227 application.SendNotification();
2228 application.Render();
2229 DALI_TEST_EQUALS( color, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2231 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2232 // flush the queue and render once
2233 application.SendNotification();
2234 application.Render();
2235 // Actor color is not clamped
2236 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2237 // world color is clamped
2238 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), TEST_LOCATION );
2240 actor.SetProperty( Actor::Property::COLOR, color );
2241 DALI_TEST_EQUALS( color, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2243 Vector3 newColor( 1.0f, 0.0f, 0.0f );
2244 actor.SetProperty( Actor::Property::COLOR, newColor );
2245 DALI_TEST_EQUALS( Vector4( newColor.r, newColor.g, newColor.b, 1.0f ), actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2247 Stage::GetCurrent().Remove( actor );
2251 int UtcDaliActorSetColorIndividual(void)
2253 TestApplication application;
2255 Actor actor = Actor::New();
2257 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2258 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2260 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2261 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2263 // flush the queue and render once
2264 application.SendNotification();
2265 application.Render();
2267 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).r, TEST_LOCATION );
2268 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2269 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2271 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2272 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2274 // flush the queue and render once
2275 application.SendNotification();
2276 application.Render();
2278 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).g, TEST_LOCATION );
2279 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2280 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2282 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2283 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2285 // flush the queue and render once
2286 application.SendNotification();
2287 application.Render();
2289 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).b, TEST_LOCATION );
2290 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2291 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2294 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2295 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2297 // flush the queue and render once
2298 application.SendNotification();
2299 application.Render();
2301 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2302 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2303 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2305 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2306 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2308 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2311 // flush the queue and render once
2312 application.SendNotification();
2313 application.Render();
2315 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2321 int UtcDaliActorGetCurrentColor(void)
2323 TestApplication application;
2324 Actor actor = Actor::New();
2325 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2327 actor.SetProperty( Actor::Property::COLOR,color);
2328 // flush the queue and render once
2329 application.SendNotification();
2330 application.Render();
2331 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2335 int UtcDaliActorGetCurrentWorldColor(void)
2337 tet_infoline("Actor::GetCurrentWorldColor");
2338 TestApplication application;
2340 Actor parent = Actor::New();
2341 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2342 parent.SetProperty( Actor::Property::COLOR, parentColor );
2343 Stage::GetCurrent().Add( parent );
2345 Actor child = Actor::New();
2346 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2347 child.SetProperty( Actor::Property::COLOR, childColor );
2348 parent.Add( child );
2350 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2351 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2353 // verify the default color mode
2354 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2356 // The actors should not have a world color yet
2357 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2358 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2360 application.SendNotification();
2361 application.Render(0);
2363 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), parentColor, TEST_LOCATION );
2364 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2366 // The actors should have a world color now
2367 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2368 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2371 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2372 application.SendNotification();
2373 application.Render(0);
2374 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), childColor, TEST_LOCATION );
2377 child.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2378 application.SendNotification();
2379 application.Render(0);
2380 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2381 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2384 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2385 application.SendNotification();
2386 application.Render(0);
2387 Vector4 expectedColor( childColor );
2388 expectedColor.a *= parentColor.a;
2389 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2390 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), expectedColor, TEST_LOCATION );
2394 int UtcDaliActorSetColorMode(void)
2396 tet_infoline("Actor::SetColorMode");
2397 TestApplication application;
2398 Actor actor = Actor::New();
2399 Actor child = Actor::New();
2402 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2403 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2405 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
2406 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2408 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2409 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2411 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2412 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2416 int UtcDaliActorScreenToLocal(void)
2418 TestApplication application;
2419 Actor actor = Actor::New();
2420 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2421 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2422 actor.SetProperty( Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2423 Stage::GetCurrent().Add(actor);
2425 // flush the queue and render once
2426 application.SendNotification();
2427 application.Render();
2432 application.SendNotification();
2433 application.Render();
2435 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2437 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2438 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2442 int UtcDaliActorSetLeaveRequired(void)
2444 TestApplication application;
2446 Actor actor = Actor::New();
2448 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,false);
2449 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2451 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,true);
2452 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == true);
2456 int UtcDaliActorGetLeaveRequired(void)
2458 TestApplication application;
2460 Actor actor = Actor::New();
2462 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2466 int UtcDaliActorSetKeyboardFocusable(void)
2468 TestApplication application;
2470 Actor actor = Actor::New();
2472 actor.SetKeyboardFocusable(true);
2473 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2475 actor.SetKeyboardFocusable(false);
2476 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2480 int UtcDaliActorIsKeyboardFocusable(void)
2482 TestApplication application;
2484 Actor actor = Actor::New();
2486 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2490 int UtcDaliActorRemoveConstraints(void)
2492 tet_infoline(" UtcDaliActorRemoveConstraints");
2493 TestApplication application;
2495 gTestConstraintCalled = false;
2497 Actor actor = Actor::New();
2499 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2501 actor.RemoveConstraints();
2503 DALI_TEST_CHECK( gTestConstraintCalled == false );
2505 Stage::GetCurrent().Add( actor );
2508 // flush the queue and render once
2509 application.SendNotification();
2510 application.Render();
2512 actor.RemoveConstraints();
2514 DALI_TEST_CHECK( gTestConstraintCalled == true );
2518 int UtcDaliActorRemoveConstraintTag(void)
2520 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2521 TestApplication application;
2523 Actor actor = Actor::New();
2525 // 1. Apply Constraint1 and Constraint2, and test...
2526 unsigned int result1 = 0u;
2527 unsigned int result2 = 0u;
2529 unsigned constraint1Tag = 1u;
2530 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2531 constraint1.SetTag( constraint1Tag );
2532 constraint1.Apply();
2534 unsigned constraint2Tag = 2u;
2535 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2536 constraint2.SetTag( constraint2Tag );
2537 constraint2.Apply();
2539 Stage::GetCurrent().Add( actor );
2540 // flush the queue and render once
2541 application.SendNotification();
2542 application.Render();
2544 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2545 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2547 // 2. Remove Constraint1 and test...
2550 actor.RemoveConstraints(constraint1Tag);
2551 // make color property dirty, which will trigger constraints to be reapplied.
2552 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2553 // flush the queue and render once
2554 application.SendNotification();
2555 application.Render();
2557 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2558 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2560 // 3. Re-Apply Constraint1 and test...
2563 constraint1.Apply();
2564 // make color property dirty, which will trigger constraints to be reapplied.
2565 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2566 // flush the queue and render once
2567 application.SendNotification();
2568 application.Render();
2570 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2571 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2573 // 2. Remove Constraint2 and test...
2576 actor.RemoveConstraints(constraint2Tag);
2577 // make color property dirty, which will trigger constraints to be reapplied.
2578 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2579 // flush the queue and render once
2580 application.SendNotification();
2581 application.Render();
2583 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2584 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2586 // 2. Remove Constraint1 as well and test...
2589 actor.RemoveConstraints(constraint1Tag);
2590 // make color property dirty, which will trigger constraints to be reapplied.
2591 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2592 // flush the queue and render once
2593 application.SendNotification();
2594 application.Render();
2596 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2597 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2601 int UtcDaliActorTouchedSignal(void)
2603 TestApplication application;
2605 ResetTouchCallbacks();
2607 // get the root layer
2608 Actor actor = Stage::GetCurrent().GetRootLayer();
2609 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2611 application.SendNotification();
2612 application.Render();
2614 // connect to its touch signal
2615 actor.TouchedSignal().Connect( TestCallback );
2617 // simulate a touch event in the middle of the screen
2618 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2619 Dali::Integration::Point point;
2620 point.SetDeviceId( 1 );
2621 point.SetState( PointState::DOWN );
2622 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2623 Dali::Integration::TouchEvent touchEvent;
2624 touchEvent.AddPoint( point );
2625 application.ProcessEvent( touchEvent );
2627 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2631 int UtcDaliActorHoveredSignal(void)
2633 TestApplication application;
2635 gHoverCallBackCalled = false;
2637 // get the root layer
2638 Actor actor = Stage::GetCurrent().GetRootLayer();
2639 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2641 application.SendNotification();
2642 application.Render();
2644 // connect to its hover signal
2645 actor.HoveredSignal().Connect( TestCallback3 );
2647 // simulate a hover event in the middle of the screen
2648 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2649 Dali::Integration::Point point;
2650 point.SetDeviceId( 1 );
2651 point.SetState( PointState::MOTION );
2652 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2653 Dali::Integration::HoverEvent hoverEvent;
2654 hoverEvent.AddPoint( point );
2655 application.ProcessEvent( hoverEvent );
2657 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2661 int UtcDaliActorOnOffStageSignal(void)
2663 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2665 TestApplication application;
2668 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2669 gActorNamesOnOffStage.clear();
2671 Actor parent = Actor::New();
2672 parent.SetProperty( Actor::Property::NAME, "parent" );
2673 parent.OnStageSignal().Connect( OnStageCallback );
2674 parent.OffStageSignal().Connect( OffStageCallback );
2676 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2677 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2679 // add parent to stage
2680 Stage::GetCurrent().Add( parent );
2681 // onstage emitted, offstage not
2682 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2683 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2684 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2686 // test adding a child, should get onstage emitted
2688 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2689 gActorNamesOnOffStage.clear();
2691 Actor child = Actor::New();
2692 child.SetProperty( Actor::Property::NAME, "child" );
2693 child.OnStageSignal().Connect( OnStageCallback );
2694 child.OffStageSignal().Connect( OffStageCallback );
2695 parent.Add( child ); // add child
2696 // onstage emitted, offstage not
2697 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2698 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2699 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2701 // test removing parent from stage
2703 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2704 gActorNamesOnOffStage.clear();
2706 Stage::GetCurrent().Remove( parent );
2707 // onstage not emitted, offstage is
2708 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2709 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2710 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2711 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2713 // test adding parent back to stage
2715 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2716 gActorNamesOnOffStage.clear();
2718 Stage::GetCurrent().Add( parent );
2719 // onstage emitted, offstage not
2720 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2721 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2722 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2723 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2725 // test removing child
2727 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2728 gActorNamesOnOffStage.clear();
2730 parent.Remove( child );
2731 // onstage not emitted, offstage is
2732 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2733 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2734 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2736 // test removing parent
2738 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2739 gActorNamesOnOffStage.clear();
2741 Stage::GetCurrent().Remove( parent );
2742 // onstage not emitted, offstage is
2743 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2744 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2745 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2749 int UtcDaliActorFindChildByName(void)
2751 tet_infoline("Testing Dali::Actor::FindChildByName()");
2752 TestApplication application;
2754 Actor parent = Actor::New();
2755 parent.SetProperty( Actor::Property::NAME, "parent" );
2756 Actor first = Actor::New();
2757 first .SetProperty( Actor::Property::NAME, "first" );
2758 Actor second = Actor::New();
2759 second.SetProperty( Actor::Property::NAME, "second" );
2764 Actor found = parent.FindChildByName( "foo" );
2765 DALI_TEST_CHECK( !found );
2767 found = parent.FindChildByName( "parent" );
2768 DALI_TEST_CHECK( found == parent );
2770 found = parent.FindChildByName( "first" );
2771 DALI_TEST_CHECK( found == first );
2773 found = parent.FindChildByName( "second" );
2774 DALI_TEST_CHECK( found == second );
2778 int UtcDaliActorFindChildById(void)
2780 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2781 TestApplication application;
2783 Actor parent = Actor::New();
2784 Actor first = Actor::New();
2785 Actor second = Actor::New();
2790 Actor found = parent.FindChildById( 100000 );
2791 DALI_TEST_CHECK( !found );
2793 found = parent.FindChildById( parent.GetId() );
2794 DALI_TEST_CHECK( found == parent );
2796 found = parent.FindChildById( first.GetId() );
2797 DALI_TEST_CHECK( found == first );
2799 found = parent.FindChildById( second.GetId() );
2800 DALI_TEST_CHECK( found == second );
2804 int UtcDaliActorHitTest(void)
2809 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2811 mTouchPoint( touchPoint ),
2816 Vector2 mTouchPoint;
2820 TestApplication application;
2821 tet_infoline(" UtcDaliActorHitTest");
2823 // Fill a vector with different hit tests.
2824 struct HitTestData* hitTestData[] = {
2825 // scale touch point result
2826 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2827 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2828 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.
2829 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2830 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.
2834 // get the root layer
2835 Actor actor = Actor::New();
2836 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2837 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2839 Stage::GetCurrent().Add( actor );
2841 ResetTouchCallbacks();
2843 unsigned int index = 0;
2844 while( NULL != hitTestData[index] )
2846 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.f, 1.f ) );
2847 actor.SetProperty( Actor::Property::SCALE, Vector3( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z ) );
2849 // flush the queue and render once
2850 application.SendNotification();
2851 application.Render();
2853 DALI_TEST_CHECK( !gTouchCallBackCalled );
2855 // connect to its touch signal
2856 actor.TouchedSignal().Connect(TestCallback);
2858 Dali::Integration::Point point;
2859 point.SetState( PointState::DOWN );
2860 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2861 Dali::Integration::TouchEvent event;
2862 event.AddPoint( point );
2864 // flush the queue and render once
2865 application.SendNotification();
2866 application.Render();
2867 application.ProcessEvent( event );
2869 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2871 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2872 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2873 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2874 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2875 hitTestData[index]->mResult );
2877 ResetTouchCallbacks();
2883 int UtcDaliActorSetDrawMode(void)
2885 TestApplication app;
2886 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2888 Actor a = Actor::New();
2890 Stage::GetCurrent().Add(a);
2891 app.SendNotification();
2893 app.SendNotification();
2896 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Ensure overlay is off by default
2898 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
2899 app.SendNotification();
2902 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is overlay
2904 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
2905 app.SendNotification();
2908 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is normal
2912 int UtcDaliActorSetDrawModeOverlayRender(void)
2914 TestApplication app;
2915 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2917 app.SendNotification();
2920 std::vector<GLuint> ids;
2921 ids.push_back( 8 ); // first rendered actor
2922 ids.push_back( 9 ); // second rendered actor
2923 ids.push_back( 10 ); // third rendered actor
2924 app.GetGlAbstraction().SetNextTextureIds( ids );
2926 BufferImage imageA = BufferImage::New(16, 16);
2927 BufferImage imageB = BufferImage::New(16, 16);
2928 BufferImage imageC = BufferImage::New(16, 16);
2929 Actor a = CreateRenderableActor( imageA );
2930 Actor b = CreateRenderableActor( imageB );
2931 Actor c = CreateRenderableActor( imageC );
2933 app.SendNotification();
2936 //Textures are bound when first created. Clear bound textures vector
2937 app.GetGlAbstraction().ClearBoundTextures();
2939 // Render a,b,c as regular non-overlays. so order will be:
2943 Stage::GetCurrent().Add(a);
2944 Stage::GetCurrent().Add(b);
2945 Stage::GetCurrent().Add(c);
2947 app.SendNotification();
2950 // Should be 3 textures changes.
2951 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2952 typedef std::vector<GLuint>::size_type TextureSize;
2953 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2954 if( boundTextures.size() == 3 )
2956 DALI_TEST_CHECK( boundTextures[0] == 8u );
2957 DALI_TEST_CHECK( boundTextures[1] == 9u );
2958 DALI_TEST_CHECK( boundTextures[2] == 10u );
2961 // Now texture ids have been set, we can monitor their render order.
2962 // render a as an overlay (last), so order will be:
2966 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
2967 app.GetGlAbstraction().ClearBoundTextures();
2969 app.SendNotification();
2972 // Should be 3 texture changes.
2973 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2974 if( boundTextures.size() == 3 )
2976 DALI_TEST_CHECK( boundTextures[0] == 9u );
2977 DALI_TEST_CHECK( boundTextures[1] == 10u );
2978 DALI_TEST_CHECK( boundTextures[2] == 8u );
2983 int UtcDaliActorGetCurrentWorldMatrix(void)
2985 TestApplication app;
2986 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2988 Actor parent = Actor::New();
2989 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
2990 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
2991 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2992 Radian rotationAngle(Degree(85.0f));
2993 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2994 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2995 parent.SetProperty( Actor::Property::POSITION, parentPosition );
2996 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
2997 parent.SetProperty( Actor::Property::SCALE, parentScale );
2998 Stage::GetCurrent().Add( parent );
3000 Actor child = Actor::New();
3001 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3002 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
3003 Radian childRotationAngle(Degree(23.0f));
3004 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
3005 Vector3 childScale( 2.0f, 2.0f, 2.0f );
3006 child.SetProperty( Actor::Property::POSITION, childPosition );
3007 child.SetProperty( Actor::Property::ORIENTATION, childRotation );
3008 child.SetProperty( Actor::Property::SCALE, childScale );
3009 parent.Add( child );
3011 app.SendNotification();
3014 app.SendNotification();
3016 Matrix parentMatrix(false);
3017 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3019 Matrix childMatrix(false);
3020 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
3022 //Child matrix should be the composition of child and parent
3023 Matrix childWorldMatrix(false);
3024 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
3026 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3027 DALI_TEST_EQUALS( child.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), childWorldMatrix, 0.001, TEST_LOCATION );
3033 int UtcDaliActorConstrainedToWorldMatrix(void)
3035 TestApplication app;
3036 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3038 Actor parent = Actor::New();
3039 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3040 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3041 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3042 Radian rotationAngle(Degree(85.0f));
3043 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3044 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3045 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3046 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3047 parent.SetProperty( Actor::Property::SCALE, parentScale );
3048 Stage::GetCurrent().Add( parent );
3050 Actor child = Actor::New();
3051 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3052 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3053 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3054 posConstraint.Apply();
3056 Stage::GetCurrent().Add( child );
3058 app.SendNotification();
3061 app.SendNotification();
3063 Matrix parentMatrix(false);
3064 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3066 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3067 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), 0.001, TEST_LOCATION );
3071 int UtcDaliActorConstrainedToOrientation(void)
3073 TestApplication app;
3074 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3076 Actor parent = Actor::New();
3077 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3078 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3079 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3080 Radian rotationAngle(Degree(85.0f));
3081 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3082 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3083 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3084 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3085 parent.SetProperty( Actor::Property::SCALE, parentScale );
3086 Stage::GetCurrent().Add( parent );
3088 Actor child = Actor::New();
3089 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3090 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3091 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3092 posConstraint.Apply();
3094 Stage::GetCurrent().Add( child );
3096 app.SendNotification();
3099 app.SendNotification();
3101 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION );
3105 int UtcDaliActorConstrainedToOpacity(void)
3107 TestApplication app;
3108 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3110 Actor parent = Actor::New();
3111 parent.SetProperty( DevelActor::Property::OPACITY, 0.7f );
3112 Stage::GetCurrent().Add( parent );
3114 Actor child = Actor::New();
3115 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3116 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3117 opacityConstraint.Apply();
3119 Stage::GetCurrent().Add( child );
3121 app.SendNotification();
3124 app.SendNotification();
3126 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), parent.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3128 parent.SetProperty( DevelActor::Property::OPACITY, 0.3f );
3130 app.SendNotification();
3133 app.SendNotification();
3135 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), parent.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3140 int UtcDaliActorUnparent(void)
3142 TestApplication app;
3143 tet_infoline(" UtcDaliActorUnparent");
3145 Actor parent = Actor::New();
3146 Stage::GetCurrent().Add( parent );
3148 Actor child = Actor::New();
3150 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3151 DALI_TEST_CHECK( !child.GetParent() );
3153 // Test that calling Unparent with no parent is a NOOP
3156 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3157 DALI_TEST_CHECK( !child.GetParent() );
3159 // Test that Unparent works
3160 parent.Add( child );
3162 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3163 DALI_TEST_CHECK( parent == child.GetParent() );
3167 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3168 DALI_TEST_CHECK( !child.GetParent() );
3170 // Test that UnparentAndReset works
3171 parent.Add( child );
3173 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3174 DALI_TEST_CHECK( parent == child.GetParent() );
3176 UnparentAndReset( child );
3178 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3179 DALI_TEST_CHECK( !child );
3181 // Test that UnparentAndReset is a NOOP with empty handle
3182 UnparentAndReset( child );
3184 DALI_TEST_CHECK( !child );
3188 int UtcDaliActorGetChildAt(void)
3190 TestApplication app;
3191 tet_infoline(" UtcDaliActorGetChildAt");
3193 Actor parent = Actor::New();
3194 Stage::GetCurrent().Add( parent );
3196 Actor child0 = Actor::New();
3197 parent.Add( child0 );
3199 Actor child1 = Actor::New();
3200 parent.Add( child1 );
3202 Actor child2 = Actor::New();
3203 parent.Add( child2 );
3205 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3206 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3207 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3211 int UtcDaliActorSetGetOverlay(void)
3213 TestApplication app;
3214 tet_infoline(" UtcDaliActorSetGetOverlay");
3216 Actor parent = Actor::New();
3217 parent.SetProperty( Actor::Property::DRAW_MODE,DrawMode::OVERLAY_2D );
3218 DALI_TEST_CHECK( parent.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) == DrawMode::OVERLAY_2D );
3223 int UtcDaliActorCreateDestroy(void)
3225 Actor* actor = new Actor;
3226 DALI_TEST_CHECK( actor );
3233 struct PropertyStringIndex
3235 const char * const name;
3236 const Property::Index index;
3237 const Property::Type type;
3240 const PropertyStringIndex PROPERTY_TABLE[] =
3242 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3243 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3244 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3245 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3246 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3247 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3248 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3249 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3250 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3251 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3252 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3253 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3254 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3255 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3256 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3257 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3258 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3259 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3260 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3261 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3262 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3263 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3264 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3265 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3266 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3267 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3268 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3269 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3270 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3271 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3272 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3273 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3274 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3275 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3276 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3277 { "name", Actor::Property::NAME, Property::STRING },
3278 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3279 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3280 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3281 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3282 { "colorMode", Actor::Property::COLOR_MODE, Property::INTEGER },
3283 { "drawMode", Actor::Property::DRAW_MODE, Property::INTEGER },
3284 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3285 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3286 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3287 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER },
3288 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3289 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3290 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3291 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3292 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3293 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3294 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3295 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3297 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3298 } // unnamed namespace
3300 int UtcDaliActorProperties(void)
3302 TestApplication app;
3304 Actor actor = Actor::New();
3306 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3308 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3309 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3310 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3311 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3316 int UtcDaliRelayoutProperties_ResizePolicies(void)
3318 TestApplication app;
3320 Actor actor = Actor::New();
3323 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3324 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3326 // Set resize policy for all dimensions
3327 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3328 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3330 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3333 // Set individual dimensions
3334 const char* const widthPolicy = "FILL_TO_PARENT";
3335 const char* const heightPolicy = "FIXED";
3337 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3338 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3340 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3341 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3343 // Set individual dimensions using enums
3344 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3345 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3347 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3348 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3350 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3351 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3356 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3358 TestApplication app;
3360 Actor actor = Actor::New();
3363 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3365 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3366 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy );
3367 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy, TEST_LOCATION );
3370 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3371 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3373 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3374 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy1, TEST_LOCATION );
3376 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3377 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy2, TEST_LOCATION );
3382 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3384 TestApplication app;
3386 Actor actor = Actor::New();
3389 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3390 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3392 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3393 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode );
3394 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), sizeMode, TEST_LOCATION );
3397 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3399 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3400 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3405 int UtcDaliRelayoutProperties_DimensionDependency(void)
3407 TestApplication app;
3409 Actor actor = Actor::New();
3412 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3413 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3416 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3417 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3419 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3420 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3422 // Test setting another resize policy
3423 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3424 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3429 int UtcDaliRelayoutProperties_Padding(void)
3431 TestApplication app;
3433 Actor actor = Actor::New();
3436 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3439 actor.SetProperty( Actor::Property::PADDING, padding );
3440 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3442 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3447 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3449 TestApplication app;
3451 Actor actor = Actor::New();
3454 Vector2 minSize( 1.0f, 2.0f );
3456 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3457 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3459 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3461 Vector2 maxSize( 3.0f, 4.0f );
3463 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3464 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3466 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3471 int UtcDaliActorGetHeightForWidth(void)
3473 TestApplication app;
3475 Actor actor = Actor::New();
3477 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3482 int UtcDaliActorGetWidthForHeight(void)
3484 TestApplication app;
3486 Actor actor = Actor::New();
3488 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3493 int UtcDaliActorGetRelayoutSize(void)
3495 TestApplication app;
3497 Actor actor = Actor::New();
3499 // Add actor to stage
3500 Stage::GetCurrent().Add( actor );
3502 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3504 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3505 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 0.0f ) );
3507 // Flush the queue and render once
3508 app.SendNotification();
3511 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3516 int UtcDaliActorSetPadding(void)
3518 TestApplication app;
3520 Actor actor = Actor::New();
3523 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3525 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3526 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3527 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3528 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3530 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3531 actor.SetProperty( Actor::Property::PADDING, padding2 );
3533 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3535 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3536 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3537 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3538 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3543 int UtcDaliActorSetMinimumSize(void)
3545 TestApplication app;
3547 Actor actor = Actor::New();
3549 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3551 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3552 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3554 Vector2 size2( 1.0f, 2.0f );
3555 actor.SetProperty( Actor::Property::MINIMUM_SIZE, size2 );
3557 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3559 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3560 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3565 int UtcDaliActorSetMaximumSize(void)
3567 TestApplication app;
3569 Actor actor = Actor::New();
3571 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3573 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3574 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3576 Vector2 size2( 1.0f, 2.0f );
3577 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, size2 );
3579 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3581 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3582 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3587 int UtcDaliActorOnRelayoutSignal(void)
3589 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3591 TestApplication application;
3594 gOnRelayoutCallBackCalled = false;
3595 gActorNamesRelayout.clear();
3597 Actor actor = Actor::New();
3598 actor.SetProperty( Actor::Property::NAME, "actor" );
3599 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3602 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3604 // Add actor to stage
3605 Stage::GetCurrent().Add( actor );
3607 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3608 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 2.0 ) );
3610 // Flush the queue and render once
3611 application.SendNotification();
3612 application.Render();
3614 // OnRelayout emitted
3615 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3616 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3621 int UtcDaliActorGetHierachyDepth(void)
3623 TestApplication application;
3624 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3627 /* Build tree of actors:
3637 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3639 Stage stage( Stage::GetCurrent() );
3641 Actor actorA = Actor::New();
3642 Actor actorB = Actor::New();
3643 Actor actorC = Actor::New();
3644 Actor actorD = Actor::New();
3645 Actor actorE = Actor::New();
3646 Actor actorF = Actor::New();
3648 //Test that root actor has depth equal 0
3649 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3651 //Test actors return depth -1 when not connected to the tree
3652 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3653 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3654 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3655 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3656 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3657 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3659 //Create the hierarchy
3660 stage.Add( actorA );
3661 actorA.Add( actorB );
3662 actorA.Add( actorC );
3663 actorB.Add( actorD );
3664 actorB.Add( actorE );
3665 actorC.Add( actorF );
3667 //Test actors return correct depth
3668 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3669 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3670 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3671 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3672 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3673 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3675 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3676 actorA.Remove( actorB );
3678 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3679 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3680 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3682 //Removing actorA from the stage. All actors should have depth equal -1
3683 stage.Remove( actorA );
3685 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3686 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3687 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3688 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3689 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3690 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3695 int UtcDaliActorAnchorPointPropertyAsString(void)
3697 TestApplication application;
3699 Actor actor = Actor::New();
3701 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3702 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3704 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3705 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3707 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3708 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3710 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3711 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3713 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3714 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER, TEST_LOCATION );
3716 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3717 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3719 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3720 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3722 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3723 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3725 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3726 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3728 // Invalid should not change anything
3729 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3730 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3735 int UtcDaliActorParentOriginPropertyAsString(void)
3737 TestApplication application;
3739 Actor actor = Actor::New();
3741 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3742 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3744 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3745 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3747 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3748 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3750 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3751 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3753 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3754 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER, TEST_LOCATION );
3756 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3757 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3759 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3760 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3762 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3763 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3765 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3766 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3768 // Invalid should not change anything
3769 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3770 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3775 int UtcDaliActorColorModePropertyAsString(void)
3777 TestApplication application;
3779 Actor actor = Actor::New();
3781 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3782 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3784 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3785 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3787 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3788 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3790 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3791 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3793 // Invalid should not change anything
3794 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3795 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3800 int UtcDaliActorDrawModePropertyAsString(void)
3802 TestApplication application;
3804 Actor actor = Actor::New();
3806 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3807 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3809 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3810 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3812 // Invalid should not change anything
3813 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3814 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3819 int UtcDaliActorColorModePropertyAsEnum(void)
3821 TestApplication application;
3823 Actor actor = Actor::New();
3825 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3826 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3828 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3829 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3831 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3832 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3834 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3835 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3840 int UtcDaliActorDrawModePropertyAsEnum(void)
3842 TestApplication application;
3844 Actor actor = Actor::New();
3846 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3847 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3849 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3850 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3855 int UtcDaliActorAddRendererP(void)
3857 tet_infoline("Testing Actor::AddRenderer");
3858 TestApplication application;
3860 Actor actor = Actor::New();
3862 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3864 Geometry geometry = CreateQuadGeometry();
3865 Shader shader = CreateShader();
3866 Renderer renderer = Renderer::New(geometry, shader);
3868 actor.AddRenderer( renderer );
3869 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3870 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3875 int UtcDaliActorAddRendererN(void)
3877 tet_infoline("Testing Actor::AddRenderer");
3878 TestApplication application;
3880 Actor actor = Actor::New();
3886 actor.AddRenderer( renderer );
3887 tet_printf("Assertion test failed - no Exception\n" );
3888 tet_result(TET_FAIL);
3890 catch(Dali::DaliException& e)
3892 DALI_TEST_PRINT_ASSERT( e );
3893 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3894 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3898 tet_printf("Assertion test failed - wrong Exception\n" );
3899 tet_result(TET_FAIL);
3905 int UtcDaliActorAddRendererOnStage(void)
3907 tet_infoline("Testing Actor::AddRenderer");
3908 TestApplication application;
3910 Actor actor = Actor::New();
3911 Stage::GetCurrent().Add(actor);
3913 application.SendNotification();
3914 application.Render(0);
3916 Geometry geometry = CreateQuadGeometry();
3917 Shader shader = CreateShader();
3918 Renderer renderer = Renderer::New(geometry, shader);
3920 application.SendNotification();
3921 application.Render(0);
3925 actor.AddRenderer( renderer );
3926 tet_result(TET_PASS);
3930 tet_result(TET_FAIL);
3936 int UtcDaliActorRemoveRendererP1(void)
3938 tet_infoline("Testing Actor::RemoveRenderer");
3939 TestApplication application;
3941 Actor actor = Actor::New();
3943 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3946 Geometry geometry = CreateQuadGeometry();
3947 Shader shader = CreateShader();
3948 Renderer renderer = Renderer::New(geometry, shader);
3950 actor.AddRenderer( renderer );
3951 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3952 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3954 application.SendNotification();
3955 application.Render();
3959 Renderer renderer = actor.GetRendererAt(0);
3960 actor.RemoveRenderer(renderer);
3961 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3963 application.SendNotification();
3964 application.Render();
3967 // Call one final time to ensure that the renderer is actually removed after
3968 // the handle goes out of scope, and excercises the deletion code path in
3969 // scene graph and render.
3970 application.SendNotification();
3971 application.Render();
3976 int UtcDaliActorRemoveRendererP2(void)
3978 tet_infoline("Testing Actor::RemoveRenderer");
3979 TestApplication application;
3981 Actor actor = Actor::New();
3983 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3985 Geometry geometry = CreateQuadGeometry();
3986 Shader shader = CreateShader();
3987 Renderer renderer = Renderer::New(geometry, shader);
3989 actor.AddRenderer( renderer );
3990 application.SendNotification();
3991 application.Render();
3993 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3994 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3996 actor.RemoveRenderer(0);
3997 application.SendNotification();
3998 application.Render();
4000 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4002 // Shut down whilst holding onto the renderer handle.
4007 int UtcDaliActorRemoveRendererN(void)
4009 tet_infoline("Testing Actor::RemoveRenderer");
4010 TestApplication application;
4012 Actor actor = Actor::New();
4014 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4016 Geometry geometry = CreateQuadGeometry();
4017 Shader shader = CreateShader();
4018 Renderer renderer = Renderer::New(geometry, shader);
4020 actor.AddRenderer( renderer );
4021 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4022 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4024 actor.RemoveRenderer(10);
4025 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4026 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4031 // Clipping test helper functions:
4032 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4034 BufferImage image = BufferImage::New( width, height );
4035 Actor actor = CreateRenderableActor( image );
4037 // Setup dimensions and position so actor is not skipped by culling.
4038 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4039 actor.SetProperty( Actor::Property::SIZE, Vector2( width, height ) );
4040 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4041 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4046 Actor CreateActorWithContent16x16()
4048 return CreateActorWithContent( 16, 16 );
4051 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4053 enabledDisableTrace.Reset();
4054 stencilTrace.Reset();
4055 enabledDisableTrace.Enable( true );
4056 stencilTrace.Enable( true );
4058 application.SendNotification();
4059 application.Render();
4061 enabledDisableTrace.Enable( false );
4062 stencilTrace.Enable( false );
4065 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4067 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4069 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4070 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4071 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4072 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4075 int UtcDaliActorPropertyClippingP(void)
4077 // This test checks the clippingMode property.
4078 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4079 TestApplication application;
4081 Actor actor = Actor::New();
4083 // Check default clippingEnabled value.
4084 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4087 bool getValueResult = getValue.Get( value );
4088 DALI_TEST_CHECK( getValueResult );
4090 if( getValueResult )
4092 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4095 // Check setting the property to the stencil mode.
4096 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4098 // Check the new value was set.
4099 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4100 getValueResult = getValue.Get( value );
4101 DALI_TEST_CHECK( getValueResult );
4103 if( getValueResult )
4105 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4108 // Check setting the property to the scissor mode.
4109 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4111 // Check the new value was set.
4112 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4113 getValueResult = getValue.Get( value );
4114 DALI_TEST_CHECK( getValueResult );
4116 if( getValueResult )
4118 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4123 int UtcDaliActorPropertyClippingN(void)
4125 // Negative test case for Clipping.
4126 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4127 TestApplication application;
4129 Actor actor = Actor::New();
4131 // Check default clippingEnabled value.
4132 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4135 bool getValueResult = getValue.Get( value );
4136 DALI_TEST_CHECK( getValueResult );
4138 if( getValueResult )
4140 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4143 // Check setting an invalid property value won't change the current property value.
4144 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4146 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4147 getValueResult = getValue.Get( value );
4148 DALI_TEST_CHECK( getValueResult );
4150 if( getValueResult )
4152 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4158 int UtcDaliActorPropertyClippingActor(void)
4160 // This test checks that an actor is correctly setup for clipping.
4161 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4162 TestApplication application;
4164 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4165 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4166 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4167 size_t startIndex = 0u;
4169 // Create a clipping actor.
4170 Actor actorDepth1Clip = CreateActorWithContent16x16();
4171 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4172 Stage::GetCurrent().Add( actorDepth1Clip );
4174 // Gather the call trace.
4175 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4177 // Check we are writing to the color buffer.
4178 CheckColorMask( glAbstraction, true );
4180 // Check the stencil buffer was enabled.
4181 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4183 // Check the stencil buffer was cleared.
4184 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4186 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4187 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4188 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4189 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4194 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4196 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4197 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4198 TestApplication application;
4200 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4201 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4202 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4203 size_t startIndex = 0u;
4205 // Create a clipping actor.
4206 Actor actorDepth1Clip = CreateActorWithContent16x16();
4207 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4208 Stage::GetCurrent().Add( actorDepth1Clip );
4210 // Gather the call trace.
4211 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4213 // Check we are writing to the color buffer.
4214 CheckColorMask( glAbstraction, true );
4216 // Check the stencil buffer was enabled.
4217 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4219 // Check the stencil buffer was cleared.
4220 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4222 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4223 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4224 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4225 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4227 // Now disable the clipping
4228 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4230 // Gather the call trace.
4231 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4233 // Check the stencil buffer was disabled.
4234 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4236 // Ensure all values in stencil-mask are set to 1.
4238 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4243 int UtcDaliActorPropertyClippingNestedChildren(void)
4245 // This test checks that a hierarchy of actors are clipped correctly by
4246 // writing to and reading from the correct bit-planes of the stencil buffer.
4247 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4248 TestApplication application;
4249 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4250 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4251 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4253 // Create a clipping actor.
4254 Actor actorDepth1Clip = CreateActorWithContent16x16();
4255 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4256 Stage::GetCurrent().Add( actorDepth1Clip );
4258 // Create a child actor.
4259 Actor childDepth2 = CreateActorWithContent16x16();
4260 actorDepth1Clip.Add( childDepth2 );
4262 // Create another clipping actor.
4263 Actor childDepth2Clip = CreateActorWithContent16x16();
4264 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4265 childDepth2.Add( childDepth2Clip );
4267 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4268 // This tests the sort algorithm.
4269 Actor childDepth3 = CreateActorWithContent16x16();
4270 childDepth2Clip.Add( childDepth3 );
4271 Actor childDepth4 = CreateActorWithContent16x16();
4272 childDepth3.Add( childDepth4 );
4274 // Gather the call trace.
4275 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4277 // Check we are writing to the color buffer.
4278 CheckColorMask( glAbstraction, true );
4280 // Check the stencil buffer was enabled.
4281 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4283 // Perform the test twice, once for 2D layer, and once for 3D.
4284 for( unsigned int i = 0u ; i < 2u; ++i )
4286 size_t startIndex = 0u;
4288 // Check the stencil buffer was cleared.
4289 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4291 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4292 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4293 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4294 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4296 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4297 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4298 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4300 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4301 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4302 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4303 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4305 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4306 // (Both must be set to pass the check).
4307 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4308 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4310 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4313 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4314 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4321 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4323 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4324 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4325 TestApplication application;
4326 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4327 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4329 /* We create a small tree of actors as follows:
4333 Clipping enabled -> B D
4337 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4340 for( int i = 0; i < 5; ++i )
4342 BufferImage image = BufferImage::New( 16u, 16u );
4343 Actor actor = CreateRenderableActor( image );
4345 // Setup dimensions and position so actor is not skipped by culling.
4346 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4347 actor.SetProperty( Actor::Property::SIZE, Vector2( 16.0f, 16.0f ) );
4351 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4355 float b = i > 2 ? 1.0f : -1.0f;
4356 actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4362 // Enable clipping on the actor at the top of the left branch.
4363 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4365 // Build the scene graph.
4366 Stage::GetCurrent().Add( actors[0] );
4369 actors[0].Add( actors[1] );
4370 actors[1].Add( actors[2] );
4373 actors[0].Add( actors[3] );
4374 actors[3].Add( actors[4] );
4376 // Gather the call trace.
4377 enabledDisableTrace.Reset();
4378 enabledDisableTrace.Enable( true );
4379 application.SendNotification();
4380 application.Render();
4381 enabledDisableTrace.Enable( false );
4383 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4385 Note: Correct enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
4386 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4388 size_t startIndex = 0u;
4389 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4390 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4391 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4393 // Swap the clipping actor from top of left branch to top of right branch.
4394 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4395 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4397 // Gather the call trace.
4398 enabledDisableTrace.Reset();
4399 enabledDisableTrace.Enable( true );
4400 application.SendNotification();
4401 application.Render();
4402 enabledDisableTrace.Enable( false );
4404 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4405 // This proves the draw order has remained the same.
4407 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4408 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4413 int UtcDaliActorPropertyScissorClippingActor(void)
4415 // This test checks that an actor is correctly setup for clipping.
4416 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4417 TestApplication application;
4419 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4420 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4421 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4423 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4424 const Vector2 imageSize( 16.0f, 16.0f );
4426 // Create a clipping actor.
4427 Actor clippingActorA = CreateActorWithContent16x16();
4428 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4429 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4430 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
4431 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
4432 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4433 Stage::GetCurrent().Add( clippingActorA );
4435 // Gather the call trace.
4436 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4438 // Check we are writing to the color buffer.
4439 CheckColorMask( glAbstraction, true );
4441 // Check scissor test was enabled.
4442 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4444 // Check the scissor was set, and the coordinates are correct.
4445 std::stringstream compareParametersString;
4446 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4447 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4449 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
4450 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT );
4452 // Gather the call trace.
4453 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4455 // Check the scissor was set, and the coordinates are correct.
4456 compareParametersString.str( std::string() );
4457 compareParametersString.clear();
4458 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4459 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4464 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4466 // This test checks that an actor is correctly setup for clipping.
4467 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4468 TestApplication application;
4471 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4472 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4473 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4475 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4476 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4477 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4479 // Create a clipping actors.
4480 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4481 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4483 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4484 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4485 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4487 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4488 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4489 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4491 clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4492 clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4494 Stage::GetCurrent().Add( clippingActorA );
4495 Stage::GetCurrent().Add( clippingActorB );
4497 // Gather the call trace.
4498 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4500 // Check we are writing to the color buffer.
4501 CheckColorMask( glAbstraction, true );
4503 // Check scissor test was enabled.
4504 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4506 // Check the scissor was set, and the coordinates are correct.
4507 std::stringstream compareParametersString;
4509 std::string clipA( "0, 500, 480, 200" );
4510 std::string clipB( "0, 380, 480, 40" );
4512 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4513 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4518 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4520 // This test checks that an actor is correctly setup for clipping.
4521 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4522 TestApplication application;
4524 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4525 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4526 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4528 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4529 const Vector2 imageSize( 16.0f, 16.0f );
4531 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4533 A is drawn first - with scissor clipping on
4534 B is drawn second - also with scissor clipping on
4535 C is the generated clipping region, the intersection ( A ∩ B )
4539 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4540 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4541 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4545 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4548 // Create a clipping actor.
4549 Actor clippingActorA = CreateActorWithContent16x16();
4550 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4551 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4552 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4553 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4554 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4555 Stage::GetCurrent().Add( clippingActorA );
4557 // Create a child clipping actor.
4558 Actor clippingActorB = CreateActorWithContent16x16();
4559 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4560 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4561 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4562 clippingActorA.Add( clippingActorB );
4564 // positionModifiers is an array of positions to position B around.
4565 // expect is an array of expected scissor clip coordinate results.
4566 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4567 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4569 // Loop through each overlap combination.
4570 for( unsigned int test = 0u; test < 4u; ++test )
4572 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4573 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4574 clippingActorB.SetProperty( Actor::Property::POSITION, Vector2( position.x, position.y ));
4576 // Gather the call trace.
4577 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4579 // Check we are writing to the color buffer.
4580 CheckColorMask( glAbstraction, true );
4582 // Check scissor test was enabled.
4583 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4585 // Check the scissor was set, and the coordinates are correct.
4586 const Vector4& expectResults( expect[test] );
4587 std::stringstream compareParametersString;
4588 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4589 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4595 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4597 // This test checks that an actor is correctly setup for clipping.
4598 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4599 TestApplication application;
4601 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4602 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4603 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4605 /* Create a nest of 2 scissors and siblings of the parent.
4615 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4616 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4617 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4618 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4619 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4620 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4622 // Create a clipping actors.
4623 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4624 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4625 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4626 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4627 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4629 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4630 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4631 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4633 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4634 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4635 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4637 clippingActorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4638 clippingActorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4639 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4641 clippingActorD.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4642 clippingActorD.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4643 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4645 clippingActorE.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4646 clippingActorE.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4648 clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4649 clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4650 clippingActorC.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 100.0f, 0.0f ));
4651 clippingActorD.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4652 clippingActorE.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4654 Stage::GetCurrent().Add( clippingActorA );
4655 clippingActorA.Add( clippingActorB );
4656 Stage::GetCurrent().Add( clippingActorC );
4657 Stage::GetCurrent().Add( clippingActorD );
4658 clippingActorD.Add( clippingActorE );
4660 // Gather the call trace.
4661 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4663 // Check we are writing to the color buffer.
4664 CheckColorMask( glAbstraction, true );
4666 // Check scissor test was enabled.
4667 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4669 // Check the scissor was set, and the coordinates are correct.
4670 std::string clipA( "0, 500, 480, 200" );
4671 std::string clipB( "0, 580, 480, 40" );
4672 std::string clipC( "0, 200, 480, 200" );
4673 std::string clipD( "0, 300, 480, 200" );
4675 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4676 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4677 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4678 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4679 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4684 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4686 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4687 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4688 TestApplication application;
4690 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4691 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4692 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4694 // Create a clipping actor.
4695 Actor actorDepth1Clip = CreateActorWithContent16x16();
4696 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4697 Stage::GetCurrent().Add( actorDepth1Clip );
4699 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4700 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4702 // Gather the call trace.
4703 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4705 // Check we are writing to the color buffer.
4706 CheckColorMask( glAbstraction, true );
4708 // Check the stencil buffer was not enabled.
4709 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4711 // Check stencil functions are not called.
4712 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4713 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4714 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4716 // Check that scissor clipping is overriden by the renderer properties.
4717 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4719 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4721 // Gather the call trace.
4722 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4724 // Check the stencil buffer was not enabled.
4725 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4727 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4732 int UtcDaliGetPropertyN(void)
4734 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4735 TestApplication app;
4737 Actor actor = Actor::New();
4739 unsigned int propertyCount = actor.GetPropertyCount();
4740 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4744 int UtcDaliActorRaiseLower(void)
4746 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4748 TestApplication application;
4750 Debug::Filter::SetGlobalLogLevel( Debug::Verbose );
4752 Stage stage( Stage::GetCurrent() );
4754 Actor actorA = Actor::New();
4755 Actor actorB = Actor::New();
4756 Actor actorC = Actor::New();
4758 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4759 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4761 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4762 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4764 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4765 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4767 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4768 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4770 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4771 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4773 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4774 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4776 stage.Add( actorA );
4777 stage.Add( actorB );
4778 stage.Add( actorC );
4780 ResetTouchCallbacks();
4782 application.SendNotification();
4783 application.Render();
4785 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4786 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4787 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4789 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4790 // Only top actor will get touched.
4791 actorA.TouchSignal().Connect( TestTouchCallback );
4792 actorB.TouchSignal().Connect( TestTouchCallback2 );
4793 actorC.TouchSignal().Connect( TestTouchCallback3 );
4795 // Connect ChildOrderChangedSignal
4796 bool orderChangedSignal( false );
4797 Actor orderChangedActor;
4798 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4799 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4801 Dali::Integration::Point point;
4802 point.SetDeviceId( 1 );
4803 point.SetState( PointState::DOWN );
4804 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4805 Dali::Integration::TouchEvent touchEvent;
4806 touchEvent.AddPoint( point );
4808 application.ProcessEvent( touchEvent );
4810 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4811 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4812 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4814 ResetTouchCallbacks();
4816 tet_printf( "Testing Raising of Actor\n" );
4818 int preActorOrder( 0 );
4819 int postActorOrder( 0 );
4821 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4822 value.Get( preActorOrder );
4824 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4826 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4827 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4829 // Ensure sort order is calculated before next touch event
4830 application.SendNotification();
4832 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4833 value.Get( postActorOrder );
4835 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4837 application.ProcessEvent( touchEvent );
4839 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4840 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4841 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4843 ResetTouchCallbacks();
4845 tet_printf( "Testing Lowering of Actor\n" );
4847 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4848 value.Get( preActorOrder );
4850 orderChangedSignal = false;
4852 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4854 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4855 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4857 application.SendNotification(); // ensure sort order calculated before next touch event
4859 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4860 value.Get( postActorOrder );
4862 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4864 application.ProcessEvent( touchEvent );
4866 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4867 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4868 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4870 ResetTouchCallbacks();
4872 Debug::Filter::SetGlobalLogLevel( Debug::NoLogging );
4877 int UtcDaliActorRaiseToTopLowerToBottom(void)
4879 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4881 TestApplication application;
4883 Stage stage( Stage::GetCurrent() );
4885 Actor actorA = Actor::New();
4886 Actor actorB = Actor::New();
4887 Actor actorC = Actor::New();
4889 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4890 // enables checking of which actor the uniform is assigned too
4891 Shader shaderA = CreateShader();
4892 shaderA.RegisterProperty( "uRendererColor",1.f);
4894 Shader shaderB = CreateShader();
4895 shaderB.RegisterProperty( "uRendererColor", 2.f );
4897 Shader shaderC = CreateShader();
4898 shaderC.RegisterProperty( "uRendererColor", 3.f );
4900 Geometry geometry = CreateQuadGeometry();
4902 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4903 Renderer rendererA = Renderer::New(geometry, shaderA);
4904 actorA.AddRenderer(rendererA);
4906 Renderer rendererB = Renderer::New(geometry, shaderB);
4907 actorB.AddRenderer(rendererB);
4909 Renderer rendererC = Renderer::New(geometry, shaderC);
4910 actorC.AddRenderer(rendererC);
4912 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4913 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4915 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4916 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4918 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4919 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4921 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4922 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4924 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4925 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4927 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4928 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4930 stage.Add( actorA );
4931 stage.Add( actorB );
4932 stage.Add( actorC );
4934 ResetTouchCallbacks();
4936 // Connect ChildOrderChangedSignal
4937 bool orderChangedSignal( false );
4938 Actor orderChangedActor;
4939 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4940 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4942 // Set up gl abstraction trace so can query the set uniform order
4943 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4944 glAbstraction.EnableSetUniformCallTrace(true);
4945 glAbstraction.ResetSetUniformCallStack();
4947 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4949 application.SendNotification();
4950 application.Render();
4952 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4955 // Test order of uniforms in stack
4956 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4957 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4958 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4960 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4962 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4964 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4965 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4966 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4968 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4969 // Only top actor will get touched.
4970 actorA.TouchSignal().Connect( TestTouchCallback );
4971 actorB.TouchSignal().Connect( TestTouchCallback2 );
4972 actorC.TouchSignal().Connect( TestTouchCallback3 );
4974 Dali::Integration::Point point;
4975 point.SetDeviceId( 1 );
4976 point.SetState( PointState::DOWN );
4977 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4978 Dali::Integration::TouchEvent touchEvent;
4979 touchEvent.AddPoint( point );
4981 application.ProcessEvent( touchEvent );
4983 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4984 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4985 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4987 ResetTouchCallbacks();
4989 tet_printf( "RaiseToTop ActorA\n" );
4991 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4992 actorA.RaiseToTop();
4993 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4994 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
4996 application.SendNotification(); // ensure sorting order is calculated before next touch event
4998 application.ProcessEvent( touchEvent );
5000 glAbstraction.ResetSetUniformCallStack();
5001 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5003 application.SendNotification();
5004 application.Render();
5006 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5008 // Test order of uniforms in stack
5009 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5010 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5011 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5013 tet_infoline( "Testing A above C and B at bottom\n" );
5014 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5016 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5018 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5019 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5020 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5022 ResetTouchCallbacks();
5024 tet_printf( "RaiseToTop ActorB\n" );
5026 orderChangedSignal = false;
5028 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5029 actorB.RaiseToTop();
5030 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5031 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5033 application.SendNotification(); // Ensure sort order is calculated before next touch event
5035 application.ProcessEvent( touchEvent );
5037 glAbstraction.ResetSetUniformCallStack();
5038 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5040 application.SendNotification();
5041 application.Render();
5043 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5045 // Test order of uniforms in stack
5046 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5047 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5048 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5050 tet_infoline( "Testing B above A and C at bottom\n" );
5051 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5053 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5055 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5056 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5057 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5059 ResetTouchCallbacks();
5061 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5063 orderChangedSignal = false;
5065 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5066 actorA.LowerToBottom();
5067 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5068 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5070 application.SendNotification();
5071 application.Render();
5073 orderChangedSignal = false;
5075 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5076 actorB.LowerToBottom();
5077 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5078 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5080 application.SendNotification();
5081 application.Render();
5083 application.ProcessEvent( touchEvent );
5085 glAbstraction.ResetSetUniformCallStack();
5086 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5088 application.SendNotification();
5089 application.Render();
5091 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5093 // Test order of uniforms in stack
5094 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5095 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5096 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5098 tet_infoline( "Testing C above A and B at bottom\n" );
5099 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5101 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5103 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5104 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5105 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5107 ResetTouchCallbacks();
5112 int UtcDaliActorRaiseAbove(void)
5114 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5116 TestApplication application;
5118 Stage stage( Stage::GetCurrent() );
5120 Actor actorA = Actor::New();
5121 Actor actorB = Actor::New();
5122 Actor actorC = Actor::New();
5124 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5125 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5127 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5128 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5130 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5131 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5133 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5134 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5136 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5137 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5139 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5140 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5142 stage.Add( actorA );
5143 stage.Add( actorB );
5144 stage.Add( actorC );
5146 ResetTouchCallbacks();
5148 application.SendNotification();
5149 application.Render();
5151 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5152 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5153 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5155 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5156 // Only top actor will get touched.
5157 actorA.TouchSignal().Connect( TestTouchCallback );
5158 actorB.TouchSignal().Connect( TestTouchCallback2 );
5159 actorC.TouchSignal().Connect( TestTouchCallback3 );
5161 bool orderChangedSignal( false );
5162 Actor orderChangedActor;
5163 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5164 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5166 Dali::Integration::Point point;
5167 point.SetDeviceId( 1 );
5168 point.SetState( PointState::DOWN );
5169 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5170 Dali::Integration::TouchEvent touchEvent;
5171 touchEvent.AddPoint( point );
5173 application.ProcessEvent( touchEvent );
5175 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5176 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5177 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5179 ResetTouchCallbacks();
5181 tet_printf( "Raise actor B Above Actor C\n" );
5183 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5184 actorB.RaiseAbove( actorC );
5185 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5186 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5188 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5189 application.SendNotification();
5190 application.ProcessEvent( touchEvent );
5192 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5193 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5194 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5196 ResetTouchCallbacks();
5198 tet_printf( "Raise actor A Above Actor B\n" );
5200 orderChangedSignal = false;
5202 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5203 actorA.RaiseAbove( actorB );
5204 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5205 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5207 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5208 application.SendNotification();
5210 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5212 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5213 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5214 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5216 ResetTouchCallbacks();
5221 int UtcDaliActorLowerBelow(void)
5223 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5225 TestApplication application;
5227 Stage stage( Stage::GetCurrent() );
5229 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5230 // enables checking of which actor the uniform is assigned too
5231 Shader shaderA = CreateShader();
5232 shaderA.RegisterProperty( "uRendererColor",1.f);
5234 Shader shaderB = CreateShader();
5235 shaderB.RegisterProperty( "uRendererColor", 2.f );
5237 Shader shaderC = CreateShader();
5238 shaderC.RegisterProperty( "uRendererColor", 3.f );
5240 Actor actorA = Actor::New();
5241 Actor actorB = Actor::New();
5242 Actor actorC = Actor::New();
5244 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5245 Geometry geometry = CreateQuadGeometry();
5247 Renderer rendererA = Renderer::New(geometry, shaderA);
5248 actorA.AddRenderer(rendererA);
5250 Renderer rendererB = Renderer::New(geometry, shaderB);
5251 actorB.AddRenderer(rendererB);
5253 Renderer rendererC = Renderer::New(geometry, shaderC);
5254 actorC.AddRenderer(rendererC);
5256 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5257 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5259 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5260 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5262 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5263 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5265 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5266 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5268 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5269 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5271 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5272 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5274 Actor container = Actor::New();
5275 container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5276 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5277 stage.Add( container );
5279 container.Add( actorA );
5280 container.Add( actorB );
5281 container.Add( actorC );
5283 ResetTouchCallbacks();
5285 // Connect ChildOrderChangedSignal
5286 bool orderChangedSignal( false );
5287 Actor orderChangedActor;
5288 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5289 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5291 // Set up gl abstraction trace so can query the set uniform order
5292 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5293 glAbstraction.EnableSetUniformCallTrace(true);
5294 glAbstraction.ResetSetUniformCallStack();
5295 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5297 glAbstraction.ResetSetUniformCallStack();
5299 application.SendNotification();
5300 application.Render();
5302 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5304 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5306 // Test order of uniforms in stack
5307 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5308 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5309 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5311 tet_infoline( "Testing C above B and A at bottom\n" );
5312 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5314 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5316 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5317 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5318 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5320 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5321 // Only top actor will get touched.
5322 actorA.TouchSignal().Connect( TestTouchCallback );
5323 actorB.TouchSignal().Connect( TestTouchCallback2 );
5324 actorC.TouchSignal().Connect( TestTouchCallback3 );
5326 Dali::Integration::Point point;
5327 point.SetDeviceId( 1 );
5328 point.SetState( PointState::DOWN );
5329 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5330 Dali::Integration::TouchEvent touchEvent;
5331 touchEvent.AddPoint( point );
5333 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5335 application.ProcessEvent( touchEvent );
5337 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5338 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5339 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5341 ResetTouchCallbacks();
5343 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" );
5345 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5346 actorC.LowerBelow( actorB );
5347 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5348 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5350 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5351 application.SendNotification();
5352 application.Render();
5354 application.ProcessEvent( touchEvent ); // touch event
5356 glAbstraction.ResetSetUniformCallStack();
5357 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5359 application.SendNotification();
5360 application.Render();
5362 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5364 // Test order of uniforms in stack
5365 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5366 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5367 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5369 tet_infoline( "Testing render order is A, C, B" );
5370 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5371 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5373 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5374 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5375 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5377 ResetTouchCallbacks();
5379 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5381 orderChangedSignal = false;
5383 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5384 actorC.LowerBelow( actorA );
5385 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5386 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5388 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5389 application.SendNotification();
5390 application.Render();
5392 application.ProcessEvent( touchEvent );
5394 glAbstraction.ResetSetUniformCallStack();
5395 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5397 application.Render();
5398 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5400 // Test order of uniforms in stack
5401 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5402 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5403 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5405 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5406 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5408 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5409 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5410 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5412 ResetTouchCallbacks();
5414 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5416 orderChangedSignal = false;
5418 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5419 actorB.LowerBelow( actorC );
5420 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5421 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5423 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5424 application.SendNotification();
5425 application.Render();
5427 application.ProcessEvent( touchEvent );
5429 glAbstraction.ResetSetUniformCallStack();
5430 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5432 application.Render();
5433 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5435 // Test order of uniforms in stack
5436 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5437 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5438 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5440 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5441 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5447 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5449 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5451 TestApplication application;
5453 Stage stage( Stage::GetCurrent() );
5455 Actor parentA = Actor::New();
5456 Actor parentB = Actor::New();
5457 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5458 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5459 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5460 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5462 parentA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5463 parentA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5465 parentB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5466 parentB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5468 stage.Add( parentA );
5469 stage.Add( parentB );
5471 Actor actorA = Actor::New();
5472 Actor actorB = Actor::New();
5473 Actor actorC = Actor::New();
5475 parentA.Add( actorA );
5476 parentA.Add( actorB );
5478 tet_printf( "Actor C added to different parent from A and B \n" );
5479 parentB.Add( actorC );
5481 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5482 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5484 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5485 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5487 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5488 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5490 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5491 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5493 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5494 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5496 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5497 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5499 ResetTouchCallbacks();
5501 // Connect ChildOrderChangedSignal
5502 bool orderChangedSignal( false );
5503 Actor orderChangedActor;
5504 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5505 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5507 application.SendNotification();
5508 application.Render();
5510 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5511 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5512 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5514 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5515 // Only top actor will get touched.
5516 actorA.TouchSignal().Connect( TestTouchCallback );
5517 actorB.TouchSignal().Connect( TestTouchCallback2 );
5518 actorC.TouchSignal().Connect( TestTouchCallback3 );
5520 Dali::Integration::Point point;
5521 point.SetDeviceId( 1 );
5522 point.SetState( PointState::DOWN );
5523 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5524 Dali::Integration::TouchEvent touchEvent;
5525 touchEvent.AddPoint( point );
5527 application.ProcessEvent( touchEvent );
5529 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5530 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5531 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5533 ResetTouchCallbacks();
5535 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5537 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5538 actorA.RaiseAbove( actorC );
5539 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5541 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5542 application.SendNotification();
5544 application.ProcessEvent( touchEvent ); // touch event
5546 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5547 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5548 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5550 ResetTouchCallbacks();
5555 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5557 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5559 TestApplication application;
5561 Stage stage( Stage::GetCurrent() );
5563 Actor actorA = Actor::New();
5564 Actor actorB = Actor::New();
5565 Actor actorC = Actor::New();
5567 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5568 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5570 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5571 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5573 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5574 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5576 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5577 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5579 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5580 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5582 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5583 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5585 ResetTouchCallbacks();
5587 // Connect ChildOrderChangedSignal
5588 bool orderChangedSignal( false );
5589 Actor orderChangedActor;
5590 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5591 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5593 application.SendNotification();
5594 application.Render();
5596 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5597 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5598 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5600 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5601 // Only top actor will get touched.
5602 actorA.TouchSignal().Connect( TestTouchCallback );
5603 actorB.TouchSignal().Connect( TestTouchCallback2 );
5604 actorC.TouchSignal().Connect( TestTouchCallback3 );
5606 Dali::Integration::Point point;
5607 point.SetDeviceId( 1 );
5608 point.SetState( PointState::DOWN );
5609 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5610 Dali::Integration::TouchEvent touchEvent;
5611 touchEvent.AddPoint( point );
5613 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5615 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5616 actorA.RaiseAbove( actorC );
5617 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5619 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5620 application.SendNotification();
5622 application.ProcessEvent( touchEvent );
5624 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5626 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5627 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5628 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5630 ResetTouchCallbacks();
5632 orderChangedSignal = false;
5634 stage.Add ( actorB );
5635 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5637 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5638 actorA.LowerBelow( actorC );
5639 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5641 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5642 application.SendNotification();
5643 application.Render();
5645 application.ProcessEvent( touchEvent );
5647 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5648 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5649 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5650 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5652 ResetTouchCallbacks();
5654 orderChangedSignal = false;
5656 tet_printf( "Adding Actor A to stage, will be on top\n" );
5658 stage.Add ( actorA );
5659 application.SendNotification();
5660 application.Render();
5662 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5664 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5665 actorB.RaiseAbove( actorC );
5666 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5668 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5669 application.SendNotification();
5671 application.ProcessEvent( touchEvent );
5673 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5674 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5675 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5676 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5678 ResetTouchCallbacks();
5680 orderChangedSignal = false;
5682 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5684 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5685 actorA.LowerBelow( actorC );
5686 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5688 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5689 application.SendNotification();
5691 application.ProcessEvent( touchEvent );
5693 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5694 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5695 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5696 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5698 ResetTouchCallbacks();
5700 orderChangedSignal = false;
5702 stage.Add ( actorC );
5704 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5705 actorA.RaiseAbove( actorC );
5706 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5707 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5709 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5710 application.SendNotification();
5711 application.Render();
5713 application.ProcessEvent( touchEvent );
5715 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5716 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5717 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5718 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5723 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5725 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5727 TestApplication application;
5729 Stage stage( Stage::GetCurrent() );
5731 Actor actorA = Actor::New();
5732 Actor actorB = Actor::New();
5733 Actor actorC = Actor::New();
5735 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5736 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5738 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5739 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5741 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5742 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5744 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5745 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5747 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5748 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5750 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5751 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5753 ResetTouchCallbacks();
5755 // Connect ChildOrderChangedSignal
5756 bool orderChangedSignal( false );
5757 Actor orderChangedActor;
5758 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5759 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5761 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5762 // Only top actor will get touched.
5763 actorA.TouchSignal().Connect( TestTouchCallback );
5764 actorB.TouchSignal().Connect( TestTouchCallback2 );
5765 actorC.TouchSignal().Connect( TestTouchCallback3 );
5767 Dali::Integration::Point point;
5768 point.SetDeviceId( 1 );
5769 point.SetState( PointState::DOWN );
5770 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5771 Dali::Integration::TouchEvent touchEvent;
5772 touchEvent.AddPoint( point );
5774 stage.Add ( actorA );
5775 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5777 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5779 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5781 application.SendNotification();
5782 application.Render();
5784 application.ProcessEvent( touchEvent );
5786 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5788 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5789 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5790 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5792 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5793 ResetTouchCallbacks();
5795 orderChangedSignal = false;
5797 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5799 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5801 // Sort actor tree before next touch event
5802 application.SendNotification();
5803 application.Render();
5805 application.ProcessEvent( touchEvent );
5807 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5809 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5810 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5811 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5812 ResetTouchCallbacks();
5814 orderChangedSignal = false;
5816 tet_printf( "Lower actor C below B but C not parented\n" );
5818 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5820 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5822 // Sort actor tree before next touch event
5823 application.SendNotification();
5824 application.Render();
5826 application.ProcessEvent( touchEvent );
5828 tet_printf( "Not parented so Lower should show no effect\n" );
5830 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5831 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5832 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5833 ResetTouchCallbacks();
5835 orderChangedSignal = false;
5837 tet_printf( "Raise actor B to top\n" );
5839 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5840 actorB.RaiseToTop();
5841 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5843 // Sort actor tree before next touch event
5844 application.SendNotification();
5845 application.Render();
5847 application.ProcessEvent( touchEvent );
5849 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5851 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5852 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5853 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5854 ResetTouchCallbacks();
5856 orderChangedSignal = false;
5858 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5860 stage.Add ( actorB );
5862 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5864 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5865 actorC.LowerToBottom();
5866 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5868 application.SendNotification();
5869 application.Render();
5871 application.ProcessEvent( touchEvent );
5873 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5875 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5876 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5877 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5878 ResetTouchCallbacks();
5884 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5886 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5888 TestApplication application;
5890 Stage stage( Stage::GetCurrent() );
5892 Actor actorA = Actor::New();
5893 Actor actorB = Actor::New();
5894 Actor actorC = Actor::New();
5896 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5897 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5899 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5900 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5902 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5903 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5905 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5906 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5908 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5909 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5911 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5912 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5914 stage.Add( actorA );
5915 stage.Add( actorB );
5916 stage.Add( actorC );
5918 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5919 // Only top actor will get touched.
5920 actorA.TouchSignal().Connect( TestTouchCallback );
5921 actorB.TouchSignal().Connect( TestTouchCallback2 );
5922 actorC.TouchSignal().Connect( TestTouchCallback3 );
5924 ResetTouchCallbacks();
5926 // Connect ChildOrderChangedSignal
5927 bool orderChangedSignal( false );
5928 Actor orderChangedActor;
5929 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5930 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5932 application.SendNotification();
5933 application.Render();
5935 Dali::Integration::Point point;
5936 point.SetDeviceId( 1 );
5937 point.SetState( PointState::DOWN );
5938 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5939 Dali::Integration::TouchEvent touchEvent;
5940 touchEvent.AddPoint( point );
5942 application.ProcessEvent( touchEvent );
5944 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5945 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5946 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5948 ResetTouchCallbacks();
5950 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5952 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5953 actorA.RaiseAbove( actorA );
5954 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5955 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5957 application.SendNotification();
5958 application.Render();
5960 application.ProcessEvent( touchEvent );
5962 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5964 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5965 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5966 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5968 ResetTouchCallbacks();
5970 orderChangedSignal = false;
5972 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5973 actorA.RaiseAbove( actorC );
5974 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5975 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5977 application.SendNotification();
5978 application.Render();
5980 application.ProcessEvent( touchEvent );
5982 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5983 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5984 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5985 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5990 int UtcDaliActorGetScreenPosition(void)
5992 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5994 TestApplication application;
5996 Stage stage( Stage::GetCurrent() );
5998 Actor actorA = Actor::New();
5999 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6001 Vector2 size2( 10.0f, 20.0f );
6002 actorA.SetProperty( Actor::Property::SIZE, size2 );
6004 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6006 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6008 stage.Add( actorA );
6010 application.SendNotification();
6011 application.Render();
6013 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6014 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6016 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6017 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6019 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6020 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6022 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6024 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6026 application.SendNotification();
6027 application.Render();
6029 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6030 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6032 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6033 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6035 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6036 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6038 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6040 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6042 application.SendNotification();
6043 application.Render();
6045 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6046 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6048 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6049 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6051 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6052 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6054 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6056 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 0.0 ));
6058 application.SendNotification();
6059 application.Render();
6061 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6062 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6064 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6065 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6067 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6068 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6070 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6072 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 420.0 ));
6074 application.SendNotification();
6075 application.Render();
6077 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6078 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6080 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6081 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6083 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6084 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6086 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6088 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6089 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 30.0 ));
6091 Actor actorB = Actor::New();
6092 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6093 actorB.SetProperty( Actor::Property::SIZE, size2 );
6094 actorB.SetProperty( Actor::Property::POSITION, Vector2( 10.f, 10.f ));
6095 actorA.Add( actorB );
6097 actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6099 application.SendNotification();
6100 application.Render();
6102 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6104 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6105 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6110 int UtcDaliActorGetScreenPositionAfterScaling(void)
6112 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6114 TestApplication application;
6116 Stage stage( Stage::GetCurrent() );
6118 Actor actorA = Actor::New();
6119 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6121 Vector2 size2( 10.0f, 20.0f );
6122 actorA.SetProperty( Actor::Property::SIZE, size2 );
6123 actorA.SetProperty( Actor::Property::SCALE, 1.5f );
6124 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6126 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6128 stage.Add( actorA );
6130 application.SendNotification();
6131 application.Render();
6133 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6134 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6136 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6137 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6139 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6140 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6142 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6144 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6146 application.SendNotification();
6147 application.Render();
6149 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6150 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6152 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6153 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6155 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6156 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6161 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6163 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6165 TestApplication application;
6167 Stage stage( Stage::GetCurrent() );
6169 Actor actorA = Actor::New();
6170 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6171 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6172 Vector2 size2( 10.0f, 20.0f );
6173 actorA.SetProperty( Actor::Property::SIZE, size2 );
6174 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6176 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6178 stage.Add( actorA );
6180 application.SendNotification();
6181 application.Render();
6183 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6184 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6186 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6187 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6189 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6190 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6192 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6194 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
6195 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6197 application.SendNotification();
6198 application.Render();
6200 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6201 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6203 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6204 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6206 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6207 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6213 int UtcDaliActorGetScreenPositionWithChildActors(void)
6215 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6217 TestApplication application;
6219 Stage stage( Stage::GetCurrent() );
6221 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6223 Actor actorA = Actor::New();
6224 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6225 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6226 Vector2 size1( 10.0f, 20.0f );
6227 actorA.SetProperty( Actor::Property::SIZE, size1 );
6228 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6230 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6232 Actor parentActorA = Actor::New();
6233 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6234 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6235 Vector2 size2( 30.0f, 60.0f );
6236 parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6237 parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6239 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6241 stage.Add( parentActorA );
6242 parentActorA.Add ( actorA );
6244 application.SendNotification();
6245 application.Render();
6247 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6248 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6250 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6251 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6253 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6254 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6256 tet_infoline( "Test 2\n");
6258 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6260 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6261 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
6263 application.SendNotification();
6264 application.Render();
6266 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6267 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6269 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6270 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6272 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6273 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6278 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6280 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6282 TestApplication application;
6284 Stage stage( Stage::GetCurrent() );
6286 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6288 Actor actorA = Actor::New();
6289 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6290 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6291 Vector2 size1( 10.0f, 20.0f );
6292 actorA.SetProperty( Actor::Property::SIZE, size1 );
6293 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6295 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6297 Actor parentActorA = Actor::New();
6298 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6299 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6300 Vector2 size2( 30.0f, 60.0f );
6301 parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6302 parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6304 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6306 Actor grandParentActorA = Actor::New();
6307 grandParentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6308 grandParentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
6309 Vector2 size3( 60.0f, 120.0f );
6310 grandParentActorA.SetProperty( Actor::Property::SIZE, size3 );
6311 grandParentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6313 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6315 stage.Add( grandParentActorA );
6316 grandParentActorA.Add ( parentActorA );
6318 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6320 parentActorA.Add ( actorA );
6322 application.SendNotification();
6323 application.Render();
6325 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6326 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6328 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6329 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6331 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6332 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6337 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6339 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6341 TestApplication application;
6343 Stage stage( Stage::GetCurrent() );
6345 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6347 Actor actorA = Actor::New();
6348 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6349 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6350 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6351 actorA.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 20.0f ) );
6352 stage.Add( actorA );
6354 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6356 Actor actorB = Actor::New();
6357 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6358 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6359 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6360 Vector2 actorBSize( 30.0f, 60.0f );
6361 actorB.SetProperty( Actor::Property::SIZE, actorBSize );
6362 stage.Add( actorB );
6364 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6366 Actor actorC = Actor::New();
6367 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6368 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6369 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6370 Vector2 actorCSize( 60.0f, 120.0f );
6371 actorC.SetProperty( Actor::Property::SIZE, actorCSize );
6372 stage.Add( actorC );
6374 application.SendNotification();
6375 application.Render();
6377 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6379 Vector2 center( stage.GetSize() * 0.5f );
6381 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6382 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6383 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6385 tet_infoline( "Add scale to all actors" );
6387 actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6388 actorB.SetProperty( Actor::Property::SCALE, 2.0f );
6389 actorC.SetProperty( Actor::Property::SCALE, 2.0f );
6391 application.SendNotification();
6392 application.Render();
6394 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6395 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6396 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6401 int utcDaliActorPositionUsesAnchorPoint(void)
6403 TestApplication application;
6404 tet_infoline( "Check default behaviour\n" );
6406 Actor actor = Actor::New();
6407 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6408 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6409 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6410 Stage::GetCurrent().Add( actor );
6412 application.SendNotification();
6413 application.Render();
6415 tet_infoline( "Check that the world position is in the center\n" );
6416 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6418 tet_infoline( "Set the position uses anchor point property to false\n" );
6419 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6421 application.SendNotification();
6422 application.Render();
6424 tet_infoline( "Check that the world position has changed appropriately\n" );
6425 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6430 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6432 TestApplication application;
6433 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6435 Actor actor = Actor::New();
6436 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6437 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6438 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6439 actor.SetProperty( Actor::Property::SCALE, 2.0f );
6440 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6441 Stage::GetCurrent().Add( actor );
6443 application.SendNotification();
6444 application.Render();
6446 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6447 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6449 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6450 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6451 application.SendNotification();
6452 application.Render();
6453 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6455 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6456 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6457 application.SendNotification();
6458 application.Render();
6459 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6464 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6466 TestApplication application;
6467 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6469 Actor actor = Actor::New();
6470 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6471 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6472 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6473 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6474 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6475 Stage::GetCurrent().Add( actor );
6477 application.SendNotification();
6478 application.Render();
6480 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6481 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6483 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6484 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6485 application.SendNotification();
6486 application.Render();
6487 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6489 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6490 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6491 application.SendNotification();
6492 application.Render();
6493 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6498 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6500 TestApplication application;
6501 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6503 Actor actor = Actor::New();
6504 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6505 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6506 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6507 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6508 actor.SetProperty( Actor::Property::SCALE, 2.0f );
6509 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6510 Stage::GetCurrent().Add( actor );
6512 application.SendNotification();
6513 application.Render();
6515 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6516 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6518 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6519 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6520 application.SendNotification();
6521 application.Render();
6522 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6524 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6525 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6526 application.SendNotification();
6527 application.Render();
6528 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6533 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6535 TestApplication application;
6536 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6538 Actor parent = Actor::New();
6540 Stage::GetCurrent().Add( parent );
6541 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6543 Actor actor = Actor::New();
6544 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6545 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6546 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6547 actor.SetProperty( Actor::Property::INHERIT_SCALE, false );
6548 actor.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
6549 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6550 parent.Add( actor );
6552 application.SendNotification();
6553 application.Render();
6555 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6557 tet_infoline( "Check the world position is in the right place\n" );
6558 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6560 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6561 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6562 application.SendNotification();
6563 application.Render();
6564 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6566 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6567 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6568 application.SendNotification();
6569 application.Render();
6570 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6575 int utcDaliActorVisibilityChangeSignalSelf(void)
6577 TestApplication application;
6578 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6580 Actor actor = Actor::New();
6582 VisibilityChangedFunctorData data;
6583 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6585 actor.SetProperty( Actor::Property::VISIBLE, false );
6587 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6589 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6592 actor.SetProperty( Actor::Property::VISIBLE, false );
6593 data.Check( false /* not called */, TEST_LOCATION );
6595 tet_infoline( "Change the visibility using properties, ensure called" );
6598 actor.SetProperty( Actor::Property::VISIBLE, true );
6599 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6601 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6604 actor.SetProperty( Actor::Property::VISIBLE, true );
6605 data.Check( false /* not called */, TEST_LOCATION );
6610 int utcDaliActorVisibilityChangeSignalChildren(void)
6612 TestApplication application;
6613 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6615 Actor parent = Actor::New();
6616 Actor child = Actor::New();
6617 parent.Add( child );
6619 Actor grandChild = Actor::New();
6620 child.Add( grandChild );
6622 VisibilityChangedFunctorData parentData;
6623 VisibilityChangedFunctorData childData;
6624 VisibilityChangedFunctorData grandChildData;
6626 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6627 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6628 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6630 parent.SetProperty( Actor::Property::VISIBLE, false );
6631 parentData.Check( false /* not called */, TEST_LOCATION );
6632 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6633 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6635 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6638 grandChildData.Reset();
6640 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6642 parent.SetProperty( Actor::Property::VISIBLE, true );
6643 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6644 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6645 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6647 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6650 grandChildData.Reset();
6652 parent.SetProperty( Actor::Property::VISIBLE, true );
6653 parentData.Check( false /* not called */, TEST_LOCATION );
6654 childData.Check( false /* not called */, TEST_LOCATION );
6655 grandChildData.Check( false /* not called */, TEST_LOCATION );
6660 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6662 TestApplication application;
6663 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6665 Actor actor = Actor::New();
6666 Stage::GetCurrent().Add( actor );
6668 application.SendNotification();
6669 application.Render();
6671 VisibilityChangedFunctorData data;
6672 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6674 Animation animation = Animation::New( 1.0f );
6675 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6677 data.Check( false, TEST_LOCATION );
6678 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6679 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6681 tet_infoline( "Play the animation and check the property value" );
6684 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6685 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6687 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6688 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6690 application.SendNotification();
6691 application.Render( 1100 ); // After the animation
6693 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6699 int utcDaliActorVisibilityChangeSignalByName(void)
6701 TestApplication application;
6702 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6704 Actor actor = Actor::New();
6706 bool signalCalled=false;
6707 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6708 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6709 actor.SetProperty( Actor::Property::VISIBLE, false );
6710 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6712 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6713 signalCalled = false;
6714 actor.SetProperty( Actor::Property::VISIBLE, false );
6715 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6717 tet_infoline( "Change the visibility using properties, ensure called" );
6718 actor.SetProperty( Actor::Property::VISIBLE, true );
6719 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6721 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6722 signalCalled = false;
6724 actor.SetProperty( Actor::Property::VISIBLE, true );
6725 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6731 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6733 gLayoutDirectionType = type;
6736 int UtcDaliActorLayoutDirectionProperty(void)
6738 TestApplication application;
6739 tet_infoline( "Check layout direction property" );
6741 Actor actor0 = Actor::New();
6742 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6743 Stage::GetCurrent().Add( actor0 );
6745 application.SendNotification();
6746 application.Render();
6748 Actor actor1 = Actor::New();
6749 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6750 Actor actor2 = Actor::New();
6751 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6752 Actor actor3 = Actor::New();
6753 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6754 Actor actor4 = Actor::New();
6755 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6756 Actor actor5 = Actor::New();
6757 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6758 Actor actor6 = Actor::New();
6759 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6760 Actor actor7 = Actor::New();
6761 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6762 Actor actor8 = Actor::New();
6763 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6764 Actor actor9 = Actor::New();
6765 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6767 actor1.Add( actor2 );
6768 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6769 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6771 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6772 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6773 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6775 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6776 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6777 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6779 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6780 actor0.Add( actor1 );
6781 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6782 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6784 Stage::GetCurrent().Add( actor3 );
6785 actor3.Add( actor4 );
6786 actor4.Add( actor5 );
6787 actor5.Add( actor6 );
6788 actor5.Add( actor7 );
6789 actor7.Add( actor8 );
6790 actor8.Add( actor9 );
6791 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6792 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6794 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6795 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6796 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6798 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6800 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6801 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6802 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6803 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6804 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6805 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6806 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6808 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6809 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6810 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6812 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6813 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6814 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6815 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6817 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6818 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6819 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6825 struct LayoutDirectionFunctor
6827 LayoutDirectionFunctor(bool& signalCalled)
6828 : mSignalCalled( signalCalled )
6832 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6833 : mSignalCalled( rhs.mSignalCalled )
6839 mSignalCalled = true;
6842 bool& mSignalCalled;
6845 int UtcDaliActorLayoutDirectionSignal(void)
6847 TestApplication application;
6848 tet_infoline( "Check changing layout direction property sends a signal" );
6850 Actor actor = Actor::New();
6851 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6852 Stage::GetCurrent().Add( actor );
6853 bool signalCalled = false;
6854 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6856 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6857 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6859 // Test that writing the same value doesn't send a signal
6860 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6861 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6863 // Test that writing a different value sends the signal
6864 signalCalled = false;
6865 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6866 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6868 signalCalled = false;
6869 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6870 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6875 struct ChildAddedSignalCheck
6877 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6878 : mSignalReceived( signalReceived ),
6879 mChildHandle( childHandle )
6883 void operator() ( Actor childHandle )
6885 mSignalReceived = true;
6886 mChildHandle = childHandle;
6890 mSignalReceived = true;
6891 mChildHandle = Actor();
6894 bool& mSignalReceived;
6895 Actor& mChildHandle;
6898 int UtcDaliChildAddedSignalP1(void)
6900 TestApplication application;
6901 auto stage = Stage::GetCurrent();
6903 bool signalReceived=false;
6906 ChildAddedSignalCheck signal( signalReceived, childActor );
6907 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6908 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6910 auto actorA = Actor::New();
6911 stage.Add( actorA );
6912 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6913 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6914 signalReceived = false;
6916 auto actorB = Actor::New();
6917 stage.Add( actorB );
6918 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6919 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6925 int UtcDaliChildAddedSignalP2(void)
6927 TestApplication application;
6928 auto stage = Stage::GetCurrent();
6930 bool signalReceived=false;
6933 ChildAddedSignalCheck signal( signalReceived, childActor );
6934 tet_infoline( "Connect to childAdded signal by name" );
6936 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6937 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6939 auto actorA = Actor::New();
6940 stage.Add( actorA );
6941 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6943 // Can't test which actor was added; signal signature is void() when connecting via name.
6944 signalReceived = false;
6946 auto actorB = Actor::New();
6947 stage.Add( actorB );
6948 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6953 int UtcDaliChildAddedSignalN(void)
6955 TestApplication application;
6956 auto stage = Stage::GetCurrent();
6958 bool signalReceived=false;
6961 ChildAddedSignalCheck signal( signalReceived, childActor );
6962 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6963 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6965 auto actorA = Actor::New();
6966 stage.Add( actorA );
6967 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6968 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6969 signalReceived = false;
6971 auto actorB = Actor::New();
6972 actorA.Add( actorB );
6973 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6978 struct ChildRemovedSignalCheck
6980 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
6981 : mSignalReceived( signalReceived ),
6982 mChildHandle( childHandle )
6986 void operator() ( Actor childHandle )
6988 mSignalReceived = true;
6989 mChildHandle = childHandle;
6994 mSignalReceived = true;
6997 bool& mSignalReceived;
6998 Actor& mChildHandle;
7001 int UtcDaliChildRemovedSignalP1(void)
7003 TestApplication application;
7004 auto stage = Stage::GetCurrent();
7006 bool signalReceived=false;
7009 ChildRemovedSignalCheck signal( signalReceived, childActor );
7010 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7011 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7013 auto actorA = Actor::New();
7014 stage.Add( actorA );
7015 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7016 DALI_TEST_CHECK( !childActor );
7018 stage.Remove( actorA );
7019 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7020 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7022 signalReceived = false;
7023 auto actorB = Actor::New();
7024 stage.Add( actorB );
7025 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7027 stage.Remove( actorB );
7028 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7029 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7034 int UtcDaliChildRemovedSignalP2(void)
7036 TestApplication application;
7037 auto stage = Stage::GetCurrent();
7039 bool signalReceived=false;
7042 ChildAddedSignalCheck signal( signalReceived, childActor );
7043 tet_infoline( "Connect to childRemoved signal by name" );
7045 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7046 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7048 auto actorA = Actor::New();
7049 stage.Add( actorA );
7050 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7052 stage.Remove( actorA );
7053 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7055 signalReceived = false;
7056 auto actorB = Actor::New();
7057 stage.Add( actorB );
7058 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7060 stage.Remove( actorB );
7061 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7067 int UtcDaliChildRemovedSignalN(void)
7069 TestApplication application;
7070 auto stage = Stage::GetCurrent();
7072 bool signalReceived=false;
7075 ChildRemovedSignalCheck signal( signalReceived, childActor );
7076 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7077 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7079 auto actorA = Actor::New();
7080 stage.Add( actorA );
7082 auto actorB = Actor::New();
7083 actorA.Add( actorB );
7085 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7086 DALI_TEST_CHECK( ! childActor );
7088 actorA.Remove( actorB );
7089 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7094 int UtcDaliChildMovedSignalP(void)
7096 TestApplication application;
7097 auto stage = Stage::GetCurrent();
7099 bool addedASignalReceived = false;
7100 bool removedASignalReceived = false;
7101 bool addedBSignalReceived = false;
7102 bool removedBSignalReceived = false;
7105 auto actorA = Actor::New();
7106 auto actorB = Actor::New();
7107 stage.Add( actorA );
7108 stage.Add( actorB );
7110 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7111 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7112 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7113 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7115 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7116 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7117 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7118 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7120 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7121 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7122 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7123 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7125 // Create a child of A
7127 auto child = Actor::New();
7128 actorA.Add( child );
7130 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7131 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7132 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7133 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7134 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7137 addedASignalReceived = false;
7138 addedBSignalReceived = false;
7139 removedASignalReceived = false;
7140 removedBSignalReceived = false;
7142 actorB.Add( child ); // Expect this child to be re-parented
7143 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7144 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7145 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7146 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7148 // Move child back to A:
7149 addedASignalReceived = false;
7150 addedBSignalReceived = false;
7151 removedASignalReceived = false;
7152 removedBSignalReceived = false;
7154 actorA.Add( child ); // Expect this child to be re-parented
7155 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7156 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7157 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7158 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7164 int utcDaliActorCulled(void)
7166 TestApplication application;
7167 auto stage = Stage::GetCurrent();
7169 tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7171 Actor actor = Actor::New();
7172 actor.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 10.0f ) );
7174 Geometry geometry = CreateQuadGeometry();
7175 Shader shader = CreateShader();
7176 Renderer renderer = Renderer::New(geometry, shader);
7177 actor.AddRenderer( renderer );
7181 application.SendNotification();
7182 application.Render( 0 );
7184 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), false, TEST_LOCATION );
7186 PropertyNotification notification = actor.AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) );
7187 notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7189 // Connect NotifySignal
7190 bool propertyNotificationSignal( false );
7191 PropertyNotification source;
7192 CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7193 notification.NotifySignal().Connect( &application, f ) ;
7195 actor.SetProperty( Actor::Property::POSITION, Vector2( 1000.0f, 1000.0f ));
7197 application.SendNotification();
7198 application.Render();
7200 application.SendNotification();
7202 DALI_TEST_EQUALS( actor.GetProperty< bool >( DevelActor::Property::CULLED ), true, TEST_LOCATION );
7204 DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7205 DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( DevelActor::Property::CULLED ), TEST_LOCATION );
7206 DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7211 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7213 TestApplication application;
7214 auto stage = Stage::GetCurrent();
7216 tet_infoline( "Ensure we clear the screen when the last actor is removed" );
7218 Actor actor = CreateRenderableActor();
7219 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7222 application.SendNotification();
7223 application.Render();
7225 auto& glAbstraction = application.GetGlAbstraction();
7226 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7230 application.SendNotification();
7231 application.Render();
7233 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7238 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7240 TestApplication application;
7241 auto stage = Stage::GetCurrent();
7243 tet_infoline( "Ensure we clear the screen when the last actor is made invisible" );
7245 Actor actor = CreateRenderableActor();
7246 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7249 application.SendNotification();
7250 application.Render();
7252 auto& glAbstraction = application.GetGlAbstraction();
7253 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7255 actor.SetProperty( Actor::Property::VISIBLE, false );
7257 application.SendNotification();
7258 application.Render();
7260 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7265 int utcDaliActorGetSizeAfterAnimation(void)
7267 TestApplication application;
7268 tet_infoline( "Check the actor size before / after an animation is finished" );
7270 Vector3 actorSize( 100.0f, 100.0f, 0.0f );
7272 Actor actor = Actor::New();
7273 actor.SetProperty( Actor::Property::SIZE, actorSize );
7274 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
7275 Stage::GetCurrent().Add( actor );
7277 // Size should be updated without rendering.
7278 Vector3 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7279 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7281 application.SendNotification();
7282 application.Render();
7284 // Size and current size should be updated.
7285 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7286 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7287 DALI_TEST_EQUALS( actorSize.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7288 DALI_TEST_EQUALS( actorSize.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7289 DALI_TEST_EQUALS( actorSize.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7291 Vector3 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7292 DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7293 DALI_TEST_EQUALS( actorSize.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7294 DALI_TEST_EQUALS( actorSize.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7295 DALI_TEST_EQUALS( actorSize.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7298 actorSize = Vector3( 200.0f, 200.0f, 0.0f );
7299 actor.SetProperty( Actor::Property::SIZE, actorSize );
7301 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7302 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7304 Vector3 targetValue( 10.0f, 20.0f, 0.0f );
7306 Animation animation = Animation::New( 1.0f );
7307 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
7310 // Size should be updated without rendering.
7311 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7312 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7314 application.SendNotification();
7315 application.Render( 1100 ); // After the animation
7317 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7318 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7319 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7320 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7321 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7323 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7324 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7325 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7326 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7327 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7329 targetValue.width = 50.0f;
7332 animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetValue.width );
7335 application.SendNotification();
7336 application.Render( 1100 ); // After the animation
7338 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7339 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7340 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7341 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7342 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7344 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7345 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7346 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7347 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7348 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7350 targetValue.height = 70.0f;
7353 animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetValue.height );
7356 application.SendNotification();
7357 application.Render( 1100 ); // After the animation
7359 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7360 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7361 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7362 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7363 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7365 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7366 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7367 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7368 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7369 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7371 Vector3 offset( 10.0f, 20.0f, 0.0f );
7374 animation.AnimateBy( Property( actor, Actor::Property::SIZE ), offset );
7377 application.SendNotification();
7378 application.Render( 1100 ); // After the animation
7380 targetValue += offset;
7382 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7383 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7384 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7385 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7386 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7388 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7389 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7390 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7391 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7392 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7394 offset.width = 20.0f;
7397 animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), offset.width );
7400 application.SendNotification();
7401 application.Render( 1100 ); // After the animation
7403 targetValue.width += offset.width;
7405 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7406 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7407 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7408 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7409 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7411 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7412 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7413 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7414 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7415 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7417 offset.height = 10.0f;
7420 animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), offset.height );
7423 application.SendNotification();
7424 application.Render( 1100 ); // After the animation
7426 targetValue.height += offset.height;
7428 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7429 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7430 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7431 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7432 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7434 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7435 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7436 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7437 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7438 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7441 actorSize = Vector3( 300.0f, 300.0f, 0.0f );
7443 actor.SetProperty( Actor::Property::SIZE, actorSize );
7445 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7446 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7448 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7449 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7451 application.SendNotification();
7452 application.Render();
7454 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7455 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7457 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7458 DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );