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;
91 static bool TestCallback(Actor actor, const TouchEvent& event)
93 gTouchCallBackCalled = true;
98 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
100 gTouchCallBackCalled = true;
105 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
107 gTouchCallBackCalled2 = true;
112 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
114 gTouchCallBackCalled3 = true;
119 static void ResetTouchCallbacks()
121 gTouchCallBackCalled = false;
122 gTouchCallBackCalled2 = false;
123 gTouchCallBackCalled3 = false;
126 static bool TestCallback3(Actor actor, const HoverEvent& event)
128 gHoverCallBackCalled = true;
133 // validation stuff for onstage & offstage signals
134 static std::vector< std::string > gActorNamesOnOffScene;
135 static int gOnSceneCallBackCalled;
136 void OnSceneCallback( Actor actor )
138 ++gOnSceneCallBackCalled;
139 gActorNamesOnOffScene.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
140 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) == true );
142 static int gOffSceneCallBackCalled;
143 void OffSceneCallback( Actor actor )
145 ++gOffSceneCallBackCalled;
146 gActorNamesOnOffScene.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
147 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) == false );
150 struct PositionComponentConstraint
152 PositionComponentConstraint(){}
154 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
156 const Matrix& m = inputs[0]->GetMatrix();
159 m.GetTransformComponents(pos, rot, scale);
163 struct OrientationComponentConstraint
165 OrientationComponentConstraint(){}
167 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
169 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
172 orientation = parentOrientation;
177 static bool gOnRelayoutCallBackCalled = false;
178 static std::vector< std::string > gActorNamesRelayout;
180 void OnRelayoutCallback( Actor actor )
182 gOnRelayoutCallBackCalled = true;
183 gActorNamesRelayout.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
186 struct VisibilityChangedFunctorData
188 VisibilityChangedFunctorData()
191 type( DevelActor::VisibilityChange::SELF ),
200 type = DevelActor::VisibilityChange::SELF;
204 void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
206 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
207 DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
208 DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
209 DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
212 void Check( bool compareCalled, const std::string& location )
214 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
219 DevelActor::VisibilityChange::Type type;
223 struct VisibilityChangedFunctor
225 VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
227 void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
230 data.visible = visible;
235 VisibilityChangedFunctorData& data;
239 struct VisibilityChangedVoidFunctor
241 VisibilityChangedVoidFunctor(bool& signalCalled)
242 : mSignalCalled( signalCalled )
247 mSignalCalled = true;
253 struct ChildOrderChangedFunctor
255 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
256 : mSignalCalled( signalCalled ),
260 void operator()( Actor actor )
262 mSignalCalled = true;
270 struct CulledPropertyNotificationFunctor
272 CulledPropertyNotificationFunctor( bool& signalCalled, PropertyNotification& propertyNotification )
273 : mSignalCalled( signalCalled ),
274 mPropertyNotification( propertyNotification )
277 void operator()( PropertyNotification& source )
279 mSignalCalled = true;
280 mPropertyNotification = source;
284 PropertyNotification& mPropertyNotification;
287 } // anonymous namespace
290 //& purpose: Testing New API
291 int UtcDaliActorNew(void)
293 TestApplication application;
295 Actor actor = Actor::New();
297 DALI_TEST_CHECK(actor);
301 //& purpose: Testing Dali::Actor::DownCast()
302 int UtcDaliActorDownCastP(void)
304 TestApplication application;
305 tet_infoline("Testing Dali::Actor::DownCast()");
307 Actor actor = Actor::New();
308 BaseHandle object(actor);
309 Actor actor2 = Actor::DownCast(object);
310 DALI_TEST_CHECK(actor2);
314 //& purpose: Testing Dali::Actor::DownCast()
315 int UtcDaliActorDownCastN(void)
317 TestApplication application;
318 tet_infoline("Testing Dali::Actor::DownCast()");
320 BaseHandle unInitializedObject;
321 Actor actor = Actor::DownCast(unInitializedObject);
322 DALI_TEST_CHECK(!actor);
326 int UtcDaliActorMoveConstructor(void)
328 TestApplication application;
330 Actor actor = Actor::New();
331 DALI_TEST_CHECK( actor );
333 int id = actor.GetProperty< int >( Actor::Property::ID );
335 Actor moved = std::move( actor);
336 DALI_TEST_CHECK( moved );
337 DALI_TEST_EQUALS( id, moved.GetProperty< int >( Actor::Property::ID ), TEST_LOCATION );
338 DALI_TEST_CHECK( !actor );
343 int UtcDaliActorMoveAssignment(void)
345 TestApplication application;
347 Actor actor = Actor::New();
348 DALI_TEST_CHECK( actor );
350 int id = actor.GetProperty< int >( Actor::Property::ID );
353 moved = std::move( actor);
354 DALI_TEST_CHECK( moved );
355 DALI_TEST_EQUALS( id, moved.GetProperty< int >( Actor::Property::ID ), TEST_LOCATION );
356 DALI_TEST_CHECK( !actor );
361 //& purpose: Testing Dali::Actor::GetName()
362 int UtcDaliActorGetName(void)
364 TestApplication application;
366 Actor actor = Actor::New();
368 DALI_TEST_CHECK(actor.GetProperty< std::string >( Actor::Property::NAME ).empty());
372 //& purpose: Testing Dali::Actor::SetName()
373 int UtcDaliActorSetName(void)
375 TestApplication application;
377 string str("ActorName");
378 Actor actor = Actor::New();
380 actor.SetProperty( Actor::Property::NAME,str);
381 DALI_TEST_CHECK(actor.GetProperty< std::string >( Actor::Property::NAME ) == str);
385 int UtcDaliActorGetId(void)
387 tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
388 TestApplication application;
390 Actor first = Actor::New();
391 Actor second = Actor::New();
392 Actor third = Actor::New();
394 DALI_TEST_CHECK(first.GetProperty< int >( Actor::Property::ID ) != second.GetProperty< int >( Actor::Property::ID ));
395 DALI_TEST_CHECK(second.GetProperty< int >( Actor::Property::ID ) != third.GetProperty< int >( Actor::Property::ID ));
399 int UtcDaliActorIsRoot(void)
401 TestApplication application;
403 Actor actor = Actor::New();
404 DALI_TEST_CHECK(!actor.GetProperty< bool >( Actor::Property::IS_ROOT ));
406 // get the root layer
407 actor = application.GetScene().GetLayer( 0 );
408 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::IS_ROOT ) );
412 int UtcDaliActorOnScene(void)
414 TestApplication application;
416 Actor actor = Actor::New();
417 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
419 // get the root layer
420 actor = application.GetScene().GetLayer( 0 );
421 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
425 int UtcDaliActorIsLayer(void)
427 TestApplication application;
429 Actor actor = Actor::New();
430 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::IS_LAYER ) );
432 // get the root layer
433 actor = application.GetScene().GetLayer( 0 );
434 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::IS_LAYER ) );
438 int UtcDaliActorGetLayer(void)
440 TestApplication application;
442 Actor actor = Actor::New();
443 application.GetScene().Add(actor);
444 Layer layer = actor.GetLayer();
446 DALI_TEST_CHECK(layer);
448 // get the root layers layer
449 actor = application.GetScene().GetLayer( 0 );
450 DALI_TEST_CHECK( actor.GetLayer() );
454 int UtcDaliActorAddP(void)
456 tet_infoline("Testing Actor::Add");
457 TestApplication application;
459 Actor parent = Actor::New();
460 Actor child = Actor::New();
462 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
466 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
468 Actor parent2 = Actor::New();
469 parent2.Add( child );
471 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
472 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
474 // try Adding to same parent again, works
475 parent2.Add( child );
476 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
478 // try reparenting an orphaned child
480 Actor temporaryParent = Actor::New();
481 temporaryParent.Add( child );
482 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
484 // temporaryParent has now died, reparent the orphaned child
485 parent2.Add( child );
486 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
491 int UtcDaliActorAddN(void)
493 tet_infoline("Testing Actor::Add");
494 TestApplication application;
496 Actor child = Actor::New();
498 Actor parent2 = Actor::New();
499 parent2.Add( child );
504 parent2.Add( parent2 );
505 tet_printf("Assertion test failed - no Exception\n" );
506 tet_result(TET_FAIL);
508 catch(Dali::DaliException& e)
510 DALI_TEST_PRINT_ASSERT( e );
511 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
512 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
516 tet_printf("Assertion test failed - wrong Exception\n" );
517 tet_result(TET_FAIL);
520 // try reparenting root
523 parent2.Add( application.GetScene().GetLayer( 0 ) );
524 tet_printf("Assertion test failed - no Exception\n" );
525 tet_result(TET_FAIL);
527 catch(Dali::DaliException& e)
529 DALI_TEST_PRINT_ASSERT( e );
530 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
531 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
535 tet_printf("Assertion test failed - wrong Exception\n" );
536 tet_result(TET_FAIL);
543 parent2.Add( empty );
544 tet_printf("Assertion test failed - no Exception\n" );
545 tet_result(TET_FAIL);
547 catch(Dali::DaliException& e)
549 DALI_TEST_PRINT_ASSERT( e );
550 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
551 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
555 tet_printf("Assertion test failed - wrong Exception\n" );
556 tet_result(TET_FAIL);
562 int UtcDaliActorRemoveN(void)
564 tet_infoline("Testing Actor::Remove");
565 TestApplication application;
567 Actor parent = Actor::New();
568 Actor child = Actor::New();
569 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
572 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
574 parent.Remove(child);
575 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
577 // remove again, no problem
578 parent.Remove(child);
579 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
583 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
584 // try Remove self, its a no-op
585 parent.Remove( parent );
586 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
592 parent.Remove( empty );
593 tet_printf("Assertion test failed - no Exception\n" );
594 tet_result(TET_FAIL);
596 catch(Dali::DaliException& e)
598 DALI_TEST_PRINT_ASSERT( e );
599 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
600 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
604 tet_printf("Assertion test failed - wrong Exception\n" );
605 tet_result(TET_FAIL);
610 int UtcDaliActorRemoveP(void)
612 TestApplication application;
614 Actor parent = Actor::New();
615 Actor child = Actor::New();
616 Actor random = Actor::New();
618 application.GetScene().Add( parent );
620 DALI_TEST_CHECK(parent.GetChildCount() == 0);
624 DALI_TEST_CHECK(parent.GetChildCount() == 1);
626 parent.Remove(random);
628 DALI_TEST_CHECK(parent.GetChildCount() == 1);
630 application.GetScene().Remove( parent );
632 DALI_TEST_CHECK(parent.GetChildCount() == 1);
636 int UtcDaliActorGetChildCount(void)
638 TestApplication application;
640 Actor parent = Actor::New();
641 Actor child = Actor::New();
643 DALI_TEST_CHECK(parent.GetChildCount() == 0);
647 DALI_TEST_CHECK(parent.GetChildCount() == 1);
651 int UtcDaliActorGetChildren01(void)
653 TestApplication application;
655 Actor parent = Actor::New();
656 Actor first = Actor::New();
657 Actor second = Actor::New();
658 Actor third = Actor::New();
664 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
665 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
666 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
670 int UtcDaliActorGetChildren02(void)
672 TestApplication application;
674 Actor parent = Actor::New();
675 Actor first = Actor::New();
676 Actor second = Actor::New();
677 Actor third = Actor::New();
683 const Actor& constParent = parent;
685 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
686 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
687 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
691 int UtcDaliActorGetParent01(void)
693 TestApplication application;
695 Actor parent = Actor::New();
696 Actor child = Actor::New();
700 DALI_TEST_CHECK(child.GetParent() == parent);
704 int UtcDaliActorGetParent02(void)
706 TestApplication application;
708 Actor actor = Actor::New();
710 DALI_TEST_CHECK(!actor.GetParent());
714 int UtcDaliActorCustomProperty(void)
716 TestApplication application;
718 Actor actor = Actor::New();
719 application.GetScene().Add( actor );
721 float startValue(1.0f);
722 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
723 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
725 application.SendNotification();
726 application.Render(0);
727 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
729 actor.SetProperty( index, 5.0f );
731 application.SendNotification();
732 application.Render(0);
733 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
737 int UtcDaliActorCustomPropertyIntToFloat(void)
739 TestApplication application;
741 Actor actor = Actor::New();
742 application.GetScene().Add( actor );
744 float startValue(5.0f);
745 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
746 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
748 application.SendNotification();
749 application.Render(0);
750 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
752 actor.SetProperty( index, int(1) );
754 application.SendNotification();
755 application.Render(0);
756 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
760 int UtcDaliActorCustomPropertyFloatToInt(void)
762 TestApplication application;
764 Actor actor = Actor::New();
765 application.GetScene().Add( actor );
768 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
769 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
771 application.SendNotification();
772 application.Render(0);
773 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
775 actor.SetProperty( index, float(1.5) );
777 application.SendNotification();
778 application.Render(0);
779 DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
783 int UtcDaliActorSetParentOrigin(void)
785 TestApplication application;
787 Actor actor = Actor::New();
789 Vector3 vector(0.7f, 0.8f, 0.9f);
790 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
792 actor.SetProperty( Actor::Property::PARENT_ORIGIN, vector );
794 // flush the queue and render once
795 application.SendNotification();
796 application.Render();
798 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
800 application.GetScene().Add( actor );
802 actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.1f, 0.2f, 0.3f ) );
804 // flush the queue and render once
805 application.SendNotification();
806 application.Render();
808 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), TEST_LOCATION );
810 application.GetScene().Remove( actor );
814 int UtcDaliActorSetParentOriginIndividual(void)
816 TestApplication application;
818 Actor actor = Actor::New();
820 Vector3 vector(0.7f, 0.8f, 0.9f);
821 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
823 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
825 // flush the queue and render once
826 application.SendNotification();
827 application.Render();
829 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).x, TEST_LOCATION );
831 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
833 // flush the queue and render once
834 application.SendNotification();
835 application.Render();
837 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).y, TEST_LOCATION );
839 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
841 // flush the queue and render once
842 application.SendNotification();
843 application.Render();
845 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).z, TEST_LOCATION );
850 int UtcDaliActorGetCurrentParentOrigin(void)
852 TestApplication application;
854 Actor actor = Actor::New();
856 Vector3 vector(0.7f, 0.8f, 0.9f);
857 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
859 actor.SetProperty( Actor::Property::PARENT_ORIGIN, vector );
861 // flush the queue and render once
862 application.SendNotification();
863 application.Render();
865 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
869 int UtcDaliActorSetAnchorPoint(void)
871 TestApplication application;
873 Actor actor = Actor::New();
875 Vector3 vector(0.7f, 0.8f, 0.9f);
876 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
878 actor.SetProperty( Actor::Property::ANCHOR_POINT, vector );
880 // flush the queue and render once
881 application.SendNotification();
882 application.Render();
884 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
886 application.GetScene().Add( actor );
888 actor.SetProperty( Actor::Property::ANCHOR_POINT, Vector3( 0.1f, 0.2f, 0.3f ) );
889 // flush the queue and render once
890 application.SendNotification();
891 application.Render();
893 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), TEST_LOCATION );
895 application.GetScene().Remove( actor );
899 int UtcDaliActorSetAnchorPointIndividual(void)
901 TestApplication application;
903 Actor actor = Actor::New();
905 Vector3 vector(0.7f, 0.8f, 0.9f);
906 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
908 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
910 // flush the queue and render once
911 application.SendNotification();
912 application.Render();
914 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).x, TEST_LOCATION );
916 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
918 // flush the queue and render once
919 application.SendNotification();
920 application.Render();
922 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).y, TEST_LOCATION );
924 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
926 // flush the queue and render once
927 application.SendNotification();
928 application.Render();
930 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).z, TEST_LOCATION );
935 int UtcDaliActorGetCurrentAnchorPoint(void)
937 TestApplication application;
939 Actor actor = Actor::New();
941 Vector3 vector(0.7f, 0.8f, 0.9f);
942 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
944 actor.SetProperty( Actor::Property::ANCHOR_POINT, vector);
946 // flush the queue and render once
947 application.SendNotification();
948 application.Render();
950 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
954 int UtcDaliActorSetSize01(void)
956 TestApplication application;
958 Actor actor = Actor::New();
959 Vector3 vector(100.0f, 100.0f, 0.0f);
961 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
963 actor.SetProperty( Actor::Property::SIZE, Vector2( vector.x, vector.y ) );
965 // Immediately retrieve the size after setting
966 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
967 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
968 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
969 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
970 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
972 // Flush the queue and render once
973 application.SendNotification();
974 application.Render();
976 // Check the size in the new frame
977 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
979 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
980 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
981 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
982 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
983 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
985 // Check async behaviour
986 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
987 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
988 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
989 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
990 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
992 // Change the resize policy and check whether the size stays the same
993 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
995 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
996 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
998 // Set a new size after resize policy is changed and check the new size
999 actor.SetProperty( Actor::Property::SIZE, Vector3( 0.1f, 0.2f, 0.0f ) );
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 // Change the resize policy again and check whether the new size stays the same
1005 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1007 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1008 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1010 // Set another new size after resize policy is changed and check the new size
1011 actor.SetProperty( Actor::Property::SIZE, Vector3( 50.0f, 60.0f, 0.0f ) );
1013 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1014 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1019 int UtcDaliActorSetSize02(void)
1021 TestApplication application;
1023 Actor actor = Actor::New();
1024 Vector3 vector(100.0f, 100.0f, 100.0f);
1026 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1028 actor.SetProperty( Actor::Property::SIZE, Vector3( vector.x, vector.y, vector.z ) );
1030 // Immediately check the size after setting
1031 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1032 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1034 // flush the queue and render once
1035 application.SendNotification();
1036 application.Render();
1038 // Check the size in the new frame
1039 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1041 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1042 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1047 // SetSize(Vector2 size)
1048 int UtcDaliActorSetSize03(void)
1050 TestApplication application;
1052 Actor actor = Actor::New();
1053 Vector3 vector(100.0f, 100.0f, 0.0f);
1055 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1057 actor.SetProperty( Actor::Property::SIZE,Vector2(vector.x, vector.y));
1059 // Immediately check the size after setting
1060 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1061 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1063 // flush the queue and render once
1064 application.SendNotification();
1065 application.Render();
1067 // Check the size in the new frame
1068 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1070 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1071 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1076 // SetSize(Vector3 size)
1077 int UtcDaliActorSetSize04(void)
1079 TestApplication application;
1081 Actor actor = Actor::New();
1082 Vector3 vector(100.0f, 100.0f, 100.0f);
1084 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1086 actor.SetProperty( Actor::Property::SIZE,vector);
1088 // Immediately check the size after setting
1089 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1090 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1092 // flush the queue and render once
1093 application.SendNotification();
1094 application.Render();
1096 // Check the size in the new frame
1097 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1099 application.GetScene().Add( actor );
1100 actor.SetProperty( Actor::Property::SIZE, Vector3( 0.1f, 0.2f, 0.3f ) );
1102 // Immediately check the size after setting
1103 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1104 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1106 // flush the queue and render once
1107 application.SendNotification();
1108 application.Render();
1110 // Check the size in the new frame
1111 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), TEST_LOCATION );
1113 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1114 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1116 application.GetScene().Remove( actor );
1120 int UtcDaliActorSetSizeIndividual(void)
1122 TestApplication application;
1124 Actor actor = Actor::New();
1126 Vector3 vector(0.7f, 0.8f, 0.9f);
1127 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1129 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1131 // Immediately check the width after setting
1132 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1133 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1135 // flush the queue and render once
1136 application.SendNotification();
1137 application.Render();
1139 // Check the width in the new frame
1140 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1142 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1143 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1145 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1147 // Immediately check the height after setting
1148 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1149 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1151 // flush the queue and render once
1152 application.SendNotification();
1153 application.Render();
1155 // Check the height in the new frame
1156 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1158 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1159 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1161 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1163 // Immediately check the depth after setting
1164 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1165 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1167 // flush the queue and render once
1168 application.SendNotification();
1169 application.Render();
1171 // Check the depth in the new frame
1172 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).depth, TEST_LOCATION );
1174 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1175 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1177 // Change the resize policy and check whether the size stays the same
1178 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1180 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1181 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1183 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1184 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1186 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1187 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1189 // Change the resize policy again and check whether the size stays the same
1190 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1192 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1193 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1195 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1196 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1198 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1199 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1204 int UtcDaliActorSetSizeIndividual02(void)
1206 TestApplication application;
1208 Actor actor = Actor::New();
1209 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1210 application.GetScene().Add( actor );
1212 Vector3 vector( 100.0f, 200.0f, 400.0f );
1213 DALI_TEST_CHECK( vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ) );
1215 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1216 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1218 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1219 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1221 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1222 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1224 // flush the queue and render once
1225 application.SendNotification();
1226 application.Render();
1228 // Check the width in the new frame
1229 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1230 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1236 int UtcDaliActorGetCurrentSize(void)
1238 TestApplication application;
1240 Actor actor = Actor::New();
1241 Vector3 vector(100.0f, 100.0f, 20.0f);
1243 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1245 actor.SetProperty( Actor::Property::SIZE,vector);
1247 // flush the queue and render once
1248 application.SendNotification();
1249 application.Render();
1251 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1255 int UtcDaliActorGetNaturalSize(void)
1257 TestApplication application;
1259 Actor actor = Actor::New();
1260 Vector3 vector( 0.0f, 0.0f, 0.0f );
1262 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1267 int UtcDaliActorGetCurrentSizeImmediate(void)
1269 TestApplication application;
1271 Actor actor = Actor::New();
1272 Vector3 vector(100.0f, 100.0f, 20.0f);
1274 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1275 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1277 actor.SetProperty( Actor::Property::SIZE,vector);
1279 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1280 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1282 // flush the queue and render once
1283 application.SendNotification();
1284 application.Render();
1286 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1287 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1290 // Build the animation
1291 const float durationSeconds = 2.0f;
1292 Animation animation = Animation::New( durationSeconds );
1293 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1294 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1296 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1298 // Start the animation
1301 application.SendNotification();
1302 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1304 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1309 int UtcDaliActorCalculateScreenExtents(void)
1311 TestApplication application;
1313 Actor actor = Actor::New();
1315 actor.SetProperty( Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1316 actor.SetProperty( Actor::Property::SIZE,Vector3{ 1.0f, 1.0f, 1.0f });
1318 application.SendNotification();
1319 application.Render();
1321 auto expectedExtent = Rect<>{ -0.5f, -0.5f, 1.0f, 1.0f };
1322 auto actualExtent = DevelActor::CalculateScreenExtents( actor );
1323 DALI_TEST_EQUALS( expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1324 DALI_TEST_EQUALS( expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1325 DALI_TEST_EQUALS( expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1326 DALI_TEST_EQUALS( expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1328 application.GetScene().Remove( actor );
1332 // SetPosition(float x, float y)
1333 int UtcDaliActorSetPosition01(void)
1335 TestApplication application;
1337 Actor actor = Actor::New();
1339 // Set to random to start off with
1340 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1342 Vector3 vector(100.0f, 100.0f, 0.0f);
1344 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1346 actor.SetProperty( Actor::Property::POSITION, Vector2(vector.x, vector.y));
1347 // flush the queue and render once
1348 application.SendNotification();
1349 application.Render();
1350 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1352 application.GetScene().Add( actor );
1353 actor.SetProperty( Actor::Property::POSITION, Vector3( 0.1f, 0.2f, 0.3f ) );
1354 // flush the queue and render once
1355 application.SendNotification();
1356 application.Render();
1357 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1359 actor.SetProperty( Actor::Property::POSITION_X, 1.0f );
1360 actor.SetProperty( Actor::Property::POSITION_Y, 1.1f );
1361 actor.SetProperty( Actor::Property::POSITION_Z, 1.2f );
1362 // flush the queue and render once
1363 application.SendNotification();
1364 application.Render();
1365 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1367 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1368 // flush the queue and render once
1369 application.SendNotification();
1370 application.Render();
1371 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1373 application.GetScene().Remove( actor );
1377 // SetPosition(float x, float y, float z)
1378 int UtcDaliActorSetPosition02(void)
1380 TestApplication application;
1382 Actor actor = Actor::New();
1384 // Set to random to start off with
1385 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1387 Vector3 vector(100.0f, 100.0f, 100.0f);
1389 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1391 actor.SetProperty( Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1393 // flush the queue and render once
1394 application.SendNotification();
1395 application.Render();
1397 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1401 // SetPosition(Vector3 position)
1402 int UtcDaliActorSetPosition03(void)
1404 TestApplication application;
1406 Actor actor = Actor::New();
1408 // Set to random to start off with
1409 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1411 Vector3 vector(100.0f, 100.0f, 100.0f);
1413 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1415 actor.SetProperty( Actor::Property::POSITION, vector);
1417 // flush the queue and render once
1418 application.SendNotification();
1419 application.Render();
1421 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1425 int UtcDaliActorSetX(void)
1427 TestApplication application;
1429 Actor actor = Actor::New();
1431 Vector3 vector(100.0f, 0.0f, 0.0f);
1433 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1435 actor.SetProperty( Actor::Property::POSITION_X, 100.0f);
1437 // flush the queue and render once
1438 application.SendNotification();
1439 application.Render();
1441 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1445 int UtcDaliActorSetY(void)
1447 TestApplication application;
1449 Actor actor = Actor::New();
1451 Vector3 vector(0.0f, 100.0f, 0.0f);
1453 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1455 actor.SetProperty( Actor::Property::POSITION_Y, 100.0f);
1457 // flush the queue and render once
1458 application.SendNotification();
1459 application.Render();
1461 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1465 int UtcDaliActorSetZ(void)
1467 TestApplication application;
1469 Actor actor = Actor::New();
1471 Vector3 vector(0.0f, 0.0f, 100.0f);
1473 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1475 actor.SetProperty( Actor::Property::POSITION_Z, 100.0f);
1477 // flush the queue and render once
1478 application.SendNotification();
1479 application.Render();
1481 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1485 int UtcDaliActorSetPositionProperties(void)
1487 TestApplication application;
1489 Actor actor = Actor::New();
1491 Vector3 vector(0.7f, 0.8f, 0.9f);
1492 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1494 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1495 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1496 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1498 // flush the queue and render once
1499 application.SendNotification();
1500 application.Render();
1502 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1503 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1504 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1505 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1506 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1508 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1509 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1510 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1512 // flush the queue and render once
1513 application.SendNotification();
1514 application.Render();
1516 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1517 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1518 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1519 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1520 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1522 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1523 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1524 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1526 // flush the queue and render once
1527 application.SendNotification();
1528 application.Render();
1530 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1531 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1532 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1533 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1534 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1539 int UtcDaliActorTranslateBy(void)
1541 TestApplication application;
1543 Actor actor = Actor::New();
1544 Vector3 vector(100.0f, 100.0f, 100.0f);
1546 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1548 actor.SetProperty( Actor::Property::POSITION, vector);
1550 // flush the queue and render once
1551 application.SendNotification();
1552 application.Render();
1554 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1556 actor.TranslateBy(vector);
1558 // flush the queue and render once
1559 application.SendNotification();
1560 application.Render();
1562 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1566 int UtcDaliActorGetCurrentPosition(void)
1568 TestApplication application;
1570 Actor actor = Actor::New();
1571 Vector3 setVector(100.0f, 100.0f, 0.0f);
1572 actor.SetProperty( Actor::Property::POSITION, setVector);
1574 // flush the queue and render once
1575 application.SendNotification();
1576 application.Render();
1578 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ) == setVector);
1582 int UtcDaliActorGetCurrentWorldPosition(void)
1584 TestApplication application;
1586 Actor parent = Actor::New();
1587 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1588 parent.SetProperty( Actor::Property::POSITION, parentPosition );
1589 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1590 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1591 application.GetScene().Add( parent );
1593 Actor child = Actor::New();
1594 child.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1595 child.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1596 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1597 child.SetProperty( Actor::Property::POSITION, childPosition );
1598 parent.Add( child );
1600 // The actors should not have a world position yet
1601 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1602 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1604 application.SendNotification();
1605 application.Render(0);
1607 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1608 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1610 // The actors should have a world position now
1611 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1612 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1616 int UtcDaliActorSetInheritPosition(void)
1618 tet_infoline("Testing Actor::SetInheritPosition");
1619 TestApplication application;
1621 Actor parent = Actor::New();
1622 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1623 parent.SetProperty( Actor::Property::POSITION, parentPosition );
1624 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1625 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1626 application.GetScene().Add( parent );
1628 Actor child = Actor::New();
1629 child.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1630 child.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1631 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1632 child.SetProperty( Actor::Property::POSITION, childPosition );
1633 parent.Add( child );
1635 // The actors should not have a world position yet
1636 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1637 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1639 // first test default, which is to inherit position
1640 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1641 application.SendNotification();
1642 application.Render(0); // should only really call Update as Render is not required to update scene
1643 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1644 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1645 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1646 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1648 //Change child position
1649 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1650 child.SetProperty( Actor::Property::POSITION, childOffset );
1652 // Use local position as world postion
1653 child.SetProperty( Actor::Property::INHERIT_POSITION, false );
1654 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), false, TEST_LOCATION );
1655 application.SendNotification();
1656 application.Render(0); // should only really call Update as Render is not required to update scene
1657 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1658 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1659 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1660 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), childOffset, TEST_LOCATION );
1662 //Change back to inherit position from parent
1663 child.SetProperty( Actor::Property::INHERIT_POSITION, true );
1664 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1665 application.SendNotification();
1666 application.Render(0); // should only really call Update as Render is not required to update scene
1667 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1668 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1669 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1670 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childOffset, TEST_LOCATION );
1674 int UtcDaliActorInheritOpacity(void)
1676 tet_infoline("Testing Actor::Inherit Opacity");
1677 TestApplication application;
1679 Actor parent = Actor::New();
1680 Actor child = Actor::New();
1681 parent.Add( child );
1682 application.GetScene().Add( parent );
1684 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1685 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1687 // flush the queue and render once
1688 application.SendNotification();
1689 application.Render();
1691 parent.SetProperty( Actor::Property::OPACITY, 0.1f );
1693 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1694 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1696 application.SendNotification();
1697 application.Render();
1699 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1700 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1701 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1702 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1703 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1704 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1709 // SetOrientation(float angleRadians, Vector3 axis)
1710 int UtcDaliActorSetOrientation01(void)
1712 TestApplication application;
1714 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1715 Actor actor = Actor::New();
1717 actor.SetProperty( Actor::Property::ORIENTATION, rotation);
1719 // flush the queue and render once
1720 application.SendNotification();
1721 application.Render();
1723 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1727 int UtcDaliActorSetOrientation02(void)
1729 TestApplication application;
1731 Actor actor = Actor::New();
1733 Radian angle( 0.785f );
1734 Vector3 axis(1.0f, 1.0f, 0.0f);
1736 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1737 Quaternion rotation( angle, axis );
1738 // flush the queue and render once
1739 application.SendNotification();
1740 application.Render();
1741 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1743 application.GetScene().Add( actor );
1744 actor.RotateBy( Degree( 360 ), axis);
1745 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1747 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) ) );
1748 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1749 // flush the queue and render once
1750 application.SendNotification();
1751 application.Render();
1752 DALI_TEST_EQUALS( result, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1754 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1755 // flush the queue and render once
1756 application.SendNotification();
1757 application.Render();
1758 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1760 application.GetScene().Remove( actor );
1764 // SetOrientation(float angleRadians, Vector3 axis)
1765 int UtcDaliActorSetOrientationProperty(void)
1767 TestApplication application;
1769 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1770 Actor actor = Actor::New();
1772 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1773 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1775 // flush the queue and render once
1776 application.SendNotification();
1777 application.Render();
1779 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1780 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1781 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1785 // RotateBy(float angleRadians, Vector3 axis)
1786 int UtcDaliActorRotateBy01(void)
1788 TestApplication application;
1790 Actor actor = Actor::New();
1792 Radian angle( M_PI * 0.25f );
1793 actor.RotateBy(( angle ), Vector3::ZAXIS);
1794 // flush the queue and render once
1795 application.SendNotification();
1796 application.Render();
1797 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1799 application.GetScene().Add( actor );
1801 actor.RotateBy( angle, Vector3::ZAXIS);
1802 // flush the queue and render once
1803 application.SendNotification();
1804 application.Render();
1805 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1807 application.GetScene().Remove( actor );
1811 // RotateBy(Quaternion relativeRotation)
1812 int UtcDaliActorRotateBy02(void)
1814 TestApplication application;
1816 Actor actor = Actor::New();
1818 Radian angle( M_PI * 0.25f );
1819 Quaternion rotation(angle, Vector3::ZAXIS);
1820 actor.RotateBy(rotation);
1821 // flush the queue and render once
1822 application.SendNotification();
1823 application.Render();
1824 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1826 actor.RotateBy(rotation);
1827 // flush the queue and render once
1828 application.SendNotification();
1829 application.Render();
1830 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1834 int UtcDaliActorGetCurrentOrientation(void)
1836 TestApplication application;
1837 Actor actor = Actor::New();
1839 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1840 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1841 // flush the queue and render once
1842 application.SendNotification();
1843 application.Render();
1844 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1848 int UtcDaliActorGetCurrentWorldOrientation(void)
1850 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1851 TestApplication application;
1853 Actor parent = Actor::New();
1854 Radian rotationAngle( Degree(90.0f) );
1855 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1856 parent.SetProperty( Actor::Property::ORIENTATION, rotation );
1857 application.GetScene().Add( parent );
1859 Actor child = Actor::New();
1860 child.SetProperty( Actor::Property::ORIENTATION, rotation );
1861 parent.Add( child );
1863 // The actors should not have a world rotation yet
1864 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1865 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1867 application.SendNotification();
1868 application.Render(0);
1870 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1871 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1873 // The actors should have a world rotation now
1874 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1875 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1877 // turn off child rotation inheritance
1878 child.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
1879 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_ORIENTATION ), false, TEST_LOCATION );
1880 application.SendNotification();
1881 application.Render(0);
1883 // The actors should have a world rotation now
1884 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1885 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1889 // SetScale(float scale)
1890 int UtcDaliActorSetScale01(void)
1892 TestApplication application;
1894 Actor actor = Actor::New();
1896 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1897 actor.SetProperty( Actor::Property::SCALE,0.25f);
1899 Vector3 scale(10.0f, 10.0f, 10.0f);
1900 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1902 actor.SetProperty( Actor::Property::SCALE,scale.x);
1904 // flush the queue and render once
1905 application.SendNotification();
1906 application.Render();
1908 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1912 // SetScale(float scaleX, float scaleY, float scaleZ)
1913 int UtcDaliActorSetScale02(void)
1915 TestApplication application;
1916 Vector3 scale(10.0f, 10.0f, 10.0f);
1918 Actor actor = Actor::New();
1920 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1921 actor.SetProperty( Actor::Property::SCALE, Vector3( 12.0f, 1.0f, 2.0f ) );
1923 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1925 actor.SetProperty( Actor::Property::SCALE, Vector3( scale.x, scale.y, scale.z ) );
1926 // flush the queue and render once
1927 application.SendNotification();
1928 application.Render();
1929 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1931 // add to stage and test
1932 application.GetScene().Add( actor );
1933 actor.SetProperty( Actor::Property::SCALE, Vector3( 2.0f, 2.0f, 2.0f ) );
1934 // flush the queue and render once
1935 application.SendNotification();
1936 application.Render();
1937 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), 0.001, TEST_LOCATION);
1939 application.GetScene().Remove( actor );
1944 // SetScale(Vector3 scale)
1945 int UtcDaliActorSetScale03(void)
1947 TestApplication application;
1948 Vector3 scale(10.0f, 10.0f, 10.0f);
1950 Actor actor = Actor::New();
1952 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1953 actor.SetProperty( Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1955 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1957 actor.SetProperty( Actor::Property::SCALE,scale);
1959 // flush the queue and render once
1960 application.SendNotification();
1961 application.Render();
1963 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1967 int UtcDaliActorSetScaleIndividual(void)
1969 TestApplication application;
1971 Actor actor = Actor::New();
1973 Vector3 vector(0.7f, 0.8f, 0.9f);
1974 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1976 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1977 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1979 // flush the queue and render once
1980 application.SendNotification();
1981 application.Render();
1983 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x, TEST_LOCATION );
1984 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1985 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1987 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1988 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1990 // flush the queue and render once
1991 application.SendNotification();
1992 application.Render();
1994 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).y, TEST_LOCATION );
1995 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1996 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1998 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1999 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
2001 // flush the queue and render once
2002 application.SendNotification();
2003 application.Render();
2005 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).z, TEST_LOCATION );
2006 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
2007 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
2009 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
2010 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
2015 int UtcDaliActorScaleBy(void)
2017 TestApplication application;
2018 Actor actor = Actor::New();
2019 Vector3 vector(100.0f, 100.0f, 100.0f);
2021 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
2023 actor.SetProperty( Actor::Property::SCALE,vector);
2025 // flush the queue and render once
2026 application.SendNotification();
2027 application.Render();
2029 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
2031 actor.ScaleBy(vector);
2033 // flush the queue and render once
2034 application.SendNotification();
2035 application.Render();
2037 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
2041 int UtcDaliActorGetCurrentScale(void)
2043 TestApplication application;
2044 Vector3 scale(12.0f, 1.0f, 2.0f);
2046 Actor actor = Actor::New();
2048 actor.SetProperty( Actor::Property::SCALE,scale);
2050 // flush the queue and render once
2051 application.SendNotification();
2052 application.Render();
2054 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
2058 int UtcDaliActorGetCurrentWorldScale(void)
2060 TestApplication application;
2062 Actor parent = Actor::New();
2063 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2064 parent.SetProperty( Actor::Property::SCALE, parentScale );
2065 application.GetScene().Add( parent );
2067 Actor child = Actor::New();
2068 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2069 child.SetProperty( Actor::Property::SCALE, childScale );
2070 parent.Add( child );
2072 // The actors should not have a scale yet
2073 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2074 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2076 // The actors should not have a world scale yet
2077 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2078 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2080 application.SendNotification();
2081 application.Render(0);
2083 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), parentScale, TEST_LOCATION );
2084 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), childScale, TEST_LOCATION );
2086 // The actors should have a world scale now
2087 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale, TEST_LOCATION );
2088 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2092 int UtcDaliActorInheritScale(void)
2094 tet_infoline("Testing Actor::SetInheritScale");
2095 TestApplication application;
2097 Actor parent = Actor::New();
2098 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2099 parent.SetProperty( Actor::Property::SCALE, parentScale );
2100 application.GetScene().Add( parent );
2102 Actor child = Actor::New();
2103 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2104 child.SetProperty( Actor::Property::SCALE, childScale );
2105 parent.Add( child );
2107 application.SendNotification();
2108 application.Render(0);
2110 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), true, TEST_LOCATION );
2111 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2113 child.SetProperty( Actor::Property::INHERIT_SCALE, false );
2114 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), false, TEST_LOCATION );
2116 application.SendNotification();
2117 application.Render(0);
2119 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), childScale, TEST_LOCATION );
2123 int UtcDaliActorSetVisible(void)
2125 TestApplication application;
2127 Actor actor = Actor::New();
2128 actor.SetProperty( Actor::Property::VISIBLE,false);
2129 // flush the queue and render once
2130 application.SendNotification();
2131 application.Render();
2132 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2134 actor.SetProperty( Actor::Property::VISIBLE,true);
2135 // flush the queue and render once
2136 application.SendNotification();
2137 application.Render();
2138 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2140 // put actor on stage
2141 application.GetScene().Add( actor );
2142 actor.SetProperty( Actor::Property::VISIBLE,false);
2143 // flush the queue and render once
2144 application.SendNotification();
2145 application.Render();
2146 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2150 int UtcDaliActorIsVisible(void)
2152 TestApplication application;
2154 Actor actor = Actor::New();
2156 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2160 int UtcDaliActorSetOpacity(void)
2162 TestApplication application;
2164 Actor actor = Actor::New();
2165 // initial opacity is 1
2166 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
2168 actor.SetProperty( Actor::Property::OPACITY, 0.4f);
2169 // flush the queue and render once
2170 application.SendNotification();
2171 application.Render();
2172 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.4f, TEST_LOCATION );
2174 // change opacity, actor is on stage to change is not immediate
2175 actor.SetProperty( Actor::Property::OPACITY, actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) + 0.1f );
2176 // flush the queue and render once
2177 application.SendNotification();
2178 application.Render();
2179 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2181 // put actor on stage
2182 application.GetScene().Add( actor );
2184 // change opacity, actor is on stage to change is not immediate
2185 actor.SetProperty( Actor::Property::OPACITY, 0.9f );
2186 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2187 // flush the queue and render once
2188 application.SendNotification();
2189 application.Render();
2190 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.9f, TEST_LOCATION );
2192 // change opacity, actor is on stage to change is not immediate
2193 actor.SetProperty( Actor::Property::OPACITY, actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) - 0.9f );
2194 // flush the queue and render once
2195 application.SendNotification();
2196 application.Render();
2197 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
2201 int UtcDaliActorGetCurrentOpacity(void)
2203 TestApplication application;
2205 Actor actor = Actor::New();
2206 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) != 0.5f);
2208 actor.SetProperty( Actor::Property::OPACITY,0.5f);
2209 // flush the queue and render once
2210 application.SendNotification();
2211 application.Render();
2212 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) == 0.5f);
2216 int UtcDaliActorSetSensitive(void)
2218 TestApplication application;
2219 Actor actor = Actor::New();
2221 bool sensitive = !actor.GetProperty< bool >( Actor::Property::SENSITIVE );
2223 actor.SetProperty( Actor::Property::SENSITIVE,sensitive);
2225 DALI_TEST_CHECK(sensitive == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2229 int UtcDaliActorIsSensitive(void)
2231 TestApplication application;
2232 Actor actor = Actor::New();
2233 actor.SetProperty( Actor::Property::SENSITIVE,false);
2235 DALI_TEST_CHECK(false == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2239 int UtcDaliActorSetColor(void)
2241 TestApplication application;
2242 Actor actor = Actor::New();
2243 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2245 DALI_TEST_CHECK(color != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2247 actor.SetProperty( Actor::Property::COLOR,color);
2248 // flush the queue and render once
2249 application.SendNotification();
2250 application.Render();
2251 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2253 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2254 // flush the queue and render once
2255 application.SendNotification();
2256 application.Render();
2257 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2259 application.GetScene().Add( actor );
2260 actor.SetProperty( Actor::Property::COLOR, color );
2261 // flush the queue and render once
2262 application.SendNotification();
2263 application.Render();
2264 DALI_TEST_EQUALS( color, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2266 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2267 // flush the queue and render once
2268 application.SendNotification();
2269 application.Render();
2270 // Actor color is not clamped
2271 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2272 // world color is clamped
2273 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), TEST_LOCATION );
2275 actor.SetProperty( Actor::Property::COLOR, color );
2276 DALI_TEST_EQUALS( color, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2278 Vector3 newColor( 1.0f, 0.0f, 0.0f );
2279 actor.SetProperty( Actor::Property::COLOR, newColor );
2280 DALI_TEST_EQUALS( Vector4( newColor.r, newColor.g, newColor.b, 1.0f ), actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2282 application.GetScene().Remove( actor );
2286 int UtcDaliActorSetColorIndividual(void)
2288 TestApplication application;
2290 Actor actor = Actor::New();
2292 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2293 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2295 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2296 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2298 // flush the queue and render once
2299 application.SendNotification();
2300 application.Render();
2302 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).r, TEST_LOCATION );
2303 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2304 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2306 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2307 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2309 // flush the queue and render once
2310 application.SendNotification();
2311 application.Render();
2313 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).g, TEST_LOCATION );
2314 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2315 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2317 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2318 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2320 // flush the queue and render once
2321 application.SendNotification();
2322 application.Render();
2324 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).b, TEST_LOCATION );
2325 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2326 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2329 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2330 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2332 // flush the queue and render once
2333 application.SendNotification();
2334 application.Render();
2336 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2337 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2338 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2340 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2341 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2343 actor.SetProperty( Actor::Property::OPACITY, 0.2f );
2346 // flush the queue and render once
2347 application.SendNotification();
2348 application.Render();
2350 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2356 int UtcDaliActorGetCurrentColor(void)
2358 TestApplication application;
2359 Actor actor = Actor::New();
2360 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2362 actor.SetProperty( Actor::Property::COLOR,color);
2363 // flush the queue and render once
2364 application.SendNotification();
2365 application.Render();
2366 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2370 int UtcDaliActorGetCurrentWorldColor(void)
2372 tet_infoline("Actor::GetCurrentWorldColor");
2373 TestApplication application;
2375 Actor parent = Actor::New();
2376 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2377 parent.SetProperty( Actor::Property::COLOR, parentColor );
2378 application.GetScene().Add( parent );
2380 Actor child = Actor::New();
2381 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2382 child.SetProperty( Actor::Property::COLOR, childColor );
2383 parent.Add( child );
2385 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2386 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2388 // verify the default color mode
2389 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2391 // The actors should not have a world color yet
2392 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2393 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2395 application.SendNotification();
2396 application.Render(0);
2398 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), parentColor, TEST_LOCATION );
2399 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2401 // The actors should have a world color now
2402 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2403 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2406 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2407 application.SendNotification();
2408 application.Render(0);
2409 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), childColor, TEST_LOCATION );
2412 child.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2413 application.SendNotification();
2414 application.Render(0);
2415 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2416 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2419 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2420 application.SendNotification();
2421 application.Render(0);
2422 Vector4 expectedColor( childColor );
2423 expectedColor.a *= parentColor.a;
2424 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2425 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), expectedColor, TEST_LOCATION );
2429 int UtcDaliActorSetColorMode(void)
2431 tet_infoline("Actor::SetColorMode");
2432 TestApplication application;
2433 Actor actor = Actor::New();
2434 Actor child = Actor::New();
2437 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2438 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2440 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
2441 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2443 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2444 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2446 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2447 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2451 int UtcDaliActorScreenToLocal(void)
2453 TestApplication application;
2454 Actor actor = Actor::New();
2455 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2456 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2457 actor.SetProperty( Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2458 application.GetScene().Add(actor);
2460 // flush the queue and render once
2461 application.SendNotification();
2462 application.Render();
2467 application.SendNotification();
2468 application.Render();
2470 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2472 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2473 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2477 int UtcDaliActorSetLeaveRequired(void)
2479 TestApplication application;
2481 Actor actor = Actor::New();
2483 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,false);
2484 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2486 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,true);
2487 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == true);
2491 int UtcDaliActorGetLeaveRequired(void)
2493 TestApplication application;
2495 Actor actor = Actor::New();
2497 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2501 int UtcDaliActorSetKeyboardFocusable(void)
2503 TestApplication application;
2505 Actor actor = Actor::New();
2507 actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
2508 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == true);
2510 actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, false );
2511 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == false);
2515 int UtcDaliActorIsKeyboardFocusable(void)
2517 TestApplication application;
2519 Actor actor = Actor::New();
2521 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == false);
2525 int UtcDaliActorRemoveConstraints(void)
2527 tet_infoline(" UtcDaliActorRemoveConstraints");
2528 TestApplication application;
2530 gTestConstraintCalled = false;
2532 Actor actor = Actor::New();
2534 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2536 actor.RemoveConstraints();
2538 DALI_TEST_CHECK( gTestConstraintCalled == false );
2540 application.GetScene().Add( actor );
2543 // flush the queue and render once
2544 application.SendNotification();
2545 application.Render();
2547 actor.RemoveConstraints();
2549 DALI_TEST_CHECK( gTestConstraintCalled == true );
2553 int UtcDaliActorRemoveConstraintTag(void)
2555 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2556 TestApplication application;
2558 Actor actor = Actor::New();
2560 // 1. Apply Constraint1 and Constraint2, and test...
2561 unsigned int result1 = 0u;
2562 unsigned int result2 = 0u;
2564 unsigned constraint1Tag = 1u;
2565 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2566 constraint1.SetTag( constraint1Tag );
2567 constraint1.Apply();
2569 unsigned constraint2Tag = 2u;
2570 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2571 constraint2.SetTag( constraint2Tag );
2572 constraint2.Apply();
2574 application.GetScene().Add( actor );
2575 // flush the queue and render once
2576 application.SendNotification();
2577 application.Render();
2579 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2580 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2582 // 2. Remove Constraint1 and test...
2585 actor.RemoveConstraints(constraint1Tag);
2586 // make color property dirty, which will trigger constraints to be reapplied.
2587 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2588 // flush the queue and render once
2589 application.SendNotification();
2590 application.Render();
2592 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2593 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2595 // 3. Re-Apply Constraint1 and test...
2598 constraint1.Apply();
2599 // make color property dirty, which will trigger constraints to be reapplied.
2600 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2601 // flush the queue and render once
2602 application.SendNotification();
2603 application.Render();
2605 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2606 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2608 // 2. Remove Constraint2 and test...
2611 actor.RemoveConstraints(constraint2Tag);
2612 // make color property dirty, which will trigger constraints to be reapplied.
2613 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2614 // flush the queue and render once
2615 application.SendNotification();
2616 application.Render();
2618 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2619 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2621 // 2. Remove Constraint1 as well and test...
2624 actor.RemoveConstraints(constraint1Tag);
2625 // make color property dirty, which will trigger constraints to be reapplied.
2626 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2627 // flush the queue and render once
2628 application.SendNotification();
2629 application.Render();
2631 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2632 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2636 int UtcDaliActorTouchedSignal(void)
2638 TestApplication application;
2640 ResetTouchCallbacks();
2642 // get the root layer
2643 Actor actor = application.GetScene().GetRootLayer();
2644 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2646 application.SendNotification();
2647 application.Render();
2649 // connect to its touch signal
2650 actor.TouchedSignal().Connect( TestCallback );
2652 // simulate a touch event in the middle of the screen
2653 Vector2 touchPoint( application.GetScene().GetSize() * 0.5 );
2654 Dali::Integration::Point point;
2655 point.SetDeviceId( 1 );
2656 point.SetState( PointState::DOWN );
2657 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2658 Dali::Integration::TouchEvent touchEvent;
2659 touchEvent.AddPoint( point );
2660 application.ProcessEvent( touchEvent );
2662 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2666 int UtcDaliActorHoveredSignal(void)
2668 TestApplication application;
2670 gHoverCallBackCalled = false;
2672 // get the root layer
2673 Actor actor = application.GetScene().GetRootLayer();
2674 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2676 application.SendNotification();
2677 application.Render();
2679 // connect to its hover signal
2680 actor.HoveredSignal().Connect( TestCallback3 );
2682 // simulate a hover event in the middle of the screen
2683 Vector2 touchPoint( application.GetScene().GetSize() * 0.5 );
2684 Dali::Integration::Point point;
2685 point.SetDeviceId( 1 );
2686 point.SetState( PointState::MOTION );
2687 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2688 Dali::Integration::HoverEvent hoverEvent;
2689 hoverEvent.AddPoint( point );
2690 application.ProcessEvent( hoverEvent );
2692 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2696 int UtcDaliActorOnOffSceneSignal(void)
2698 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2700 TestApplication application;
2703 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2704 gActorNamesOnOffScene.clear();
2706 Actor parent = Actor::New();
2707 parent.SetProperty( Actor::Property::NAME, "parent" );
2708 parent.OnSceneSignal().Connect( OnSceneCallback );
2709 parent.OffSceneSignal().Connect( OffSceneCallback );
2711 DALI_TEST_CHECK( gOnSceneCallBackCalled == 0 );
2712 DALI_TEST_CHECK( gOffSceneCallBackCalled == 0 );
2714 // add parent to the scene
2715 application.GetScene().Add( parent );
2716 // onstage emitted, offstage not
2717 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 1, TEST_LOCATION );
2718 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 0, TEST_LOCATION );
2719 DALI_TEST_EQUALS( "parent", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2721 // test adding a child, should get onstage emitted
2723 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2724 gActorNamesOnOffScene.clear();
2726 Actor child = Actor::New();
2727 child.SetProperty( Actor::Property::NAME, "child" );
2728 child.OnSceneSignal().Connect( OnSceneCallback );
2729 child.OffSceneSignal().Connect( OffSceneCallback );
2730 parent.Add( child ); // add child
2731 // onscene emitted, offscene not
2732 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 1, TEST_LOCATION );
2733 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 0, TEST_LOCATION );
2734 DALI_TEST_EQUALS( "child", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2736 // test removing parent from the scene
2738 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2739 gActorNamesOnOffScene.clear();
2741 application.GetScene().Remove( parent );
2742 // onscene not emitted, offscene is
2743 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 0, TEST_LOCATION );
2744 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 2, TEST_LOCATION );
2745 DALI_TEST_EQUALS( "child", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2746 DALI_TEST_EQUALS( "parent", gActorNamesOnOffScene[ 1 ], TEST_LOCATION );
2748 // test adding parent back to the scene
2750 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2751 gActorNamesOnOffScene.clear();
2753 application.GetScene().Add( parent );
2754 // onscene emitted, offscene not
2755 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 2, TEST_LOCATION );
2756 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 0, TEST_LOCATION );
2757 DALI_TEST_EQUALS( "parent", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2758 DALI_TEST_EQUALS( "child", gActorNamesOnOffScene[ 1 ], TEST_LOCATION );
2760 // test removing child
2762 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2763 gActorNamesOnOffScene.clear();
2765 parent.Remove( child );
2766 // onscene not emitted, offscene is
2767 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 0, TEST_LOCATION );
2768 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 1, TEST_LOCATION );
2769 DALI_TEST_EQUALS( "child", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2771 // test removing parent
2773 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2774 gActorNamesOnOffScene.clear();
2776 application.GetScene().Remove( parent );
2777 // onscene not emitted, offscene is
2778 DALI_TEST_EQUALS( gOnSceneCallBackCalled, 0, TEST_LOCATION );
2779 DALI_TEST_EQUALS( gOffSceneCallBackCalled, 1, TEST_LOCATION );
2780 DALI_TEST_EQUALS( "parent", gActorNamesOnOffScene[ 0 ], TEST_LOCATION );
2784 int UtcDaliActorFindChildByName(void)
2786 tet_infoline("Testing Dali::Actor::FindChildByName()");
2787 TestApplication application;
2789 Actor parent = Actor::New();
2790 parent.SetProperty( Actor::Property::NAME, "parent" );
2791 Actor first = Actor::New();
2792 first .SetProperty( Actor::Property::NAME, "first" );
2793 Actor second = Actor::New();
2794 second.SetProperty( Actor::Property::NAME, "second" );
2799 Actor found = parent.FindChildByName( "foo" );
2800 DALI_TEST_CHECK( !found );
2802 found = parent.FindChildByName( "parent" );
2803 DALI_TEST_CHECK( found == parent );
2805 found = parent.FindChildByName( "first" );
2806 DALI_TEST_CHECK( found == first );
2808 found = parent.FindChildByName( "second" );
2809 DALI_TEST_CHECK( found == second );
2813 int UtcDaliActorFindChildById(void)
2815 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2816 TestApplication application;
2818 Actor parent = Actor::New();
2819 Actor first = Actor::New();
2820 Actor second = Actor::New();
2825 Actor found = parent.FindChildById( 100000 );
2826 DALI_TEST_CHECK( !found );
2828 found = parent.FindChildById( parent.GetProperty< int >( Actor::Property::ID ) );
2829 DALI_TEST_CHECK( found == parent );
2831 found = parent.FindChildById( first.GetProperty< int >( Actor::Property::ID ) );
2832 DALI_TEST_CHECK( found == first );
2834 found = parent.FindChildById( second.GetProperty< int >( Actor::Property::ID ) );
2835 DALI_TEST_CHECK( found == second );
2839 int UtcDaliActorHitTest(void)
2844 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2846 mTouchPoint( touchPoint ),
2851 Vector2 mTouchPoint;
2855 TestApplication application;
2856 tet_infoline(" UtcDaliActorHitTest");
2858 // Fill a vector with different hit tests.
2859 struct HitTestData* hitTestData[] = {
2860 // scale touch point result
2861 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2862 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2863 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.
2864 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2865 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.
2869 // get the root layer
2870 Actor actor = Actor::New();
2871 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2872 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2874 application.GetScene().Add( actor );
2876 ResetTouchCallbacks();
2878 unsigned int index = 0;
2879 while( NULL != hitTestData[index] )
2881 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.f, 1.f ) );
2882 actor.SetProperty( Actor::Property::SCALE, Vector3( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z ) );
2884 // flush the queue and render once
2885 application.SendNotification();
2886 application.Render();
2888 DALI_TEST_CHECK( !gTouchCallBackCalled );
2890 // connect to its touch signal
2891 actor.TouchedSignal().Connect(TestCallback);
2893 Dali::Integration::Point point;
2894 point.SetState( PointState::DOWN );
2895 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2896 Dali::Integration::TouchEvent event;
2897 event.AddPoint( point );
2899 // flush the queue and render once
2900 application.SendNotification();
2901 application.Render();
2902 application.ProcessEvent( event );
2904 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2906 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2907 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2908 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2909 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2910 hitTestData[index]->mResult );
2912 ResetTouchCallbacks();
2918 int UtcDaliActorSetDrawMode(void)
2920 TestApplication application;
2921 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2923 Actor a = Actor::New();
2925 application.GetScene().Add(a);
2926 application.SendNotification();
2927 application.Render(0);
2928 application.SendNotification();
2929 application.Render(1);
2931 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Ensure overlay is off by default
2933 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
2934 application.SendNotification();
2935 application.Render(1);
2937 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is overlay
2939 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
2940 application.SendNotification();
2941 application.Render(1);
2943 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is normal
2947 int UtcDaliActorSetDrawModeOverlayRender(void)
2949 TestApplication application;
2950 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2952 application.SendNotification();
2953 application.Render(1);
2955 std::vector<GLuint> ids;
2956 ids.push_back( 8 ); // first rendered actor
2957 ids.push_back( 9 ); // second rendered actor
2958 ids.push_back( 10 ); // third rendered actor
2959 application.GetGlAbstraction().SetNextTextureIds( ids );
2961 Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2962 Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2963 Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2964 Actor a = CreateRenderableActor( imageA );
2965 Actor b = CreateRenderableActor( imageB );
2966 Actor c = CreateRenderableActor( imageC );
2968 application.SendNotification();
2969 application.Render(1);
2971 //Textures are bound when first created. Clear bound textures vector
2972 application.GetGlAbstraction().ClearBoundTextures();
2974 // Render a,b,c as regular non-overlays. so order will be:
2978 application.GetScene().Add(a);
2979 application.GetScene().Add(b);
2980 application.GetScene().Add(c);
2982 application.SendNotification();
2983 application.Render(1);
2985 // Should be 3 textures changes.
2986 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2987 typedef std::vector<GLuint>::size_type TextureSize;
2988 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2989 if( boundTextures.size() == 3 )
2991 DALI_TEST_CHECK( boundTextures[0] == 8u );
2992 DALI_TEST_CHECK( boundTextures[1] == 9u );
2993 DALI_TEST_CHECK( boundTextures[2] == 10u );
2996 // Now texture ids have been set, we can monitor their render order.
2997 // render a as an overlay (last), so order will be:
3001 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3002 application.GetGlAbstraction().ClearBoundTextures();
3004 application.SendNotification();
3005 application.Render(1);
3007 // Should be 3 texture changes.
3008 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
3009 if( boundTextures.size() == 3 )
3011 DALI_TEST_CHECK( boundTextures[0] == 9u );
3012 DALI_TEST_CHECK( boundTextures[1] == 10u );
3013 DALI_TEST_CHECK( boundTextures[2] == 8u );
3018 int UtcDaliActorGetCurrentWorldMatrix(void)
3020 TestApplication application;
3021 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3023 Actor parent = Actor::New();
3024 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3025 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3026 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3027 Radian rotationAngle(Degree(85.0f));
3028 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3029 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3030 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3031 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3032 parent.SetProperty( Actor::Property::SCALE, parentScale );
3033 application.GetScene().Add( parent );
3035 Actor child = Actor::New();
3036 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3037 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
3038 Radian childRotationAngle(Degree(23.0f));
3039 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
3040 Vector3 childScale( 2.0f, 2.0f, 2.0f );
3041 child.SetProperty( Actor::Property::POSITION, childPosition );
3042 child.SetProperty( Actor::Property::ORIENTATION, childRotation );
3043 child.SetProperty( Actor::Property::SCALE, childScale );
3044 parent.Add( child );
3046 application.SendNotification();
3047 application.Render(0);
3048 application.Render();
3049 application.SendNotification();
3051 Matrix parentMatrix(false);
3052 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3054 Matrix childMatrix(false);
3055 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
3057 //Child matrix should be the composition of child and parent
3058 Matrix childWorldMatrix(false);
3059 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
3061 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3062 DALI_TEST_EQUALS( child.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), childWorldMatrix, 0.001, TEST_LOCATION );
3068 int UtcDaliActorConstrainedToWorldMatrix(void)
3070 TestApplication application;
3071 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3073 Actor parent = Actor::New();
3074 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3075 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3076 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3077 Radian rotationAngle(Degree(85.0f));
3078 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3079 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3080 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3081 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3082 parent.SetProperty( Actor::Property::SCALE, parentScale );
3083 application.GetScene().Add( parent );
3085 Actor child = Actor::New();
3086 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3087 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3088 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3089 posConstraint.Apply();
3091 application.GetScene().Add( child );
3093 application.SendNotification();
3094 application.Render(0);
3095 application.Render();
3096 application.SendNotification();
3098 Matrix parentMatrix(false);
3099 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3101 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3102 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), 0.001, TEST_LOCATION );
3106 int UtcDaliActorConstrainedToOrientation(void)
3108 TestApplication application;
3109 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3111 Actor parent = Actor::New();
3112 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3113 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3114 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3115 Radian rotationAngle(Degree(85.0f));
3116 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3117 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3118 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3119 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3120 parent.SetProperty( Actor::Property::SCALE, parentScale );
3121 application.GetScene().Add( parent );
3123 Actor child = Actor::New();
3124 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3125 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3126 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3127 posConstraint.Apply();
3129 application.GetScene().Add( child );
3131 application.SendNotification();
3132 application.Render(0);
3133 application.Render();
3134 application.SendNotification();
3136 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION );
3140 int UtcDaliActorConstrainedToOpacity(void)
3142 TestApplication application;
3143 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3145 Actor parent = Actor::New();
3146 parent.SetProperty( Actor::Property::OPACITY, 0.7f );
3147 application.GetScene().Add( parent );
3149 Actor child = Actor::New();
3150 Constraint opacityConstraint = Constraint::New<float>( child, Actor::Property::OPACITY, EqualToConstraint() );
3151 opacityConstraint.AddSource( Source( parent, Actor::Property::OPACITY ) );
3152 opacityConstraint.Apply();
3154 application.GetScene().Add( child );
3156 application.SendNotification();
3157 application.Render(0);
3158 application.Render();
3159 application.SendNotification();
3161 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( Actor::Property::OPACITY ), parent.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3163 parent.SetProperty( Actor::Property::OPACITY, 0.3f );
3165 application.SendNotification();
3166 application.Render(0);
3167 application.Render();
3168 application.SendNotification();
3170 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( Actor::Property::OPACITY ), parent.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3175 int UtcDaliActorUnparent(void)
3177 TestApplication application;
3178 tet_infoline(" UtcDaliActorUnparent");
3180 Actor parent = Actor::New();
3181 application.GetScene().Add( parent );
3183 Actor child = Actor::New();
3185 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3186 DALI_TEST_CHECK( !child.GetParent() );
3188 // Test that calling Unparent with no parent is a NOOP
3191 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3192 DALI_TEST_CHECK( !child.GetParent() );
3194 // Test that Unparent works
3195 parent.Add( child );
3197 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3198 DALI_TEST_CHECK( parent == child.GetParent() );
3202 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3203 DALI_TEST_CHECK( !child.GetParent() );
3205 // Test that UnparentAndReset works
3206 parent.Add( child );
3208 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3209 DALI_TEST_CHECK( parent == child.GetParent() );
3211 UnparentAndReset( child );
3213 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3214 DALI_TEST_CHECK( !child );
3216 // Test that UnparentAndReset is a NOOP with empty handle
3217 UnparentAndReset( child );
3219 DALI_TEST_CHECK( !child );
3223 int UtcDaliActorGetChildAt(void)
3225 TestApplication application;
3226 tet_infoline(" UtcDaliActorGetChildAt");
3228 Actor parent = Actor::New();
3229 application.GetScene().Add( parent );
3231 Actor child0 = Actor::New();
3232 parent.Add( child0 );
3234 Actor child1 = Actor::New();
3235 parent.Add( child1 );
3237 Actor child2 = Actor::New();
3238 parent.Add( child2 );
3240 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3241 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3242 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3246 int UtcDaliActorSetGetOverlay(void)
3248 TestApplication application;
3249 tet_infoline(" UtcDaliActorSetGetOverlay");
3251 Actor parent = Actor::New();
3252 parent.SetProperty( Actor::Property::DRAW_MODE,DrawMode::OVERLAY_2D );
3253 DALI_TEST_CHECK( parent.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) == DrawMode::OVERLAY_2D );
3258 int UtcDaliActorCreateDestroy(void)
3260 Actor* actor = new Actor;
3261 DALI_TEST_CHECK( actor );
3268 struct PropertyStringIndex
3270 const char * const name;
3271 const Property::Index index;
3272 const Property::Type type;
3275 const PropertyStringIndex PROPERTY_TABLE[] =
3277 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3278 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3279 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3280 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3281 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3282 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3283 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3284 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3285 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3286 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3287 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3288 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3289 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3290 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3291 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3292 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3293 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3294 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3295 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3296 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3297 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3298 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3299 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3300 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3301 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3302 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3303 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3304 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3305 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3306 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3307 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3308 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3309 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3310 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3311 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3312 { "name", Actor::Property::NAME, Property::STRING },
3313 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3314 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3315 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3316 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3317 { "colorMode", Actor::Property::COLOR_MODE, Property::INTEGER },
3318 { "drawMode", Actor::Property::DRAW_MODE, Property::INTEGER },
3319 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3320 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3321 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3322 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER },
3323 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3324 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3325 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3326 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3327 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3328 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3329 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3330 { "opacity", Actor::Property::OPACITY, Property::FLOAT },
3332 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3333 } // unnamed namespace
3335 int UtcDaliActorProperties(void)
3337 TestApplication application;
3339 Actor actor = Actor::New();
3341 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3343 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3344 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3345 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3346 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3351 int UtcDaliRelayoutProperties_ResizePolicies(void)
3353 TestApplication application;
3355 Actor actor = Actor::New();
3358 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3359 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3361 // Set resize policy for all dimensions
3362 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3363 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3365 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3368 // Set individual dimensions
3369 const char* const widthPolicy = "FILL_TO_PARENT";
3370 const char* const heightPolicy = "FIXED";
3372 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3373 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3375 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3376 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3378 // Set individual dimensions using enums
3379 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3380 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3382 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3383 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3385 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3386 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3391 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3393 TestApplication application;
3395 Actor actor = Actor::New();
3398 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3400 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3401 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy );
3402 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy, TEST_LOCATION );
3405 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3406 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3408 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3409 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy1, TEST_LOCATION );
3411 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3412 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy2, TEST_LOCATION );
3417 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3419 TestApplication application;
3421 Actor actor = Actor::New();
3424 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3425 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3427 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3428 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode );
3429 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), sizeMode, TEST_LOCATION );
3432 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3434 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3435 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3440 int UtcDaliRelayoutProperties_DimensionDependency(void)
3442 TestApplication application;
3444 Actor actor = Actor::New();
3447 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3448 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3451 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3452 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3454 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3455 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3457 // Test setting another resize policy
3458 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3459 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3464 int UtcDaliRelayoutProperties_Padding(void)
3466 TestApplication application;
3468 Actor actor = Actor::New();
3471 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3474 actor.SetProperty( Actor::Property::PADDING, padding );
3475 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3477 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3482 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3484 TestApplication application;
3486 Actor actor = Actor::New();
3489 Vector2 minSize( 1.0f, 2.0f );
3491 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3492 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3494 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3496 Vector2 maxSize( 3.0f, 4.0f );
3498 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3499 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3501 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3506 int UtcDaliActorGetHeightForWidth(void)
3508 TestApplication application;
3510 Actor actor = Actor::New();
3512 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3517 int UtcDaliActorGetWidthForHeight(void)
3519 TestApplication application;
3521 Actor actor = Actor::New();
3523 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3528 int UtcDaliActorGetRelayoutSize(void)
3530 TestApplication application;
3532 Actor actor = Actor::New();
3534 // Add actor to stage
3535 application.GetScene().Add( actor );
3537 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3539 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3540 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 0.0f ) );
3542 // Flush the queue and render once
3543 application.SendNotification();
3544 application.Render();
3546 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3551 int UtcDaliActorSetPadding(void)
3553 TestApplication application;
3555 Actor actor = Actor::New();
3558 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3560 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3561 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3562 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3563 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3565 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3566 actor.SetProperty( Actor::Property::PADDING, padding2 );
3568 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3570 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3571 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3572 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3573 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3578 int UtcDaliActorSetMinimumSize(void)
3580 TestApplication application;
3582 Actor actor = Actor::New();
3584 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3586 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3587 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3589 Vector2 size2( 1.0f, 2.0f );
3590 actor.SetProperty( Actor::Property::MINIMUM_SIZE, size2 );
3592 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3594 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3595 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3600 int UtcDaliActorSetMaximumSize(void)
3602 TestApplication application;
3604 Actor actor = Actor::New();
3606 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3608 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3609 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3611 Vector2 size2( 1.0f, 2.0f );
3612 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, size2 );
3614 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3616 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3617 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3622 int UtcDaliActorOnRelayoutSignal(void)
3624 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3626 TestApplication application;
3629 gOnRelayoutCallBackCalled = false;
3630 gActorNamesRelayout.clear();
3632 Actor actor = Actor::New();
3633 actor.SetProperty( Actor::Property::NAME, "actor" );
3634 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3637 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3639 // Add actor to stage
3640 application.GetScene().Add( actor );
3642 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3643 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 2.0 ) );
3645 // Flush the queue and render once
3646 application.SendNotification();
3647 application.Render();
3649 // OnRelayout emitted
3650 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3651 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3656 int UtcDaliActorGetHierachyDepth(void)
3658 TestApplication application;
3659 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3662 /* Build tree of actors:
3672 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3674 Integration::Scene stage( application.GetScene() );
3676 Actor actorA = Actor::New();
3677 Actor actorB = Actor::New();
3678 Actor actorC = Actor::New();
3679 Actor actorD = Actor::New();
3680 Actor actorE = Actor::New();
3681 Actor actorF = Actor::New();
3683 //Test that root actor has depth equal 0
3684 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3686 //Test actors return depth -1 when not connected to the tree
3687 DALI_TEST_EQUALS( -1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3688 DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3689 DALI_TEST_EQUALS( -1, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3690 DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3691 DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3692 DALI_TEST_EQUALS( -1, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3694 //Create the hierarchy
3695 stage.Add( actorA );
3696 actorA.Add( actorB );
3697 actorA.Add( actorC );
3698 actorB.Add( actorD );
3699 actorB.Add( actorE );
3700 actorC.Add( actorF );
3702 //Test actors return correct depth
3703 DALI_TEST_EQUALS( 1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3704 DALI_TEST_EQUALS( 2, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3705 DALI_TEST_EQUALS( 2, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3706 DALI_TEST_EQUALS( 3, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3707 DALI_TEST_EQUALS( 3, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3708 DALI_TEST_EQUALS( 3, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3710 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3711 actorA.Remove( actorB );
3713 DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3714 DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3715 DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3717 //Removing actorA from the stage. All actors should have depth equal -1
3718 stage.Remove( actorA );
3720 DALI_TEST_EQUALS( -1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3721 DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3722 DALI_TEST_EQUALS( -1, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3723 DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3724 DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3725 DALI_TEST_EQUALS( -1, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3730 int UtcDaliActorAnchorPointPropertyAsString(void)
3732 TestApplication application;
3734 Actor actor = Actor::New();
3736 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3737 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3739 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3740 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3742 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3743 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3745 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3746 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3748 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3749 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER, TEST_LOCATION );
3751 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3752 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3754 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3755 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3757 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3758 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3760 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3761 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3763 // Invalid should not change anything
3764 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3765 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3770 int UtcDaliActorParentOriginPropertyAsString(void)
3772 TestApplication application;
3774 Actor actor = Actor::New();
3776 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3777 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3779 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3780 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3782 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3783 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3785 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3786 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3788 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3789 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER, TEST_LOCATION );
3791 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3792 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3794 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3795 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3797 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3798 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3800 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3801 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3803 // Invalid should not change anything
3804 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3805 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3810 int UtcDaliActorColorModePropertyAsString(void)
3812 TestApplication application;
3814 Actor actor = Actor::New();
3816 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3817 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3819 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3820 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3822 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3823 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3825 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3826 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3828 // Invalid should not change anything
3829 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3830 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3835 int UtcDaliActorDrawModePropertyAsString(void)
3837 TestApplication application;
3839 Actor actor = Actor::New();
3841 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3842 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3844 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3845 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3847 // Invalid should not change anything
3848 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3849 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3854 int UtcDaliActorColorModePropertyAsEnum(void)
3856 TestApplication application;
3858 Actor actor = Actor::New();
3860 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3861 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3863 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3864 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3866 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3867 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3869 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3870 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3875 int UtcDaliActorDrawModePropertyAsEnum(void)
3877 TestApplication application;
3879 Actor actor = Actor::New();
3881 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3882 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3884 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3885 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3890 int UtcDaliActorAddRendererP(void)
3892 tet_infoline("Testing Actor::AddRenderer");
3893 TestApplication application;
3895 Actor actor = Actor::New();
3897 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3899 Geometry geometry = CreateQuadGeometry();
3900 Shader shader = CreateShader();
3901 Renderer renderer = Renderer::New(geometry, shader);
3903 actor.AddRenderer( renderer );
3904 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3905 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3910 int UtcDaliActorAddRendererN01(void)
3912 tet_infoline("Testing Actor::AddRenderer");
3913 TestApplication application;
3915 Actor actor = Actor::New();
3921 actor.AddRenderer( renderer );
3922 tet_printf("Assertion test failed - no Exception\n" );
3923 tet_result(TET_FAIL);
3925 catch(Dali::DaliException& e)
3927 DALI_TEST_PRINT_ASSERT( e );
3928 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3929 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3933 tet_printf("Assertion test failed - wrong Exception\n" );
3934 tet_result(TET_FAIL);
3940 int UtcDaliActorAddRendererN02(void)
3942 tet_infoline( "UtcDaliActorAddRendererN02" );
3948 TestApplication application;
3950 Geometry geometry = CreateQuadGeometry();
3951 Shader shader = CreateShader();
3952 renderer = Renderer::New( geometry, shader );
3954 actor = Actor::New();
3957 // try illegal AddRenderer
3960 actor.AddRenderer( renderer );
3961 tet_printf( "Assertion test failed - no Exception\n" );
3962 tet_result( TET_FAIL );
3964 catch( Dali::DaliException& e )
3966 DALI_TEST_PRINT_ASSERT( e );
3967 DALI_TEST_ASSERT( e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION );
3971 tet_printf( "Assertion test failed - wrong Exception\n" );
3972 tet_result( TET_FAIL );
3978 int UtcDaliActorAddRendererOnScene(void)
3980 tet_infoline("Testing Actor::AddRenderer");
3981 TestApplication application;
3983 Actor actor = Actor::New();
3984 application.GetScene().Add(actor);
3986 application.SendNotification();
3987 application.Render(0);
3989 Geometry geometry = CreateQuadGeometry();
3990 Shader shader = CreateShader();
3991 Renderer renderer = Renderer::New(geometry, shader);
3993 application.SendNotification();
3994 application.Render(0);
3998 actor.AddRenderer( renderer );
3999 tet_result(TET_PASS);
4003 tet_result(TET_FAIL);
4009 int UtcDaliActorRemoveRendererP1(void)
4011 tet_infoline("Testing Actor::RemoveRenderer");
4012 TestApplication application;
4014 Actor actor = Actor::New();
4016 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4019 Geometry geometry = CreateQuadGeometry();
4020 Shader shader = CreateShader();
4021 Renderer renderer = Renderer::New(geometry, shader);
4023 actor.AddRenderer( renderer );
4024 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4025 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4027 application.SendNotification();
4028 application.Render();
4032 Renderer renderer = actor.GetRendererAt(0);
4033 actor.RemoveRenderer(renderer);
4034 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4036 application.SendNotification();
4037 application.Render();
4040 // Call one final time to ensure that the renderer is actually removed after
4041 // the handle goes out of scope, and excercises the deletion code path in
4042 // scene graph and render.
4043 application.SendNotification();
4044 application.Render();
4049 int UtcDaliActorRemoveRendererP2(void)
4051 tet_infoline("Testing Actor::RemoveRenderer");
4052 TestApplication application;
4054 Actor actor = Actor::New();
4056 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4058 Geometry geometry = CreateQuadGeometry();
4059 Shader shader = CreateShader();
4060 Renderer renderer = Renderer::New(geometry, shader);
4062 actor.AddRenderer( renderer );
4063 application.SendNotification();
4064 application.Render();
4066 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4067 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4069 actor.RemoveRenderer(0);
4070 application.SendNotification();
4071 application.Render();
4073 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4075 // Shut down whilst holding onto the renderer handle.
4080 int UtcDaliActorRemoveRendererN(void)
4082 tet_infoline("Testing Actor::RemoveRenderer");
4083 TestApplication application;
4085 Actor actor = Actor::New();
4087 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4089 Geometry geometry = CreateQuadGeometry();
4090 Shader shader = CreateShader();
4091 Renderer renderer = Renderer::New(geometry, shader);
4093 actor.AddRenderer( renderer );
4094 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4095 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4097 actor.RemoveRenderer(10);
4098 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4099 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4104 // Clipping test helper functions:
4105 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4107 Texture image = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
4108 Actor actor = CreateRenderableActor( image );
4110 // Setup dimensions and position so actor is not skipped by culling.
4111 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4112 actor.SetProperty( Actor::Property::SIZE, Vector2( width, height ) );
4113 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4114 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4119 Actor CreateActorWithContent16x16()
4121 return CreateActorWithContent( 16, 16 );
4124 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4126 enabledDisableTrace.Reset();
4127 stencilTrace.Reset();
4128 enabledDisableTrace.Enable( true );
4129 stencilTrace.Enable( true );
4131 application.SendNotification();
4132 application.Render();
4134 enabledDisableTrace.Enable( false );
4135 stencilTrace.Enable( false );
4138 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4140 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4142 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4143 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4144 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4145 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4148 int UtcDaliActorPropertyClippingP(void)
4150 // This test checks the clippingMode property.
4151 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4152 TestApplication application;
4154 Actor actor = Actor::New();
4156 // Check default clippingEnabled value.
4157 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4160 bool getValueResult = getValue.Get( value );
4161 DALI_TEST_CHECK( getValueResult );
4163 if( getValueResult )
4165 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4168 // Check setting the property to the stencil mode.
4169 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4171 // Check the new value was set.
4172 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4173 getValueResult = getValue.Get( value );
4174 DALI_TEST_CHECK( getValueResult );
4176 if( getValueResult )
4178 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4181 // Check setting the property to the scissor mode.
4182 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4184 // Check the new value was set.
4185 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4186 getValueResult = getValue.Get( value );
4187 DALI_TEST_CHECK( getValueResult );
4189 if( getValueResult )
4191 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4196 int UtcDaliActorPropertyClippingN(void)
4198 // Negative test case for Clipping.
4199 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4200 TestApplication application;
4202 Actor actor = Actor::New();
4204 // Check default clippingEnabled value.
4205 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4208 bool getValueResult = getValue.Get( value );
4209 DALI_TEST_CHECK( getValueResult );
4211 if( getValueResult )
4213 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4216 // Check setting an invalid property value won't change the current property value.
4217 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4219 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4220 getValueResult = getValue.Get( value );
4221 DALI_TEST_CHECK( getValueResult );
4223 if( getValueResult )
4225 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4231 int UtcDaliActorPropertyClippingActor(void)
4233 // This test checks that an actor is correctly setup for clipping.
4234 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4235 TestApplication application;
4237 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4238 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4239 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4240 size_t startIndex = 0u;
4242 // Create a clipping actor.
4243 Actor actorDepth1Clip = CreateActorWithContent16x16();
4244 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4245 application.GetScene().Add( actorDepth1Clip );
4247 // Gather the call trace.
4248 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4250 // Check we are writing to the color buffer.
4251 CheckColorMask( glAbstraction, true );
4253 // Check the stencil buffer was enabled.
4254 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4256 // Check the stencil buffer was cleared.
4257 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4259 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4260 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4261 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4262 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4267 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4269 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4270 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4271 TestApplication application;
4273 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4274 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4275 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4276 size_t startIndex = 0u;
4278 // Create a clipping actor.
4279 Actor actorDepth1Clip = CreateActorWithContent16x16();
4280 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4281 application.GetScene().Add( actorDepth1Clip );
4283 // Gather the call trace.
4284 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4286 // Check we are writing to the color buffer.
4287 CheckColorMask( glAbstraction, true );
4289 // Check the stencil buffer was enabled.
4290 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4292 // Check the stencil buffer was cleared.
4293 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4295 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4296 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4297 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4298 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4300 // Now disable the clipping
4301 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4303 // Gather the call trace.
4304 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4306 // Check the stencil buffer was disabled.
4307 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4309 // Ensure all values in stencil-mask are set to 1.
4311 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4316 int UtcDaliActorPropertyClippingNestedChildren(void)
4318 // This test checks that a hierarchy of actors are clipped correctly by
4319 // writing to and reading from the correct bit-planes of the stencil buffer.
4320 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4321 TestApplication application;
4322 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4323 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4324 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4326 // Create a clipping actor.
4327 Actor actorDepth1Clip = CreateActorWithContent16x16();
4328 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4329 application.GetScene().Add( actorDepth1Clip );
4331 // Create a child actor.
4332 Actor childDepth2 = CreateActorWithContent16x16();
4333 actorDepth1Clip.Add( childDepth2 );
4335 // Create another clipping actor.
4336 Actor childDepth2Clip = CreateActorWithContent16x16();
4337 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4338 childDepth2.Add( childDepth2Clip );
4340 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4341 // This tests the sort algorithm.
4342 Actor childDepth3 = CreateActorWithContent16x16();
4343 childDepth2Clip.Add( childDepth3 );
4344 Actor childDepth4 = CreateActorWithContent16x16();
4345 childDepth3.Add( childDepth4 );
4347 // Gather the call trace.
4348 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4350 // Check we are writing to the color buffer.
4351 CheckColorMask( glAbstraction, true );
4353 // Check the stencil buffer was enabled.
4354 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4356 // Perform the test twice, once for 2D layer, and once for 3D.
4357 for( unsigned int i = 0u ; i < 2u; ++i )
4359 size_t startIndex = 0u;
4361 // Check the stencil buffer was cleared.
4362 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4364 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4365 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4366 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4367 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4369 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4370 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4371 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4373 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4374 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4375 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4376 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4378 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4379 // (Both must be set to pass the check).
4380 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4381 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4383 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4386 application.GetScene().GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
4387 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4394 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4396 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4397 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4398 TestApplication application;
4399 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4400 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4402 /* We create a small tree of actors as follows:
4406 Clipping enabled -> B D
4410 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4413 for( int i = 0; i < 5; ++i )
4415 Texture image = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u );
4416 Actor actor = CreateRenderableActor( image );
4418 // Setup dimensions and position so actor is not skipped by culling.
4419 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4420 actor.SetProperty( Actor::Property::SIZE, Vector2( 16.0f, 16.0f ) );
4424 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4428 float b = i > 2 ? 1.0f : -1.0f;
4429 actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4435 // Enable clipping on the actor at the top of the left branch.
4436 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4438 // Build the scene graph.
4439 application.GetScene().Add( actors[0] );
4442 actors[0].Add( actors[1] );
4443 actors[1].Add( actors[2] );
4446 actors[0].Add( actors[3] );
4447 actors[3].Add( actors[4] );
4449 // Gather the call trace.
4450 enabledDisableTrace.Reset();
4451 enabledDisableTrace.Enable( true );
4452 application.SendNotification();
4453 application.Render();
4454 enabledDisableTrace.Enable( false );
4456 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4458 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
4459 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4461 size_t startIndex = 0u;
4462 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4463 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4464 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4466 // Swap the clipping actor from top of left branch to top of right branch.
4467 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4468 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4470 // Gather the call trace.
4471 enabledDisableTrace.Reset();
4472 enabledDisableTrace.Enable( true );
4473 application.SendNotification();
4474 application.Render();
4475 enabledDisableTrace.Enable( false );
4477 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4478 // This proves the draw order has remained the same.
4480 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4481 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4486 int UtcDaliActorPropertyScissorClippingActor(void)
4488 // This test checks that an actor is correctly setup for clipping.
4489 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4490 TestApplication application;
4492 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4493 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4494 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4496 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4497 const Vector2 imageSize( 16.0f, 16.0f );
4499 // Create a clipping actor.
4500 Actor clippingActorA = CreateActorWithContent16x16();
4501 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4502 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4503 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
4504 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
4505 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4506 application.GetScene().Add( clippingActorA );
4508 // Gather the call trace.
4509 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4511 // Check we are writing to the color buffer.
4512 CheckColorMask( glAbstraction, true );
4514 // Check scissor test was enabled.
4515 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4517 // Check the scissor was set, and the coordinates are correct.
4518 std::stringstream compareParametersString;
4519 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4520 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4522 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
4523 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT );
4525 // Gather the call trace.
4526 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4528 // Check the scissor was set, and the coordinates are correct.
4529 compareParametersString.str( std::string() );
4530 compareParametersString.clear();
4531 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4532 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4537 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4539 // This test checks that an actor is correctly setup for clipping.
4540 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4541 TestApplication application;
4544 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4545 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4546 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4548 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4549 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4550 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4552 // Create a clipping actors.
4553 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4554 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4556 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4557 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4558 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4560 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4561 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4562 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4564 clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4565 clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4567 application.GetScene().Add( clippingActorA );
4568 application.GetScene().Add( clippingActorB );
4570 // Gather the call trace.
4571 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4573 // Check we are writing to the color buffer.
4574 CheckColorMask( glAbstraction, true );
4576 // Check scissor test was enabled.
4577 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4579 // Check the scissor was set, and the coordinates are correct.
4580 std::stringstream compareParametersString;
4582 std::string clipA( "0, 500, 480, 200" );
4583 std::string clipB( "0, 380, 480, 40" );
4585 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4586 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4591 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4593 // This test checks that an actor is correctly setup for clipping.
4594 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4595 TestApplication application;
4597 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4598 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4599 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4601 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4602 const Vector2 imageSize( 16.0f, 16.0f );
4604 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4606 A is drawn first - with scissor clipping on
4607 B is drawn second - also with scissor clipping on
4608 C is the generated clipping region, the intersection ( A ∩ B )
4612 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4613 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4614 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4618 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4621 // Create a clipping actor.
4622 Actor clippingActorA = CreateActorWithContent16x16();
4623 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4624 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4625 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4626 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4627 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4628 application.GetScene().Add( clippingActorA );
4630 // Create a child clipping actor.
4631 Actor clippingActorB = CreateActorWithContent16x16();
4632 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4633 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4634 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4635 clippingActorA.Add( clippingActorB );
4637 // positionModifiers is an array of positions to position B around.
4638 // expect is an array of expected scissor clip coordinate results.
4639 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4640 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4642 // Loop through each overlap combination.
4643 for( unsigned int test = 0u; test < 4u; ++test )
4645 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4646 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4647 clippingActorB.SetProperty( Actor::Property::POSITION, Vector2( position.x, position.y ));
4649 // Gather the call trace.
4650 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4652 // Check we are writing to the color buffer.
4653 CheckColorMask( glAbstraction, true );
4655 // Check scissor test was enabled.
4656 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4658 // Check the scissor was set, and the coordinates are correct.
4659 const Vector4& expectResults( expect[test] );
4660 std::stringstream compareParametersString;
4661 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4662 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4668 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4670 // This test checks that an actor is correctly setup for clipping.
4671 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4672 TestApplication application;
4674 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4675 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4676 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4678 /* Create a nest of 2 scissors and siblings of the parent.
4688 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4689 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4690 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4691 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4692 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4693 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4695 // Create a clipping actors.
4696 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4697 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4698 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4699 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4700 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4702 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4703 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4704 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4706 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4707 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4708 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4710 clippingActorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4711 clippingActorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4712 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4714 clippingActorD.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4715 clippingActorD.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4716 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4718 clippingActorE.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4719 clippingActorE.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4721 clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4722 clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4723 clippingActorC.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 100.0f, 0.0f ));
4724 clippingActorD.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4725 clippingActorE.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4727 application.GetScene().Add( clippingActorA );
4728 clippingActorA.Add( clippingActorB );
4729 application.GetScene().Add( clippingActorC );
4730 application.GetScene().Add( clippingActorD );
4731 clippingActorD.Add( clippingActorE );
4733 // Gather the call trace.
4734 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4736 // Check we are writing to the color buffer.
4737 CheckColorMask( glAbstraction, true );
4739 // Check scissor test was enabled.
4740 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4742 // Check the scissor was set, and the coordinates are correct.
4743 std::string clipA( "0, 500, 480, 200" );
4744 std::string clipB( "0, 580, 480, 40" );
4745 std::string clipC( "0, 200, 480, 200" );
4746 std::string clipD( "0, 300, 480, 200" );
4748 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4749 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4750 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4751 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4752 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4757 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4759 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4760 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4761 TestApplication application;
4763 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4764 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4765 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4767 // Create a clipping actor.
4768 Actor actorDepth1Clip = CreateActorWithContent16x16();
4769 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4770 application.GetScene().Add( actorDepth1Clip );
4772 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4773 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4775 // Gather the call trace.
4776 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4778 // Check we are writing to the color buffer.
4779 CheckColorMask( glAbstraction, true );
4781 // Check the stencil buffer was not enabled.
4782 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4784 // Check stencil functions are not called.
4785 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4786 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4787 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4789 // Check that scissor clipping is overriden by the renderer properties.
4790 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4792 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4794 // Gather the call trace.
4795 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4797 // Check the stencil buffer was not enabled.
4798 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4800 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4805 int UtcDaliGetPropertyN(void)
4807 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4808 TestApplication application;
4810 Actor actor = Actor::New();
4812 unsigned int propertyCount = actor.GetPropertyCount();
4813 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4817 int UtcDaliActorRaiseLower(void)
4819 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4821 TestApplication application;
4823 Debug::Filter::SetGlobalLogLevel( Debug::Verbose );
4825 Integration::Scene stage( application.GetScene() );
4827 Actor actorA = Actor::New();
4828 Actor actorB = Actor::New();
4829 Actor actorC = Actor::New();
4831 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4832 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4834 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4835 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4837 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4838 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4840 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4841 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4843 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4844 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4846 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4847 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4849 stage.Add( actorA );
4850 stage.Add( actorB );
4851 stage.Add( actorC );
4853 ResetTouchCallbacks();
4855 application.SendNotification();
4856 application.Render();
4858 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4859 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4860 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4862 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4863 // Only top actor will get touched.
4864 actorA.TouchSignal().Connect( TestTouchCallback );
4865 actorB.TouchSignal().Connect( TestTouchCallback2 );
4866 actorC.TouchSignal().Connect( TestTouchCallback3 );
4868 // Connect ChildOrderChangedSignal
4869 bool orderChangedSignal( false );
4870 Actor orderChangedActor;
4871 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4872 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4874 Dali::Integration::Point point;
4875 point.SetDeviceId( 1 );
4876 point.SetState( PointState::DOWN );
4877 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4878 Dali::Integration::TouchEvent touchEvent;
4879 touchEvent.AddPoint( point );
4881 application.ProcessEvent( touchEvent );
4883 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4884 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4885 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4887 ResetTouchCallbacks();
4889 tet_printf( "Testing Raising of Actor\n" );
4891 int preActorOrder( 0 );
4892 int postActorOrder( 0 );
4894 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4895 value.Get( preActorOrder );
4897 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4899 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4900 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4902 // Ensure sort order is calculated before next touch event
4903 application.SendNotification();
4905 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4906 value.Get( postActorOrder );
4908 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4910 application.ProcessEvent( touchEvent );
4912 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4913 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4914 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4916 ResetTouchCallbacks();
4918 tet_printf( "Testing Lowering of Actor\n" );
4920 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4921 value.Get( preActorOrder );
4923 orderChangedSignal = false;
4925 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4927 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4928 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4930 application.SendNotification(); // ensure sort order calculated before next touch event
4932 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4933 value.Get( postActorOrder );
4935 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4937 application.ProcessEvent( touchEvent );
4939 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4940 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4941 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4943 ResetTouchCallbacks();
4945 Debug::Filter::SetGlobalLogLevel( Debug::NoLogging );
4950 int UtcDaliActorRaiseToTopLowerToBottom(void)
4952 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4954 TestApplication application;
4956 Integration::Scene stage( application.GetScene() );
4958 Actor actorA = Actor::New();
4959 Actor actorB = Actor::New();
4960 Actor actorC = Actor::New();
4962 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4963 // enables checking of which actor the uniform is assigned too
4964 Shader shaderA = CreateShader();
4965 shaderA.RegisterProperty( "uRendererColor",1.f);
4967 Shader shaderB = CreateShader();
4968 shaderB.RegisterProperty( "uRendererColor", 2.f );
4970 Shader shaderC = CreateShader();
4971 shaderC.RegisterProperty( "uRendererColor", 3.f );
4973 Geometry geometry = CreateQuadGeometry();
4975 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4976 Renderer rendererA = Renderer::New(geometry, shaderA);
4977 actorA.AddRenderer(rendererA);
4979 Renderer rendererB = Renderer::New(geometry, shaderB);
4980 actorB.AddRenderer(rendererB);
4982 Renderer rendererC = Renderer::New(geometry, shaderC);
4983 actorC.AddRenderer(rendererC);
4985 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4986 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4988 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4989 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4991 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4992 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4994 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4995 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4997 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4998 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5000 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5001 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5003 stage.Add( actorA );
5004 stage.Add( actorB );
5005 stage.Add( actorC );
5007 ResetTouchCallbacks();
5009 // Connect ChildOrderChangedSignal
5010 bool orderChangedSignal( false );
5011 Actor orderChangedActor;
5012 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5013 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5015 // Set up gl abstraction trace so can query the set uniform order
5016 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5017 glAbstraction.EnableSetUniformCallTrace(true);
5018 glAbstraction.ResetSetUniformCallStack();
5020 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5022 application.SendNotification();
5023 application.Render();
5025 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
5028 // Test order of uniforms in stack
5029 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5030 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5031 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5033 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5035 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5037 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5038 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5039 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5041 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5042 // Only top actor will get touched.
5043 actorA.TouchSignal().Connect( TestTouchCallback );
5044 actorB.TouchSignal().Connect( TestTouchCallback2 );
5045 actorC.TouchSignal().Connect( TestTouchCallback3 );
5047 Dali::Integration::Point point;
5048 point.SetDeviceId( 1 );
5049 point.SetState( PointState::DOWN );
5050 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5051 Dali::Integration::TouchEvent touchEvent;
5052 touchEvent.AddPoint( point );
5054 application.ProcessEvent( touchEvent );
5056 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5057 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5058 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5060 ResetTouchCallbacks();
5062 tet_printf( "RaiseToTop ActorA\n" );
5064 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5065 actorA.RaiseToTop();
5066 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5067 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5069 application.SendNotification(); // ensure sorting order is calculated before next touch event
5071 application.ProcessEvent( touchEvent );
5073 glAbstraction.ResetSetUniformCallStack();
5074 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5076 application.SendNotification();
5077 application.Render();
5079 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5081 // Test order of uniforms in stack
5082 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5083 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5084 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5086 tet_infoline( "Testing A above C and B at bottom\n" );
5087 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5089 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5091 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5092 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5093 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5095 ResetTouchCallbacks();
5097 tet_printf( "RaiseToTop ActorB\n" );
5099 orderChangedSignal = false;
5101 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5102 actorB.RaiseToTop();
5103 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5104 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5106 application.SendNotification(); // Ensure sort order is calculated before next touch event
5108 application.ProcessEvent( touchEvent );
5110 glAbstraction.ResetSetUniformCallStack();
5111 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5113 application.SendNotification();
5114 application.Render();
5116 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5118 // Test order of uniforms in stack
5119 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5120 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5121 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5123 tet_infoline( "Testing B above A and C at bottom\n" );
5124 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5126 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5128 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5129 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5130 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5132 ResetTouchCallbacks();
5134 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5136 orderChangedSignal = false;
5138 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5139 actorA.LowerToBottom();
5140 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5141 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5143 application.SendNotification();
5144 application.Render();
5146 orderChangedSignal = false;
5148 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5149 actorB.LowerToBottom();
5150 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5151 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5153 application.SendNotification();
5154 application.Render();
5156 application.ProcessEvent( touchEvent );
5158 glAbstraction.ResetSetUniformCallStack();
5159 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5161 application.SendNotification();
5162 application.Render();
5164 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5166 // Test order of uniforms in stack
5167 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5168 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5169 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5171 tet_infoline( "Testing C above A and B at bottom\n" );
5172 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5174 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5176 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5177 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5178 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5180 ResetTouchCallbacks();
5185 int UtcDaliActorRaiseAbove(void)
5187 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5189 TestApplication application;
5191 Integration::Scene stage( application.GetScene() );
5193 Actor actorA = Actor::New();
5194 Actor actorB = Actor::New();
5195 Actor actorC = Actor::New();
5197 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5198 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5200 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5201 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5203 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5204 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5206 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5207 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5209 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5210 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5212 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5213 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5215 stage.Add( actorA );
5216 stage.Add( actorB );
5217 stage.Add( actorC );
5219 ResetTouchCallbacks();
5221 application.SendNotification();
5222 application.Render();
5224 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5225 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5226 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5228 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5229 // Only top actor will get touched.
5230 actorA.TouchSignal().Connect( TestTouchCallback );
5231 actorB.TouchSignal().Connect( TestTouchCallback2 );
5232 actorC.TouchSignal().Connect( TestTouchCallback3 );
5234 bool orderChangedSignal( false );
5235 Actor orderChangedActor;
5236 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5237 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5239 Dali::Integration::Point point;
5240 point.SetDeviceId( 1 );
5241 point.SetState( PointState::DOWN );
5242 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5243 Dali::Integration::TouchEvent touchEvent;
5244 touchEvent.AddPoint( point );
5246 application.ProcessEvent( touchEvent );
5248 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5249 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5250 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5252 ResetTouchCallbacks();
5254 tet_printf( "Raise actor B Above Actor C\n" );
5256 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5257 actorB.RaiseAbove( actorC );
5258 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5259 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5261 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5262 application.SendNotification();
5263 application.ProcessEvent( touchEvent );
5265 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5266 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5267 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5269 ResetTouchCallbacks();
5271 tet_printf( "Raise actor A Above Actor B\n" );
5273 orderChangedSignal = false;
5275 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5276 actorA.RaiseAbove( actorB );
5277 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5278 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5280 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5281 application.SendNotification();
5283 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5285 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5286 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5287 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5289 ResetTouchCallbacks();
5294 int UtcDaliActorLowerBelow(void)
5296 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5298 TestApplication application;
5300 Integration::Scene stage( application.GetScene() );
5302 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5303 // enables checking of which actor the uniform is assigned too
5304 Shader shaderA = CreateShader();
5305 shaderA.RegisterProperty( "uRendererColor",1.f);
5307 Shader shaderB = CreateShader();
5308 shaderB.RegisterProperty( "uRendererColor", 2.f );
5310 Shader shaderC = CreateShader();
5311 shaderC.RegisterProperty( "uRendererColor", 3.f );
5313 Actor actorA = Actor::New();
5314 Actor actorB = Actor::New();
5315 Actor actorC = Actor::New();
5317 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5318 Geometry geometry = CreateQuadGeometry();
5320 Renderer rendererA = Renderer::New(geometry, shaderA);
5321 actorA.AddRenderer(rendererA);
5323 Renderer rendererB = Renderer::New(geometry, shaderB);
5324 actorB.AddRenderer(rendererB);
5326 Renderer rendererC = Renderer::New(geometry, shaderC);
5327 actorC.AddRenderer(rendererC);
5329 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5330 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5332 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5333 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5335 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5336 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5338 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5339 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5341 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5342 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5344 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5345 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5347 Actor container = Actor::New();
5348 container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5349 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5350 stage.Add( container );
5352 container.Add( actorA );
5353 container.Add( actorB );
5354 container.Add( actorC );
5356 ResetTouchCallbacks();
5358 // Connect ChildOrderChangedSignal
5359 bool orderChangedSignal( false );
5360 Actor orderChangedActor;
5361 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5362 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5364 // Set up gl abstraction trace so can query the set uniform order
5365 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5366 glAbstraction.EnableSetUniformCallTrace(true);
5367 glAbstraction.ResetSetUniformCallStack();
5368 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5370 glAbstraction.ResetSetUniformCallStack();
5372 application.SendNotification();
5373 application.Render();
5375 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5377 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5379 // Test order of uniforms in stack
5380 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5381 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5382 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5384 tet_infoline( "Testing C above B and A at bottom\n" );
5385 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5387 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5389 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5390 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5391 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5393 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5394 // Only top actor will get touched.
5395 actorA.TouchSignal().Connect( TestTouchCallback );
5396 actorB.TouchSignal().Connect( TestTouchCallback2 );
5397 actorC.TouchSignal().Connect( TestTouchCallback3 );
5399 Dali::Integration::Point point;
5400 point.SetDeviceId( 1 );
5401 point.SetState( PointState::DOWN );
5402 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5403 Dali::Integration::TouchEvent touchEvent;
5404 touchEvent.AddPoint( point );
5406 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5408 application.ProcessEvent( touchEvent );
5410 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5411 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5412 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5414 ResetTouchCallbacks();
5416 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" );
5418 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5419 actorC.LowerBelow( actorB );
5420 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5421 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5423 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5424 application.SendNotification();
5425 application.Render();
5427 application.ProcessEvent( touchEvent ); // touch event
5429 glAbstraction.ResetSetUniformCallStack();
5430 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5432 application.SendNotification();
5433 application.Render();
5435 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5437 // Test order of uniforms in stack
5438 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5439 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5440 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5442 tet_infoline( "Testing render order is A, C, B" );
5443 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5444 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5446 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5447 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5448 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5450 ResetTouchCallbacks();
5452 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5454 orderChangedSignal = false;
5456 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5457 actorC.LowerBelow( actorA );
5458 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5459 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5461 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5462 application.SendNotification();
5463 application.Render();
5465 application.ProcessEvent( touchEvent );
5467 glAbstraction.ResetSetUniformCallStack();
5468 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5470 application.Render();
5471 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5473 // Test order of uniforms in stack
5474 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5475 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5476 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5478 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5479 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5481 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5482 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5483 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5485 ResetTouchCallbacks();
5487 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5489 orderChangedSignal = false;
5491 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5492 actorB.LowerBelow( actorC );
5493 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5494 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5496 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5497 application.SendNotification();
5498 application.Render();
5500 application.ProcessEvent( touchEvent );
5502 glAbstraction.ResetSetUniformCallStack();
5503 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5505 application.Render();
5506 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5508 // Test order of uniforms in stack
5509 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5510 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5511 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5513 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5514 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5520 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5522 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5524 TestApplication application;
5526 Integration::Scene stage( application.GetScene() );
5528 Actor parentA = Actor::New();
5529 Actor parentB = Actor::New();
5530 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5531 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5532 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5533 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5535 parentA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5536 parentA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5538 parentB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5539 parentB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5541 stage.Add( parentA );
5542 stage.Add( parentB );
5544 Actor actorA = Actor::New();
5545 Actor actorB = Actor::New();
5546 Actor actorC = Actor::New();
5548 parentA.Add( actorA );
5549 parentA.Add( actorB );
5551 tet_printf( "Actor C added to different parent from A and B \n" );
5552 parentB.Add( actorC );
5554 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5555 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5557 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5558 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5560 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5561 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5563 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5564 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5566 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5567 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5569 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5570 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5572 ResetTouchCallbacks();
5574 // Connect ChildOrderChangedSignal
5575 bool orderChangedSignal( false );
5576 Actor orderChangedActor;
5577 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5578 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5580 application.SendNotification();
5581 application.Render();
5583 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5584 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5585 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5587 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5588 // Only top actor will get touched.
5589 actorA.TouchSignal().Connect( TestTouchCallback );
5590 actorB.TouchSignal().Connect( TestTouchCallback2 );
5591 actorC.TouchSignal().Connect( TestTouchCallback3 );
5593 Dali::Integration::Point point;
5594 point.SetDeviceId( 1 );
5595 point.SetState( PointState::DOWN );
5596 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5597 Dali::Integration::TouchEvent touchEvent;
5598 touchEvent.AddPoint( point );
5600 application.ProcessEvent( touchEvent );
5602 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5603 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5604 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5606 ResetTouchCallbacks();
5608 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5610 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5611 actorA.RaiseAbove( actorC );
5612 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5614 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5615 application.SendNotification();
5617 application.ProcessEvent( touchEvent ); // touch event
5619 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5620 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5621 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5623 ResetTouchCallbacks();
5628 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5630 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5632 TestApplication application;
5634 Integration::Scene stage( application.GetScene() );
5636 Actor actorA = Actor::New();
5637 Actor actorB = Actor::New();
5638 Actor actorC = Actor::New();
5640 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5641 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5643 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5644 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5646 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5647 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5649 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5650 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5652 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5653 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5655 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5656 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5658 ResetTouchCallbacks();
5660 // Connect ChildOrderChangedSignal
5661 bool orderChangedSignal( false );
5662 Actor orderChangedActor;
5663 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5664 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5666 application.SendNotification();
5667 application.Render();
5669 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5670 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5671 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5673 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5674 // Only top actor will get touched.
5675 actorA.TouchSignal().Connect( TestTouchCallback );
5676 actorB.TouchSignal().Connect( TestTouchCallback2 );
5677 actorC.TouchSignal().Connect( TestTouchCallback3 );
5679 Dali::Integration::Point point;
5680 point.SetDeviceId( 1 );
5681 point.SetState( PointState::DOWN );
5682 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5683 Dali::Integration::TouchEvent touchEvent;
5684 touchEvent.AddPoint( point );
5686 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5688 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5689 actorA.RaiseAbove( actorC );
5690 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5692 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5693 application.SendNotification();
5695 application.ProcessEvent( touchEvent );
5697 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5699 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5700 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5701 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5703 ResetTouchCallbacks();
5705 orderChangedSignal = false;
5707 stage.Add ( actorB );
5708 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5710 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5711 actorA.LowerBelow( actorC );
5712 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5714 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5715 application.SendNotification();
5716 application.Render();
5718 application.ProcessEvent( touchEvent );
5720 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5721 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5722 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5723 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5725 ResetTouchCallbacks();
5727 orderChangedSignal = false;
5729 tet_printf( "Adding Actor A to stage, will be on top\n" );
5731 stage.Add ( actorA );
5732 application.SendNotification();
5733 application.Render();
5735 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5737 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5738 actorB.RaiseAbove( actorC );
5739 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5741 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5742 application.SendNotification();
5744 application.ProcessEvent( touchEvent );
5746 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5747 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5748 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5749 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5751 ResetTouchCallbacks();
5753 orderChangedSignal = false;
5755 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5757 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5758 actorA.LowerBelow( actorC );
5759 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5761 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5762 application.SendNotification();
5764 application.ProcessEvent( touchEvent );
5766 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5767 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5768 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5769 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5771 ResetTouchCallbacks();
5773 orderChangedSignal = false;
5775 stage.Add ( actorC );
5777 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5778 actorA.RaiseAbove( actorC );
5779 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5780 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5782 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5783 application.SendNotification();
5784 application.Render();
5786 application.ProcessEvent( touchEvent );
5788 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5789 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5790 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5791 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5796 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5798 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5800 TestApplication application;
5802 Integration::Scene stage( application.GetScene() );
5804 Actor actorA = Actor::New();
5805 Actor actorB = Actor::New();
5806 Actor actorC = Actor::New();
5808 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5809 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5811 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5812 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5814 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5815 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5817 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5818 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5820 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5821 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5823 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5824 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5826 ResetTouchCallbacks();
5828 // Connect ChildOrderChangedSignal
5829 bool orderChangedSignal( false );
5830 Actor orderChangedActor;
5831 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5832 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5834 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5835 // Only top actor will get touched.
5836 actorA.TouchSignal().Connect( TestTouchCallback );
5837 actorB.TouchSignal().Connect( TestTouchCallback2 );
5838 actorC.TouchSignal().Connect( TestTouchCallback3 );
5840 Dali::Integration::Point point;
5841 point.SetDeviceId( 1 );
5842 point.SetState( PointState::DOWN );
5843 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5844 Dali::Integration::TouchEvent touchEvent;
5845 touchEvent.AddPoint( point );
5847 stage.Add ( actorA );
5848 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5850 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5852 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5854 application.SendNotification();
5855 application.Render();
5857 application.ProcessEvent( touchEvent );
5859 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5861 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5862 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5863 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5865 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5866 ResetTouchCallbacks();
5868 orderChangedSignal = false;
5870 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5872 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5874 // Sort actor tree before next touch event
5875 application.SendNotification();
5876 application.Render();
5878 application.ProcessEvent( touchEvent );
5880 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5882 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5883 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5884 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5885 ResetTouchCallbacks();
5887 orderChangedSignal = false;
5889 tet_printf( "Lower actor C below B but C not parented\n" );
5891 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5893 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5895 // Sort actor tree before next touch event
5896 application.SendNotification();
5897 application.Render();
5899 application.ProcessEvent( touchEvent );
5901 tet_printf( "Not parented so Lower should show no effect\n" );
5903 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5904 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5905 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5906 ResetTouchCallbacks();
5908 orderChangedSignal = false;
5910 tet_printf( "Raise actor B to top\n" );
5912 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5913 actorB.RaiseToTop();
5914 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5916 // Sort actor tree before next touch event
5917 application.SendNotification();
5918 application.Render();
5920 application.ProcessEvent( touchEvent );
5922 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5924 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5925 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5926 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5927 ResetTouchCallbacks();
5929 orderChangedSignal = false;
5931 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5933 stage.Add ( actorB );
5935 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5937 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5938 actorC.LowerToBottom();
5939 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5941 application.SendNotification();
5942 application.Render();
5944 application.ProcessEvent( touchEvent );
5946 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5948 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5949 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5950 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5951 ResetTouchCallbacks();
5957 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5959 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5961 TestApplication application;
5963 Integration::Scene stage( application.GetScene() );
5965 Actor actorA = Actor::New();
5966 Actor actorB = Actor::New();
5967 Actor actorC = Actor::New();
5969 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5970 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5972 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5973 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5975 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5976 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5978 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5979 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5981 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5982 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5984 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5985 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5987 stage.Add( actorA );
5988 stage.Add( actorB );
5989 stage.Add( actorC );
5991 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5992 // Only top actor will get touched.
5993 actorA.TouchSignal().Connect( TestTouchCallback );
5994 actorB.TouchSignal().Connect( TestTouchCallback2 );
5995 actorC.TouchSignal().Connect( TestTouchCallback3 );
5997 ResetTouchCallbacks();
5999 // Connect ChildOrderChangedSignal
6000 bool orderChangedSignal( false );
6001 Actor orderChangedActor;
6002 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
6003 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
6005 application.SendNotification();
6006 application.Render();
6008 Dali::Integration::Point point;
6009 point.SetDeviceId( 1 );
6010 point.SetState( PointState::DOWN );
6011 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
6012 Dali::Integration::TouchEvent touchEvent;
6013 touchEvent.AddPoint( point );
6015 application.ProcessEvent( touchEvent );
6017 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
6018 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6019 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
6021 ResetTouchCallbacks();
6023 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
6025 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6026 actorA.RaiseAbove( actorA );
6027 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6028 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6030 application.SendNotification();
6031 application.Render();
6033 application.ProcessEvent( touchEvent );
6035 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
6037 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
6038 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6039 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
6041 ResetTouchCallbacks();
6043 orderChangedSignal = false;
6045 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6046 actorA.RaiseAbove( actorC );
6047 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6048 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6050 application.SendNotification();
6051 application.Render();
6053 application.ProcessEvent( touchEvent );
6055 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
6056 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
6057 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6058 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
6063 int UtcDaliActorGetScreenPosition(void)
6065 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
6067 TestApplication application;
6069 Integration::Scene stage( application.GetScene() );
6071 Actor actorA = Actor::New();
6072 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6074 Vector2 size2( 10.0f, 20.0f );
6075 actorA.SetProperty( Actor::Property::SIZE, size2 );
6077 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6079 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6081 stage.Add( actorA );
6083 application.SendNotification();
6084 application.Render();
6086 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6087 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6089 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6090 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6092 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6093 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6095 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6097 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6099 application.SendNotification();
6100 application.Render();
6102 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6103 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6105 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6106 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6108 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6109 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6111 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6113 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6115 application.SendNotification();
6116 application.Render();
6118 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6119 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6121 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6122 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6124 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6125 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6127 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6129 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 0.0 ));
6131 application.SendNotification();
6132 application.Render();
6134 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6135 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6137 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6138 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6140 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6141 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6143 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6145 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 420.0 ));
6147 application.SendNotification();
6148 application.Render();
6150 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6151 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6153 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6154 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6156 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6157 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6159 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6161 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6162 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 30.0 ));
6164 Actor actorB = Actor::New();
6165 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6166 actorB.SetProperty( Actor::Property::SIZE, size2 );
6167 actorB.SetProperty( Actor::Property::POSITION, Vector2( 10.f, 10.f ));
6168 actorA.Add( actorB );
6170 actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6172 application.SendNotification();
6173 application.Render();
6175 actorScreenPosition = actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6177 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6178 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6183 int UtcDaliActorGetScreenPositionAfterScaling(void)
6185 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6187 TestApplication application;
6189 Integration::Scene stage( application.GetScene() );
6191 Actor actorA = Actor::New();
6192 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6194 Vector2 size2( 10.0f, 20.0f );
6195 actorA.SetProperty( Actor::Property::SIZE, size2 );
6196 actorA.SetProperty( Actor::Property::SCALE, 1.5f );
6197 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6199 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6201 stage.Add( actorA );
6203 application.SendNotification();
6204 application.Render();
6206 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6207 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6209 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6210 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6212 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6213 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6215 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6217 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6219 application.SendNotification();
6220 application.Render();
6222 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6223 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6225 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6226 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6228 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6229 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6234 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6236 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6238 TestApplication application;
6240 Integration::Scene stage( application.GetScene() );
6242 Actor actorA = Actor::New();
6243 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6244 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6245 Vector2 size2( 10.0f, 20.0f );
6246 actorA.SetProperty( Actor::Property::SIZE, size2 );
6247 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6249 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6251 stage.Add( actorA );
6253 application.SendNotification();
6254 application.Render();
6256 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6257 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6259 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6260 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6262 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6263 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6265 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6267 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
6268 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6270 application.SendNotification();
6271 application.Render();
6273 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6274 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6276 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6277 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6279 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6280 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6286 int UtcDaliActorGetScreenPositionWithChildActors(void)
6288 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6290 TestApplication application;
6292 Integration::Scene stage( application.GetScene() );
6294 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6296 Actor actorA = Actor::New();
6297 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6298 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6299 Vector2 size1( 10.0f, 20.0f );
6300 actorA.SetProperty( Actor::Property::SIZE, size1 );
6301 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6303 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6305 Actor parentActorA = Actor::New();
6306 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6307 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6308 Vector2 size2( 30.0f, 60.0f );
6309 parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6310 parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6312 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6314 stage.Add( parentActorA );
6315 parentActorA.Add ( actorA );
6317 application.SendNotification();
6318 application.Render();
6320 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6321 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6323 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6324 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6326 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6327 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6329 tet_infoline( "Test 2\n");
6331 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6333 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6334 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
6336 application.SendNotification();
6337 application.Render();
6339 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6340 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6342 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6343 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6345 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6346 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6351 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6353 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6355 TestApplication application;
6357 Integration::Scene stage( application.GetScene() );
6359 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6361 Actor actorA = Actor::New();
6362 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6363 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6364 Vector2 size1( 10.0f, 20.0f );
6365 actorA.SetProperty( Actor::Property::SIZE, size1 );
6366 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6368 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6370 Actor parentActorA = Actor::New();
6371 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6372 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6373 Vector2 size2( 30.0f, 60.0f );
6374 parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6375 parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6377 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6379 Actor grandParentActorA = Actor::New();
6380 grandParentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6381 grandParentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
6382 Vector2 size3( 60.0f, 120.0f );
6383 grandParentActorA.SetProperty( Actor::Property::SIZE, size3 );
6384 grandParentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6386 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6388 stage.Add( grandParentActorA );
6389 grandParentActorA.Add ( parentActorA );
6391 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6393 parentActorA.Add ( actorA );
6395 application.SendNotification();
6396 application.Render();
6398 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6399 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6401 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6402 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6404 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6405 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6410 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6412 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6414 TestApplication application;
6416 Integration::Scene stage( application.GetScene() );
6418 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6420 Actor actorA = Actor::New();
6421 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6422 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6423 actorA.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6424 actorA.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 20.0f ) );
6425 stage.Add( actorA );
6427 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6429 Actor actorB = Actor::New();
6430 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6431 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6432 actorB.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6433 Vector2 actorBSize( 30.0f, 60.0f );
6434 actorB.SetProperty( Actor::Property::SIZE, actorBSize );
6435 stage.Add( actorB );
6437 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6439 Actor actorC = Actor::New();
6440 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6441 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6442 actorC.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6443 Vector2 actorCSize( 60.0f, 120.0f );
6444 actorC.SetProperty( Actor::Property::SIZE, actorCSize );
6445 stage.Add( actorC );
6447 application.SendNotification();
6448 application.Render();
6450 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6452 Vector2 center( stage.GetSize() * 0.5f );
6454 DALI_TEST_EQUALS( actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6455 DALI_TEST_EQUALS( actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6456 DALI_TEST_EQUALS( actorC.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6458 tet_infoline( "Add scale to all actors" );
6460 actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6461 actorB.SetProperty( Actor::Property::SCALE, 2.0f );
6462 actorC.SetProperty( Actor::Property::SCALE, 2.0f );
6464 application.SendNotification();
6465 application.Render();
6467 DALI_TEST_EQUALS( actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6468 DALI_TEST_EQUALS( actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6469 DALI_TEST_EQUALS( actorC.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6474 int utcDaliActorPositionUsesAnchorPoint(void)
6476 TestApplication application;
6477 tet_infoline( "Check default behaviour\n" );
6479 Actor actor = Actor::New();
6480 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6481 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6482 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6483 application.GetScene().Add( actor );
6485 application.SendNotification();
6486 application.Render();
6488 tet_infoline( "Check that the world position is in the center\n" );
6489 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6491 tet_infoline( "Set the position uses anchor point property to false\n" );
6492 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6494 application.SendNotification();
6495 application.Render();
6497 tet_infoline( "Check that the world position has changed appropriately\n" );
6498 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6503 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6505 TestApplication application;
6506 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6508 Actor actor = Actor::New();
6509 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6510 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6511 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6512 actor.SetProperty( Actor::Property::SCALE, 2.0f );
6513 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6514 application.GetScene().Add( actor );
6516 application.SendNotification();
6517 application.Render();
6519 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6520 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6522 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6523 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6524 application.SendNotification();
6525 application.Render();
6526 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6528 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6529 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6530 application.SendNotification();
6531 application.Render();
6532 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6537 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6539 TestApplication application;
6540 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6542 Actor actor = Actor::New();
6543 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6544 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6545 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6546 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6547 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6548 application.GetScene().Add( actor );
6550 application.SendNotification();
6551 application.Render();
6553 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
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 TOP_LEFT and ensure the world position changes accordingly" );
6557 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6558 application.SendNotification();
6559 application.Render();
6560 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6562 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6563 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6564 application.SendNotification();
6565 application.Render();
6566 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6571 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6573 TestApplication application;
6574 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6576 Actor actor = Actor::New();
6577 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6578 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6579 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6580 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6581 actor.SetProperty( Actor::Property::SCALE, 2.0f );
6582 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6583 application.GetScene().Add( actor );
6585 application.SendNotification();
6586 application.Render();
6588 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6589 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6591 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6592 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6593 application.SendNotification();
6594 application.Render();
6595 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6597 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6598 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6599 application.SendNotification();
6600 application.Render();
6601 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6606 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6608 TestApplication application;
6609 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6611 Actor parent = Actor::New();
6613 application.GetScene().Add( parent );
6614 Vector2 stageSize( application.GetScene().GetSize() );
6616 Actor actor = Actor::New();
6617 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6618 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6619 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6620 actor.SetProperty( Actor::Property::INHERIT_SCALE, false );
6621 actor.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
6622 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6623 parent.Add( actor );
6625 application.SendNotification();
6626 application.Render();
6628 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6630 tet_infoline( "Check the world position is in the right place\n" );
6631 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6633 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6634 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6635 application.SendNotification();
6636 application.Render();
6637 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6639 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6640 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6641 application.SendNotification();
6642 application.Render();
6643 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6648 int utcDaliActorVisibilityChangeSignalSelf(void)
6650 TestApplication application;
6651 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6653 Actor actor = Actor::New();
6655 VisibilityChangedFunctorData data;
6656 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6658 actor.SetProperty( Actor::Property::VISIBLE, false );
6660 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6662 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6665 actor.SetProperty( Actor::Property::VISIBLE, false );
6666 data.Check( false /* not called */, TEST_LOCATION );
6668 tet_infoline( "Change the visibility using properties, ensure called" );
6671 actor.SetProperty( Actor::Property::VISIBLE, true );
6672 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6674 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6677 actor.SetProperty( Actor::Property::VISIBLE, true );
6678 data.Check( false /* not called */, TEST_LOCATION );
6683 int utcDaliActorVisibilityChangeSignalChildren(void)
6685 TestApplication application;
6686 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6688 Actor parent = Actor::New();
6689 Actor child = Actor::New();
6690 parent.Add( child );
6692 Actor grandChild = Actor::New();
6693 child.Add( grandChild );
6695 VisibilityChangedFunctorData parentData;
6696 VisibilityChangedFunctorData childData;
6697 VisibilityChangedFunctorData grandChildData;
6699 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6700 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6701 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6703 parent.SetProperty( Actor::Property::VISIBLE, false );
6704 parentData.Check( false /* not called */, TEST_LOCATION );
6705 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6706 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6708 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6711 grandChildData.Reset();
6713 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6715 parent.SetProperty( Actor::Property::VISIBLE, true );
6716 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6717 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6718 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6720 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6723 grandChildData.Reset();
6725 parent.SetProperty( Actor::Property::VISIBLE, true );
6726 parentData.Check( false /* not called */, TEST_LOCATION );
6727 childData.Check( false /* not called */, TEST_LOCATION );
6728 grandChildData.Check( false /* not called */, TEST_LOCATION );
6733 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6735 TestApplication application;
6736 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6738 Actor actor = Actor::New();
6739 application.GetScene().Add( actor );
6741 application.SendNotification();
6742 application.Render();
6744 VisibilityChangedFunctorData data;
6745 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6747 Animation animation = Animation::New( 1.0f );
6748 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6750 data.Check( false, TEST_LOCATION );
6751 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6752 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6754 tet_infoline( "Play the animation and check the property value" );
6757 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6758 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6760 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6761 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6763 application.SendNotification();
6764 application.Render( 1100 ); // After the animation
6766 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6772 int utcDaliActorVisibilityChangeSignalByName(void)
6774 TestApplication application;
6775 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6777 Actor actor = Actor::New();
6779 bool signalCalled=false;
6780 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6781 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6782 actor.SetProperty( Actor::Property::VISIBLE, false );
6783 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6785 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6786 signalCalled = false;
6787 actor.SetProperty( Actor::Property::VISIBLE, false );
6788 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6790 tet_infoline( "Change the visibility using properties, ensure called" );
6791 actor.SetProperty( Actor::Property::VISIBLE, true );
6792 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6794 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6795 signalCalled = false;
6797 actor.SetProperty( Actor::Property::VISIBLE, true );
6798 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6804 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6806 gLayoutDirectionType = type;
6809 int UtcDaliActorLayoutDirectionProperty(void)
6811 TestApplication application;
6812 tet_infoline( "Check layout direction property" );
6814 Actor actor0 = Actor::New();
6815 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6816 application.GetScene().Add( actor0 );
6818 application.SendNotification();
6819 application.Render();
6821 Actor actor1 = Actor::New();
6822 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6823 Actor actor2 = Actor::New();
6824 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6825 Actor actor3 = Actor::New();
6826 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6827 Actor actor4 = Actor::New();
6828 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6829 Actor actor5 = Actor::New();
6830 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6831 Actor actor6 = Actor::New();
6832 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6833 Actor actor7 = Actor::New();
6834 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6835 Actor actor8 = Actor::New();
6836 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6837 Actor actor9 = Actor::New();
6838 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6840 actor1.Add( actor2 );
6841 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6842 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6844 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6845 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6846 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6848 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6849 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6850 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6852 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6853 actor0.Add( actor1 );
6854 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6855 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6857 application.GetScene().Add( actor3 );
6858 actor3.Add( actor4 );
6859 actor4.Add( actor5 );
6860 actor5.Add( actor6 );
6861 actor5.Add( actor7 );
6862 actor7.Add( actor8 );
6863 actor8.Add( actor9 );
6864 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6865 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6867 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6868 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6869 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6871 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6873 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6874 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6875 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6876 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6877 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6878 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6879 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6881 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6882 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6883 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6885 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6886 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6887 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6888 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6890 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6891 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6892 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6898 struct LayoutDirectionFunctor
6900 LayoutDirectionFunctor(bool& signalCalled)
6901 : mSignalCalled( signalCalled )
6905 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6906 : mSignalCalled( rhs.mSignalCalled )
6912 mSignalCalled = true;
6915 bool& mSignalCalled;
6918 int UtcDaliActorLayoutDirectionSignal(void)
6920 TestApplication application;
6921 tet_infoline( "Check changing layout direction property sends a signal" );
6923 Actor actor = Actor::New();
6924 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6925 application.GetScene().Add( actor );
6926 bool signalCalled = false;
6927 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6929 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6930 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6932 // Test that writing the same value doesn't send a signal
6933 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6934 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6936 // Test that writing a different value sends the signal
6937 signalCalled = false;
6938 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6939 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6941 signalCalled = false;
6942 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6943 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6948 struct ChildAddedSignalCheck
6950 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6951 : mSignalReceived( signalReceived ),
6952 mChildHandle( childHandle )
6956 void operator() ( Actor childHandle )
6958 mSignalReceived = true;
6959 mChildHandle = childHandle;
6963 mSignalReceived = true;
6964 mChildHandle = Actor();
6967 bool& mSignalReceived;
6968 Actor& mChildHandle;
6971 int UtcDaliChildAddedSignalP1(void)
6973 TestApplication application;
6974 auto stage = application.GetScene();
6976 bool signalReceived=false;
6979 ChildAddedSignalCheck signal( signalReceived, childActor );
6980 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6981 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6983 auto actorA = Actor::New();
6984 stage.Add( actorA );
6985 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6986 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6987 signalReceived = false;
6989 auto actorB = Actor::New();
6990 stage.Add( actorB );
6991 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6992 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6998 int UtcDaliChildAddedSignalP2(void)
7000 TestApplication application;
7001 auto stage = application.GetScene();
7003 bool signalReceived=false;
7006 ChildAddedSignalCheck signal( signalReceived, childActor );
7007 tet_infoline( "Connect to childAdded signal by name" );
7009 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
7010 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7012 auto actorA = Actor::New();
7013 stage.Add( actorA );
7014 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7016 // Can't test which actor was added; signal signature is void() when connecting via name.
7017 signalReceived = false;
7019 auto actorB = Actor::New();
7020 stage.Add( actorB );
7021 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7026 int UtcDaliChildAddedSignalN(void)
7028 TestApplication application;
7029 auto stage = application.GetScene();
7031 bool signalReceived=false;
7034 ChildAddedSignalCheck signal( signalReceived, childActor );
7035 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7036 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7038 auto actorA = Actor::New();
7039 stage.Add( actorA );
7040 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7041 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7042 signalReceived = false;
7044 auto actorB = Actor::New();
7045 actorA.Add( actorB );
7046 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7051 struct ChildRemovedSignalCheck
7053 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
7054 : mSignalReceived( signalReceived ),
7055 mChildHandle( childHandle )
7059 void operator() ( Actor childHandle )
7061 mSignalReceived = true;
7062 mChildHandle = childHandle;
7067 mSignalReceived = true;
7070 bool& mSignalReceived;
7071 Actor& mChildHandle;
7074 int UtcDaliChildRemovedSignalP1(void)
7076 TestApplication application;
7077 auto stage = application.GetScene();
7079 bool signalReceived=false;
7082 ChildRemovedSignalCheck signal( signalReceived, childActor );
7083 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7084 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7086 auto actorA = Actor::New();
7087 stage.Add( actorA );
7088 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7089 DALI_TEST_CHECK( !childActor );
7091 stage.Remove( actorA );
7092 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7093 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7095 signalReceived = false;
7096 auto actorB = Actor::New();
7097 stage.Add( actorB );
7098 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7100 stage.Remove( actorB );
7101 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7102 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7107 int UtcDaliChildRemovedSignalP2(void)
7109 TestApplication application;
7110 auto stage = application.GetScene();
7112 bool signalReceived=false;
7115 ChildAddedSignalCheck signal( signalReceived, childActor );
7116 tet_infoline( "Connect to childRemoved signal by name" );
7118 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", signal );
7119 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7121 auto actorA = Actor::New();
7122 stage.Add( actorA );
7123 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7125 stage.Remove( actorA );
7126 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7128 signalReceived = false;
7129 auto actorB = Actor::New();
7130 stage.Add( actorB );
7131 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7133 stage.Remove( actorB );
7134 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7140 int UtcDaliChildRemovedSignalN(void)
7142 TestApplication application;
7143 auto stage = application.GetScene();
7145 bool signalReceived=false;
7148 ChildRemovedSignalCheck signal( signalReceived, childActor );
7149 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7150 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7152 auto actorA = Actor::New();
7153 stage.Add( actorA );
7155 auto actorB = Actor::New();
7156 actorA.Add( actorB );
7158 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7159 DALI_TEST_CHECK( ! childActor );
7161 actorA.Remove( actorB );
7162 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7167 int UtcDaliChildMovedSignalP(void)
7169 TestApplication application;
7170 auto stage = application.GetScene();
7172 bool addedASignalReceived = false;
7173 bool removedASignalReceived = false;
7174 bool addedBSignalReceived = false;
7175 bool removedBSignalReceived = false;
7178 auto actorA = Actor::New();
7179 auto actorB = Actor::New();
7180 stage.Add( actorA );
7181 stage.Add( actorB );
7183 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7184 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7185 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7186 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7188 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7189 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7190 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7191 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7193 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7194 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7195 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7196 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7198 // Create a child of A
7200 auto child = Actor::New();
7201 actorA.Add( child );
7203 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7204 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7205 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7206 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7207 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7210 addedASignalReceived = false;
7211 addedBSignalReceived = false;
7212 removedASignalReceived = false;
7213 removedBSignalReceived = false;
7215 actorB.Add( child ); // Expect this child to be re-parented
7216 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7217 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7218 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7219 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7221 // Move child back to A:
7222 addedASignalReceived = false;
7223 addedBSignalReceived = false;
7224 removedASignalReceived = false;
7225 removedBSignalReceived = false;
7227 actorA.Add( child ); // Expect this child to be re-parented
7228 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7229 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7230 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7231 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7237 int utcDaliActorCulled(void)
7239 TestApplication application;
7240 auto stage = application.GetScene();
7242 tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7244 Actor actor = Actor::New();
7245 actor.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 10.0f ) );
7247 Geometry geometry = CreateQuadGeometry();
7248 Shader shader = CreateShader();
7249 Renderer renderer = Renderer::New(geometry, shader);
7250 actor.AddRenderer( renderer );
7254 application.SendNotification();
7255 application.Render( 0 );
7257 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::CULLED ), false, TEST_LOCATION );
7259 PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::CULLED, LessThanCondition( 0.5f ) );
7260 notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7262 // Connect NotifySignal
7263 bool propertyNotificationSignal( false );
7264 PropertyNotification source;
7265 CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7266 notification.NotifySignal().Connect( &application, f ) ;
7268 actor.SetProperty( Actor::Property::POSITION, Vector2( 1000.0f, 1000.0f ));
7270 application.SendNotification();
7271 application.Render();
7273 application.SendNotification();
7275 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::CULLED ), true, TEST_LOCATION );
7277 DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7278 DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( Actor::Property::CULLED ), TEST_LOCATION );
7279 DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7284 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7286 TestApplication application;
7287 auto stage = application.GetScene();
7289 tet_infoline( "Ensure we clear the screen when the last actor is removed" );
7291 Actor actor = CreateRenderableActor();
7292 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7295 application.SendNotification();
7296 application.Render();
7298 auto& glAbstraction = application.GetGlAbstraction();
7299 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7303 application.SendNotification();
7304 application.Render();
7306 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7311 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7313 TestApplication application;
7314 auto stage = application.GetScene();
7316 tet_infoline( "Ensure we clear the screen when the last actor is made invisible" );
7318 Actor actor = CreateRenderableActor();
7319 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7322 application.SendNotification();
7323 application.Render();
7325 auto& glAbstraction = application.GetGlAbstraction();
7326 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7328 actor.SetProperty( Actor::Property::VISIBLE, false );
7330 application.SendNotification();
7331 application.Render();
7333 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7338 int utcDaliActorGetSizeAfterAnimation(void)
7340 TestApplication application;
7341 tet_infoline( "Check the actor size before / after an animation is finished" );
7343 Vector3 actorSize( 100.0f, 100.0f, 0.0f );
7345 Actor actor = Actor::New();
7346 actor.SetProperty( Actor::Property::SIZE, actorSize );
7347 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
7348 application.GetScene().Add( actor );
7350 // Size should be updated without rendering.
7351 Vector3 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7352 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7354 application.SendNotification();
7355 application.Render();
7357 // Size and current size should be updated.
7358 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7359 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7360 DALI_TEST_EQUALS( actorSize.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7361 DALI_TEST_EQUALS( actorSize.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7362 DALI_TEST_EQUALS( actorSize.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7364 Vector3 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7365 DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7366 DALI_TEST_EQUALS( actorSize.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7367 DALI_TEST_EQUALS( actorSize.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7368 DALI_TEST_EQUALS( actorSize.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7371 actorSize = Vector3( 200.0f, 200.0f, 0.0f );
7372 actor.SetProperty( Actor::Property::SIZE, actorSize );
7374 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7375 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7377 Vector3 targetValue( 10.0f, 20.0f, 0.0f );
7379 Animation animation = Animation::New( 1.0f );
7380 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
7383 // Size should be updated without rendering.
7384 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7385 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7387 application.SendNotification();
7388 application.Render( 1100 ); // After the animation
7390 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7391 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7392 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7393 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7394 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7396 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7397 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7398 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7399 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7400 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7402 targetValue.width = 50.0f;
7405 animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetValue.width );
7408 application.SendNotification();
7409 application.Render( 1100 ); // After the animation
7411 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7412 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7413 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7414 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7415 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7417 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7418 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7419 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7420 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7421 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7423 targetValue.height = 70.0f;
7426 animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetValue.height );
7429 application.SendNotification();
7430 application.Render( 1100 ); // After the animation
7432 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7433 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7434 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7435 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7436 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7438 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7439 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7440 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7441 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7442 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7444 Vector3 offset( 10.0f, 20.0f, 0.0f );
7447 animation.AnimateBy( Property( actor, Actor::Property::SIZE ), offset );
7450 application.SendNotification();
7451 application.Render( 1100 ); // After the animation
7453 targetValue += offset;
7455 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7456 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7457 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7458 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7459 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7461 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7462 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7463 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7464 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7465 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7467 offset.width = 20.0f;
7470 animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), offset.width );
7473 application.SendNotification();
7474 application.Render( 1100 ); // After the animation
7476 targetValue.width += offset.width;
7478 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7479 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7480 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7481 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7482 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7484 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7485 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7486 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7487 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7488 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7490 offset.height = 10.0f;
7493 animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), offset.height );
7496 application.SendNotification();
7497 application.Render( 1100 ); // After the animation
7499 targetValue.height += offset.height;
7501 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7502 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7503 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7504 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7505 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7507 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7508 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7509 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7510 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7511 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7514 actorSize = Vector3( 300.0f, 300.0f, 0.0f );
7516 actor.SetProperty( Actor::Property::SIZE, actorSize );
7518 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7519 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7521 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7522 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7524 application.SendNotification();
7525 application.Render();
7527 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7528 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7530 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7531 DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7536 int utcDaliActorPartialUpdate(void)
7538 TestApplication application(
7539 TestApplication::DEFAULT_SURFACE_WIDTH,
7540 TestApplication::DEFAULT_SURFACE_HEIGHT,
7541 TestApplication::DEFAULT_HORIZONTAL_DPI,
7542 TestApplication::DEFAULT_VERTICAL_DPI,
7546 tet_infoline("Check the damaged area");
7548 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7550 std::vector<Rect<int>> damagedRects;
7551 Rect<int> clippingRect;
7552 application.SendNotification();
7553 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7555 // First render pass, nothing to render, adaptor would just do swap buffer.
7556 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7557 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7559 Actor actor = CreateRenderableActor();
7560 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7561 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7562 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7563 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7564 application.GetScene().Add(actor);
7566 application.SendNotification();
7568 // 1. Actor added, damaged rect is added size of actor
7569 damagedRects.clear();
7570 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7571 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7574 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7575 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7576 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7577 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7578 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7579 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7580 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7583 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7584 application.SendNotification();
7586 damagedRects.clear();
7587 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7588 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7591 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7592 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7593 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7594 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7595 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7596 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7597 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7599 // 3. Set new position
7600 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7601 application.SendNotification();
7603 damagedRects.clear();
7604 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7605 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7608 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7609 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7610 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7611 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7612 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7613 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7614 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7616 application.GetScene().Remove(actor);
7617 application.SendNotification();
7619 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7620 damagedRects.clear();
7621 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7622 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7624 clippingRect = damagedRects[0];
7625 clippingRect.Merge(damagedRects[1]);
7626 clippingRect.Merge(damagedRects[2]);
7628 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7629 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7630 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7632 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7633 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7634 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7635 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7636 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7641 int utcDaliActorPartialUpdateSetColor(void)
7643 TestApplication application(
7644 TestApplication::DEFAULT_SURFACE_WIDTH,
7645 TestApplication::DEFAULT_SURFACE_HEIGHT,
7646 TestApplication::DEFAULT_HORIZONTAL_DPI,
7647 TestApplication::DEFAULT_VERTICAL_DPI,
7651 tet_infoline("Check uniform update");
7653 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7655 std::vector<Rect<int>> damagedRects;
7656 Rect<int> clippingRect;
7657 application.SendNotification();
7658 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7660 // First render pass, nothing to render, adaptor would just do swap buffer.
7661 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7662 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7664 Actor actor = CreateRenderableActor();
7665 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7666 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7667 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7668 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7669 application.GetScene().Add(actor);
7671 application.SendNotification();
7673 // 1. Actor added, damaged rect is added size of actor
7674 damagedRects.clear();
7675 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7676 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7679 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7680 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7681 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7682 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7683 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7684 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7685 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7687 damagedRects.clear();
7688 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7690 damagedRects.clear();
7691 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7694 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
7695 application.SendNotification();
7697 damagedRects.clear();
7698 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7699 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7702 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7703 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7704 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7705 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7706 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7707 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7708 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7713 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
7714 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
7715 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
7716 const char* const RENDER_SHADOW_VERTEX_SOURCE =
7717 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
7718 " uniform mediump mat4 uLightCameraViewMatrix;\n"
7722 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
7723 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
7724 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
7727 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
7728 "uniform lowp vec4 uShadowColor;\n"
7731 " lowp float alpha;\n"
7732 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
7733 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
7736 int utcDaliActorPartialUpdateSetProperty(void)
7738 TestApplication application(
7739 TestApplication::DEFAULT_SURFACE_WIDTH,
7740 TestApplication::DEFAULT_SURFACE_HEIGHT,
7741 TestApplication::DEFAULT_HORIZONTAL_DPI,
7742 TestApplication::DEFAULT_VERTICAL_DPI,
7746 tet_infoline( "Set/Update property with partial update" );
7748 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7750 std::vector<Rect<int>> damagedRects;
7751 Rect<int> clippingRect;
7752 application.SendNotification();
7753 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7755 // First render pass, nothing to render, adaptor would just do swap buffer.
7756 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7757 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7759 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
7760 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
7761 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7762 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7763 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7764 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7765 application.GetScene().Add(actor);
7767 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
7769 damagedRects.clear();
7770 application.SendNotification();
7771 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7772 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7775 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7776 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7777 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7778 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7779 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7780 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7781 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7783 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex( SHADER_SHADOW_COLOR_PROPERTY_NAME );
7784 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
7786 damagedRects.clear();
7787 application.SendNotification();
7788 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7789 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7791 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7792 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7793 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7794 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7795 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7796 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7798 damagedRects.clear();
7799 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7800 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7802 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7803 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7804 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7805 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7806 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7807 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7809 damagedRects.clear();
7810 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7811 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7816 int utcDaliActorPartialUpdateTwoActors(void)
7818 TestApplication application(
7819 TestApplication::DEFAULT_SURFACE_WIDTH,
7820 TestApplication::DEFAULT_SURFACE_HEIGHT,
7821 TestApplication::DEFAULT_HORIZONTAL_DPI,
7822 TestApplication::DEFAULT_VERTICAL_DPI,
7826 tet_infoline("Check the damaged rects with partial update and two actors");
7828 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7830 Actor actor = CreateRenderableActor();
7831 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
7832 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
7833 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7834 application.GetScene().Add(actor);
7836 Actor actor2 = CreateRenderableActor();
7837 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
7838 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
7839 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7840 application.GetScene().Add(actor2);
7842 application.SendNotification();
7843 std::vector<Rect<int>> damagedRects;
7844 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7846 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
7847 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
7848 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
7850 // in screen coordinates, adaptor would calculate it using previous frames information
7851 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
7852 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7854 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7855 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7856 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7857 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7862 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
7864 TestApplication application(
7865 TestApplication::DEFAULT_SURFACE_WIDTH,
7866 TestApplication::DEFAULT_SURFACE_HEIGHT,
7867 TestApplication::DEFAULT_HORIZONTAL_DPI,
7868 TestApplication::DEFAULT_VERTICAL_DPI,
7872 tet_infoline( "Check the damaged rect with partial update and actor size hint" );
7874 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7876 Actor actor = CreateRenderableActor();
7877 actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f));
7878 actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f));
7879 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0));
7880 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7881 application.GetScene().Add(actor);
7883 application.SendNotification();
7884 std::vector<Rect<int>> damagedRects;
7885 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7887 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7889 Rect<int> clippingRect = Rect<int>(0, 496, 160, 320);
7890 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7892 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7894 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7895 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7896 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7897 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7902 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
7904 TestApplication application;
7906 Actor actor = Actor::New();
7907 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
7908 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
7909 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
7910 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
7911 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
7912 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7913 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7914 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
7918 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
7920 TestApplication application;
7922 Actor actor = Actor::New();
7924 // Make sure setting invalid types does not cause a crash
7927 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
7928 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
7929 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
7930 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
7931 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
7932 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
7933 tet_result(TET_PASS);
7937 tet_result(TET_FAIL);