2 * Copyright (c) 2020 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;
92 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
94 gTouchCallBackCalled = true;
99 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
101 gTouchCallBackCalled2 = true;
106 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
108 gTouchCallBackCalled3 = true;
113 static void ResetTouchCallbacks()
115 gTouchCallBackCalled = false;
116 gTouchCallBackCalled2 = false;
117 gTouchCallBackCalled3 = false;
120 static bool TestCallback3(Actor actor, const HoverEvent& event)
122 gHoverCallBackCalled = true;
127 // validation stuff for onstage & offstage signals
128 static std::vector< std::string > gActorNamesOnOffScene;
129 static int gOnSceneCallBackCalled;
130 void OnSceneCallback( Actor actor )
132 ++gOnSceneCallBackCalled;
133 gActorNamesOnOffScene.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
134 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) == true );
136 static int gOffSceneCallBackCalled;
137 void OffSceneCallback( Actor actor )
139 ++gOffSceneCallBackCalled;
140 gActorNamesOnOffScene.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
141 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) == false );
144 struct PositionComponentConstraint
146 PositionComponentConstraint(){}
148 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
150 const Matrix& m = inputs[0]->GetMatrix();
153 m.GetTransformComponents(pos, rot, scale);
157 struct OrientationComponentConstraint
159 OrientationComponentConstraint(){}
161 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
163 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
166 orientation = parentOrientation;
171 static bool gOnRelayoutCallBackCalled = false;
172 static std::vector< std::string > gActorNamesRelayout;
174 void OnRelayoutCallback( Actor actor )
176 gOnRelayoutCallBackCalled = true;
177 gActorNamesRelayout.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
180 struct VisibilityChangedFunctorData
182 VisibilityChangedFunctorData()
185 type( DevelActor::VisibilityChange::SELF ),
194 type = DevelActor::VisibilityChange::SELF;
198 void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
200 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
201 DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
202 DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
203 DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
206 void Check( bool compareCalled, const std::string& location )
208 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
213 DevelActor::VisibilityChange::Type type;
217 struct VisibilityChangedFunctor
219 VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
221 void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
224 data.visible = visible;
229 VisibilityChangedFunctorData& data;
233 struct VisibilityChangedVoidFunctor
235 VisibilityChangedVoidFunctor(bool& signalCalled)
236 : mSignalCalled( signalCalled )
241 mSignalCalled = true;
247 struct ChildOrderChangedFunctor
249 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
250 : mSignalCalled( signalCalled ),
254 void operator()( Actor actor )
256 mSignalCalled = true;
264 struct CulledPropertyNotificationFunctor
266 CulledPropertyNotificationFunctor( bool& signalCalled, PropertyNotification& propertyNotification )
267 : mSignalCalled( signalCalled ),
268 mPropertyNotification( propertyNotification )
271 void operator()( PropertyNotification& source )
273 mSignalCalled = true;
274 mPropertyNotification = source;
278 PropertyNotification& mPropertyNotification;
281 } // anonymous namespace
284 //& purpose: Testing New API
285 int UtcDaliActorNew(void)
287 TestApplication application;
289 Actor actor = Actor::New();
291 DALI_TEST_CHECK(actor);
295 //& purpose: Testing Dali::Actor::DownCast()
296 int UtcDaliActorDownCastP(void)
298 TestApplication application;
299 tet_infoline("Testing Dali::Actor::DownCast()");
301 Actor actor = Actor::New();
302 BaseHandle object(actor);
303 Actor actor2 = Actor::DownCast(object);
304 DALI_TEST_CHECK(actor2);
308 //& purpose: Testing Dali::Actor::DownCast()
309 int UtcDaliActorDownCastN(void)
311 TestApplication application;
312 tet_infoline("Testing Dali::Actor::DownCast()");
314 BaseHandle unInitializedObject;
315 Actor actor = Actor::DownCast(unInitializedObject);
316 DALI_TEST_CHECK(!actor);
320 int UtcDaliActorMoveConstructor(void)
322 TestApplication application;
324 Actor actor = Actor::New();
325 DALI_TEST_CHECK( actor );
327 int id = actor.GetProperty< int >( Actor::Property::ID );
329 Actor moved = std::move( actor);
330 DALI_TEST_CHECK( moved );
331 DALI_TEST_EQUALS( id, moved.GetProperty< int >( Actor::Property::ID ), TEST_LOCATION );
332 DALI_TEST_CHECK( !actor );
337 int UtcDaliActorMoveAssignment(void)
339 TestApplication application;
341 Actor actor = Actor::New();
342 DALI_TEST_CHECK( actor );
344 int id = actor.GetProperty< int >( Actor::Property::ID );
347 moved = std::move( actor);
348 DALI_TEST_CHECK( moved );
349 DALI_TEST_EQUALS( id, moved.GetProperty< int >( Actor::Property::ID ), TEST_LOCATION );
350 DALI_TEST_CHECK( !actor );
355 //& purpose: Testing Dali::Actor::GetName()
356 int UtcDaliActorGetName(void)
358 TestApplication application;
360 Actor actor = Actor::New();
362 DALI_TEST_CHECK(actor.GetProperty< std::string >( Actor::Property::NAME ).empty());
366 //& purpose: Testing Dali::Actor::SetName()
367 int UtcDaliActorSetName(void)
369 TestApplication application;
371 string str("ActorName");
372 Actor actor = Actor::New();
374 actor.SetProperty( Actor::Property::NAME,str);
375 DALI_TEST_CHECK(actor.GetProperty< std::string >( Actor::Property::NAME ) == str);
379 int UtcDaliActorGetId(void)
381 tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
382 TestApplication application;
384 Actor first = Actor::New();
385 Actor second = Actor::New();
386 Actor third = Actor::New();
388 DALI_TEST_CHECK(first.GetProperty< int >( Actor::Property::ID ) != second.GetProperty< int >( Actor::Property::ID ));
389 DALI_TEST_CHECK(second.GetProperty< int >( Actor::Property::ID ) != third.GetProperty< int >( Actor::Property::ID ));
393 int UtcDaliActorIsRoot(void)
395 TestApplication application;
397 Actor actor = Actor::New();
398 DALI_TEST_CHECK(!actor.GetProperty< bool >( Actor::Property::IS_ROOT ));
400 // get the root layer
401 actor = application.GetScene().GetLayer( 0 );
402 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::IS_ROOT ) );
406 int UtcDaliActorOnScene(void)
408 TestApplication application;
410 Actor actor = Actor::New();
411 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
413 // get the root layer
414 actor = application.GetScene().GetLayer( 0 );
415 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
419 int UtcDaliActorIsLayer(void)
421 TestApplication application;
423 Actor actor = Actor::New();
424 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::IS_LAYER ) );
426 // get the root layer
427 actor = application.GetScene().GetLayer( 0 );
428 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::IS_LAYER ) );
432 int UtcDaliActorGetLayer(void)
434 TestApplication application;
436 Actor actor = Actor::New();
437 application.GetScene().Add(actor);
438 Layer layer = actor.GetLayer();
440 DALI_TEST_CHECK(layer);
442 // get the root layers layer
443 actor = application.GetScene().GetLayer( 0 );
444 DALI_TEST_CHECK( actor.GetLayer() );
448 int UtcDaliActorAddP(void)
450 tet_infoline("Testing Actor::Add");
451 TestApplication application;
453 Actor parent = Actor::New();
454 Actor child = Actor::New();
456 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
460 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
462 Actor parent2 = Actor::New();
463 parent2.Add( child );
465 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
466 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
468 // try Adding to same parent again, works
469 parent2.Add( child );
470 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
472 // try reparenting an orphaned child
474 Actor temporaryParent = Actor::New();
475 temporaryParent.Add( child );
476 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
478 // temporaryParent has now died, reparent the orphaned child
479 parent2.Add( child );
480 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
485 int UtcDaliActorAddN(void)
487 tet_infoline("Testing Actor::Add");
488 TestApplication application;
490 Actor child = Actor::New();
492 Actor parent2 = Actor::New();
493 parent2.Add( child );
498 parent2.Add( parent2 );
499 tet_printf("Assertion test failed - no Exception\n" );
500 tet_result(TET_FAIL);
502 catch(Dali::DaliException& e)
504 DALI_TEST_PRINT_ASSERT( e );
505 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
506 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
510 tet_printf("Assertion test failed - wrong Exception\n" );
511 tet_result(TET_FAIL);
514 // try reparenting root
517 parent2.Add( application.GetScene().GetLayer( 0 ) );
518 tet_printf("Assertion test failed - no Exception\n" );
519 tet_result(TET_FAIL);
521 catch(Dali::DaliException& e)
523 DALI_TEST_PRINT_ASSERT( e );
524 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
525 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
529 tet_printf("Assertion test failed - wrong Exception\n" );
530 tet_result(TET_FAIL);
537 parent2.Add( empty );
538 tet_printf("Assertion test failed - no Exception\n" );
539 tet_result(TET_FAIL);
541 catch(Dali::DaliException& e)
543 DALI_TEST_PRINT_ASSERT( e );
544 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
545 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
549 tet_printf("Assertion test failed - wrong Exception\n" );
550 tet_result(TET_FAIL);
556 int UtcDaliActorRemoveN(void)
558 tet_infoline("Testing Actor::Remove");
559 TestApplication application;
561 Actor parent = Actor::New();
562 Actor child = Actor::New();
563 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
566 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
568 parent.Remove(child);
569 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
571 // remove again, no problem
572 parent.Remove(child);
573 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
577 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
578 // try Remove self, its a no-op
579 parent.Remove( parent );
580 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
586 parent.Remove( empty );
587 tet_printf("Assertion test failed - no Exception\n" );
588 tet_result(TET_FAIL);
590 catch(Dali::DaliException& e)
592 DALI_TEST_PRINT_ASSERT( e );
593 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
594 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
598 tet_printf("Assertion test failed - wrong Exception\n" );
599 tet_result(TET_FAIL);
604 int UtcDaliActorRemoveP(void)
606 TestApplication application;
608 Actor parent = Actor::New();
609 Actor child = Actor::New();
610 Actor random = Actor::New();
612 application.GetScene().Add( parent );
614 DALI_TEST_CHECK(parent.GetChildCount() == 0);
618 DALI_TEST_CHECK(parent.GetChildCount() == 1);
620 parent.Remove(random);
622 DALI_TEST_CHECK(parent.GetChildCount() == 1);
624 application.GetScene().Remove( parent );
626 DALI_TEST_CHECK(parent.GetChildCount() == 1);
630 int UtcDaliActorGetChildCount(void)
632 TestApplication application;
634 Actor parent = Actor::New();
635 Actor child = Actor::New();
637 DALI_TEST_CHECK(parent.GetChildCount() == 0);
641 DALI_TEST_CHECK(parent.GetChildCount() == 1);
645 int UtcDaliActorGetChildren01(void)
647 TestApplication application;
649 Actor parent = Actor::New();
650 Actor first = Actor::New();
651 Actor second = Actor::New();
652 Actor third = Actor::New();
658 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
659 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
660 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
664 int UtcDaliActorGetChildren02(void)
666 TestApplication application;
668 Actor parent = Actor::New();
669 Actor first = Actor::New();
670 Actor second = Actor::New();
671 Actor third = Actor::New();
677 const Actor& constParent = parent;
679 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
680 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
681 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
685 int UtcDaliActorGetParent01(void)
687 TestApplication application;
689 Actor parent = Actor::New();
690 Actor child = Actor::New();
694 DALI_TEST_CHECK(child.GetParent() == parent);
698 int UtcDaliActorGetParent02(void)
700 TestApplication application;
702 Actor actor = Actor::New();
704 DALI_TEST_CHECK(!actor.GetParent());
708 int UtcDaliActorCustomProperty(void)
710 TestApplication application;
712 Actor actor = Actor::New();
713 application.GetScene().Add( actor );
715 float startValue(1.0f);
716 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
717 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
719 application.SendNotification();
720 application.Render(0);
721 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
723 actor.SetProperty( index, 5.0f );
725 application.SendNotification();
726 application.Render(0);
727 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
731 int UtcDaliActorCustomPropertyIntToFloat(void)
733 TestApplication application;
735 Actor actor = Actor::New();
736 application.GetScene().Add( actor );
738 float startValue(5.0f);
739 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
740 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
742 application.SendNotification();
743 application.Render(0);
744 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
746 actor.SetProperty( index, int(1) );
748 application.SendNotification();
749 application.Render(0);
750 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
754 int UtcDaliActorCustomPropertyFloatToInt(void)
756 TestApplication application;
758 Actor actor = Actor::New();
759 application.GetScene().Add( actor );
762 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
763 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
765 application.SendNotification();
766 application.Render(0);
767 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
769 actor.SetProperty( index, float(1.5) );
771 application.SendNotification();
772 application.Render(0);
773 DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
777 int UtcDaliActorSetParentOrigin(void)
779 TestApplication application;
781 Actor actor = Actor::New();
783 Vector3 vector(0.7f, 0.8f, 0.9f);
784 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
786 actor.SetProperty( Actor::Property::PARENT_ORIGIN, vector );
788 // flush the queue and render once
789 application.SendNotification();
790 application.Render();
792 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
794 application.GetScene().Add( actor );
796 actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.1f, 0.2f, 0.3f ) );
798 // flush the queue and render once
799 application.SendNotification();
800 application.Render();
802 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), TEST_LOCATION );
804 application.GetScene().Remove( actor );
808 int UtcDaliActorSetParentOriginIndividual(void)
810 TestApplication application;
812 Actor actor = Actor::New();
814 Vector3 vector(0.7f, 0.8f, 0.9f);
815 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
817 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
819 // flush the queue and render once
820 application.SendNotification();
821 application.Render();
823 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).x, TEST_LOCATION );
825 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
827 // flush the queue and render once
828 application.SendNotification();
829 application.Render();
831 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).y, TEST_LOCATION );
833 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
835 // flush the queue and render once
836 application.SendNotification();
837 application.Render();
839 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).z, TEST_LOCATION );
844 int UtcDaliActorGetCurrentParentOrigin(void)
846 TestApplication application;
848 Actor actor = Actor::New();
850 Vector3 vector(0.7f, 0.8f, 0.9f);
851 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
853 actor.SetProperty( Actor::Property::PARENT_ORIGIN, vector );
855 // flush the queue and render once
856 application.SendNotification();
857 application.Render();
859 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
863 int UtcDaliActorSetAnchorPoint(void)
865 TestApplication application;
867 Actor actor = Actor::New();
869 Vector3 vector(0.7f, 0.8f, 0.9f);
870 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
872 actor.SetProperty( Actor::Property::ANCHOR_POINT, vector );
874 // flush the queue and render once
875 application.SendNotification();
876 application.Render();
878 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
880 application.GetScene().Add( actor );
882 actor.SetProperty( Actor::Property::ANCHOR_POINT, Vector3( 0.1f, 0.2f, 0.3f ) );
883 // flush the queue and render once
884 application.SendNotification();
885 application.Render();
887 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), TEST_LOCATION );
889 application.GetScene().Remove( actor );
893 int UtcDaliActorSetAnchorPointIndividual(void)
895 TestApplication application;
897 Actor actor = Actor::New();
899 Vector3 vector(0.7f, 0.8f, 0.9f);
900 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
902 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
904 // flush the queue and render once
905 application.SendNotification();
906 application.Render();
908 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).x, TEST_LOCATION );
910 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
912 // flush the queue and render once
913 application.SendNotification();
914 application.Render();
916 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).y, TEST_LOCATION );
918 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
920 // flush the queue and render once
921 application.SendNotification();
922 application.Render();
924 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).z, TEST_LOCATION );
929 int UtcDaliActorGetCurrentAnchorPoint(void)
931 TestApplication application;
933 Actor actor = Actor::New();
935 Vector3 vector(0.7f, 0.8f, 0.9f);
936 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
938 actor.SetProperty( Actor::Property::ANCHOR_POINT, vector);
940 // flush the queue and render once
941 application.SendNotification();
942 application.Render();
944 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
948 int UtcDaliActorSetSize01(void)
950 TestApplication application;
952 Actor actor = Actor::New();
953 Vector3 vector(100.0f, 100.0f, 0.0f);
955 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
957 actor.SetProperty( Actor::Property::SIZE, Vector2( vector.x, vector.y ) );
959 // Immediately retrieve the size after setting
960 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
961 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
962 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
963 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
964 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
966 // Flush the queue and render once
967 application.SendNotification();
968 application.Render();
970 // Check the size in the new frame
971 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
973 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
974 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
975 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
976 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
977 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
979 // Check async behaviour
980 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
981 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
982 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
983 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
984 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
986 // Change the resize policy and check whether the size stays the same
987 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
989 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
990 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
992 // Set a new size after resize policy is changed and check the new size
993 actor.SetProperty( Actor::Property::SIZE, Vector3( 0.1f, 0.2f, 0.0f ) );
995 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
996 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
998 // Change the resize policy again and check whether the new size stays the same
999 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1001 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1002 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1004 // Set another new size after resize policy is changed and check the new size
1005 actor.SetProperty( Actor::Property::SIZE, Vector3( 50.0f, 60.0f, 0.0f ) );
1007 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1008 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1013 int UtcDaliActorSetSize02(void)
1015 TestApplication application;
1017 Actor actor = Actor::New();
1018 Vector3 vector(100.0f, 100.0f, 100.0f);
1020 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1022 actor.SetProperty( Actor::Property::SIZE, Vector3( vector.x, vector.y, vector.z ) );
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(Vector2 size)
1042 int UtcDaliActorSetSize03(void)
1044 TestApplication application;
1046 Actor actor = Actor::New();
1047 Vector3 vector(100.0f, 100.0f, 0.0f);
1049 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1051 actor.SetProperty( Actor::Property::SIZE,Vector2(vector.x, vector.y));
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 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1065 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1070 // SetSize(Vector3 size)
1071 int UtcDaliActorSetSize04(void)
1073 TestApplication application;
1075 Actor actor = Actor::New();
1076 Vector3 vector(100.0f, 100.0f, 100.0f);
1078 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1080 actor.SetProperty( Actor::Property::SIZE,vector);
1082 // Immediately check the size after setting
1083 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1084 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1086 // flush the queue and render once
1087 application.SendNotification();
1088 application.Render();
1090 // Check the size in the new frame
1091 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1093 application.GetScene().Add( actor );
1094 actor.SetProperty( Actor::Property::SIZE, Vector3( 0.1f, 0.2f, 0.3f ) );
1096 // Immediately check the size after setting
1097 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1098 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1100 // flush the queue and render once
1101 application.SendNotification();
1102 application.Render();
1104 // Check the size in the new frame
1105 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), TEST_LOCATION );
1107 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1108 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1110 application.GetScene().Remove( actor );
1114 int UtcDaliActorSetSizeIndividual(void)
1116 TestApplication application;
1118 Actor actor = Actor::New();
1120 Vector3 vector(0.7f, 0.8f, 0.9f);
1121 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1123 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1125 // Immediately check the width after setting
1126 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1127 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1129 // flush the queue and render once
1130 application.SendNotification();
1131 application.Render();
1133 // Check the width in the new frame
1134 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1136 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1137 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1139 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1141 // Immediately check the height after setting
1142 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1143 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1145 // flush the queue and render once
1146 application.SendNotification();
1147 application.Render();
1149 // Check the height in the new frame
1150 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1152 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1153 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1155 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1157 // Immediately check the depth after setting
1158 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1159 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1161 // flush the queue and render once
1162 application.SendNotification();
1163 application.Render();
1165 // Check the depth in the new frame
1166 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).depth, TEST_LOCATION );
1168 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1169 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1171 // Change the resize policy and check whether the size stays the same
1172 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1174 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1175 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1177 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1178 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1180 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1181 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1183 // Change the resize policy again and check whether the size stays the same
1184 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1186 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1187 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1189 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1190 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1192 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1193 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1198 int UtcDaliActorSetSizeIndividual02(void)
1200 TestApplication application;
1202 Actor actor = Actor::New();
1203 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1204 application.GetScene().Add( actor );
1206 Vector3 vector( 100.0f, 200.0f, 400.0f );
1207 DALI_TEST_CHECK( vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ) );
1209 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1210 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1212 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1213 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1215 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1216 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1218 // flush the queue and render once
1219 application.SendNotification();
1220 application.Render();
1222 // Check the width in the new frame
1223 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1224 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1230 int UtcDaliActorGetCurrentSize(void)
1232 TestApplication application;
1234 Actor actor = Actor::New();
1235 Vector3 vector(100.0f, 100.0f, 20.0f);
1237 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1239 actor.SetProperty( Actor::Property::SIZE,vector);
1241 // flush the queue and render once
1242 application.SendNotification();
1243 application.Render();
1245 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1249 int UtcDaliActorGetNaturalSize(void)
1251 TestApplication application;
1253 Actor actor = Actor::New();
1254 Vector3 vector( 0.0f, 0.0f, 0.0f );
1256 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1261 int UtcDaliActorGetCurrentSizeImmediate(void)
1263 TestApplication application;
1265 Actor actor = Actor::New();
1266 Vector3 vector(100.0f, 100.0f, 20.0f);
1268 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1269 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1271 actor.SetProperty( Actor::Property::SIZE,vector);
1273 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1274 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1276 // flush the queue and render once
1277 application.SendNotification();
1278 application.Render();
1280 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1281 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1284 // Build the animation
1285 const float durationSeconds = 2.0f;
1286 Animation animation = Animation::New( durationSeconds );
1287 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1288 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1290 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1292 // Start the animation
1295 application.SendNotification();
1296 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1298 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1303 int UtcDaliActorCalculateScreenExtents(void)
1305 TestApplication application;
1307 Actor actor = Actor::New();
1309 actor.SetProperty( Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1310 actor.SetProperty( Actor::Property::SIZE,Vector3{ 1.0f, 1.0f, 1.0f });
1312 application.SendNotification();
1313 application.Render();
1315 auto expectedExtent = Rect<>{ -0.5f, -0.5f, 1.0f, 1.0f };
1316 auto actualExtent = DevelActor::CalculateScreenExtents( actor );
1317 DALI_TEST_EQUALS( expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1318 DALI_TEST_EQUALS( expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1319 DALI_TEST_EQUALS( expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1320 DALI_TEST_EQUALS( expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1322 application.GetScene().Remove( actor );
1326 // SetPosition(float x, float y)
1327 int UtcDaliActorSetPosition01(void)
1329 TestApplication application;
1331 Actor actor = Actor::New();
1333 // Set to random to start off with
1334 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1336 Vector3 vector(100.0f, 100.0f, 0.0f);
1338 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1340 actor.SetProperty( Actor::Property::POSITION, Vector2(vector.x, vector.y));
1341 // flush the queue and render once
1342 application.SendNotification();
1343 application.Render();
1344 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1346 application.GetScene().Add( actor );
1347 actor.SetProperty( Actor::Property::POSITION, Vector3( 0.1f, 0.2f, 0.3f ) );
1348 // flush the queue and render once
1349 application.SendNotification();
1350 application.Render();
1351 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1353 actor.SetProperty( Actor::Property::POSITION_X, 1.0f );
1354 actor.SetProperty( Actor::Property::POSITION_Y, 1.1f );
1355 actor.SetProperty( Actor::Property::POSITION_Z, 1.2f );
1356 // flush the queue and render once
1357 application.SendNotification();
1358 application.Render();
1359 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1361 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1362 // flush the queue and render once
1363 application.SendNotification();
1364 application.Render();
1365 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1367 application.GetScene().Remove( actor );
1371 // SetPosition(float x, float y, float z)
1372 int UtcDaliActorSetPosition02(void)
1374 TestApplication application;
1376 Actor actor = Actor::New();
1378 // Set to random to start off with
1379 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1381 Vector3 vector(100.0f, 100.0f, 100.0f);
1383 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1385 actor.SetProperty( Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1387 // flush the queue and render once
1388 application.SendNotification();
1389 application.Render();
1391 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1395 // SetPosition(Vector3 position)
1396 int UtcDaliActorSetPosition03(void)
1398 TestApplication application;
1400 Actor actor = Actor::New();
1402 // Set to random to start off with
1403 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1405 Vector3 vector(100.0f, 100.0f, 100.0f);
1407 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1409 actor.SetProperty( Actor::Property::POSITION, vector);
1411 // flush the queue and render once
1412 application.SendNotification();
1413 application.Render();
1415 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1419 int UtcDaliActorSetX(void)
1421 TestApplication application;
1423 Actor actor = Actor::New();
1425 Vector3 vector(100.0f, 0.0f, 0.0f);
1427 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1429 actor.SetProperty( Actor::Property::POSITION_X, 100.0f);
1431 // flush the queue and render once
1432 application.SendNotification();
1433 application.Render();
1435 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1439 int UtcDaliActorSetY(void)
1441 TestApplication application;
1443 Actor actor = Actor::New();
1445 Vector3 vector(0.0f, 100.0f, 0.0f);
1447 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1449 actor.SetProperty( Actor::Property::POSITION_Y, 100.0f);
1451 // flush the queue and render once
1452 application.SendNotification();
1453 application.Render();
1455 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1459 int UtcDaliActorSetZ(void)
1461 TestApplication application;
1463 Actor actor = Actor::New();
1465 Vector3 vector(0.0f, 0.0f, 100.0f);
1467 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1469 actor.SetProperty( Actor::Property::POSITION_Z, 100.0f);
1471 // flush the queue and render once
1472 application.SendNotification();
1473 application.Render();
1475 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1479 int UtcDaliActorSetPositionProperties(void)
1481 TestApplication application;
1483 Actor actor = Actor::New();
1485 Vector3 vector(0.7f, 0.8f, 0.9f);
1486 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1488 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1489 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1490 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1492 // flush the queue and render once
1493 application.SendNotification();
1494 application.Render();
1496 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1497 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1498 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1499 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1500 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1502 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1503 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1504 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1506 // flush the queue and render once
1507 application.SendNotification();
1508 application.Render();
1510 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1511 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1512 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1513 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1514 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1516 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1517 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1518 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1520 // flush the queue and render once
1521 application.SendNotification();
1522 application.Render();
1524 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1525 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1526 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1527 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1528 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1533 int UtcDaliActorTranslateBy(void)
1535 TestApplication application;
1537 Actor actor = Actor::New();
1538 Vector3 vector(100.0f, 100.0f, 100.0f);
1540 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1542 actor.SetProperty( Actor::Property::POSITION, vector);
1544 // flush the queue and render once
1545 application.SendNotification();
1546 application.Render();
1548 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1550 actor.TranslateBy(vector);
1552 // flush the queue and render once
1553 application.SendNotification();
1554 application.Render();
1556 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1560 int UtcDaliActorGetCurrentPosition(void)
1562 TestApplication application;
1564 Actor actor = Actor::New();
1565 Vector3 setVector(100.0f, 100.0f, 0.0f);
1566 actor.SetProperty( Actor::Property::POSITION, setVector);
1568 // flush the queue and render once
1569 application.SendNotification();
1570 application.Render();
1572 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ) == setVector);
1576 int UtcDaliActorGetCurrentWorldPosition(void)
1578 TestApplication application;
1580 Actor parent = Actor::New();
1581 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1582 parent.SetProperty( Actor::Property::POSITION, parentPosition );
1583 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1584 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1585 application.GetScene().Add( parent );
1587 Actor child = Actor::New();
1588 child.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1589 child.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1590 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1591 child.SetProperty( Actor::Property::POSITION, childPosition );
1592 parent.Add( child );
1594 // The actors should not have a world position yet
1595 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1596 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1598 application.SendNotification();
1599 application.Render(0);
1601 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1602 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1604 // The actors should have a world position now
1605 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1606 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1610 int UtcDaliActorSetInheritPosition(void)
1612 tet_infoline("Testing Actor::SetInheritPosition");
1613 TestApplication application;
1615 Actor parent = Actor::New();
1616 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1617 parent.SetProperty( Actor::Property::POSITION, parentPosition );
1618 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1619 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1620 application.GetScene().Add( parent );
1622 Actor child = Actor::New();
1623 child.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1624 child.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1625 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1626 child.SetProperty( Actor::Property::POSITION, childPosition );
1627 parent.Add( child );
1629 // The actors should not have a world position yet
1630 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1631 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1633 // first test default, which is to inherit position
1634 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1635 application.SendNotification();
1636 application.Render(0); // should only really call Update as Render is not required to update scene
1637 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1638 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1639 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1640 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1642 //Change child position
1643 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1644 child.SetProperty( Actor::Property::POSITION, childOffset );
1646 // Use local position as world postion
1647 child.SetProperty( Actor::Property::INHERIT_POSITION, false );
1648 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), false, TEST_LOCATION );
1649 application.SendNotification();
1650 application.Render(0); // should only really call Update as Render is not required to update scene
1651 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1652 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1653 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1654 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), childOffset, TEST_LOCATION );
1656 //Change back to inherit position from parent
1657 child.SetProperty( Actor::Property::INHERIT_POSITION, true );
1658 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1659 application.SendNotification();
1660 application.Render(0); // should only really call Update as Render is not required to update scene
1661 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1662 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1663 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1664 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childOffset, TEST_LOCATION );
1668 int UtcDaliActorInheritOpacity(void)
1670 tet_infoline("Testing Actor::Inherit Opacity");
1671 TestApplication application;
1673 Actor parent = Actor::New();
1674 Actor child = Actor::New();
1675 parent.Add( child );
1676 application.GetScene().Add( parent );
1678 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1679 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1681 // flush the queue and render once
1682 application.SendNotification();
1683 application.Render();
1685 parent.SetProperty( Actor::Property::OPACITY, 0.1f );
1687 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1688 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1690 application.SendNotification();
1691 application.Render();
1693 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1694 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1695 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1696 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1697 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1698 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1703 // SetOrientation(float angleRadians, Vector3 axis)
1704 int UtcDaliActorSetOrientation01(void)
1706 TestApplication application;
1708 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1709 Actor actor = Actor::New();
1711 actor.SetProperty( Actor::Property::ORIENTATION, rotation);
1713 // flush the queue and render once
1714 application.SendNotification();
1715 application.Render();
1717 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1721 int UtcDaliActorSetOrientation02(void)
1723 TestApplication application;
1725 Actor actor = Actor::New();
1727 Radian angle( 0.785f );
1728 Vector3 axis(1.0f, 1.0f, 0.0f);
1730 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1731 Quaternion rotation( angle, axis );
1732 // flush the queue and render once
1733 application.SendNotification();
1734 application.Render();
1735 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1737 application.GetScene().Add( actor );
1738 actor.RotateBy( Degree( 360 ), axis);
1739 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1741 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) ) );
1742 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1743 // flush the queue and render once
1744 application.SendNotification();
1745 application.Render();
1746 DALI_TEST_EQUALS( result, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1748 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1749 // flush the queue and render once
1750 application.SendNotification();
1751 application.Render();
1752 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1754 application.GetScene().Remove( actor );
1758 // SetOrientation(float angleRadians, Vector3 axis)
1759 int UtcDaliActorSetOrientationProperty(void)
1761 TestApplication application;
1763 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1764 Actor actor = Actor::New();
1766 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1767 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1769 // flush the queue and render once
1770 application.SendNotification();
1771 application.Render();
1773 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1774 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1775 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1779 // RotateBy(float angleRadians, Vector3 axis)
1780 int UtcDaliActorRotateBy01(void)
1782 TestApplication application;
1784 Actor actor = Actor::New();
1786 Radian angle( M_PI * 0.25f );
1787 actor.RotateBy(( angle ), Vector3::ZAXIS);
1788 // flush the queue and render once
1789 application.SendNotification();
1790 application.Render();
1791 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1793 application.GetScene().Add( actor );
1795 actor.RotateBy( angle, Vector3::ZAXIS);
1796 // flush the queue and render once
1797 application.SendNotification();
1798 application.Render();
1799 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1801 application.GetScene().Remove( actor );
1805 // RotateBy(Quaternion relativeRotation)
1806 int UtcDaliActorRotateBy02(void)
1808 TestApplication application;
1810 Actor actor = Actor::New();
1812 Radian angle( M_PI * 0.25f );
1813 Quaternion rotation(angle, Vector3::ZAXIS);
1814 actor.RotateBy(rotation);
1815 // flush the queue and render once
1816 application.SendNotification();
1817 application.Render();
1818 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1820 actor.RotateBy(rotation);
1821 // flush the queue and render once
1822 application.SendNotification();
1823 application.Render();
1824 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1828 int UtcDaliActorGetCurrentOrientation(void)
1830 TestApplication application;
1831 Actor actor = Actor::New();
1833 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1834 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1835 // flush the queue and render once
1836 application.SendNotification();
1837 application.Render();
1838 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1842 int UtcDaliActorGetCurrentWorldOrientation(void)
1844 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1845 TestApplication application;
1847 Actor parent = Actor::New();
1848 Radian rotationAngle( Degree(90.0f) );
1849 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1850 parent.SetProperty( Actor::Property::ORIENTATION, rotation );
1851 application.GetScene().Add( parent );
1853 Actor child = Actor::New();
1854 child.SetProperty( Actor::Property::ORIENTATION, rotation );
1855 parent.Add( child );
1857 // The actors should not have a world rotation yet
1858 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1859 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1861 application.SendNotification();
1862 application.Render(0);
1864 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1865 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1867 // The actors should have a world rotation now
1868 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1869 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1871 // turn off child rotation inheritance
1872 child.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
1873 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_ORIENTATION ), false, TEST_LOCATION );
1874 application.SendNotification();
1875 application.Render(0);
1877 // The actors should have a world rotation now
1878 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1879 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1883 // SetScale(float scale)
1884 int UtcDaliActorSetScale01(void)
1886 TestApplication application;
1888 Actor actor = Actor::New();
1890 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1891 actor.SetProperty( Actor::Property::SCALE,0.25f);
1893 Vector3 scale(10.0f, 10.0f, 10.0f);
1894 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1896 actor.SetProperty( Actor::Property::SCALE,scale.x);
1898 // flush the queue and render once
1899 application.SendNotification();
1900 application.Render();
1902 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1906 // SetScale(float scaleX, float scaleY, float scaleZ)
1907 int UtcDaliActorSetScale02(void)
1909 TestApplication application;
1910 Vector3 scale(10.0f, 10.0f, 10.0f);
1912 Actor actor = Actor::New();
1914 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1915 actor.SetProperty( Actor::Property::SCALE, Vector3( 12.0f, 1.0f, 2.0f ) );
1917 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1919 actor.SetProperty( Actor::Property::SCALE, Vector3( scale.x, scale.y, scale.z ) );
1920 // flush the queue and render once
1921 application.SendNotification();
1922 application.Render();
1923 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1925 // add to stage and test
1926 application.GetScene().Add( actor );
1927 actor.SetProperty( Actor::Property::SCALE, Vector3( 2.0f, 2.0f, 2.0f ) );
1928 // flush the queue and render once
1929 application.SendNotification();
1930 application.Render();
1931 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), 0.001, TEST_LOCATION);
1933 application.GetScene().Remove( actor );
1938 // SetScale(Vector3 scale)
1939 int UtcDaliActorSetScale03(void)
1941 TestApplication application;
1942 Vector3 scale(10.0f, 10.0f, 10.0f);
1944 Actor actor = Actor::New();
1946 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1947 actor.SetProperty( Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1949 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1951 actor.SetProperty( Actor::Property::SCALE,scale);
1953 // flush the queue and render once
1954 application.SendNotification();
1955 application.Render();
1957 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1961 int UtcDaliActorSetScaleIndividual(void)
1963 TestApplication application;
1965 Actor actor = Actor::New();
1967 Vector3 vector(0.7f, 0.8f, 0.9f);
1968 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1970 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1971 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1973 // flush the queue and render once
1974 application.SendNotification();
1975 application.Render();
1977 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x, TEST_LOCATION );
1978 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1979 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1981 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1982 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1984 // flush the queue and render once
1985 application.SendNotification();
1986 application.Render();
1988 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).y, TEST_LOCATION );
1989 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1990 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1992 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1993 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1995 // flush the queue and render once
1996 application.SendNotification();
1997 application.Render();
1999 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).z, TEST_LOCATION );
2000 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
2001 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
2003 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
2004 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
2009 int UtcDaliActorScaleBy(void)
2011 TestApplication application;
2012 Actor actor = Actor::New();
2013 Vector3 vector(100.0f, 100.0f, 100.0f);
2015 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
2017 actor.SetProperty( Actor::Property::SCALE,vector);
2019 // flush the queue and render once
2020 application.SendNotification();
2021 application.Render();
2023 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
2025 actor.ScaleBy(vector);
2027 // flush the queue and render once
2028 application.SendNotification();
2029 application.Render();
2031 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
2035 int UtcDaliActorGetCurrentScale(void)
2037 TestApplication application;
2038 Vector3 scale(12.0f, 1.0f, 2.0f);
2040 Actor actor = Actor::New();
2042 actor.SetProperty( Actor::Property::SCALE,scale);
2044 // flush the queue and render once
2045 application.SendNotification();
2046 application.Render();
2048 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
2052 int UtcDaliActorGetCurrentWorldScale(void)
2054 TestApplication application;
2056 Actor parent = Actor::New();
2057 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2058 parent.SetProperty( Actor::Property::SCALE, parentScale );
2059 application.GetScene().Add( parent );
2061 Actor child = Actor::New();
2062 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2063 child.SetProperty( Actor::Property::SCALE, childScale );
2064 parent.Add( child );
2066 // The actors should not have a scale yet
2067 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2068 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2070 // The actors should not have a world scale yet
2071 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2072 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2074 application.SendNotification();
2075 application.Render(0);
2077 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), parentScale, TEST_LOCATION );
2078 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), childScale, TEST_LOCATION );
2080 // The actors should have a world scale now
2081 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale, TEST_LOCATION );
2082 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2086 int UtcDaliActorInheritScale(void)
2088 tet_infoline("Testing Actor::SetInheritScale");
2089 TestApplication application;
2091 Actor parent = Actor::New();
2092 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2093 parent.SetProperty( Actor::Property::SCALE, parentScale );
2094 application.GetScene().Add( parent );
2096 Actor child = Actor::New();
2097 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2098 child.SetProperty( Actor::Property::SCALE, childScale );
2099 parent.Add( child );
2101 application.SendNotification();
2102 application.Render(0);
2104 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), true, TEST_LOCATION );
2105 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2107 child.SetProperty( Actor::Property::INHERIT_SCALE, false );
2108 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), false, TEST_LOCATION );
2110 application.SendNotification();
2111 application.Render(0);
2113 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), childScale, TEST_LOCATION );
2117 int UtcDaliActorSetVisible(void)
2119 TestApplication application;
2121 Actor actor = Actor::New();
2122 actor.SetProperty( Actor::Property::VISIBLE,false);
2123 // flush the queue and render once
2124 application.SendNotification();
2125 application.Render();
2126 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2128 actor.SetProperty( Actor::Property::VISIBLE,true);
2129 // flush the queue and render once
2130 application.SendNotification();
2131 application.Render();
2132 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2134 // put actor on stage
2135 application.GetScene().Add( actor );
2136 actor.SetProperty( Actor::Property::VISIBLE,false);
2137 // flush the queue and render once
2138 application.SendNotification();
2139 application.Render();
2140 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2144 int UtcDaliActorIsVisible(void)
2146 TestApplication application;
2148 Actor actor = Actor::New();
2150 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2154 int UtcDaliActorSetOpacity(void)
2156 TestApplication application;
2158 Actor actor = Actor::New();
2159 // initial opacity is 1
2160 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
2162 actor.SetProperty( Actor::Property::OPACITY, 0.4f);
2163 // flush the queue and render once
2164 application.SendNotification();
2165 application.Render();
2166 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.4f, TEST_LOCATION );
2168 // change opacity, actor is on stage to change is not immediate
2169 actor.SetProperty( Actor::Property::OPACITY, actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) + 0.1f );
2170 // flush the queue and render once
2171 application.SendNotification();
2172 application.Render();
2173 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2175 // put actor on stage
2176 application.GetScene().Add( actor );
2178 // change opacity, actor is on stage to change is not immediate
2179 actor.SetProperty( Actor::Property::OPACITY, 0.9f );
2180 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2181 // flush the queue and render once
2182 application.SendNotification();
2183 application.Render();
2184 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.9f, TEST_LOCATION );
2186 // change opacity, actor is on stage to change is not immediate
2187 actor.SetProperty( Actor::Property::OPACITY, actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) - 0.9f );
2188 // flush the queue and render once
2189 application.SendNotification();
2190 application.Render();
2191 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
2195 int UtcDaliActorGetCurrentOpacity(void)
2197 TestApplication application;
2199 Actor actor = Actor::New();
2200 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) != 0.5f);
2202 actor.SetProperty( Actor::Property::OPACITY,0.5f);
2203 // flush the queue and render once
2204 application.SendNotification();
2205 application.Render();
2206 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) == 0.5f);
2210 int UtcDaliActorSetSensitive(void)
2212 TestApplication application;
2213 Actor actor = Actor::New();
2215 bool sensitive = !actor.GetProperty< bool >( Actor::Property::SENSITIVE );
2217 actor.SetProperty( Actor::Property::SENSITIVE,sensitive);
2219 DALI_TEST_CHECK(sensitive == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2223 int UtcDaliActorIsSensitive(void)
2225 TestApplication application;
2226 Actor actor = Actor::New();
2227 actor.SetProperty( Actor::Property::SENSITIVE,false);
2229 DALI_TEST_CHECK(false == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2233 int UtcDaliActorSetColor(void)
2235 TestApplication application;
2236 Actor actor = Actor::New();
2237 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2239 DALI_TEST_CHECK(color != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2241 actor.SetProperty( Actor::Property::COLOR,color);
2242 // flush the queue and render once
2243 application.SendNotification();
2244 application.Render();
2245 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2247 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2248 // flush the queue and render once
2249 application.SendNotification();
2250 application.Render();
2251 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2253 application.GetScene().Add( actor );
2254 actor.SetProperty( Actor::Property::COLOR, color );
2255 // flush the queue and render once
2256 application.SendNotification();
2257 application.Render();
2258 DALI_TEST_EQUALS( color, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2260 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2261 // flush the queue and render once
2262 application.SendNotification();
2263 application.Render();
2264 // Actor color is not clamped
2265 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2266 // world color is clamped
2267 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), TEST_LOCATION );
2269 actor.SetProperty( Actor::Property::COLOR, color );
2270 DALI_TEST_EQUALS( color, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2272 Vector3 newColor( 1.0f, 0.0f, 0.0f );
2273 actor.SetProperty( Actor::Property::COLOR, newColor );
2274 DALI_TEST_EQUALS( Vector4( newColor.r, newColor.g, newColor.b, 1.0f ), actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2276 application.GetScene().Remove( actor );
2280 int UtcDaliActorSetColorIndividual(void)
2282 TestApplication application;
2284 Actor actor = Actor::New();
2286 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2287 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2289 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2290 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2292 // flush the queue and render once
2293 application.SendNotification();
2294 application.Render();
2296 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).r, TEST_LOCATION );
2297 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2298 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2300 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2301 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2303 // flush the queue and render once
2304 application.SendNotification();
2305 application.Render();
2307 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).g, TEST_LOCATION );
2308 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2309 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2311 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2312 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2314 // flush the queue and render once
2315 application.SendNotification();
2316 application.Render();
2318 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).b, TEST_LOCATION );
2319 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2320 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2323 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2324 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2326 // flush the queue and render once
2327 application.SendNotification();
2328 application.Render();
2330 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2331 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2332 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2334 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2335 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2337 actor.SetProperty( Actor::Property::OPACITY, 0.2f );
2340 // flush the queue and render once
2341 application.SendNotification();
2342 application.Render();
2344 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2350 int UtcDaliActorGetCurrentColor(void)
2352 TestApplication application;
2353 Actor actor = Actor::New();
2354 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2356 actor.SetProperty( Actor::Property::COLOR,color);
2357 // flush the queue and render once
2358 application.SendNotification();
2359 application.Render();
2360 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2364 int UtcDaliActorGetCurrentWorldColor(void)
2366 tet_infoline("Actor::GetCurrentWorldColor");
2367 TestApplication application;
2369 Actor parent = Actor::New();
2370 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2371 parent.SetProperty( Actor::Property::COLOR, parentColor );
2372 application.GetScene().Add( parent );
2374 Actor child = Actor::New();
2375 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2376 child.SetProperty( Actor::Property::COLOR, childColor );
2377 parent.Add( child );
2379 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2380 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2382 // verify the default color mode
2383 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2385 // The actors should not have a world color yet
2386 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2387 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2389 application.SendNotification();
2390 application.Render(0);
2392 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), parentColor, TEST_LOCATION );
2393 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2395 // The actors should have a world color now
2396 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2397 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2400 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2401 application.SendNotification();
2402 application.Render(0);
2403 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), childColor, TEST_LOCATION );
2406 child.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2407 application.SendNotification();
2408 application.Render(0);
2409 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2410 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2413 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2414 application.SendNotification();
2415 application.Render(0);
2416 Vector4 expectedColor( childColor );
2417 expectedColor.a *= parentColor.a;
2418 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2419 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), expectedColor, TEST_LOCATION );
2423 int UtcDaliActorSetColorMode(void)
2425 tet_infoline("Actor::SetColorMode");
2426 TestApplication application;
2427 Actor actor = Actor::New();
2428 Actor child = Actor::New();
2431 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2432 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2434 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
2435 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2437 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2438 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2440 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2441 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2445 int UtcDaliActorScreenToLocal(void)
2447 TestApplication application;
2448 Actor actor = Actor::New();
2449 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2450 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2451 actor.SetProperty( Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2452 application.GetScene().Add(actor);
2454 // flush the queue and render once
2455 application.SendNotification();
2456 application.Render();
2461 application.SendNotification();
2462 application.Render();
2464 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2466 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2467 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2471 int UtcDaliActorSetLeaveRequired(void)
2473 TestApplication application;
2475 Actor actor = Actor::New();
2477 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,false);
2478 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2480 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,true);
2481 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == true);
2485 int UtcDaliActorGetLeaveRequired(void)
2487 TestApplication application;
2489 Actor actor = Actor::New();
2491 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2495 int UtcDaliActorSetKeyboardFocusable(void)
2497 TestApplication application;
2499 Actor actor = Actor::New();
2501 actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
2502 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == true);
2504 actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, false );
2505 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == false);
2509 int UtcDaliActorIsKeyboardFocusable(void)
2511 TestApplication application;
2513 Actor actor = Actor::New();
2515 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == false);
2519 int UtcDaliActorRemoveConstraints(void)
2521 tet_infoline(" UtcDaliActorRemoveConstraints");
2522 TestApplication application;
2524 gTestConstraintCalled = false;
2526 Actor actor = Actor::New();
2528 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2530 actor.RemoveConstraints();
2532 DALI_TEST_CHECK( gTestConstraintCalled == false );
2534 application.GetScene().Add( actor );
2537 // flush the queue and render once
2538 application.SendNotification();
2539 application.Render();
2541 actor.RemoveConstraints();
2543 DALI_TEST_CHECK( gTestConstraintCalled == true );
2547 int UtcDaliActorRemoveConstraintTag(void)
2549 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2550 TestApplication application;
2552 Actor actor = Actor::New();
2554 // 1. Apply Constraint1 and Constraint2, and test...
2555 unsigned int result1 = 0u;
2556 unsigned int result2 = 0u;
2558 unsigned constraint1Tag = 1u;
2559 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2560 constraint1.SetTag( constraint1Tag );
2561 constraint1.Apply();
2563 unsigned constraint2Tag = 2u;
2564 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2565 constraint2.SetTag( constraint2Tag );
2566 constraint2.Apply();
2568 application.GetScene().Add( actor );
2569 // flush the queue and render once
2570 application.SendNotification();
2571 application.Render();
2573 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2574 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2576 // 2. Remove Constraint1 and test...
2579 actor.RemoveConstraints(constraint1Tag);
2580 // make color property dirty, which will trigger constraints to be reapplied.
2581 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2582 // flush the queue and render once
2583 application.SendNotification();
2584 application.Render();
2586 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2587 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2589 // 3. Re-Apply Constraint1 and test...
2592 constraint1.Apply();
2593 // make color property dirty, which will trigger constraints to be reapplied.
2594 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2595 // flush the queue and render once
2596 application.SendNotification();
2597 application.Render();
2599 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2600 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2602 // 2. Remove Constraint2 and test...
2605 actor.RemoveConstraints(constraint2Tag);
2606 // make color property dirty, which will trigger constraints to be reapplied.
2607 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2608 // flush the queue and render once
2609 application.SendNotification();
2610 application.Render();
2612 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2613 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2615 // 2. Remove Constraint1 as well and test...
2618 actor.RemoveConstraints(constraint1Tag);
2619 // make color property dirty, which will trigger constraints to be reapplied.
2620 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2621 // flush the queue and render once
2622 application.SendNotification();
2623 application.Render();
2625 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2626 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2630 int UtcDaliActorTouchedSignal(void)
2632 TestApplication application;
2634 ResetTouchCallbacks();
2636 // get the root layer
2637 Actor actor = application.GetScene().GetRootLayer();
2638 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2640 application.SendNotification();
2641 application.Render();
2643 // connect to its touch signal
2644 actor.TouchSignal().Connect( TestTouchCallback );
2646 // simulate a touch event in the middle of the screen
2647 Vector2 touchPoint( application.GetScene().GetSize() * 0.5 );
2648 Dali::Integration::Point point;
2649 point.SetDeviceId( 1 );
2650 point.SetState( PointState::DOWN );
2651 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2652 Dali::Integration::TouchEvent touchEvent;
2653 touchEvent.AddPoint( point );
2654 application.ProcessEvent( touchEvent );
2656 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2660 int UtcDaliActorHoveredSignal(void)
2662 TestApplication application;
2664 gHoverCallBackCalled = false;
2666 // get the root layer
2667 Actor actor = application.GetScene().GetRootLayer();
2668 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2670 application.SendNotification();
2671 application.Render();
2673 // connect to its hover signal
2674 actor.HoveredSignal().Connect( TestCallback3 );
2676 // simulate a hover event in the middle of the screen
2677 Vector2 touchPoint( application.GetScene().GetSize() * 0.5 );
2678 Dali::Integration::Point point;
2679 point.SetDeviceId( 1 );
2680 point.SetState( PointState::MOTION );
2681 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2682 Dali::Integration::HoverEvent hoverEvent;
2683 hoverEvent.AddPoint( point );
2684 application.ProcessEvent( hoverEvent );
2686 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2690 int UtcDaliActorOnOffSceneSignal(void)
2692 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2694 TestApplication application;
2697 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2698 gActorNamesOnOffScene.clear();
2700 Actor parent = Actor::New();
2701 parent.SetProperty( Actor::Property::NAME, "parent" );
2702 parent.OnSceneSignal().Connect( OnSceneCallback );
2703 parent.OffSceneSignal().Connect( OffSceneCallback );
2705 DALI_TEST_CHECK( gOnSceneCallBackCalled == 0 );
2706 DALI_TEST_CHECK( gOffSceneCallBackCalled == 0 );
2708 // add parent to the scene
2709 application.GetScene().Add( parent );
2710 // onstage emitted, offstage not
2711 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 1, TEST_LOCATION );
2712 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 0, TEST_LOCATION );
2713 DALI_TEST_EQUALS( "parent", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2715 // test adding a child, should get onstage emitted
2717 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2718 gActorNamesOnOffScene.clear();
2720 Actor child = Actor::New();
2721 child.SetProperty( Actor::Property::NAME, "child" );
2722 child.OnSceneSignal().Connect( OnSceneCallback );
2723 child.OffSceneSignal().Connect( OffSceneCallback );
2724 parent.Add( child ); // add child
2725 // onscene emitted, offscene not
2726 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 1, TEST_LOCATION );
2727 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 0, TEST_LOCATION );
2728 DALI_TEST_EQUALS( "child", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2730 // test removing parent from the scene
2732 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2733 gActorNamesOnOffScene.clear();
2735 application.GetScene().Remove( parent );
2736 // onscene not emitted, offscene is
2737 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 0, TEST_LOCATION );
2738 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 2, TEST_LOCATION );
2739 DALI_TEST_EQUALS( "child", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2740 DALI_TEST_EQUALS( "parent", gActorNamesOnOffScene[ 1 ], TEST_LOCATION );
2742 // test adding parent back to the scene
2744 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2745 gActorNamesOnOffScene.clear();
2747 application.GetScene().Add( parent );
2748 // onscene emitted, offscene not
2749 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 2, TEST_LOCATION );
2750 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 0, TEST_LOCATION );
2751 DALI_TEST_EQUALS( "parent", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2752 DALI_TEST_EQUALS( "child", gActorNamesOnOffScene[ 1 ], TEST_LOCATION );
2754 // test removing child
2756 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2757 gActorNamesOnOffScene.clear();
2759 parent.Remove( child );
2760 // onscene not emitted, offscene is
2761 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 0, TEST_LOCATION );
2762 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 1, TEST_LOCATION );
2763 DALI_TEST_EQUALS( "child", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2765 // test removing parent
2767 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2768 gActorNamesOnOffScene.clear();
2770 application.GetScene().Remove( parent );
2771 // onscene not emitted, offscene is
2772 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 0, TEST_LOCATION );
2773 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 1, TEST_LOCATION );
2774 DALI_TEST_EQUALS( "parent", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2778 int UtcDaliActorFindChildByName(void)
2780 tet_infoline("Testing Dali::Actor::FindChildByName()");
2781 TestApplication application;
2783 Actor parent = Actor::New();
2784 parent.SetProperty( Actor::Property::NAME, "parent" );
2785 Actor first = Actor::New();
2786 first .SetProperty( Actor::Property::NAME, "first" );
2787 Actor second = Actor::New();
2788 second.SetProperty( Actor::Property::NAME, "second" );
2793 Actor found = parent.FindChildByName( "foo" );
2794 DALI_TEST_CHECK( !found );
2796 found = parent.FindChildByName( "parent" );
2797 DALI_TEST_CHECK( found == parent );
2799 found = parent.FindChildByName( "first" );
2800 DALI_TEST_CHECK( found == first );
2802 found = parent.FindChildByName( "second" );
2803 DALI_TEST_CHECK( found == second );
2807 int UtcDaliActorFindChildById(void)
2809 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2810 TestApplication application;
2812 Actor parent = Actor::New();
2813 Actor first = Actor::New();
2814 Actor second = Actor::New();
2819 Actor found = parent.FindChildById( 100000 );
2820 DALI_TEST_CHECK( !found );
2822 found = parent.FindChildById( parent.GetProperty< int >( Actor::Property::ID ) );
2823 DALI_TEST_CHECK( found == parent );
2825 found = parent.FindChildById( first.GetProperty< int >( Actor::Property::ID ) );
2826 DALI_TEST_CHECK( found == first );
2828 found = parent.FindChildById( second.GetProperty< int >( Actor::Property::ID ) );
2829 DALI_TEST_CHECK( found == second );
2833 int UtcDaliActorHitTest(void)
2838 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2840 mTouchPoint( touchPoint ),
2845 Vector2 mTouchPoint;
2849 TestApplication application;
2850 tet_infoline(" UtcDaliActorHitTest");
2852 // Fill a vector with different hit tests.
2853 struct HitTestData* hitTestData[] = {
2854 // scale touch point result
2855 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2856 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2857 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.
2858 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2859 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.
2863 // get the root layer
2864 Actor actor = Actor::New();
2865 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2866 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2868 application.GetScene().Add( actor );
2870 ResetTouchCallbacks();
2872 unsigned int index = 0;
2873 while( NULL != hitTestData[index] )
2875 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.f, 1.f ) );
2876 actor.SetProperty( Actor::Property::SCALE, Vector3( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z ) );
2878 // flush the queue and render once
2879 application.SendNotification();
2880 application.Render();
2882 DALI_TEST_CHECK( !gTouchCallBackCalled );
2884 // connect to its touch signal
2885 actor.TouchSignal().Connect(TestTouchCallback);
2887 Dali::Integration::Point point;
2888 point.SetState( PointState::DOWN );
2889 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2890 Dali::Integration::TouchEvent event;
2891 event.AddPoint( point );
2893 // flush the queue and render once
2894 application.SendNotification();
2895 application.Render();
2896 application.ProcessEvent( event );
2898 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2900 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2901 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2902 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2903 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2904 hitTestData[index]->mResult );
2906 ResetTouchCallbacks();
2912 int UtcDaliActorSetDrawMode(void)
2914 TestApplication application;
2915 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2917 Actor a = Actor::New();
2919 application.GetScene().Add(a);
2920 application.SendNotification();
2921 application.Render(0);
2922 application.SendNotification();
2923 application.Render(1);
2925 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Ensure overlay is off by default
2927 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
2928 application.SendNotification();
2929 application.Render(1);
2931 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is overlay
2933 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
2934 application.SendNotification();
2935 application.Render(1);
2937 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is normal
2941 int UtcDaliActorSetDrawModeOverlayRender(void)
2943 TestApplication application;
2944 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2946 application.SendNotification();
2947 application.Render(1);
2949 std::vector<GLuint> ids;
2950 ids.push_back( 8 ); // first rendered actor
2951 ids.push_back( 9 ); // second rendered actor
2952 ids.push_back( 10 ); // third rendered actor
2953 application.GetGlAbstraction().SetNextTextureIds( ids );
2955 Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2956 Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2957 Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2958 Actor a = CreateRenderableActor( imageA );
2959 Actor b = CreateRenderableActor( imageB );
2960 Actor c = CreateRenderableActor( imageC );
2962 application.SendNotification();
2963 application.Render(1);
2965 //Textures are bound when first created. Clear bound textures vector
2966 application.GetGlAbstraction().ClearBoundTextures();
2968 // Render a,b,c as regular non-overlays. so order will be:
2972 application.GetScene().Add(a);
2973 application.GetScene().Add(b);
2974 application.GetScene().Add(c);
2976 application.SendNotification();
2977 application.Render(1);
2979 // Should be 3 textures changes.
2980 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2981 typedef std::vector<GLuint>::size_type TextureSize;
2982 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2983 if( boundTextures.size() == 3 )
2985 DALI_TEST_CHECK( boundTextures[0] == 8u );
2986 DALI_TEST_CHECK( boundTextures[1] == 9u );
2987 DALI_TEST_CHECK( boundTextures[2] == 10u );
2990 // Now texture ids have been set, we can monitor their render order.
2991 // render a as an overlay (last), so order will be:
2995 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
2996 application.GetGlAbstraction().ClearBoundTextures();
2998 application.SendNotification();
2999 application.Render(1);
3001 // Should be 3 texture changes.
3002 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
3003 if( boundTextures.size() == 3 )
3005 DALI_TEST_CHECK( boundTextures[0] == 9u );
3006 DALI_TEST_CHECK( boundTextures[1] == 10u );
3007 DALI_TEST_CHECK( boundTextures[2] == 8u );
3012 int UtcDaliActorGetCurrentWorldMatrix(void)
3014 TestApplication application;
3015 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3017 Actor parent = Actor::New();
3018 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3019 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3020 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3021 Radian rotationAngle(Degree(85.0f));
3022 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3023 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3024 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3025 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3026 parent.SetProperty( Actor::Property::SCALE, parentScale );
3027 application.GetScene().Add( parent );
3029 Actor child = Actor::New();
3030 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3031 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
3032 Radian childRotationAngle(Degree(23.0f));
3033 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
3034 Vector3 childScale( 2.0f, 2.0f, 2.0f );
3035 child.SetProperty( Actor::Property::POSITION, childPosition );
3036 child.SetProperty( Actor::Property::ORIENTATION, childRotation );
3037 child.SetProperty( Actor::Property::SCALE, childScale );
3038 parent.Add( child );
3040 application.SendNotification();
3041 application.Render(0);
3042 application.Render();
3043 application.SendNotification();
3045 Matrix parentMatrix(false);
3046 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3048 Matrix childMatrix(false);
3049 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
3051 //Child matrix should be the composition of child and parent
3052 Matrix childWorldMatrix(false);
3053 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
3055 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3056 DALI_TEST_EQUALS( child.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), childWorldMatrix, 0.001, TEST_LOCATION );
3062 int UtcDaliActorConstrainedToWorldMatrix(void)
3064 TestApplication application;
3065 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3067 Actor parent = Actor::New();
3068 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3069 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3070 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3071 Radian rotationAngle(Degree(85.0f));
3072 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3073 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3074 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3075 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3076 parent.SetProperty( Actor::Property::SCALE, parentScale );
3077 application.GetScene().Add( parent );
3079 Actor child = Actor::New();
3080 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3081 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3082 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3083 posConstraint.Apply();
3085 application.GetScene().Add( child );
3087 application.SendNotification();
3088 application.Render(0);
3089 application.Render();
3090 application.SendNotification();
3092 Matrix parentMatrix(false);
3093 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3095 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3096 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), 0.001, TEST_LOCATION );
3100 int UtcDaliActorConstrainedToOrientation(void)
3102 TestApplication application;
3103 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3105 Actor parent = Actor::New();
3106 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3107 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3108 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3109 Radian rotationAngle(Degree(85.0f));
3110 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3111 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3112 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3113 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3114 parent.SetProperty( Actor::Property::SCALE, parentScale );
3115 application.GetScene().Add( parent );
3117 Actor child = Actor::New();
3118 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3119 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3120 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3121 posConstraint.Apply();
3123 application.GetScene().Add( child );
3125 application.SendNotification();
3126 application.Render(0);
3127 application.Render();
3128 application.SendNotification();
3130 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION );
3134 int UtcDaliActorConstrainedToOpacity(void)
3136 TestApplication application;
3137 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3139 Actor parent = Actor::New();
3140 parent.SetProperty( Actor::Property::OPACITY, 0.7f );
3141 application.GetScene().Add( parent );
3143 Actor child = Actor::New();
3144 Constraint opacityConstraint = Constraint::New<float>( child, Actor::Property::OPACITY, EqualToConstraint() );
3145 opacityConstraint.AddSource( Source( parent, Actor::Property::OPACITY ) );
3146 opacityConstraint.Apply();
3148 application.GetScene().Add( child );
3150 application.SendNotification();
3151 application.Render(0);
3152 application.Render();
3153 application.SendNotification();
3155 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( Actor::Property::OPACITY ), parent.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3157 parent.SetProperty( Actor::Property::OPACITY, 0.3f );
3159 application.SendNotification();
3160 application.Render(0);
3161 application.Render();
3162 application.SendNotification();
3164 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( Actor::Property::OPACITY ), parent.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3169 int UtcDaliActorUnparent(void)
3171 TestApplication application;
3172 tet_infoline(" UtcDaliActorUnparent");
3174 Actor parent = Actor::New();
3175 application.GetScene().Add( parent );
3177 Actor child = Actor::New();
3179 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3180 DALI_TEST_CHECK( !child.GetParent() );
3182 // Test that calling Unparent with no parent is a NOOP
3185 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3186 DALI_TEST_CHECK( !child.GetParent() );
3188 // Test that Unparent works
3189 parent.Add( child );
3191 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3192 DALI_TEST_CHECK( parent == child.GetParent() );
3196 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3197 DALI_TEST_CHECK( !child.GetParent() );
3199 // Test that UnparentAndReset works
3200 parent.Add( child );
3202 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3203 DALI_TEST_CHECK( parent == child.GetParent() );
3205 UnparentAndReset( child );
3207 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3208 DALI_TEST_CHECK( !child );
3210 // Test that UnparentAndReset is a NOOP with empty handle
3211 UnparentAndReset( child );
3213 DALI_TEST_CHECK( !child );
3217 int UtcDaliActorGetChildAt(void)
3219 TestApplication application;
3220 tet_infoline(" UtcDaliActorGetChildAt");
3222 Actor parent = Actor::New();
3223 application.GetScene().Add( parent );
3225 Actor child0 = Actor::New();
3226 parent.Add( child0 );
3228 Actor child1 = Actor::New();
3229 parent.Add( child1 );
3231 Actor child2 = Actor::New();
3232 parent.Add( child2 );
3234 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3235 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3236 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3240 int UtcDaliActorSetGetOverlay(void)
3242 TestApplication application;
3243 tet_infoline(" UtcDaliActorSetGetOverlay");
3245 Actor parent = Actor::New();
3246 parent.SetProperty( Actor::Property::DRAW_MODE,DrawMode::OVERLAY_2D );
3247 DALI_TEST_CHECK( parent.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) == DrawMode::OVERLAY_2D );
3252 int UtcDaliActorCreateDestroy(void)
3254 Actor* actor = new Actor;
3255 DALI_TEST_CHECK( actor );
3262 struct PropertyStringIndex
3264 const char * const name;
3265 const Property::Index index;
3266 const Property::Type type;
3269 const PropertyStringIndex PROPERTY_TABLE[] =
3271 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3272 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3273 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3274 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3275 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3276 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3277 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3278 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3279 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3280 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3281 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3282 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3283 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3284 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3285 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3286 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3287 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3288 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3289 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3290 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3291 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3292 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3293 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3294 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3295 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3296 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3297 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3298 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3299 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3300 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3301 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3302 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3303 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3304 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3305 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3306 { "name", Actor::Property::NAME, Property::STRING },
3307 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3308 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3309 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3310 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3311 { "colorMode", Actor::Property::COLOR_MODE, Property::INTEGER },
3312 { "drawMode", Actor::Property::DRAW_MODE, Property::INTEGER },
3313 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3314 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3315 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3316 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER },
3317 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3318 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3319 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3320 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3321 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3322 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3323 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3324 { "opacity", Actor::Property::OPACITY, Property::FLOAT },
3326 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3327 } // unnamed namespace
3329 int UtcDaliActorProperties(void)
3331 TestApplication application;
3333 Actor actor = Actor::New();
3335 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3337 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3338 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3339 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3340 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3345 int UtcDaliRelayoutProperties_ResizePolicies(void)
3347 TestApplication application;
3349 Actor actor = Actor::New();
3352 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3353 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3355 // Set resize policy for all dimensions
3356 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3357 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3359 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3362 // Set individual dimensions
3363 const char* const widthPolicy = "FILL_TO_PARENT";
3364 const char* const heightPolicy = "FIXED";
3366 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3367 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3369 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3370 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3372 // Set individual dimensions using enums
3373 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3374 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3376 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3377 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3379 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3380 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3385 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3387 TestApplication application;
3389 Actor actor = Actor::New();
3392 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3394 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3395 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy );
3396 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy, TEST_LOCATION );
3399 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3400 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3402 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3403 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy1, TEST_LOCATION );
3405 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3406 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy2, TEST_LOCATION );
3411 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3413 TestApplication application;
3415 Actor actor = Actor::New();
3418 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3419 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3421 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3422 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode );
3423 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), sizeMode, TEST_LOCATION );
3426 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3428 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3429 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3434 int UtcDaliRelayoutProperties_DimensionDependency(void)
3436 TestApplication application;
3438 Actor actor = Actor::New();
3441 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3442 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3445 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3446 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3448 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3449 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3451 // Test setting another resize policy
3452 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3453 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3458 int UtcDaliRelayoutProperties_Padding(void)
3460 TestApplication application;
3462 Actor actor = Actor::New();
3465 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3468 actor.SetProperty( Actor::Property::PADDING, padding );
3469 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3471 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3476 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3478 TestApplication application;
3480 Actor actor = Actor::New();
3483 Vector2 minSize( 1.0f, 2.0f );
3485 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3486 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3488 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3490 Vector2 maxSize( 3.0f, 4.0f );
3492 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3493 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3495 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3500 int UtcDaliActorGetHeightForWidth(void)
3502 TestApplication application;
3504 Actor actor = Actor::New();
3506 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3511 int UtcDaliActorGetWidthForHeight(void)
3513 TestApplication application;
3515 Actor actor = Actor::New();
3517 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3522 int UtcDaliActorGetRelayoutSize(void)
3524 TestApplication application;
3526 Actor actor = Actor::New();
3528 // Add actor to stage
3529 application.GetScene().Add( actor );
3531 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3533 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3534 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 0.0f ) );
3536 // Flush the queue and render once
3537 application.SendNotification();
3538 application.Render();
3540 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3545 int UtcDaliActorSetPadding(void)
3547 TestApplication application;
3549 Actor actor = Actor::New();
3552 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3554 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3555 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3556 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3557 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3559 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3560 actor.SetProperty( Actor::Property::PADDING, padding2 );
3562 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3564 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3565 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3566 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3567 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3572 int UtcDaliActorSetMinimumSize(void)
3574 TestApplication application;
3576 Actor actor = Actor::New();
3578 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3580 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3581 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3583 Vector2 size2( 1.0f, 2.0f );
3584 actor.SetProperty( Actor::Property::MINIMUM_SIZE, size2 );
3586 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3588 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3589 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3594 int UtcDaliActorSetMaximumSize(void)
3596 TestApplication application;
3598 Actor actor = Actor::New();
3600 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3602 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3603 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3605 Vector2 size2( 1.0f, 2.0f );
3606 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, size2 );
3608 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3610 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3611 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3616 int UtcDaliActorOnRelayoutSignal(void)
3618 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3620 TestApplication application;
3623 gOnRelayoutCallBackCalled = false;
3624 gActorNamesRelayout.clear();
3626 Actor actor = Actor::New();
3627 actor.SetProperty( Actor::Property::NAME, "actor" );
3628 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3631 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3633 // Add actor to stage
3634 application.GetScene().Add( actor );
3636 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3637 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 2.0 ) );
3639 // Flush the queue and render once
3640 application.SendNotification();
3641 application.Render();
3643 // OnRelayout emitted
3644 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3645 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3650 int UtcDaliActorGetHierachyDepth(void)
3652 TestApplication application;
3653 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3656 /* Build tree of actors:
3666 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3668 Integration::Scene stage( application.GetScene() );
3670 Actor actorA = Actor::New();
3671 Actor actorB = Actor::New();
3672 Actor actorC = Actor::New();
3673 Actor actorD = Actor::New();
3674 Actor actorE = Actor::New();
3675 Actor actorF = Actor::New();
3677 //Test that root actor has depth equal 0
3678 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3680 //Test actors return depth -1 when not connected to the tree
3681 DALI_TEST_EQUALS( -1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3682 DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3683 DALI_TEST_EQUALS( -1, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3684 DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3685 DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3686 DALI_TEST_EQUALS( -1, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3688 //Create the hierarchy
3689 stage.Add( actorA );
3690 actorA.Add( actorB );
3691 actorA.Add( actorC );
3692 actorB.Add( actorD );
3693 actorB.Add( actorE );
3694 actorC.Add( actorF );
3696 //Test actors return correct depth
3697 DALI_TEST_EQUALS( 1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3698 DALI_TEST_EQUALS( 2, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3699 DALI_TEST_EQUALS( 2, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3700 DALI_TEST_EQUALS( 3, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3701 DALI_TEST_EQUALS( 3, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3702 DALI_TEST_EQUALS( 3, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3704 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3705 actorA.Remove( actorB );
3707 DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3708 DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3709 DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3711 //Removing actorA from the stage. All actors should have depth equal -1
3712 stage.Remove( actorA );
3714 DALI_TEST_EQUALS( -1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3715 DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3716 DALI_TEST_EQUALS( -1, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3717 DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3718 DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3719 DALI_TEST_EQUALS( -1, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3724 int UtcDaliActorAnchorPointPropertyAsString(void)
3726 TestApplication application;
3728 Actor actor = Actor::New();
3730 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3731 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3733 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3734 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3736 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3737 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3739 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3740 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3742 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3743 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER, TEST_LOCATION );
3745 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3746 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3748 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3749 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3751 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3752 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3754 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3755 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3757 // Invalid should not change anything
3758 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3759 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3764 int UtcDaliActorParentOriginPropertyAsString(void)
3766 TestApplication application;
3768 Actor actor = Actor::New();
3770 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3771 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3773 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3774 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3776 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3777 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3779 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3780 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3782 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3783 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER, TEST_LOCATION );
3785 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3786 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3788 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3789 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3791 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3792 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3794 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3795 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3797 // Invalid should not change anything
3798 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3799 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3804 int UtcDaliActorColorModePropertyAsString(void)
3806 TestApplication application;
3808 Actor actor = Actor::New();
3810 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3811 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3813 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3814 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3816 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3817 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3819 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3820 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3822 // Invalid should not change anything
3823 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3824 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3829 int UtcDaliActorDrawModePropertyAsString(void)
3831 TestApplication application;
3833 Actor actor = Actor::New();
3835 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3836 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3838 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3839 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3841 // Invalid should not change anything
3842 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3843 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3848 int UtcDaliActorColorModePropertyAsEnum(void)
3850 TestApplication application;
3852 Actor actor = Actor::New();
3854 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3855 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3857 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3858 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3860 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3861 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3863 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3864 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3869 int UtcDaliActorDrawModePropertyAsEnum(void)
3871 TestApplication application;
3873 Actor actor = Actor::New();
3875 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3876 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3878 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3879 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3884 int UtcDaliActorAddRendererP(void)
3886 tet_infoline("Testing Actor::AddRenderer");
3887 TestApplication application;
3889 Actor actor = Actor::New();
3891 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3893 Geometry geometry = CreateQuadGeometry();
3894 Shader shader = CreateShader();
3895 Renderer renderer = Renderer::New(geometry, shader);
3897 actor.AddRenderer( renderer );
3898 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3899 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3904 int UtcDaliActorAddRendererN01(void)
3906 tet_infoline("Testing Actor::AddRenderer");
3907 TestApplication application;
3909 Actor actor = Actor::New();
3915 actor.AddRenderer( renderer );
3916 tet_printf("Assertion test failed - no Exception\n" );
3917 tet_result(TET_FAIL);
3919 catch(Dali::DaliException& e)
3921 DALI_TEST_PRINT_ASSERT( e );
3922 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3923 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3927 tet_printf("Assertion test failed - wrong Exception\n" );
3928 tet_result(TET_FAIL);
3934 int UtcDaliActorAddRendererN02(void)
3936 tet_infoline( "UtcDaliActorAddRendererN02" );
3942 TestApplication application;
3944 Geometry geometry = CreateQuadGeometry();
3945 Shader shader = CreateShader();
3946 renderer = Renderer::New( geometry, shader );
3948 actor = Actor::New();
3951 // try illegal AddRenderer
3954 actor.AddRenderer( renderer );
3955 tet_printf( "Assertion test failed - no Exception\n" );
3956 tet_result( TET_FAIL );
3958 catch( Dali::DaliException& e )
3960 DALI_TEST_PRINT_ASSERT( e );
3961 DALI_TEST_ASSERT( e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION );
3965 tet_printf( "Assertion test failed - wrong Exception\n" );
3966 tet_result( TET_FAIL );
3972 int UtcDaliActorAddRendererOnScene(void)
3974 tet_infoline("Testing Actor::AddRenderer");
3975 TestApplication application;
3977 Actor actor = Actor::New();
3978 application.GetScene().Add(actor);
3980 application.SendNotification();
3981 application.Render(0);
3983 Geometry geometry = CreateQuadGeometry();
3984 Shader shader = CreateShader();
3985 Renderer renderer = Renderer::New(geometry, shader);
3987 application.SendNotification();
3988 application.Render(0);
3992 actor.AddRenderer( renderer );
3993 tet_result(TET_PASS);
3997 tet_result(TET_FAIL);
4003 int UtcDaliActorRemoveRendererP1(void)
4005 tet_infoline("Testing Actor::RemoveRenderer");
4006 TestApplication application;
4008 Actor actor = Actor::New();
4010 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4013 Geometry geometry = CreateQuadGeometry();
4014 Shader shader = CreateShader();
4015 Renderer renderer = Renderer::New(geometry, shader);
4017 actor.AddRenderer( renderer );
4018 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4019 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4021 application.SendNotification();
4022 application.Render();
4026 Renderer renderer = actor.GetRendererAt(0);
4027 actor.RemoveRenderer(renderer);
4028 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4030 application.SendNotification();
4031 application.Render();
4034 // Call one final time to ensure that the renderer is actually removed after
4035 // the handle goes out of scope, and excercises the deletion code path in
4036 // scene graph and render.
4037 application.SendNotification();
4038 application.Render();
4043 int UtcDaliActorRemoveRendererP2(void)
4045 tet_infoline("Testing Actor::RemoveRenderer");
4046 TestApplication application;
4048 Actor actor = Actor::New();
4050 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4052 Geometry geometry = CreateQuadGeometry();
4053 Shader shader = CreateShader();
4054 Renderer renderer = Renderer::New(geometry, shader);
4056 actor.AddRenderer( renderer );
4057 application.SendNotification();
4058 application.Render();
4060 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4061 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4063 actor.RemoveRenderer(0);
4064 application.SendNotification();
4065 application.Render();
4067 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4069 // Shut down whilst holding onto the renderer handle.
4074 int UtcDaliActorRemoveRendererN(void)
4076 tet_infoline("Testing Actor::RemoveRenderer");
4077 TestApplication application;
4079 Actor actor = Actor::New();
4081 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4083 Geometry geometry = CreateQuadGeometry();
4084 Shader shader = CreateShader();
4085 Renderer renderer = Renderer::New(geometry, shader);
4087 actor.AddRenderer( renderer );
4088 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4089 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4091 actor.RemoveRenderer(10);
4092 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4093 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4098 // Clipping test helper functions:
4099 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4101 Texture image = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
4102 Actor actor = CreateRenderableActor( image );
4104 // Setup dimensions and position so actor is not skipped by culling.
4105 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4106 actor.SetProperty( Actor::Property::SIZE, Vector2( width, height ) );
4107 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4108 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4113 Actor CreateActorWithContent16x16()
4115 return CreateActorWithContent( 16, 16 );
4118 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4120 enabledDisableTrace.Reset();
4121 stencilTrace.Reset();
4122 enabledDisableTrace.Enable( true );
4123 stencilTrace.Enable( true );
4125 application.SendNotification();
4126 application.Render();
4128 enabledDisableTrace.Enable( false );
4129 stencilTrace.Enable( false );
4132 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4134 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4136 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4137 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4138 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4139 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4142 int UtcDaliActorPropertyClippingP(void)
4144 // This test checks the clippingMode property.
4145 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4146 TestApplication application;
4148 Actor actor = Actor::New();
4150 // Check default clippingEnabled value.
4151 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4154 bool getValueResult = getValue.Get( value );
4155 DALI_TEST_CHECK( getValueResult );
4157 if( getValueResult )
4159 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4162 // Check setting the property to the stencil mode.
4163 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4165 // Check the new value was set.
4166 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4167 getValueResult = getValue.Get( value );
4168 DALI_TEST_CHECK( getValueResult );
4170 if( getValueResult )
4172 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4175 // Check setting the property to the scissor mode.
4176 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4178 // Check the new value was set.
4179 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4180 getValueResult = getValue.Get( value );
4181 DALI_TEST_CHECK( getValueResult );
4183 if( getValueResult )
4185 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4190 int UtcDaliActorPropertyClippingN(void)
4192 // Negative test case for Clipping.
4193 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4194 TestApplication application;
4196 Actor actor = Actor::New();
4198 // Check default clippingEnabled value.
4199 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4202 bool getValueResult = getValue.Get( value );
4203 DALI_TEST_CHECK( getValueResult );
4205 if( getValueResult )
4207 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4210 // Check setting an invalid property value won't change the current property value.
4211 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4213 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4214 getValueResult = getValue.Get( value );
4215 DALI_TEST_CHECK( getValueResult );
4217 if( getValueResult )
4219 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4225 int UtcDaliActorPropertyClippingActor(void)
4227 // This test checks that an actor is correctly setup for clipping.
4228 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4229 TestApplication application;
4231 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4232 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4233 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4234 size_t startIndex = 0u;
4236 // Create a clipping actor.
4237 Actor actorDepth1Clip = CreateActorWithContent16x16();
4238 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4239 application.GetScene().Add( actorDepth1Clip );
4241 // Gather the call trace.
4242 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4244 // Check we are writing to the color buffer.
4245 CheckColorMask( glAbstraction, true );
4247 // Check the stencil buffer was enabled.
4248 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4250 // Check the stencil buffer was cleared.
4251 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4253 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4254 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4255 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4256 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4261 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4263 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4264 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4265 TestApplication application;
4267 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4268 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4269 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4270 size_t startIndex = 0u;
4272 // Create a clipping actor.
4273 Actor actorDepth1Clip = CreateActorWithContent16x16();
4274 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4275 application.GetScene().Add( actorDepth1Clip );
4277 // Gather the call trace.
4278 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4280 // Check we are writing to the color buffer.
4281 CheckColorMask( glAbstraction, true );
4283 // Check the stencil buffer was enabled.
4284 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4286 // Check the stencil buffer was cleared.
4287 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4289 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4290 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4291 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4292 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4294 // Now disable the clipping
4295 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4297 // Gather the call trace.
4298 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4300 // Check the stencil buffer was disabled.
4301 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4303 // Ensure all values in stencil-mask are set to 1.
4305 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4310 int UtcDaliActorPropertyClippingNestedChildren(void)
4312 // This test checks that a hierarchy of actors are clipped correctly by
4313 // writing to and reading from the correct bit-planes of the stencil buffer.
4314 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4315 TestApplication application;
4316 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4317 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4318 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4320 // Create a clipping actor.
4321 Actor actorDepth1Clip = CreateActorWithContent16x16();
4322 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4323 application.GetScene().Add( actorDepth1Clip );
4325 // Create a child actor.
4326 Actor childDepth2 = CreateActorWithContent16x16();
4327 actorDepth1Clip.Add( childDepth2 );
4329 // Create another clipping actor.
4330 Actor childDepth2Clip = CreateActorWithContent16x16();
4331 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4332 childDepth2.Add( childDepth2Clip );
4334 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4335 // This tests the sort algorithm.
4336 Actor childDepth3 = CreateActorWithContent16x16();
4337 childDepth2Clip.Add( childDepth3 );
4338 Actor childDepth4 = CreateActorWithContent16x16();
4339 childDepth3.Add( childDepth4 );
4341 // Gather the call trace.
4342 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4344 // Check we are writing to the color buffer.
4345 CheckColorMask( glAbstraction, true );
4347 // Check the stencil buffer was enabled.
4348 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4350 // Perform the test twice, once for 2D layer, and once for 3D.
4351 for( unsigned int i = 0u ; i < 2u; ++i )
4353 size_t startIndex = 0u;
4355 // Check the stencil buffer was cleared.
4356 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4358 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4359 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4360 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4361 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4363 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4364 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4365 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4367 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4368 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4369 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4370 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4372 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4373 // (Both must be set to pass the check).
4374 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4375 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4377 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4380 application.GetScene().GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
4381 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4388 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4390 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4391 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4392 TestApplication application;
4393 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4394 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4396 /* We create a small tree of actors as follows:
4400 Clipping enabled -> B D
4404 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4407 for( int i = 0; i < 5; ++i )
4409 Texture image = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u );
4410 Actor actor = CreateRenderableActor( image );
4412 // Setup dimensions and position so actor is not skipped by culling.
4413 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4414 actor.SetProperty( Actor::Property::SIZE, Vector2( 16.0f, 16.0f ) );
4418 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4422 float b = i > 2 ? 1.0f : -1.0f;
4423 actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4429 // Enable clipping on the actor at the top of the left branch.
4430 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4432 // Build the scene graph.
4433 application.GetScene().Add( actors[0] );
4436 actors[0].Add( actors[1] );
4437 actors[1].Add( actors[2] );
4440 actors[0].Add( actors[3] );
4441 actors[3].Add( actors[4] );
4443 // Gather the call trace.
4444 enabledDisableTrace.Reset();
4445 enabledDisableTrace.Enable( true );
4446 application.SendNotification();
4447 application.Render();
4448 enabledDisableTrace.Enable( false );
4450 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4452 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
4453 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4455 size_t startIndex = 0u;
4456 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4457 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4458 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4460 // Swap the clipping actor from top of left branch to top of right branch.
4461 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4462 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4464 // Gather the call trace.
4465 enabledDisableTrace.Reset();
4466 enabledDisableTrace.Enable( true );
4467 application.SendNotification();
4468 application.Render();
4469 enabledDisableTrace.Enable( false );
4471 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4472 // This proves the draw order has remained the same.
4474 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4475 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4480 int UtcDaliActorPropertyScissorClippingActor(void)
4482 // This test checks that an actor is correctly setup for clipping.
4483 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4484 TestApplication application;
4486 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4487 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4488 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4490 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4491 const Vector2 imageSize( 16.0f, 16.0f );
4493 // Create a clipping actor.
4494 Actor clippingActorA = CreateActorWithContent16x16();
4495 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4496 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4497 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
4498 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
4499 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4500 application.GetScene().Add( clippingActorA );
4502 // Gather the call trace.
4503 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4505 // Check we are writing to the color buffer.
4506 CheckColorMask( glAbstraction, true );
4508 // Check scissor test was enabled.
4509 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4511 // Check the scissor was set, and the coordinates are correct.
4512 std::stringstream compareParametersString;
4513 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4514 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4516 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
4517 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT );
4519 // Gather the call trace.
4520 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4522 // Check the scissor was set, and the coordinates are correct.
4523 compareParametersString.str( std::string() );
4524 compareParametersString.clear();
4525 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4526 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4531 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4533 // This test checks that an actor is correctly setup for clipping.
4534 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4535 TestApplication application;
4538 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4539 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4540 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4542 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4543 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4544 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4546 // Create a clipping actors.
4547 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4548 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4550 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4551 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4552 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4554 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4555 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4556 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4558 clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4559 clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4561 application.GetScene().Add( clippingActorA );
4562 application.GetScene().Add( clippingActorB );
4564 // Gather the call trace.
4565 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4567 // Check we are writing to the color buffer.
4568 CheckColorMask( glAbstraction, true );
4570 // Check scissor test was enabled.
4571 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4573 // Check the scissor was set, and the coordinates are correct.
4574 std::stringstream compareParametersString;
4576 std::string clipA( "0, 500, 480, 200" );
4577 std::string clipB( "0, 380, 480, 40" );
4579 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4580 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4585 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4587 // This test checks that an actor is correctly setup for clipping.
4588 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4589 TestApplication application;
4591 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4592 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4593 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4595 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4596 const Vector2 imageSize( 16.0f, 16.0f );
4598 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4600 A is drawn first - with scissor clipping on
4601 B is drawn second - also with scissor clipping on
4602 C is the generated clipping region, the intersection ( A ∩ B )
4606 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4607 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4608 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4612 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4615 // Create a clipping actor.
4616 Actor clippingActorA = CreateActorWithContent16x16();
4617 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4618 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4619 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4620 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4621 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4622 application.GetScene().Add( clippingActorA );
4624 // Create a child clipping actor.
4625 Actor clippingActorB = CreateActorWithContent16x16();
4626 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4627 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4628 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4629 clippingActorA.Add( clippingActorB );
4631 // positionModifiers is an array of positions to position B around.
4632 // expect is an array of expected scissor clip coordinate results.
4633 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4634 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4636 // Loop through each overlap combination.
4637 for( unsigned int test = 0u; test < 4u; ++test )
4639 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4640 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4641 clippingActorB.SetProperty( Actor::Property::POSITION, Vector2( position.x, position.y ));
4643 // Gather the call trace.
4644 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4646 // Check we are writing to the color buffer.
4647 CheckColorMask( glAbstraction, true );
4649 // Check scissor test was enabled.
4650 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4652 // Check the scissor was set, and the coordinates are correct.
4653 const Vector4& expectResults( expect[test] );
4654 std::stringstream compareParametersString;
4655 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4656 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4662 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4664 // This test checks that an actor is correctly setup for clipping.
4665 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4666 TestApplication application;
4668 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4669 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4670 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4672 /* Create a nest of 2 scissors and siblings of the parent.
4682 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4683 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4684 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4685 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4686 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4687 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4689 // Create a clipping actors.
4690 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4691 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4692 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4693 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4694 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4696 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4697 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4698 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4700 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4701 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4702 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4704 clippingActorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4705 clippingActorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4706 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4708 clippingActorD.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4709 clippingActorD.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4710 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4712 clippingActorE.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4713 clippingActorE.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4715 clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4716 clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4717 clippingActorC.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 100.0f, 0.0f ));
4718 clippingActorD.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4719 clippingActorE.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4721 application.GetScene().Add( clippingActorA );
4722 clippingActorA.Add( clippingActorB );
4723 application.GetScene().Add( clippingActorC );
4724 application.GetScene().Add( clippingActorD );
4725 clippingActorD.Add( clippingActorE );
4727 // Gather the call trace.
4728 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4730 // Check we are writing to the color buffer.
4731 CheckColorMask( glAbstraction, true );
4733 // Check scissor test was enabled.
4734 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4736 // Check the scissor was set, and the coordinates are correct.
4737 std::string clipA( "0, 500, 480, 200" );
4738 std::string clipB( "0, 580, 480, 40" );
4739 std::string clipC( "0, 200, 480, 200" );
4740 std::string clipD( "0, 300, 480, 200" );
4742 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4743 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4744 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4745 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4746 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4751 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4753 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4754 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4755 TestApplication application;
4757 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4758 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4759 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4761 // Create a clipping actor.
4762 Actor actorDepth1Clip = CreateActorWithContent16x16();
4763 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4764 application.GetScene().Add( actorDepth1Clip );
4766 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4767 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4769 // Gather the call trace.
4770 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4772 // Check we are writing to the color buffer.
4773 CheckColorMask( glAbstraction, true );
4775 // Check the stencil buffer was not enabled.
4776 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4778 // Check stencil functions are not called.
4779 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4780 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4781 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4783 // Check that scissor clipping is overriden by the renderer properties.
4784 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4786 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4788 // Gather the call trace.
4789 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4791 // Check the stencil buffer was not enabled.
4792 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4794 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4799 int UtcDaliGetPropertyN(void)
4801 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4802 TestApplication application;
4804 Actor actor = Actor::New();
4806 unsigned int propertyCount = actor.GetPropertyCount();
4807 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4811 int UtcDaliActorRaiseLower(void)
4813 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4815 TestApplication application;
4817 Debug::Filter::SetGlobalLogLevel( Debug::Verbose );
4819 Integration::Scene stage( application.GetScene() );
4821 Actor actorA = Actor::New();
4822 Actor actorB = Actor::New();
4823 Actor actorC = Actor::New();
4825 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4826 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4828 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4829 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4831 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4832 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4834 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4835 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4837 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4838 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4840 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4841 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4843 stage.Add( actorA );
4844 stage.Add( actorB );
4845 stage.Add( actorC );
4847 ResetTouchCallbacks();
4849 application.SendNotification();
4850 application.Render();
4852 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4853 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4854 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4856 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4857 // Only top actor will get touched.
4858 actorA.TouchSignal().Connect( TestTouchCallback );
4859 actorB.TouchSignal().Connect( TestTouchCallback2 );
4860 actorC.TouchSignal().Connect( TestTouchCallback3 );
4862 // Connect ChildOrderChangedSignal
4863 bool orderChangedSignal( false );
4864 Actor orderChangedActor;
4865 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4866 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4868 Dali::Integration::Point point;
4869 point.SetDeviceId( 1 );
4870 point.SetState( PointState::DOWN );
4871 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4872 Dali::Integration::TouchEvent touchEvent;
4873 touchEvent.AddPoint( point );
4875 application.ProcessEvent( touchEvent );
4877 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4878 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4879 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4881 ResetTouchCallbacks();
4883 tet_printf( "Testing Raising of Actor\n" );
4885 int preActorOrder( 0 );
4886 int postActorOrder( 0 );
4888 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4889 value.Get( preActorOrder );
4891 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4893 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4894 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4896 // Ensure sort order is calculated before next touch event
4897 application.SendNotification();
4899 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4900 value.Get( postActorOrder );
4902 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4904 application.ProcessEvent( touchEvent );
4906 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4907 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4908 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4910 ResetTouchCallbacks();
4912 tet_printf( "Testing Lowering of Actor\n" );
4914 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4915 value.Get( preActorOrder );
4917 orderChangedSignal = false;
4919 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4921 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4922 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4924 application.SendNotification(); // ensure sort order calculated before next touch event
4926 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4927 value.Get( postActorOrder );
4929 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4931 application.ProcessEvent( touchEvent );
4933 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4934 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4935 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4937 ResetTouchCallbacks();
4939 Debug::Filter::SetGlobalLogLevel( Debug::NoLogging );
4944 int UtcDaliActorRaiseToTopLowerToBottom(void)
4946 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4948 TestApplication application;
4950 Integration::Scene stage( application.GetScene() );
4952 Actor actorA = Actor::New();
4953 Actor actorB = Actor::New();
4954 Actor actorC = Actor::New();
4956 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4957 // enables checking of which actor the uniform is assigned too
4958 Shader shaderA = CreateShader();
4959 shaderA.RegisterProperty( "uRendererColor",1.f);
4961 Shader shaderB = CreateShader();
4962 shaderB.RegisterProperty( "uRendererColor", 2.f );
4964 Shader shaderC = CreateShader();
4965 shaderC.RegisterProperty( "uRendererColor", 3.f );
4967 Geometry geometry = CreateQuadGeometry();
4969 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4970 Renderer rendererA = Renderer::New(geometry, shaderA);
4971 actorA.AddRenderer(rendererA);
4973 Renderer rendererB = Renderer::New(geometry, shaderB);
4974 actorB.AddRenderer(rendererB);
4976 Renderer rendererC = Renderer::New(geometry, shaderC);
4977 actorC.AddRenderer(rendererC);
4979 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4980 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4982 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4983 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4985 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4986 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4988 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4989 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4991 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4992 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4994 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4995 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4997 stage.Add( actorA );
4998 stage.Add( actorB );
4999 stage.Add( actorC );
5001 ResetTouchCallbacks();
5003 // Connect ChildOrderChangedSignal
5004 bool orderChangedSignal( false );
5005 Actor orderChangedActor;
5006 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5007 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5009 // Set up gl abstraction trace so can query the set uniform order
5010 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5011 glAbstraction.EnableSetUniformCallTrace(true);
5012 glAbstraction.ResetSetUniformCallStack();
5014 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5016 application.SendNotification();
5017 application.Render();
5019 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
5022 // Test order of uniforms in stack
5023 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5024 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5025 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5027 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5029 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5031 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5032 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5033 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5035 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5036 // Only top actor will get touched.
5037 actorA.TouchSignal().Connect( TestTouchCallback );
5038 actorB.TouchSignal().Connect( TestTouchCallback2 );
5039 actorC.TouchSignal().Connect( TestTouchCallback3 );
5041 Dali::Integration::Point point;
5042 point.SetDeviceId( 1 );
5043 point.SetState( PointState::DOWN );
5044 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5045 Dali::Integration::TouchEvent touchEvent;
5046 touchEvent.AddPoint( point );
5048 application.ProcessEvent( touchEvent );
5050 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5051 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5052 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5054 ResetTouchCallbacks();
5056 tet_printf( "RaiseToTop ActorA\n" );
5058 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5059 actorA.RaiseToTop();
5060 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5061 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5063 application.SendNotification(); // ensure sorting order is calculated before next touch event
5065 application.ProcessEvent( touchEvent );
5067 glAbstraction.ResetSetUniformCallStack();
5068 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5070 application.SendNotification();
5071 application.Render();
5073 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5075 // Test order of uniforms in stack
5076 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5077 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5078 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5080 tet_infoline( "Testing A above C and B at bottom\n" );
5081 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5083 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5085 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5086 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5087 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5089 ResetTouchCallbacks();
5091 tet_printf( "RaiseToTop ActorB\n" );
5093 orderChangedSignal = false;
5095 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5096 actorB.RaiseToTop();
5097 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5098 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5100 application.SendNotification(); // Ensure sort order is calculated before next touch event
5102 application.ProcessEvent( touchEvent );
5104 glAbstraction.ResetSetUniformCallStack();
5105 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5107 application.SendNotification();
5108 application.Render();
5110 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5112 // Test order of uniforms in stack
5113 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5114 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5115 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5117 tet_infoline( "Testing B above A and C at bottom\n" );
5118 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5120 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5122 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5123 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5124 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5126 ResetTouchCallbacks();
5128 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5130 orderChangedSignal = false;
5132 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5133 actorA.LowerToBottom();
5134 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5135 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5137 application.SendNotification();
5138 application.Render();
5140 orderChangedSignal = false;
5142 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5143 actorB.LowerToBottom();
5144 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5145 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5147 application.SendNotification();
5148 application.Render();
5150 application.ProcessEvent( touchEvent );
5152 glAbstraction.ResetSetUniformCallStack();
5153 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5155 application.SendNotification();
5156 application.Render();
5158 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5160 // Test order of uniforms in stack
5161 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5162 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5163 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5165 tet_infoline( "Testing C above A and B at bottom\n" );
5166 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5168 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5170 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5171 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5172 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5174 ResetTouchCallbacks();
5179 int UtcDaliActorRaiseAbove(void)
5181 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5183 TestApplication application;
5185 Integration::Scene stage( application.GetScene() );
5187 Actor actorA = Actor::New();
5188 Actor actorB = Actor::New();
5189 Actor actorC = Actor::New();
5191 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5192 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5194 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5195 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5197 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5198 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5200 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5201 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5203 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5204 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5206 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5207 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5209 stage.Add( actorA );
5210 stage.Add( actorB );
5211 stage.Add( actorC );
5213 ResetTouchCallbacks();
5215 application.SendNotification();
5216 application.Render();
5218 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5219 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5220 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5222 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5223 // Only top actor will get touched.
5224 actorA.TouchSignal().Connect( TestTouchCallback );
5225 actorB.TouchSignal().Connect( TestTouchCallback2 );
5226 actorC.TouchSignal().Connect( TestTouchCallback3 );
5228 bool orderChangedSignal( false );
5229 Actor orderChangedActor;
5230 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5231 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5233 Dali::Integration::Point point;
5234 point.SetDeviceId( 1 );
5235 point.SetState( PointState::DOWN );
5236 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5237 Dali::Integration::TouchEvent touchEvent;
5238 touchEvent.AddPoint( point );
5240 application.ProcessEvent( touchEvent );
5242 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5243 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5244 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5246 ResetTouchCallbacks();
5248 tet_printf( "Raise actor B Above Actor C\n" );
5250 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5251 actorB.RaiseAbove( actorC );
5252 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5253 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5255 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5256 application.SendNotification();
5257 application.ProcessEvent( touchEvent );
5259 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5260 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5261 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5263 ResetTouchCallbacks();
5265 tet_printf( "Raise actor A Above Actor B\n" );
5267 orderChangedSignal = false;
5269 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5270 actorA.RaiseAbove( actorB );
5271 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5272 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5274 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5275 application.SendNotification();
5277 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5279 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5280 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5281 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5283 ResetTouchCallbacks();
5288 int UtcDaliActorLowerBelow(void)
5290 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5292 TestApplication application;
5294 Integration::Scene stage( application.GetScene() );
5296 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5297 // enables checking of which actor the uniform is assigned too
5298 Shader shaderA = CreateShader();
5299 shaderA.RegisterProperty( "uRendererColor",1.f);
5301 Shader shaderB = CreateShader();
5302 shaderB.RegisterProperty( "uRendererColor", 2.f );
5304 Shader shaderC = CreateShader();
5305 shaderC.RegisterProperty( "uRendererColor", 3.f );
5307 Actor actorA = Actor::New();
5308 Actor actorB = Actor::New();
5309 Actor actorC = Actor::New();
5311 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5312 Geometry geometry = CreateQuadGeometry();
5314 Renderer rendererA = Renderer::New(geometry, shaderA);
5315 actorA.AddRenderer(rendererA);
5317 Renderer rendererB = Renderer::New(geometry, shaderB);
5318 actorB.AddRenderer(rendererB);
5320 Renderer rendererC = Renderer::New(geometry, shaderC);
5321 actorC.AddRenderer(rendererC);
5323 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5324 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5326 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5327 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5329 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5330 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5332 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5333 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5335 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5336 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5338 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5339 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5341 Actor container = Actor::New();
5342 container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5343 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5344 stage.Add( container );
5346 container.Add( actorA );
5347 container.Add( actorB );
5348 container.Add( actorC );
5350 ResetTouchCallbacks();
5352 // Connect ChildOrderChangedSignal
5353 bool orderChangedSignal( false );
5354 Actor orderChangedActor;
5355 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5356 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5358 // Set up gl abstraction trace so can query the set uniform order
5359 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5360 glAbstraction.EnableSetUniformCallTrace(true);
5361 glAbstraction.ResetSetUniformCallStack();
5362 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5364 glAbstraction.ResetSetUniformCallStack();
5366 application.SendNotification();
5367 application.Render();
5369 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5371 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5373 // Test order of uniforms in stack
5374 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5375 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5376 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5378 tet_infoline( "Testing C above B and A at bottom\n" );
5379 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5381 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5383 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5384 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5385 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5387 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5388 // Only top actor will get touched.
5389 actorA.TouchSignal().Connect( TestTouchCallback );
5390 actorB.TouchSignal().Connect( TestTouchCallback2 );
5391 actorC.TouchSignal().Connect( TestTouchCallback3 );
5393 Dali::Integration::Point point;
5394 point.SetDeviceId( 1 );
5395 point.SetState( PointState::DOWN );
5396 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5397 Dali::Integration::TouchEvent touchEvent;
5398 touchEvent.AddPoint( point );
5400 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5402 application.ProcessEvent( touchEvent );
5404 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5405 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5406 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5408 ResetTouchCallbacks();
5410 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" );
5412 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5413 actorC.LowerBelow( actorB );
5414 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5415 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5417 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5418 application.SendNotification();
5419 application.Render();
5421 application.ProcessEvent( touchEvent ); // touch event
5423 glAbstraction.ResetSetUniformCallStack();
5424 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5426 application.SendNotification();
5427 application.Render();
5429 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5431 // Test order of uniforms in stack
5432 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5433 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5434 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5436 tet_infoline( "Testing render order is A, C, B" );
5437 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5438 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5440 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5441 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5442 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5444 ResetTouchCallbacks();
5446 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5448 orderChangedSignal = false;
5450 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5451 actorC.LowerBelow( actorA );
5452 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5453 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5455 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5456 application.SendNotification();
5457 application.Render();
5459 application.ProcessEvent( touchEvent );
5461 glAbstraction.ResetSetUniformCallStack();
5462 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5464 application.Render();
5465 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5467 // Test order of uniforms in stack
5468 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5469 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5470 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5472 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5473 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5475 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5476 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5477 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5479 ResetTouchCallbacks();
5481 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5483 orderChangedSignal = false;
5485 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5486 actorB.LowerBelow( actorC );
5487 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5488 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5490 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5491 application.SendNotification();
5492 application.Render();
5494 application.ProcessEvent( touchEvent );
5496 glAbstraction.ResetSetUniformCallStack();
5497 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5499 application.Render();
5500 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5502 // Test order of uniforms in stack
5503 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5504 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5505 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5507 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5508 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5514 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5516 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5518 TestApplication application;
5520 Integration::Scene stage( application.GetScene() );
5522 Actor parentA = Actor::New();
5523 Actor parentB = Actor::New();
5524 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5525 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5526 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5527 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5529 parentA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5530 parentA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5532 parentB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5533 parentB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5535 stage.Add( parentA );
5536 stage.Add( parentB );
5538 Actor actorA = Actor::New();
5539 Actor actorB = Actor::New();
5540 Actor actorC = Actor::New();
5542 parentA.Add( actorA );
5543 parentA.Add( actorB );
5545 tet_printf( "Actor C added to different parent from A and B \n" );
5546 parentB.Add( actorC );
5548 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5549 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5551 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5552 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5554 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5555 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5557 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5558 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5560 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5561 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5563 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5564 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5566 ResetTouchCallbacks();
5568 // Connect ChildOrderChangedSignal
5569 bool orderChangedSignal( false );
5570 Actor orderChangedActor;
5571 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5572 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5574 application.SendNotification();
5575 application.Render();
5577 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5578 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5579 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5581 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5582 // Only top actor will get touched.
5583 actorA.TouchSignal().Connect( TestTouchCallback );
5584 actorB.TouchSignal().Connect( TestTouchCallback2 );
5585 actorC.TouchSignal().Connect( TestTouchCallback3 );
5587 Dali::Integration::Point point;
5588 point.SetDeviceId( 1 );
5589 point.SetState( PointState::DOWN );
5590 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5591 Dali::Integration::TouchEvent touchEvent;
5592 touchEvent.AddPoint( point );
5594 application.ProcessEvent( touchEvent );
5596 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5597 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5598 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5600 ResetTouchCallbacks();
5602 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5604 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5605 actorA.RaiseAbove( actorC );
5606 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5608 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5609 application.SendNotification();
5611 application.ProcessEvent( touchEvent ); // touch event
5613 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5614 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5615 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5617 ResetTouchCallbacks();
5622 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5624 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5626 TestApplication application;
5628 Integration::Scene stage( application.GetScene() );
5630 Actor actorA = Actor::New();
5631 Actor actorB = Actor::New();
5632 Actor actorC = Actor::New();
5634 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5635 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5637 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5638 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5640 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5641 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5643 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5644 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5646 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5647 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5649 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5650 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5652 ResetTouchCallbacks();
5654 // Connect ChildOrderChangedSignal
5655 bool orderChangedSignal( false );
5656 Actor orderChangedActor;
5657 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5658 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5660 application.SendNotification();
5661 application.Render();
5663 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5664 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5665 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5667 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5668 // Only top actor will get touched.
5669 actorA.TouchSignal().Connect( TestTouchCallback );
5670 actorB.TouchSignal().Connect( TestTouchCallback2 );
5671 actorC.TouchSignal().Connect( TestTouchCallback3 );
5673 Dali::Integration::Point point;
5674 point.SetDeviceId( 1 );
5675 point.SetState( PointState::DOWN );
5676 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5677 Dali::Integration::TouchEvent touchEvent;
5678 touchEvent.AddPoint( point );
5680 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5682 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5683 actorA.RaiseAbove( actorC );
5684 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5686 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5687 application.SendNotification();
5689 application.ProcessEvent( touchEvent );
5691 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5693 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5694 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5695 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5697 ResetTouchCallbacks();
5699 orderChangedSignal = false;
5701 stage.Add ( actorB );
5702 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5704 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5705 actorA.LowerBelow( actorC );
5706 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5708 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5709 application.SendNotification();
5710 application.Render();
5712 application.ProcessEvent( touchEvent );
5714 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5715 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5716 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5717 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5719 ResetTouchCallbacks();
5721 orderChangedSignal = false;
5723 tet_printf( "Adding Actor A to stage, will be on top\n" );
5725 stage.Add ( actorA );
5726 application.SendNotification();
5727 application.Render();
5729 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5731 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5732 actorB.RaiseAbove( actorC );
5733 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5735 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5736 application.SendNotification();
5738 application.ProcessEvent( touchEvent );
5740 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5741 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5742 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5743 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5745 ResetTouchCallbacks();
5747 orderChangedSignal = false;
5749 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5751 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5752 actorA.LowerBelow( actorC );
5753 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5755 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5756 application.SendNotification();
5758 application.ProcessEvent( touchEvent );
5760 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5761 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5762 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5763 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5765 ResetTouchCallbacks();
5767 orderChangedSignal = false;
5769 stage.Add ( actorC );
5771 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5772 actorA.RaiseAbove( actorC );
5773 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5774 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5776 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5777 application.SendNotification();
5778 application.Render();
5780 application.ProcessEvent( touchEvent );
5782 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5783 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5784 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5785 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5790 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5792 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5794 TestApplication application;
5796 Integration::Scene stage( application.GetScene() );
5798 Actor actorA = Actor::New();
5799 Actor actorB = Actor::New();
5800 Actor actorC = Actor::New();
5802 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5803 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5805 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5806 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5808 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5809 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5811 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5812 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5814 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5815 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5817 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5818 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5820 ResetTouchCallbacks();
5822 // Connect ChildOrderChangedSignal
5823 bool orderChangedSignal( false );
5824 Actor orderChangedActor;
5825 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5826 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5828 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5829 // Only top actor will get touched.
5830 actorA.TouchSignal().Connect( TestTouchCallback );
5831 actorB.TouchSignal().Connect( TestTouchCallback2 );
5832 actorC.TouchSignal().Connect( TestTouchCallback3 );
5834 Dali::Integration::Point point;
5835 point.SetDeviceId( 1 );
5836 point.SetState( PointState::DOWN );
5837 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5838 Dali::Integration::TouchEvent touchEvent;
5839 touchEvent.AddPoint( point );
5841 stage.Add ( actorA );
5842 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5844 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5846 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5848 application.SendNotification();
5849 application.Render();
5851 application.ProcessEvent( touchEvent );
5853 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5855 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5856 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5857 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5859 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5860 ResetTouchCallbacks();
5862 orderChangedSignal = false;
5864 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5866 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5868 // Sort actor tree before next touch event
5869 application.SendNotification();
5870 application.Render();
5872 application.ProcessEvent( touchEvent );
5874 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5876 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5877 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5878 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5879 ResetTouchCallbacks();
5881 orderChangedSignal = false;
5883 tet_printf( "Lower actor C below B but C not parented\n" );
5885 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5887 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5889 // Sort actor tree before next touch event
5890 application.SendNotification();
5891 application.Render();
5893 application.ProcessEvent( touchEvent );
5895 tet_printf( "Not parented so Lower should show no effect\n" );
5897 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5898 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5899 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5900 ResetTouchCallbacks();
5902 orderChangedSignal = false;
5904 tet_printf( "Raise actor B to top\n" );
5906 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5907 actorB.RaiseToTop();
5908 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5910 // Sort actor tree before next touch event
5911 application.SendNotification();
5912 application.Render();
5914 application.ProcessEvent( touchEvent );
5916 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5918 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5919 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5920 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5921 ResetTouchCallbacks();
5923 orderChangedSignal = false;
5925 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5927 stage.Add ( actorB );
5929 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5931 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5932 actorC.LowerToBottom();
5933 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5935 application.SendNotification();
5936 application.Render();
5938 application.ProcessEvent( touchEvent );
5940 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5942 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5943 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5944 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5945 ResetTouchCallbacks();
5951 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5953 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5955 TestApplication application;
5957 Integration::Scene stage( application.GetScene() );
5959 Actor actorA = Actor::New();
5960 Actor actorB = Actor::New();
5961 Actor actorC = Actor::New();
5963 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5964 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5966 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5967 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5969 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5970 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5972 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5973 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5975 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5976 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5978 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5979 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5981 stage.Add( actorA );
5982 stage.Add( actorB );
5983 stage.Add( actorC );
5985 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5986 // Only top actor will get touched.
5987 actorA.TouchSignal().Connect( TestTouchCallback );
5988 actorB.TouchSignal().Connect( TestTouchCallback2 );
5989 actorC.TouchSignal().Connect( TestTouchCallback3 );
5991 ResetTouchCallbacks();
5993 // Connect ChildOrderChangedSignal
5994 bool orderChangedSignal( false );
5995 Actor orderChangedActor;
5996 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5997 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5999 application.SendNotification();
6000 application.Render();
6002 Dali::Integration::Point point;
6003 point.SetDeviceId( 1 );
6004 point.SetState( PointState::DOWN );
6005 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
6006 Dali::Integration::TouchEvent touchEvent;
6007 touchEvent.AddPoint( point );
6009 application.ProcessEvent( touchEvent );
6011 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
6012 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6013 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
6015 ResetTouchCallbacks();
6017 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
6019 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6020 actorA.RaiseAbove( actorA );
6021 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6022 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6024 application.SendNotification();
6025 application.Render();
6027 application.ProcessEvent( touchEvent );
6029 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
6031 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
6032 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6033 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
6035 ResetTouchCallbacks();
6037 orderChangedSignal = false;
6039 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6040 actorA.RaiseAbove( actorC );
6041 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6042 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6044 application.SendNotification();
6045 application.Render();
6047 application.ProcessEvent( touchEvent );
6049 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
6050 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
6051 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6052 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
6057 int UtcDaliActorGetScreenPosition(void)
6059 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
6061 TestApplication application;
6063 Integration::Scene stage( application.GetScene() );
6065 Actor actorA = Actor::New();
6066 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6068 Vector2 size2( 10.0f, 20.0f );
6069 actorA.SetProperty( Actor::Property::SIZE, size2 );
6071 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6073 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6075 stage.Add( actorA );
6077 application.SendNotification();
6078 application.Render();
6080 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6081 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6083 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6084 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6086 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6087 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6089 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6091 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6093 application.SendNotification();
6094 application.Render();
6096 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6097 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6099 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6100 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6102 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6103 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6105 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6107 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6109 application.SendNotification();
6110 application.Render();
6112 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6113 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6115 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6116 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6118 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6119 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6121 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6123 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 0.0 ));
6125 application.SendNotification();
6126 application.Render();
6128 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6129 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6131 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6132 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6134 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6135 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6137 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6139 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 420.0 ));
6141 application.SendNotification();
6142 application.Render();
6144 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6145 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6147 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6148 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6150 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6151 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6153 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6155 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6156 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 30.0 ));
6158 Actor actorB = Actor::New();
6159 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6160 actorB.SetProperty( Actor::Property::SIZE, size2 );
6161 actorB.SetProperty( Actor::Property::POSITION, Vector2( 10.f, 10.f ));
6162 actorA.Add( actorB );
6164 actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6166 application.SendNotification();
6167 application.Render();
6169 actorScreenPosition = actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6171 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6172 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6177 int UtcDaliActorGetScreenPositionAfterScaling(void)
6179 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6181 TestApplication application;
6183 Integration::Scene stage( application.GetScene() );
6185 Actor actorA = Actor::New();
6186 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6188 Vector2 size2( 10.0f, 20.0f );
6189 actorA.SetProperty( Actor::Property::SIZE, size2 );
6190 actorA.SetProperty( Actor::Property::SCALE, 1.5f );
6191 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6193 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6195 stage.Add( actorA );
6197 application.SendNotification();
6198 application.Render();
6200 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6201 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6203 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6204 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6206 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6207 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6209 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6211 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6213 application.SendNotification();
6214 application.Render();
6216 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6217 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6219 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6220 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6222 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6223 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6228 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6230 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6232 TestApplication application;
6234 Integration::Scene stage( application.GetScene() );
6236 Actor actorA = Actor::New();
6237 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6238 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6239 Vector2 size2( 10.0f, 20.0f );
6240 actorA.SetProperty( Actor::Property::SIZE, size2 );
6241 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6243 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6245 stage.Add( actorA );
6247 application.SendNotification();
6248 application.Render();
6250 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6251 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6253 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6254 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6256 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6257 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6259 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6261 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
6262 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6264 application.SendNotification();
6265 application.Render();
6267 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6268 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6270 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6271 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6273 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6274 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6280 int UtcDaliActorGetScreenPositionWithChildActors(void)
6282 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6284 TestApplication application;
6286 Integration::Scene stage( application.GetScene() );
6288 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6290 Actor actorA = Actor::New();
6291 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6292 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6293 Vector2 size1( 10.0f, 20.0f );
6294 actorA.SetProperty( Actor::Property::SIZE, size1 );
6295 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6297 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6299 Actor parentActorA = Actor::New();
6300 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6301 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6302 Vector2 size2( 30.0f, 60.0f );
6303 parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6304 parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6306 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6308 stage.Add( parentActorA );
6309 parentActorA.Add ( actorA );
6311 application.SendNotification();
6312 application.Render();
6314 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6315 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6317 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6318 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6320 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6321 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6323 tet_infoline( "Test 2\n");
6325 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6327 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6328 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
6330 application.SendNotification();
6331 application.Render();
6333 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6334 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6336 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6337 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6339 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6340 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6345 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6347 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6349 TestApplication application;
6351 Integration::Scene stage( application.GetScene() );
6353 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6355 Actor actorA = Actor::New();
6356 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6357 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6358 Vector2 size1( 10.0f, 20.0f );
6359 actorA.SetProperty( Actor::Property::SIZE, size1 );
6360 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6362 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6364 Actor parentActorA = Actor::New();
6365 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6366 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6367 Vector2 size2( 30.0f, 60.0f );
6368 parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6369 parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6371 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6373 Actor grandParentActorA = Actor::New();
6374 grandParentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6375 grandParentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
6376 Vector2 size3( 60.0f, 120.0f );
6377 grandParentActorA.SetProperty( Actor::Property::SIZE, size3 );
6378 grandParentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6380 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6382 stage.Add( grandParentActorA );
6383 grandParentActorA.Add ( parentActorA );
6385 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6387 parentActorA.Add ( actorA );
6389 application.SendNotification();
6390 application.Render();
6392 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6393 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6395 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6396 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6398 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6399 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6404 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6406 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6408 TestApplication application;
6410 Integration::Scene stage( application.GetScene() );
6412 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6414 Actor actorA = Actor::New();
6415 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6416 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6417 actorA.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6418 actorA.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 20.0f ) );
6419 stage.Add( actorA );
6421 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6423 Actor actorB = Actor::New();
6424 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6425 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6426 actorB.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6427 Vector2 actorBSize( 30.0f, 60.0f );
6428 actorB.SetProperty( Actor::Property::SIZE, actorBSize );
6429 stage.Add( actorB );
6431 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6433 Actor actorC = Actor::New();
6434 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6435 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6436 actorC.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6437 Vector2 actorCSize( 60.0f, 120.0f );
6438 actorC.SetProperty( Actor::Property::SIZE, actorCSize );
6439 stage.Add( actorC );
6441 application.SendNotification();
6442 application.Render();
6444 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6446 Vector2 center( stage.GetSize() * 0.5f );
6448 DALI_TEST_EQUALS( actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6449 DALI_TEST_EQUALS( actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6450 DALI_TEST_EQUALS( actorC.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6452 tet_infoline( "Add scale to all actors" );
6454 actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6455 actorB.SetProperty( Actor::Property::SCALE, 2.0f );
6456 actorC.SetProperty( Actor::Property::SCALE, 2.0f );
6458 application.SendNotification();
6459 application.Render();
6461 DALI_TEST_EQUALS( actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6462 DALI_TEST_EQUALS( actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6463 DALI_TEST_EQUALS( actorC.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6468 int utcDaliActorPositionUsesAnchorPoint(void)
6470 TestApplication application;
6471 tet_infoline( "Check default behaviour\n" );
6473 Actor actor = Actor::New();
6474 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6475 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6476 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6477 application.GetScene().Add( actor );
6479 application.SendNotification();
6480 application.Render();
6482 tet_infoline( "Check that the world position is in the center\n" );
6483 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6485 tet_infoline( "Set the position uses anchor point property to false\n" );
6486 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6488 application.SendNotification();
6489 application.Render();
6491 tet_infoline( "Check that the world position has changed appropriately\n" );
6492 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6497 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6499 TestApplication application;
6500 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6502 Actor actor = Actor::New();
6503 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6504 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6505 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6506 actor.SetProperty( Actor::Property::SCALE, 2.0f );
6507 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6508 application.GetScene().Add( actor );
6510 application.SendNotification();
6511 application.Render();
6513 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6514 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6516 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6517 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6518 application.SendNotification();
6519 application.Render();
6520 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6522 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6523 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6524 application.SendNotification();
6525 application.Render();
6526 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6531 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6533 TestApplication application;
6534 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6536 Actor actor = Actor::New();
6537 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6538 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6539 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6540 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6541 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6542 application.GetScene().Add( actor );
6544 application.SendNotification();
6545 application.Render();
6547 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6548 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6550 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6551 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6552 application.SendNotification();
6553 application.Render();
6554 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6556 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6557 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6558 application.SendNotification();
6559 application.Render();
6560 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6565 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6567 TestApplication application;
6568 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6570 Actor actor = Actor::New();
6571 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6572 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6573 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6574 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6575 actor.SetProperty( Actor::Property::SCALE, 2.0f );
6576 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6577 application.GetScene().Add( actor );
6579 application.SendNotification();
6580 application.Render();
6582 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6583 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6585 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6586 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6587 application.SendNotification();
6588 application.Render();
6589 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6591 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6592 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6593 application.SendNotification();
6594 application.Render();
6595 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6600 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6602 TestApplication application;
6603 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6605 Actor parent = Actor::New();
6607 application.GetScene().Add( parent );
6608 Vector2 stageSize( application.GetScene().GetSize() );
6610 Actor actor = Actor::New();
6611 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6612 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6613 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6614 actor.SetProperty( Actor::Property::INHERIT_SCALE, false );
6615 actor.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
6616 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6617 parent.Add( actor );
6619 application.SendNotification();
6620 application.Render();
6622 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6624 tet_infoline( "Check the world position is in the right place\n" );
6625 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6627 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6628 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6629 application.SendNotification();
6630 application.Render();
6631 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6633 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6634 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6635 application.SendNotification();
6636 application.Render();
6637 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6642 int utcDaliActorVisibilityChangeSignalSelf(void)
6644 TestApplication application;
6645 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6647 Actor actor = Actor::New();
6649 VisibilityChangedFunctorData data;
6650 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6652 actor.SetProperty( Actor::Property::VISIBLE, false );
6654 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6656 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6659 actor.SetProperty( Actor::Property::VISIBLE, false );
6660 data.Check( false /* not called */, TEST_LOCATION );
6662 tet_infoline( "Change the visibility using properties, ensure called" );
6665 actor.SetProperty( Actor::Property::VISIBLE, true );
6666 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6668 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6671 actor.SetProperty( Actor::Property::VISIBLE, true );
6672 data.Check( false /* not called */, TEST_LOCATION );
6677 int utcDaliActorVisibilityChangeSignalChildren(void)
6679 TestApplication application;
6680 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6682 Actor parent = Actor::New();
6683 Actor child = Actor::New();
6684 parent.Add( child );
6686 Actor grandChild = Actor::New();
6687 child.Add( grandChild );
6689 VisibilityChangedFunctorData parentData;
6690 VisibilityChangedFunctorData childData;
6691 VisibilityChangedFunctorData grandChildData;
6693 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6694 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6695 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6697 parent.SetProperty( Actor::Property::VISIBLE, false );
6698 parentData.Check( false /* not called */, TEST_LOCATION );
6699 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6700 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6702 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6705 grandChildData.Reset();
6707 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6709 parent.SetProperty( Actor::Property::VISIBLE, true );
6710 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6711 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6712 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6714 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6717 grandChildData.Reset();
6719 parent.SetProperty( Actor::Property::VISIBLE, true );
6720 parentData.Check( false /* not called */, TEST_LOCATION );
6721 childData.Check( false /* not called */, TEST_LOCATION );
6722 grandChildData.Check( false /* not called */, TEST_LOCATION );
6727 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6729 TestApplication application;
6730 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6732 Actor actor = Actor::New();
6733 application.GetScene().Add( actor );
6735 application.SendNotification();
6736 application.Render();
6738 VisibilityChangedFunctorData data;
6739 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6741 Animation animation = Animation::New( 1.0f );
6742 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6744 data.Check( false, TEST_LOCATION );
6745 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6746 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6748 tet_infoline( "Play the animation and check the property value" );
6751 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6752 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6754 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6755 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6757 application.SendNotification();
6758 application.Render( 1100 ); // After the animation
6760 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6766 int utcDaliActorVisibilityChangeSignalByName(void)
6768 TestApplication application;
6769 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6771 Actor actor = Actor::New();
6773 bool signalCalled=false;
6774 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6775 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6776 actor.SetProperty( Actor::Property::VISIBLE, false );
6777 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6779 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6780 signalCalled = false;
6781 actor.SetProperty( Actor::Property::VISIBLE, false );
6782 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6784 tet_infoline( "Change the visibility using properties, ensure called" );
6785 actor.SetProperty( Actor::Property::VISIBLE, true );
6786 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6788 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6789 signalCalled = false;
6791 actor.SetProperty( Actor::Property::VISIBLE, true );
6792 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6798 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6800 gLayoutDirectionType = type;
6803 int UtcDaliActorLayoutDirectionProperty(void)
6805 TestApplication application;
6806 tet_infoline( "Check layout direction property" );
6808 Actor actor0 = Actor::New();
6809 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6810 application.GetScene().Add( actor0 );
6812 application.SendNotification();
6813 application.Render();
6815 Actor actor1 = Actor::New();
6816 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6817 Actor actor2 = Actor::New();
6818 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6819 Actor actor3 = Actor::New();
6820 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6821 Actor actor4 = Actor::New();
6822 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6823 Actor actor5 = Actor::New();
6824 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6825 Actor actor6 = Actor::New();
6826 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6827 Actor actor7 = Actor::New();
6828 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6829 Actor actor8 = Actor::New();
6830 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6831 Actor actor9 = Actor::New();
6832 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6834 actor1.Add( actor2 );
6835 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6836 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6838 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6839 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6840 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6842 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6843 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6844 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6846 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6847 actor0.Add( actor1 );
6848 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6849 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6851 application.GetScene().Add( actor3 );
6852 actor3.Add( actor4 );
6853 actor4.Add( actor5 );
6854 actor5.Add( actor6 );
6855 actor5.Add( actor7 );
6856 actor7.Add( actor8 );
6857 actor8.Add( actor9 );
6858 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6859 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6861 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6862 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6863 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6865 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6867 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6868 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6869 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6870 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6871 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6872 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6873 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6875 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6876 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6877 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6879 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6880 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6881 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6882 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6884 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6885 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6886 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6892 struct LayoutDirectionFunctor
6894 LayoutDirectionFunctor(bool& signalCalled)
6895 : mSignalCalled( signalCalled )
6899 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6900 : mSignalCalled( rhs.mSignalCalled )
6906 mSignalCalled = true;
6909 bool& mSignalCalled;
6912 int UtcDaliActorLayoutDirectionSignal(void)
6914 TestApplication application;
6915 tet_infoline( "Check changing layout direction property sends a signal" );
6917 Actor actor = Actor::New();
6918 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6919 application.GetScene().Add( actor );
6920 bool signalCalled = false;
6921 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6923 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6924 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6926 // Test that writing the same value doesn't send a signal
6927 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6928 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6930 // Test that writing a different value sends the signal
6931 signalCalled = false;
6932 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6933 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6935 signalCalled = false;
6936 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6937 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6942 struct ChildAddedSignalCheck
6944 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6945 : mSignalReceived( signalReceived ),
6946 mChildHandle( childHandle )
6950 void operator() ( Actor childHandle )
6952 mSignalReceived = true;
6953 mChildHandle = childHandle;
6957 mSignalReceived = true;
6958 mChildHandle = Actor();
6961 bool& mSignalReceived;
6962 Actor& mChildHandle;
6965 int UtcDaliChildAddedSignalP1(void)
6967 TestApplication application;
6968 auto stage = application.GetScene();
6970 bool signalReceived=false;
6973 ChildAddedSignalCheck signal( signalReceived, childActor );
6974 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6975 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6977 auto actorA = Actor::New();
6978 stage.Add( actorA );
6979 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6980 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6981 signalReceived = false;
6983 auto actorB = Actor::New();
6984 stage.Add( actorB );
6985 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6986 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6992 int UtcDaliChildAddedSignalP2(void)
6994 TestApplication application;
6995 auto stage = application.GetScene();
6997 bool signalReceived=false;
7000 ChildAddedSignalCheck signal( signalReceived, childActor );
7001 tet_infoline( "Connect to childAdded signal by name" );
7003 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
7004 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7006 auto actorA = Actor::New();
7007 stage.Add( actorA );
7008 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7010 // Can't test which actor was added; signal signature is void() when connecting via name.
7011 signalReceived = false;
7013 auto actorB = Actor::New();
7014 stage.Add( actorB );
7015 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7020 int UtcDaliChildAddedSignalN(void)
7022 TestApplication application;
7023 auto stage = application.GetScene();
7025 bool signalReceived=false;
7028 ChildAddedSignalCheck signal( signalReceived, childActor );
7029 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7030 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7032 auto actorA = Actor::New();
7033 stage.Add( actorA );
7034 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7035 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7036 signalReceived = false;
7038 auto actorB = Actor::New();
7039 actorA.Add( actorB );
7040 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7045 struct ChildRemovedSignalCheck
7047 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
7048 : mSignalReceived( signalReceived ),
7049 mChildHandle( childHandle )
7053 void operator() ( Actor childHandle )
7055 mSignalReceived = true;
7056 mChildHandle = childHandle;
7061 mSignalReceived = true;
7064 bool& mSignalReceived;
7065 Actor& mChildHandle;
7068 int UtcDaliChildRemovedSignalP1(void)
7070 TestApplication application;
7071 auto stage = application.GetScene();
7073 bool signalReceived=false;
7076 ChildRemovedSignalCheck signal( signalReceived, childActor );
7077 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7078 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7080 auto actorA = Actor::New();
7081 stage.Add( actorA );
7082 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7083 DALI_TEST_CHECK( !childActor );
7085 stage.Remove( actorA );
7086 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7087 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7089 signalReceived = false;
7090 auto actorB = Actor::New();
7091 stage.Add( actorB );
7092 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7094 stage.Remove( actorB );
7095 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7096 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7101 int UtcDaliChildRemovedSignalP2(void)
7103 TestApplication application;
7104 auto stage = application.GetScene();
7106 bool signalReceived=false;
7109 ChildAddedSignalCheck signal( signalReceived, childActor );
7110 tet_infoline( "Connect to childRemoved signal by name" );
7112 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7113 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7115 auto actorA = Actor::New();
7116 stage.Add( actorA );
7117 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7119 stage.Remove( actorA );
7120 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7122 signalReceived = false;
7123 auto actorB = Actor::New();
7124 stage.Add( actorB );
7125 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7127 stage.Remove( actorB );
7128 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7134 int UtcDaliChildRemovedSignalN(void)
7136 TestApplication application;
7137 auto stage = application.GetScene();
7139 bool signalReceived=false;
7142 ChildRemovedSignalCheck signal( signalReceived, childActor );
7143 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7144 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7146 auto actorA = Actor::New();
7147 stage.Add( actorA );
7149 auto actorB = Actor::New();
7150 actorA.Add( actorB );
7152 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7153 DALI_TEST_CHECK( ! childActor );
7155 actorA.Remove( actorB );
7156 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7161 int UtcDaliChildMovedSignalP(void)
7163 TestApplication application;
7164 auto stage = application.GetScene();
7166 bool addedASignalReceived = false;
7167 bool removedASignalReceived = false;
7168 bool addedBSignalReceived = false;
7169 bool removedBSignalReceived = false;
7172 auto actorA = Actor::New();
7173 auto actorB = Actor::New();
7174 stage.Add( actorA );
7175 stage.Add( actorB );
7177 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7178 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7179 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7180 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7182 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7183 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7184 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7185 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7187 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7188 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7189 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7190 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7192 // Create a child of A
7194 auto child = Actor::New();
7195 actorA.Add( child );
7197 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7198 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7199 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7200 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7201 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7204 addedASignalReceived = false;
7205 addedBSignalReceived = false;
7206 removedASignalReceived = false;
7207 removedBSignalReceived = false;
7209 actorB.Add( child ); // Expect this child to be re-parented
7210 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7211 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7212 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7213 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7215 // Move child back to A:
7216 addedASignalReceived = false;
7217 addedBSignalReceived = false;
7218 removedASignalReceived = false;
7219 removedBSignalReceived = false;
7221 actorA.Add( child ); // Expect this child to be re-parented
7222 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7223 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7224 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7225 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7231 int utcDaliActorCulled(void)
7233 TestApplication application;
7234 auto stage = application.GetScene();
7236 tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7238 Actor actor = Actor::New();
7239 actor.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 10.0f ) );
7241 Geometry geometry = CreateQuadGeometry();
7242 Shader shader = CreateShader();
7243 Renderer renderer = Renderer::New(geometry, shader);
7244 actor.AddRenderer( renderer );
7248 application.SendNotification();
7249 application.Render( 0 );
7251 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::CULLED ), false, TEST_LOCATION );
7253 PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::CULLED, LessThanCondition( 0.5f ) );
7254 notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7256 // Connect NotifySignal
7257 bool propertyNotificationSignal( false );
7258 PropertyNotification source;
7259 CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7260 notification.NotifySignal().Connect( &application, f ) ;
7262 actor.SetProperty( Actor::Property::POSITION, Vector2( 1000.0f, 1000.0f ));
7264 application.SendNotification();
7265 application.Render();
7267 application.SendNotification();
7269 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::CULLED ), true, TEST_LOCATION );
7271 DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7272 DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( Actor::Property::CULLED ), TEST_LOCATION );
7273 DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7278 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7280 TestApplication application;
7281 auto stage = application.GetScene();
7283 tet_infoline( "Ensure we clear the screen when the last actor is removed" );
7285 Actor actor = CreateRenderableActor();
7286 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7289 application.SendNotification();
7290 application.Render();
7292 auto& glAbstraction = application.GetGlAbstraction();
7293 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7297 application.SendNotification();
7298 application.Render();
7300 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7305 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7307 TestApplication application;
7308 auto stage = application.GetScene();
7310 tet_infoline( "Ensure we clear the screen when the last actor is made invisible" );
7312 Actor actor = CreateRenderableActor();
7313 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7316 application.SendNotification();
7317 application.Render();
7319 auto& glAbstraction = application.GetGlAbstraction();
7320 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7322 actor.SetProperty( Actor::Property::VISIBLE, false );
7324 application.SendNotification();
7325 application.Render();
7327 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7332 int utcDaliActorGetSizeAfterAnimation(void)
7334 TestApplication application;
7335 tet_infoline( "Check the actor size before / after an animation is finished" );
7337 Vector3 actorSize( 100.0f, 100.0f, 0.0f );
7339 Actor actor = Actor::New();
7340 actor.SetProperty( Actor::Property::SIZE, actorSize );
7341 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
7342 application.GetScene().Add( actor );
7344 // Size should be updated without rendering.
7345 Vector3 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7346 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7348 application.SendNotification();
7349 application.Render();
7351 // Size and current size should be updated.
7352 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7353 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7354 DALI_TEST_EQUALS( actorSize.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7355 DALI_TEST_EQUALS( actorSize.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7356 DALI_TEST_EQUALS( actorSize.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7358 Vector3 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7359 DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7360 DALI_TEST_EQUALS( actorSize.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7361 DALI_TEST_EQUALS( actorSize.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7362 DALI_TEST_EQUALS( actorSize.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7365 actorSize = Vector3( 200.0f, 200.0f, 0.0f );
7366 actor.SetProperty( Actor::Property::SIZE, actorSize );
7368 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7369 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7371 Vector3 targetValue( 10.0f, 20.0f, 0.0f );
7373 Animation animation = Animation::New( 1.0f );
7374 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
7377 // Size should be updated without rendering.
7378 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7379 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7381 application.SendNotification();
7382 application.Render( 1100 ); // After the animation
7384 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7385 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7386 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7387 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7388 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7390 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7391 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7392 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7393 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7394 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7396 targetValue.width = 50.0f;
7399 animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetValue.width );
7402 application.SendNotification();
7403 application.Render( 1100 ); // After the animation
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 targetValue.height = 70.0f;
7420 animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetValue.height );
7423 application.SendNotification();
7424 application.Render( 1100 ); // After the animation
7426 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7427 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7428 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7429 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7430 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7432 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7433 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7434 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7435 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7436 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7438 Vector3 offset( 10.0f, 20.0f, 0.0f );
7441 animation.AnimateBy( Property( actor, Actor::Property::SIZE ), offset );
7444 application.SendNotification();
7445 application.Render( 1100 ); // After the animation
7447 targetValue += offset;
7449 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7450 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7451 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7452 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7453 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7455 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7456 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7457 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7458 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7459 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7461 offset.width = 20.0f;
7464 animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), offset.width );
7467 application.SendNotification();
7468 application.Render( 1100 ); // After the animation
7470 targetValue.width += offset.width;
7472 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7473 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7474 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7475 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7476 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7478 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7479 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7480 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7481 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7482 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7484 offset.height = 10.0f;
7487 animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), offset.height );
7490 application.SendNotification();
7491 application.Render( 1100 ); // After the animation
7493 targetValue.height += offset.height;
7495 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7496 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7497 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7498 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7499 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7501 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7502 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7503 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7504 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7505 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7508 actorSize = Vector3( 300.0f, 300.0f, 0.0f );
7510 actor.SetProperty( Actor::Property::SIZE, actorSize );
7512 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7513 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7515 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7516 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7518 application.SendNotification();
7519 application.Render();
7521 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7522 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7524 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7525 DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7530 int utcDaliActorPartialUpdate(void)
7532 TestApplication application(
7533 TestApplication::DEFAULT_SURFACE_WIDTH,
7534 TestApplication::DEFAULT_SURFACE_HEIGHT,
7535 TestApplication::DEFAULT_HORIZONTAL_DPI,
7536 TestApplication::DEFAULT_VERTICAL_DPI,
7540 tet_infoline("Check the damaged area");
7542 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7544 std::vector<Rect<int>> damagedRects;
7545 Rect<int> clippingRect;
7546 application.SendNotification();
7547 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7549 // First render pass, nothing to render, adaptor would just do swap buffer.
7550 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7551 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7553 Actor actor = CreateRenderableActor();
7554 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7555 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7556 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7557 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7558 application.GetScene().Add(actor);
7560 application.SendNotification();
7562 // 1. Actor added, damaged rect is added size of actor
7563 damagedRects.clear();
7564 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7565 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7568 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7569 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7570 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7571 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7572 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7573 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7574 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7577 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7578 application.SendNotification();
7580 damagedRects.clear();
7581 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7582 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7585 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7586 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7587 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7588 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7589 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7590 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7591 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7593 // 3. Set new position
7594 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7595 application.SendNotification();
7597 damagedRects.clear();
7598 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7599 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7602 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7603 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7604 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7605 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7606 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7607 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7608 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7610 application.GetScene().Remove(actor);
7611 application.SendNotification();
7613 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7614 damagedRects.clear();
7615 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7616 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7618 clippingRect = damagedRects[0];
7619 clippingRect.Merge(damagedRects[1]);
7620 clippingRect.Merge(damagedRects[2]);
7622 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7623 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7624 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7626 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7627 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7628 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7629 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7630 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7635 int utcDaliActorPartialUpdateSetColor(void)
7637 TestApplication application(
7638 TestApplication::DEFAULT_SURFACE_WIDTH,
7639 TestApplication::DEFAULT_SURFACE_HEIGHT,
7640 TestApplication::DEFAULT_HORIZONTAL_DPI,
7641 TestApplication::DEFAULT_VERTICAL_DPI,
7645 tet_infoline("Check uniform update");
7647 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7649 std::vector<Rect<int>> damagedRects;
7650 Rect<int> clippingRect;
7651 application.SendNotification();
7652 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7654 // First render pass, nothing to render, adaptor would just do swap buffer.
7655 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7656 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7658 Actor actor = CreateRenderableActor();
7659 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7660 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7661 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7662 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7663 application.GetScene().Add(actor);
7665 application.SendNotification();
7667 // 1. Actor added, damaged rect is added size of actor
7668 damagedRects.clear();
7669 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7670 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7673 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7674 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7675 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7676 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7677 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7678 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7679 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7681 damagedRects.clear();
7682 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7684 damagedRects.clear();
7685 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7688 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
7689 application.SendNotification();
7691 damagedRects.clear();
7692 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7693 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7696 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7697 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7698 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7699 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7700 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7701 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7702 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7707 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
7708 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
7709 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
7710 const char* const RENDER_SHADOW_VERTEX_SOURCE =
7711 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
7712 " uniform mediump mat4 uLightCameraViewMatrix;\n"
7716 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
7717 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
7718 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
7721 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
7722 "uniform lowp vec4 uShadowColor;\n"
7725 " lowp float alpha;\n"
7726 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
7727 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
7730 int utcDaliActorPartialUpdateSetProperty(void)
7732 TestApplication application(
7733 TestApplication::DEFAULT_SURFACE_WIDTH,
7734 TestApplication::DEFAULT_SURFACE_HEIGHT,
7735 TestApplication::DEFAULT_HORIZONTAL_DPI,
7736 TestApplication::DEFAULT_VERTICAL_DPI,
7740 tet_infoline( "Set/Update property with partial update" );
7742 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7744 std::vector<Rect<int>> damagedRects;
7745 Rect<int> clippingRect;
7746 application.SendNotification();
7747 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7749 // First render pass, nothing to render, adaptor would just do swap buffer.
7750 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7751 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7753 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
7754 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
7755 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7756 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7757 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7758 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7759 application.GetScene().Add(actor);
7761 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
7763 damagedRects.clear();
7764 application.SendNotification();
7765 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7766 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7769 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7770 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7771 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7772 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7773 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7774 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7775 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7777 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex( SHADER_SHADOW_COLOR_PROPERTY_NAME );
7778 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
7780 damagedRects.clear();
7781 application.SendNotification();
7782 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7783 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7785 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7786 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7787 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7788 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7789 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7790 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7792 damagedRects.clear();
7793 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7794 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7796 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7797 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7798 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7799 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7800 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7801 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7803 damagedRects.clear();
7804 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7805 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7810 int utcDaliActorPartialUpdateTwoActors(void)
7812 TestApplication application(
7813 TestApplication::DEFAULT_SURFACE_WIDTH,
7814 TestApplication::DEFAULT_SURFACE_HEIGHT,
7815 TestApplication::DEFAULT_HORIZONTAL_DPI,
7816 TestApplication::DEFAULT_VERTICAL_DPI,
7820 tet_infoline("Check the damaged rects with partial update and two actors");
7822 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7824 Actor actor = CreateRenderableActor();
7825 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
7826 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
7827 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7828 application.GetScene().Add(actor);
7830 Actor actor2 = CreateRenderableActor();
7831 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
7832 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
7833 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7834 application.GetScene().Add(actor2);
7836 application.SendNotification();
7837 std::vector<Rect<int>> damagedRects;
7838 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7840 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
7841 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
7842 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
7844 // in screen coordinates, adaptor would calculate it using previous frames information
7845 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
7846 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7848 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7849 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7850 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7851 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7856 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
7858 TestApplication application(
7859 TestApplication::DEFAULT_SURFACE_WIDTH,
7860 TestApplication::DEFAULT_SURFACE_HEIGHT,
7861 TestApplication::DEFAULT_HORIZONTAL_DPI,
7862 TestApplication::DEFAULT_VERTICAL_DPI,
7866 tet_infoline( "Check the damaged rect with partial update and actor size hint" );
7868 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7870 Actor actor = CreateRenderableActor();
7871 actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f));
7872 actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f));
7873 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0));
7874 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7875 application.GetScene().Add(actor);
7877 application.SendNotification();
7878 std::vector<Rect<int>> damagedRects;
7879 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7881 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7883 Rect<int> clippingRect = Rect<int>(0, 496, 160, 320);
7884 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7886 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7888 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7889 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7890 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7891 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7896 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
7898 TestApplication application;
7900 Actor actor = Actor::New();
7901 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
7902 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
7903 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
7904 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
7905 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
7906 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7907 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7908 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
7912 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
7914 TestApplication application;
7916 Actor actor = Actor::New();
7918 // Make sure setting invalid types does not cause a crash
7921 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
7922 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
7923 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
7924 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
7925 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
7926 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
7927 tet_result(TET_PASS);
7931 tet_result(TET_FAIL);