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 > gActorNamesOnOffStage;
135 static int gOnStageCallBackCalled;
136 void OnStageCallback( Actor actor )
138 ++gOnStageCallBackCalled;
139 gActorNamesOnOffStage.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
140 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) == true );
142 static int gOffStageCallBackCalled;
143 void OffStageCallback( Actor actor )
145 ++gOffStageCallBackCalled;
146 gActorNamesOnOffStage.push_back( actor.GetProperty< std::string >( Actor::Property::NAME ) );
147 DALI_TEST_CHECK( actor.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 //& purpose: Testing Dali::Actor::GetName()
327 int UtcDaliActorGetName(void)
329 TestApplication application;
331 Actor actor = Actor::New();
333 DALI_TEST_CHECK(actor.GetProperty< std::string >( Actor::Property::NAME ).empty());
337 //& purpose: Testing Dali::Actor::SetName()
338 int UtcDaliActorSetName(void)
340 TestApplication application;
342 string str("ActorName");
343 Actor actor = Actor::New();
345 actor.SetProperty( Actor::Property::NAME,str);
346 DALI_TEST_CHECK(actor.GetProperty< std::string >( Actor::Property::NAME ) == str);
350 int UtcDaliActorGetId(void)
352 tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
353 TestApplication application;
355 Actor first = Actor::New();
356 Actor second = Actor::New();
357 Actor third = Actor::New();
359 DALI_TEST_CHECK(first.GetProperty< int >( Actor::Property::ID ) != second.GetProperty< int >( Actor::Property::ID ));
360 DALI_TEST_CHECK(second.GetProperty< int >( Actor::Property::ID ) != third.GetProperty< int >( Actor::Property::ID ));
364 int UtcDaliActorIsRoot(void)
366 TestApplication application;
368 Actor actor = Actor::New();
369 DALI_TEST_CHECK(!actor.GetProperty< bool >( Actor::Property::IS_ROOT ));
371 // get the root layer
372 actor = application.GetScene().GetLayer( 0 );
373 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::IS_ROOT ) );
377 int UtcDaliActorOnStage(void)
379 TestApplication application;
381 Actor actor = Actor::New();
382 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
384 // get the root layer
385 actor = application.GetScene().GetLayer( 0 );
386 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) );
390 int UtcDaliActorIsLayer(void)
392 TestApplication application;
394 Actor actor = Actor::New();
395 DALI_TEST_CHECK( !actor.GetProperty< bool >( Actor::Property::IS_LAYER ) );
397 // get the root layer
398 actor = application.GetScene().GetLayer( 0 );
399 DALI_TEST_CHECK( actor.GetProperty< bool >( Actor::Property::IS_LAYER ) );
403 int UtcDaliActorGetLayer(void)
405 TestApplication application;
407 Actor actor = Actor::New();
408 application.GetScene().Add(actor);
409 Layer layer = actor.GetLayer();
411 DALI_TEST_CHECK(layer);
413 // get the root layers layer
414 actor = application.GetScene().GetLayer( 0 );
415 DALI_TEST_CHECK( actor.GetLayer() );
419 int UtcDaliActorAddP(void)
421 tet_infoline("Testing Actor::Add");
422 TestApplication application;
424 Actor parent = Actor::New();
425 Actor child = Actor::New();
427 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
431 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
433 Actor parent2 = Actor::New();
434 parent2.Add( child );
436 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
437 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
439 // try Adding to same parent again, works
440 parent2.Add( child );
441 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
443 // try reparenting an orphaned child
445 Actor temporaryParent = Actor::New();
446 temporaryParent.Add( child );
447 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
449 // temporaryParent has now died, reparent the orphaned child
450 parent2.Add( child );
451 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
456 int UtcDaliActorAddN(void)
458 tet_infoline("Testing Actor::Add");
459 TestApplication application;
461 Actor child = Actor::New();
463 Actor parent2 = Actor::New();
464 parent2.Add( child );
469 parent2.Add( parent2 );
470 tet_printf("Assertion test failed - no Exception\n" );
471 tet_result(TET_FAIL);
473 catch(Dali::DaliException& e)
475 DALI_TEST_PRINT_ASSERT( e );
476 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
477 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
481 tet_printf("Assertion test failed - wrong Exception\n" );
482 tet_result(TET_FAIL);
485 // try reparenting root
488 parent2.Add( application.GetScene().GetLayer( 0 ) );
489 tet_printf("Assertion test failed - no Exception\n" );
490 tet_result(TET_FAIL);
492 catch(Dali::DaliException& e)
494 DALI_TEST_PRINT_ASSERT( e );
495 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
496 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
500 tet_printf("Assertion test failed - wrong Exception\n" );
501 tet_result(TET_FAIL);
508 parent2.Add( empty );
509 tet_printf("Assertion test failed - no Exception\n" );
510 tet_result(TET_FAIL);
512 catch(Dali::DaliException& e)
514 DALI_TEST_PRINT_ASSERT( e );
515 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
516 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
520 tet_printf("Assertion test failed - wrong Exception\n" );
521 tet_result(TET_FAIL);
527 int UtcDaliActorRemoveN(void)
529 tet_infoline("Testing Actor::Remove");
530 TestApplication application;
532 Actor parent = Actor::New();
533 Actor child = Actor::New();
534 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
537 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
539 parent.Remove(child);
540 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
542 // remove again, no problem
543 parent.Remove(child);
544 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
548 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
549 // try Remove self, its a no-op
550 parent.Remove( parent );
551 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
557 parent.Remove( empty );
558 tet_printf("Assertion test failed - no Exception\n" );
559 tet_result(TET_FAIL);
561 catch(Dali::DaliException& e)
563 DALI_TEST_PRINT_ASSERT( e );
564 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
565 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
569 tet_printf("Assertion test failed - wrong Exception\n" );
570 tet_result(TET_FAIL);
575 int UtcDaliActorRemoveP(void)
577 TestApplication application;
579 Actor parent = Actor::New();
580 Actor child = Actor::New();
581 Actor random = Actor::New();
583 application.GetScene().Add( parent );
585 DALI_TEST_CHECK(parent.GetChildCount() == 0);
589 DALI_TEST_CHECK(parent.GetChildCount() == 1);
591 parent.Remove(random);
593 DALI_TEST_CHECK(parent.GetChildCount() == 1);
595 application.GetScene().Remove( parent );
597 DALI_TEST_CHECK(parent.GetChildCount() == 1);
601 int UtcDaliActorGetChildCount(void)
603 TestApplication application;
605 Actor parent = Actor::New();
606 Actor child = Actor::New();
608 DALI_TEST_CHECK(parent.GetChildCount() == 0);
612 DALI_TEST_CHECK(parent.GetChildCount() == 1);
616 int UtcDaliActorGetChildren01(void)
618 TestApplication application;
620 Actor parent = Actor::New();
621 Actor first = Actor::New();
622 Actor second = Actor::New();
623 Actor third = Actor::New();
629 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
630 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
631 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
635 int UtcDaliActorGetChildren02(void)
637 TestApplication application;
639 Actor parent = Actor::New();
640 Actor first = Actor::New();
641 Actor second = Actor::New();
642 Actor third = Actor::New();
648 const Actor& constParent = parent;
650 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
651 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
652 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
656 int UtcDaliActorGetParent01(void)
658 TestApplication application;
660 Actor parent = Actor::New();
661 Actor child = Actor::New();
665 DALI_TEST_CHECK(child.GetParent() == parent);
669 int UtcDaliActorGetParent02(void)
671 TestApplication application;
673 Actor actor = Actor::New();
675 DALI_TEST_CHECK(!actor.GetParent());
679 int UtcDaliActorCustomProperty(void)
681 TestApplication application;
683 Actor actor = Actor::New();
684 application.GetScene().Add( actor );
686 float startValue(1.0f);
687 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
688 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
690 application.SendNotification();
691 application.Render(0);
692 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
694 actor.SetProperty( index, 5.0f );
696 application.SendNotification();
697 application.Render(0);
698 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
702 int UtcDaliActorCustomPropertyIntToFloat(void)
704 TestApplication application;
706 Actor actor = Actor::New();
707 application.GetScene().Add( actor );
709 float startValue(5.0f);
710 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
711 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
713 application.SendNotification();
714 application.Render(0);
715 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
717 actor.SetProperty( index, int(1) );
719 application.SendNotification();
720 application.Render(0);
721 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
725 int UtcDaliActorCustomPropertyFloatToInt(void)
727 TestApplication application;
729 Actor actor = Actor::New();
730 application.GetScene().Add( actor );
733 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
734 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
736 application.SendNotification();
737 application.Render(0);
738 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
740 actor.SetProperty( index, float(1.5) );
742 application.SendNotification();
743 application.Render(0);
744 DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
748 int UtcDaliActorSetParentOrigin(void)
750 TestApplication application;
752 Actor actor = Actor::New();
754 Vector3 vector(0.7f, 0.8f, 0.9f);
755 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
757 actor.SetProperty( Actor::Property::PARENT_ORIGIN, vector );
759 // flush the queue and render once
760 application.SendNotification();
761 application.Render();
763 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
765 application.GetScene().Add( actor );
767 actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.1f, 0.2f, 0.3f ) );
769 // flush the queue and render once
770 application.SendNotification();
771 application.Render();
773 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), TEST_LOCATION );
775 application.GetScene().Remove( actor );
779 int UtcDaliActorSetParentOriginIndividual(void)
781 TestApplication application;
783 Actor actor = Actor::New();
785 Vector3 vector(0.7f, 0.8f, 0.9f);
786 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
788 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
790 // flush the queue and render once
791 application.SendNotification();
792 application.Render();
794 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).x, TEST_LOCATION );
796 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
798 // flush the queue and render once
799 application.SendNotification();
800 application.Render();
802 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).y, TEST_LOCATION );
804 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
806 // flush the queue and render once
807 application.SendNotification();
808 application.Render();
810 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ).z, TEST_LOCATION );
815 int UtcDaliActorGetCurrentParentOrigin(void)
817 TestApplication application;
819 Actor actor = Actor::New();
821 Vector3 vector(0.7f, 0.8f, 0.9f);
822 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
824 actor.SetProperty( Actor::Property::PARENT_ORIGIN, vector );
826 // flush the queue and render once
827 application.SendNotification();
828 application.Render();
830 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ));
834 int UtcDaliActorSetAnchorPoint(void)
836 TestApplication application;
838 Actor actor = Actor::New();
840 Vector3 vector(0.7f, 0.8f, 0.9f);
841 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
843 actor.SetProperty( Actor::Property::ANCHOR_POINT, vector );
845 // flush the queue and render once
846 application.SendNotification();
847 application.Render();
849 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
851 application.GetScene().Add( actor );
853 actor.SetProperty( Actor::Property::ANCHOR_POINT, Vector3( 0.1f, 0.2f, 0.3f ) );
854 // flush the queue and render once
855 application.SendNotification();
856 application.Render();
858 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), TEST_LOCATION );
860 application.GetScene().Remove( actor );
864 int UtcDaliActorSetAnchorPointIndividual(void)
866 TestApplication application;
868 Actor actor = Actor::New();
870 Vector3 vector(0.7f, 0.8f, 0.9f);
871 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
873 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
875 // flush the queue and render once
876 application.SendNotification();
877 application.Render();
879 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).x, TEST_LOCATION );
881 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
883 // flush the queue and render once
884 application.SendNotification();
885 application.Render();
887 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).y, TEST_LOCATION );
889 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
891 // flush the queue and render once
892 application.SendNotification();
893 application.Render();
895 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ).z, TEST_LOCATION );
900 int UtcDaliActorGetCurrentAnchorPoint(void)
902 TestApplication application;
904 Actor actor = Actor::New();
906 Vector3 vector(0.7f, 0.8f, 0.9f);
907 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
909 actor.SetProperty( Actor::Property::ANCHOR_POINT, vector);
911 // flush the queue and render once
912 application.SendNotification();
913 application.Render();
915 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
919 int UtcDaliActorSetSize01(void)
921 TestApplication application;
923 Actor actor = Actor::New();
924 Vector3 vector(100.0f, 100.0f, 0.0f);
926 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
928 actor.SetProperty( Actor::Property::SIZE, Vector2( vector.x, vector.y ) );
930 // Immediately retrieve the size after setting
931 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
932 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
933 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
934 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
935 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
937 // Flush the queue and render once
938 application.SendNotification();
939 application.Render();
941 // Check the size in the new frame
942 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
944 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
945 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
946 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
947 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
948 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
950 // Check async behaviour
951 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
952 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
953 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
954 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
955 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
957 // Change the resize policy and check whether the size stays the same
958 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
960 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
961 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
963 // Set a new size after resize policy is changed and check the new size
964 actor.SetProperty( Actor::Property::SIZE, Vector3( 0.1f, 0.2f, 0.0f ) );
966 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
967 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
969 // Change the resize policy again and check whether the new size stays the same
970 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
972 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
973 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
975 // Set another new size after resize policy is changed and check the new size
976 actor.SetProperty( Actor::Property::SIZE, Vector3( 50.0f, 60.0f, 0.0f ) );
978 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
979 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
984 int UtcDaliActorSetSize02(void)
986 TestApplication application;
988 Actor actor = Actor::New();
989 Vector3 vector(100.0f, 100.0f, 100.0f);
991 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
993 actor.SetProperty( Actor::Property::SIZE, Vector3( vector.x, vector.y, vector.z ) );
995 // Immediately check the size after setting
996 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
997 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
999 // flush the queue and render once
1000 application.SendNotification();
1001 application.Render();
1003 // Check the size in the new frame
1004 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1006 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1007 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1012 // SetSize(Vector2 size)
1013 int UtcDaliActorSetSize03(void)
1015 TestApplication application;
1017 Actor actor = Actor::New();
1018 Vector3 vector(100.0f, 100.0f, 0.0f);
1020 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1022 actor.SetProperty( Actor::Property::SIZE,Vector2(vector.x, vector.y));
1024 // Immediately check the size after setting
1025 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1026 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1028 // flush the queue and render once
1029 application.SendNotification();
1030 application.Render();
1032 // Check the size in the new frame
1033 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1035 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1036 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1041 // SetSize(Vector3 size)
1042 int UtcDaliActorSetSize04(void)
1044 TestApplication application;
1046 Actor actor = Actor::New();
1047 Vector3 vector(100.0f, 100.0f, 100.0f);
1049 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1051 actor.SetProperty( Actor::Property::SIZE,vector);
1053 // Immediately check the size after setting
1054 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1055 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1057 // flush the queue and render once
1058 application.SendNotification();
1059 application.Render();
1061 // Check the size in the new frame
1062 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1064 application.GetScene().Add( actor );
1065 actor.SetProperty( Actor::Property::SIZE, Vector3( 0.1f, 0.2f, 0.3f ) );
1067 // Immediately check the size after setting
1068 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1069 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1071 // flush the queue and render once
1072 application.SendNotification();
1073 application.Render();
1075 // Check the size in the new frame
1076 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), TEST_LOCATION );
1078 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1079 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1081 application.GetScene().Remove( actor );
1085 int UtcDaliActorSetSizeIndividual(void)
1087 TestApplication application;
1089 Actor actor = Actor::New();
1091 Vector3 vector(0.7f, 0.8f, 0.9f);
1092 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1094 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1096 // Immediately check the width after setting
1097 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1098 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1100 // flush the queue and render once
1101 application.SendNotification();
1102 application.Render();
1104 // Check the width in the new frame
1105 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1107 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1108 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1110 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1112 // Immediately check the height after setting
1113 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1114 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1116 // flush the queue and render once
1117 application.SendNotification();
1118 application.Render();
1120 // Check the height in the new frame
1121 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1123 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1124 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1126 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1128 // Immediately check the depth after setting
1129 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1130 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1132 // flush the queue and render once
1133 application.SendNotification();
1134 application.Render();
1136 // Check the depth in the new frame
1137 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).depth, TEST_LOCATION );
1139 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1140 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1142 // Change the resize policy and check whether the size stays the same
1143 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1145 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1146 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1148 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1149 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1151 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1152 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1154 // Change the resize policy again and check whether the size stays the same
1155 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1157 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1158 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1160 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1161 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1163 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1164 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1169 int UtcDaliActorSetSizeIndividual02(void)
1171 TestApplication application;
1173 Actor actor = Actor::New();
1174 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1175 application.GetScene().Add( actor );
1177 Vector3 vector( 100.0f, 200.0f, 400.0f );
1178 DALI_TEST_CHECK( vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ) );
1180 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1181 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1183 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1184 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1186 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1187 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1189 // flush the queue and render once
1190 application.SendNotification();
1191 application.Render();
1193 // Check the width in the new frame
1194 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).width, TEST_LOCATION );
1195 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, TEST_LOCATION );
1201 int UtcDaliActorGetCurrentSize(void)
1203 TestApplication application;
1205 Actor actor = Actor::New();
1206 Vector3 vector(100.0f, 100.0f, 20.0f);
1208 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1210 actor.SetProperty( Actor::Property::SIZE,vector);
1212 // flush the queue and render once
1213 application.SendNotification();
1214 application.Render();
1216 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1220 int UtcDaliActorGetNaturalSize(void)
1222 TestApplication application;
1224 Actor actor = Actor::New();
1225 Vector3 vector( 0.0f, 0.0f, 0.0f );
1227 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1232 int UtcDaliActorGetCurrentSizeImmediate(void)
1234 TestApplication application;
1236 Actor actor = Actor::New();
1237 Vector3 vector(100.0f, 100.0f, 20.0f);
1239 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1240 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1242 actor.SetProperty( Actor::Property::SIZE,vector);
1244 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1245 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1247 // flush the queue and render once
1248 application.SendNotification();
1249 application.Render();
1251 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1252 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ));
1255 // Build the animation
1256 const float durationSeconds = 2.0f;
1257 Animation animation = Animation::New( durationSeconds );
1258 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1259 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1261 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1263 // Start the animation
1266 application.SendNotification();
1267 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1269 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1274 int UtcDaliActorCalculateScreenExtents(void)
1276 TestApplication application;
1278 Actor actor = Actor::New();
1280 actor.SetProperty( Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1281 actor.SetProperty( Actor::Property::SIZE,Vector3{ 1.0f, 1.0f, 1.0f });
1283 application.SendNotification();
1284 application.Render();
1286 auto expectedExtent = Rect<>{ -0.5f, -0.5f, 1.0f, 1.0f };
1287 auto actualExtent = DevelActor::CalculateScreenExtents( actor );
1288 DALI_TEST_EQUALS( expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1289 DALI_TEST_EQUALS( expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1290 DALI_TEST_EQUALS( expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1291 DALI_TEST_EQUALS( expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1293 application.GetScene().Remove( actor );
1297 // SetPosition(float x, float y)
1298 int UtcDaliActorSetPosition01(void)
1300 TestApplication application;
1302 Actor actor = Actor::New();
1304 // Set to random to start off with
1305 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1307 Vector3 vector(100.0f, 100.0f, 0.0f);
1309 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1311 actor.SetProperty( Actor::Property::POSITION, Vector2(vector.x, vector.y));
1312 // flush the queue and render once
1313 application.SendNotification();
1314 application.Render();
1315 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1317 application.GetScene().Add( actor );
1318 actor.SetProperty( Actor::Property::POSITION, Vector3( 0.1f, 0.2f, 0.3f ) );
1319 // flush the queue and render once
1320 application.SendNotification();
1321 application.Render();
1322 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1324 actor.SetProperty( Actor::Property::POSITION_X, 1.0f );
1325 actor.SetProperty( Actor::Property::POSITION_Y, 1.1f );
1326 actor.SetProperty( Actor::Property::POSITION_Z, 1.2f );
1327 // flush the queue and render once
1328 application.SendNotification();
1329 application.Render();
1330 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION );
1332 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1333 // flush the queue and render once
1334 application.SendNotification();
1335 application.Render();
1336 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1338 application.GetScene().Remove( actor );
1342 // SetPosition(float x, float y, float z)
1343 int UtcDaliActorSetPosition02(void)
1345 TestApplication application;
1347 Actor actor = Actor::New();
1349 // Set to random to start off with
1350 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1352 Vector3 vector(100.0f, 100.0f, 100.0f);
1354 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1356 actor.SetProperty( Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1358 // flush the queue and render once
1359 application.SendNotification();
1360 application.Render();
1362 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1366 // SetPosition(Vector3 position)
1367 int UtcDaliActorSetPosition03(void)
1369 TestApplication application;
1371 Actor actor = Actor::New();
1373 // Set to random to start off with
1374 actor.SetProperty( Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1376 Vector3 vector(100.0f, 100.0f, 100.0f);
1378 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1380 actor.SetProperty( Actor::Property::POSITION, vector);
1382 // flush the queue and render once
1383 application.SendNotification();
1384 application.Render();
1386 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1390 int UtcDaliActorSetX(void)
1392 TestApplication application;
1394 Actor actor = Actor::New();
1396 Vector3 vector(100.0f, 0.0f, 0.0f);
1398 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1400 actor.SetProperty( Actor::Property::POSITION_X, 100.0f);
1402 // flush the queue and render once
1403 application.SendNotification();
1404 application.Render();
1406 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1410 int UtcDaliActorSetY(void)
1412 TestApplication application;
1414 Actor actor = Actor::New();
1416 Vector3 vector(0.0f, 100.0f, 0.0f);
1418 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1420 actor.SetProperty( Actor::Property::POSITION_Y, 100.0f);
1422 // flush the queue and render once
1423 application.SendNotification();
1424 application.Render();
1426 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1430 int UtcDaliActorSetZ(void)
1432 TestApplication application;
1434 Actor actor = Actor::New();
1436 Vector3 vector(0.0f, 0.0f, 100.0f);
1438 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1440 actor.SetProperty( Actor::Property::POSITION_Z, 100.0f);
1442 // flush the queue and render once
1443 application.SendNotification();
1444 application.Render();
1446 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1450 int UtcDaliActorSetPositionProperties(void)
1452 TestApplication application;
1454 Actor actor = Actor::New();
1456 Vector3 vector(0.7f, 0.8f, 0.9f);
1457 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1459 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1460 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1461 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1463 // flush the queue and render once
1464 application.SendNotification();
1465 application.Render();
1467 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1468 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1469 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1470 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1471 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1473 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1474 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1475 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1477 // flush the queue and render once
1478 application.SendNotification();
1479 application.Render();
1481 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1482 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1483 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1484 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1485 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1487 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1488 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1489 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1491 // flush the queue and render once
1492 application.SendNotification();
1493 application.Render();
1495 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1496 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1497 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1498 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1499 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1504 int UtcDaliActorTranslateBy(void)
1506 TestApplication application;
1508 Actor actor = Actor::New();
1509 Vector3 vector(100.0f, 100.0f, 100.0f);
1511 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1513 actor.SetProperty( Actor::Property::POSITION, vector);
1515 // flush the queue and render once
1516 application.SendNotification();
1517 application.Render();
1519 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1521 actor.TranslateBy(vector);
1523 // flush the queue and render once
1524 application.SendNotification();
1525 application.Render();
1527 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ));
1531 int UtcDaliActorGetCurrentPosition(void)
1533 TestApplication application;
1535 Actor actor = Actor::New();
1536 Vector3 setVector(100.0f, 100.0f, 0.0f);
1537 actor.SetProperty( Actor::Property::POSITION, setVector);
1539 // flush the queue and render once
1540 application.SendNotification();
1541 application.Render();
1543 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ) == setVector);
1547 int UtcDaliActorGetCurrentWorldPosition(void)
1549 TestApplication application;
1551 Actor parent = Actor::New();
1552 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1553 parent.SetProperty( Actor::Property::POSITION, parentPosition );
1554 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1555 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1556 application.GetScene().Add( parent );
1558 Actor child = Actor::New();
1559 child.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1560 child.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1561 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1562 child.SetProperty( Actor::Property::POSITION, childPosition );
1563 parent.Add( child );
1565 // The actors should not have a world position yet
1566 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1567 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1569 application.SendNotification();
1570 application.Render(0);
1572 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1573 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1575 // The actors should have a world position now
1576 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1577 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1581 int UtcDaliActorSetInheritPosition(void)
1583 tet_infoline("Testing Actor::SetInheritPosition");
1584 TestApplication application;
1586 Actor parent = Actor::New();
1587 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1588 parent.SetProperty( Actor::Property::POSITION, parentPosition );
1589 parent.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1590 parent.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1591 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( 10.0f, 11.0f, 12.0f );
1597 child.SetProperty( Actor::Property::POSITION, childPosition );
1598 parent.Add( child );
1600 // The actors should not have a world position yet
1601 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1602 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3::ZERO, TEST_LOCATION );
1604 // first test default, which is to inherit position
1605 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1606 application.SendNotification();
1607 application.Render(0); // should only really call Update as Render is not required to update scene
1608 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1609 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childPosition, TEST_LOCATION );
1610 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1611 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childPosition, TEST_LOCATION );
1613 //Change child position
1614 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1615 child.SetProperty( Actor::Property::POSITION, childOffset );
1617 // Use local position as world postion
1618 child.SetProperty( Actor::Property::INHERIT_POSITION, false );
1619 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), false, TEST_LOCATION );
1620 application.SendNotification();
1621 application.Render(0); // should only really call Update as Render is not required to update scene
1622 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1623 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1624 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1625 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), childOffset, TEST_LOCATION );
1627 //Change back to inherit position from parent
1628 child.SetProperty( Actor::Property::INHERIT_POSITION, true );
1629 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_POSITION ), true, TEST_LOCATION );
1630 application.SendNotification();
1631 application.Render(0); // should only really call Update as Render is not required to update scene
1632 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parentPosition, TEST_LOCATION );
1633 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), childOffset, TEST_LOCATION );
1634 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition, TEST_LOCATION );
1635 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), parentPosition + childOffset, TEST_LOCATION );
1639 int UtcDaliActorInheritOpacity(void)
1641 tet_infoline("Testing Actor::Inherit Opacity");
1642 TestApplication application;
1644 Actor parent = Actor::New();
1645 Actor child = Actor::New();
1646 parent.Add( child );
1647 application.GetScene().Add( parent );
1649 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1650 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1652 // flush the queue and render once
1653 application.SendNotification();
1654 application.Render();
1656 parent.SetProperty( Actor::Property::OPACITY, 0.1f );
1658 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1659 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION );
1661 application.SendNotification();
1662 application.Render();
1664 DALI_TEST_EQUALS( parent.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1665 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION );
1666 DALI_TEST_EQUALS( parent.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1667 DALI_TEST_EQUALS( child.GetProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1668 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::WORLD_COLOR ).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION );
1669 DALI_TEST_EQUALS( child.GetCurrentProperty( Actor::Property::COLOR_ALPHA ).Get<float>(), 1.f, 0.0001f, TEST_LOCATION );
1674 // SetOrientation(float angleRadians, Vector3 axis)
1675 int UtcDaliActorSetOrientation01(void)
1677 TestApplication application;
1679 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1680 Actor actor = Actor::New();
1682 actor.SetProperty( Actor::Property::ORIENTATION, rotation);
1684 // flush the queue and render once
1685 application.SendNotification();
1686 application.Render();
1688 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1692 int UtcDaliActorSetOrientation02(void)
1694 TestApplication application;
1696 Actor actor = Actor::New();
1698 Radian angle( 0.785f );
1699 Vector3 axis(1.0f, 1.0f, 0.0f);
1701 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1702 Quaternion rotation( angle, axis );
1703 // flush the queue and render once
1704 application.SendNotification();
1705 application.Render();
1706 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1708 application.GetScene().Add( actor );
1709 actor.RotateBy( Degree( 360 ), axis);
1710 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1712 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) ) );
1713 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1714 // flush the queue and render once
1715 application.SendNotification();
1716 application.Render();
1717 DALI_TEST_EQUALS( result, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1719 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( angle, axis ) );
1720 // flush the queue and render once
1721 application.SendNotification();
1722 application.Render();
1723 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1725 application.GetScene().Remove( actor );
1729 // SetOrientation(float angleRadians, Vector3 axis)
1730 int UtcDaliActorSetOrientationProperty(void)
1732 TestApplication application;
1734 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1735 Actor actor = Actor::New();
1737 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1738 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1740 // flush the queue and render once
1741 application.SendNotification();
1742 application.Render();
1744 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1745 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1746 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1750 // RotateBy(float angleRadians, Vector3 axis)
1751 int UtcDaliActorRotateBy01(void)
1753 TestApplication application;
1755 Actor actor = Actor::New();
1757 Radian angle( M_PI * 0.25f );
1758 actor.RotateBy(( angle ), Vector3::ZAXIS);
1759 // flush the queue and render once
1760 application.SendNotification();
1761 application.Render();
1762 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1764 application.GetScene().Add( actor );
1766 actor.RotateBy( angle, Vector3::ZAXIS);
1767 // flush the queue and render once
1768 application.SendNotification();
1769 application.Render();
1770 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1772 application.GetScene().Remove( actor );
1776 // RotateBy(Quaternion relativeRotation)
1777 int UtcDaliActorRotateBy02(void)
1779 TestApplication application;
1781 Actor actor = Actor::New();
1783 Radian angle( M_PI * 0.25f );
1784 Quaternion rotation(angle, Vector3::ZAXIS);
1785 actor.RotateBy(rotation);
1786 // flush the queue and render once
1787 application.SendNotification();
1788 application.Render();
1789 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1791 actor.RotateBy(rotation);
1792 // flush the queue and render once
1793 application.SendNotification();
1794 application.Render();
1795 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1799 int UtcDaliActorGetCurrentOrientation(void)
1801 TestApplication application;
1802 Actor actor = Actor::New();
1804 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1805 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1806 // flush the queue and render once
1807 application.SendNotification();
1808 application.Render();
1809 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1813 int UtcDaliActorGetCurrentWorldOrientation(void)
1815 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1816 TestApplication application;
1818 Actor parent = Actor::New();
1819 Radian rotationAngle( Degree(90.0f) );
1820 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1821 parent.SetProperty( Actor::Property::ORIENTATION, rotation );
1822 application.GetScene().Add( parent );
1824 Actor child = Actor::New();
1825 child.SetProperty( Actor::Property::ORIENTATION, rotation );
1826 parent.Add( child );
1828 // The actors should not have a world rotation yet
1829 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1830 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1832 application.SendNotification();
1833 application.Render(0);
1835 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1836 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1838 // The actors should have a world rotation now
1839 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1840 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1842 // turn off child rotation inheritance
1843 child.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
1844 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_ORIENTATION ), false, TEST_LOCATION );
1845 application.SendNotification();
1846 application.Render(0);
1848 // The actors should have a world rotation now
1849 DALI_TEST_EQUALS( parent.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1850 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::WORLD_ORIENTATION ), rotation, 0.001, TEST_LOCATION );
1854 // SetScale(float scale)
1855 int UtcDaliActorSetScale01(void)
1857 TestApplication application;
1859 Actor actor = Actor::New();
1861 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1862 actor.SetProperty( Actor::Property::SCALE,0.25f);
1864 Vector3 scale(10.0f, 10.0f, 10.0f);
1865 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1867 actor.SetProperty( Actor::Property::SCALE,scale.x);
1869 // flush the queue and render once
1870 application.SendNotification();
1871 application.Render();
1873 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1877 // SetScale(float scaleX, float scaleY, float scaleZ)
1878 int UtcDaliActorSetScale02(void)
1880 TestApplication application;
1881 Vector3 scale(10.0f, 10.0f, 10.0f);
1883 Actor actor = Actor::New();
1885 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1886 actor.SetProperty( Actor::Property::SCALE, Vector3( 12.0f, 1.0f, 2.0f ) );
1888 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1890 actor.SetProperty( Actor::Property::SCALE, Vector3( scale.x, scale.y, scale.z ) );
1891 // flush the queue and render once
1892 application.SendNotification();
1893 application.Render();
1894 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1896 // add to stage and test
1897 application.GetScene().Add( actor );
1898 actor.SetProperty( Actor::Property::SCALE, Vector3( 2.0f, 2.0f, 2.0f ) );
1899 // flush the queue and render once
1900 application.SendNotification();
1901 application.Render();
1902 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), 0.001, TEST_LOCATION);
1904 application.GetScene().Remove( actor );
1909 // SetScale(Vector3 scale)
1910 int UtcDaliActorSetScale03(void)
1912 TestApplication application;
1913 Vector3 scale(10.0f, 10.0f, 10.0f);
1915 Actor actor = Actor::New();
1917 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1918 actor.SetProperty( Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1920 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) != scale);
1922 actor.SetProperty( Actor::Property::SCALE,scale);
1924 // flush the queue and render once
1925 application.SendNotification();
1926 application.Render();
1928 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
1932 int UtcDaliActorSetScaleIndividual(void)
1934 TestApplication application;
1936 Actor actor = Actor::New();
1938 Vector3 vector(0.7f, 0.8f, 0.9f);
1939 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1941 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1942 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1944 // flush the queue and render once
1945 application.SendNotification();
1946 application.Render();
1948 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x, TEST_LOCATION );
1949 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1950 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1952 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1953 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1955 // flush the queue and render once
1956 application.SendNotification();
1957 application.Render();
1959 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).y, TEST_LOCATION );
1960 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1961 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1963 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1964 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1966 // flush the queue and render once
1967 application.SendNotification();
1968 application.Render();
1970 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).z, TEST_LOCATION );
1971 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1972 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1974 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1975 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1980 int UtcDaliActorScaleBy(void)
1982 TestApplication application;
1983 Actor actor = Actor::New();
1984 Vector3 vector(100.0f, 100.0f, 100.0f);
1986 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1988 actor.SetProperty( Actor::Property::SCALE,vector);
1990 // flush the queue and render once
1991 application.SendNotification();
1992 application.Render();
1994 DALI_TEST_CHECK(vector == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
1996 actor.ScaleBy(vector);
1998 // flush the queue and render once
1999 application.SendNotification();
2000 application.Render();
2002 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ));
2006 int UtcDaliActorGetCurrentScale(void)
2008 TestApplication application;
2009 Vector3 scale(12.0f, 1.0f, 2.0f);
2011 Actor actor = Actor::New();
2013 actor.SetProperty( Actor::Property::SCALE,scale);
2015 // flush the queue and render once
2016 application.SendNotification();
2017 application.Render();
2019 DALI_TEST_CHECK(actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) == scale);
2023 int UtcDaliActorGetCurrentWorldScale(void)
2025 TestApplication application;
2027 Actor parent = Actor::New();
2028 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2029 parent.SetProperty( Actor::Property::SCALE, parentScale );
2030 application.GetScene().Add( parent );
2032 Actor child = Actor::New();
2033 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2034 child.SetProperty( Actor::Property::SCALE, childScale );
2035 parent.Add( child );
2037 // The actors should not have a scale yet
2038 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2039 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
2041 // The actors should not have a world scale yet
2042 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2043 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), Vector3::ONE, TEST_LOCATION );
2045 application.SendNotification();
2046 application.Render(0);
2048 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), parentScale, TEST_LOCATION );
2049 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), childScale, TEST_LOCATION );
2051 // The actors should have a world scale now
2052 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale, TEST_LOCATION );
2053 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2057 int UtcDaliActorInheritScale(void)
2059 tet_infoline("Testing Actor::SetInheritScale");
2060 TestApplication application;
2062 Actor parent = Actor::New();
2063 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2064 parent.SetProperty( Actor::Property::SCALE, parentScale );
2065 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 application.SendNotification();
2073 application.Render(0);
2075 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), true, TEST_LOCATION );
2076 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), parentScale * childScale, TEST_LOCATION );
2078 child.SetProperty( Actor::Property::INHERIT_SCALE, false );
2079 DALI_TEST_EQUALS( child.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), false, TEST_LOCATION );
2081 application.SendNotification();
2082 application.Render(0);
2084 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE ), childScale, TEST_LOCATION );
2088 int UtcDaliActorSetVisible(void)
2090 TestApplication application;
2092 Actor actor = Actor::New();
2093 actor.SetProperty( Actor::Property::VISIBLE,false);
2094 // flush the queue and render once
2095 application.SendNotification();
2096 application.Render();
2097 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2099 actor.SetProperty( Actor::Property::VISIBLE,true);
2100 // flush the queue and render once
2101 application.SendNotification();
2102 application.Render();
2103 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2105 // put actor on stage
2106 application.GetScene().Add( actor );
2107 actor.SetProperty( Actor::Property::VISIBLE,false);
2108 // flush the queue and render once
2109 application.SendNotification();
2110 application.Render();
2111 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false);
2115 int UtcDaliActorIsVisible(void)
2117 TestApplication application;
2119 Actor actor = Actor::New();
2121 DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true);
2125 int UtcDaliActorSetOpacity(void)
2127 TestApplication application;
2129 Actor actor = Actor::New();
2130 // initial opacity is 1
2131 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
2133 actor.SetProperty( Actor::Property::OPACITY, 0.4f);
2134 // flush the queue and render once
2135 application.SendNotification();
2136 application.Render();
2137 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.4f, TEST_LOCATION );
2139 // change opacity, actor is on stage to change is not immediate
2140 actor.SetProperty( Actor::Property::OPACITY, actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) + 0.1f );
2141 // flush the queue and render once
2142 application.SendNotification();
2143 application.Render();
2144 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2146 // put actor on stage
2147 application.GetScene().Add( actor );
2149 // change opacity, actor is on stage to change is not immediate
2150 actor.SetProperty( Actor::Property::OPACITY, 0.9f );
2151 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, TEST_LOCATION );
2152 // flush the queue and render once
2153 application.SendNotification();
2154 application.Render();
2155 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.9f, TEST_LOCATION );
2157 // change opacity, actor is on stage to change is not immediate
2158 actor.SetProperty( Actor::Property::OPACITY, actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) - 0.9f );
2159 // flush the queue and render once
2160 application.SendNotification();
2161 application.Render();
2162 DALI_TEST_EQUALS(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
2166 int UtcDaliActorGetCurrentOpacity(void)
2168 TestApplication application;
2170 Actor actor = Actor::New();
2171 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) != 0.5f);
2173 actor.SetProperty( Actor::Property::OPACITY,0.5f);
2174 // flush the queue and render once
2175 application.SendNotification();
2176 application.Render();
2177 DALI_TEST_CHECK(actor.GetCurrentProperty< float >( Actor::Property::OPACITY ) == 0.5f);
2181 int UtcDaliActorSetSensitive(void)
2183 TestApplication application;
2184 Actor actor = Actor::New();
2186 bool sensitive = !actor.GetProperty< bool >( Actor::Property::SENSITIVE );
2188 actor.SetProperty( Actor::Property::SENSITIVE,sensitive);
2190 DALI_TEST_CHECK(sensitive == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2194 int UtcDaliActorIsSensitive(void)
2196 TestApplication application;
2197 Actor actor = Actor::New();
2198 actor.SetProperty( Actor::Property::SENSITIVE,false);
2200 DALI_TEST_CHECK(false == actor.GetProperty< bool >( Actor::Property::SENSITIVE ));
2204 int UtcDaliActorSetColor(void)
2206 TestApplication application;
2207 Actor actor = Actor::New();
2208 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2210 DALI_TEST_CHECK(color != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2212 actor.SetProperty( Actor::Property::COLOR,color);
2213 // flush the queue and render once
2214 application.SendNotification();
2215 application.Render();
2216 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2218 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2219 // flush the queue and render once
2220 application.SendNotification();
2221 application.Render();
2222 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2224 application.GetScene().Add( actor );
2225 actor.SetProperty( Actor::Property::COLOR, color );
2226 // flush the queue and render once
2227 application.SendNotification();
2228 application.Render();
2229 DALI_TEST_EQUALS( color, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2231 actor.SetProperty( Actor::Property::COLOR, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ) + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2232 // flush the queue and render once
2233 application.SendNotification();
2234 application.Render();
2235 // Actor color is not clamped
2236 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2237 // world color is clamped
2238 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), TEST_LOCATION );
2240 actor.SetProperty( Actor::Property::COLOR, color );
2241 DALI_TEST_EQUALS( color, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2243 Vector3 newColor( 1.0f, 0.0f, 0.0f );
2244 actor.SetProperty( Actor::Property::COLOR, newColor );
2245 DALI_TEST_EQUALS( Vector4( newColor.r, newColor.g, newColor.b, 1.0f ), actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2247 application.GetScene().Remove( actor );
2251 int UtcDaliActorSetColorIndividual(void)
2253 TestApplication application;
2255 Actor actor = Actor::New();
2257 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2258 DALI_TEST_CHECK(vector != actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2260 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2261 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2263 // flush the queue and render once
2264 application.SendNotification();
2265 application.Render();
2267 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).r, TEST_LOCATION );
2268 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2269 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2271 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2272 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2274 // flush the queue and render once
2275 application.SendNotification();
2276 application.Render();
2278 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).g, TEST_LOCATION );
2279 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2280 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2282 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2283 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2285 // flush the queue and render once
2286 application.SendNotification();
2287 application.Render();
2289 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).b, TEST_LOCATION );
2290 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2291 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2294 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2295 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2297 // flush the queue and render once
2298 application.SendNotification();
2299 application.Render();
2301 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2302 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2303 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2305 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2306 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2308 actor.SetProperty( Actor::Property::OPACITY, 0.2f );
2311 // flush the queue and render once
2312 application.SendNotification();
2313 application.Render();
2315 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ).a, TEST_LOCATION );
2321 int UtcDaliActorGetCurrentColor(void)
2323 TestApplication application;
2324 Actor actor = Actor::New();
2325 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2327 actor.SetProperty( Actor::Property::COLOR,color);
2328 // flush the queue and render once
2329 application.SendNotification();
2330 application.Render();
2331 DALI_TEST_CHECK(color == actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ));
2335 int UtcDaliActorGetCurrentWorldColor(void)
2337 tet_infoline("Actor::GetCurrentWorldColor");
2338 TestApplication application;
2340 Actor parent = Actor::New();
2341 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2342 parent.SetProperty( Actor::Property::COLOR, parentColor );
2343 application.GetScene().Add( parent );
2345 Actor child = Actor::New();
2346 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2347 child.SetProperty( Actor::Property::COLOR, childColor );
2348 parent.Add( child );
2350 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2351 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
2353 // verify the default color mode
2354 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2356 // The actors should not have a world color yet
2357 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2358 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Color::WHITE, TEST_LOCATION );
2360 application.SendNotification();
2361 application.Render(0);
2363 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), parentColor, TEST_LOCATION );
2364 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2366 // The actors should have a world color now
2367 DALI_TEST_EQUALS( parent.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2368 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2371 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2372 application.SendNotification();
2373 application.Render(0);
2374 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), childColor, TEST_LOCATION );
2377 child.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2378 application.SendNotification();
2379 application.Render(0);
2380 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2381 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), parentColor, TEST_LOCATION );
2384 child.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2385 application.SendNotification();
2386 application.Render(0);
2387 Vector4 expectedColor( childColor );
2388 expectedColor.a *= parentColor.a;
2389 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), childColor, TEST_LOCATION );
2390 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ), expectedColor, TEST_LOCATION );
2394 int UtcDaliActorSetColorMode(void)
2396 tet_infoline("Actor::SetColorMode");
2397 TestApplication application;
2398 Actor actor = Actor::New();
2399 Actor child = Actor::New();
2402 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
2403 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2405 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
2406 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2408 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
2409 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2411 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
2412 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), TEST_LOCATION );
2416 int UtcDaliActorScreenToLocal(void)
2418 TestApplication application;
2419 Actor actor = Actor::New();
2420 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2421 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
2422 actor.SetProperty( Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2423 application.GetScene().Add(actor);
2425 // flush the queue and render once
2426 application.SendNotification();
2427 application.Render();
2432 application.SendNotification();
2433 application.Render();
2435 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2437 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2438 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2442 int UtcDaliActorSetLeaveRequired(void)
2444 TestApplication application;
2446 Actor actor = Actor::New();
2448 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,false);
2449 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2451 actor.SetProperty( Actor::Property::LEAVE_REQUIRED,true);
2452 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == true);
2456 int UtcDaliActorGetLeaveRequired(void)
2458 TestApplication application;
2460 Actor actor = Actor::New();
2462 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ) == false);
2466 int UtcDaliActorSetKeyboardFocusable(void)
2468 TestApplication application;
2470 Actor actor = Actor::New();
2472 actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
2473 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == true);
2475 actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, false );
2476 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == false);
2480 int UtcDaliActorIsKeyboardFocusable(void)
2482 TestApplication application;
2484 Actor actor = Actor::New();
2486 DALI_TEST_CHECK(actor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) == false);
2490 int UtcDaliActorRemoveConstraints(void)
2492 tet_infoline(" UtcDaliActorRemoveConstraints");
2493 TestApplication application;
2495 gTestConstraintCalled = false;
2497 Actor actor = Actor::New();
2499 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2501 actor.RemoveConstraints();
2503 DALI_TEST_CHECK( gTestConstraintCalled == false );
2505 application.GetScene().Add( actor );
2508 // flush the queue and render once
2509 application.SendNotification();
2510 application.Render();
2512 actor.RemoveConstraints();
2514 DALI_TEST_CHECK( gTestConstraintCalled == true );
2518 int UtcDaliActorRemoveConstraintTag(void)
2520 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2521 TestApplication application;
2523 Actor actor = Actor::New();
2525 // 1. Apply Constraint1 and Constraint2, and test...
2526 unsigned int result1 = 0u;
2527 unsigned int result2 = 0u;
2529 unsigned constraint1Tag = 1u;
2530 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2531 constraint1.SetTag( constraint1Tag );
2532 constraint1.Apply();
2534 unsigned constraint2Tag = 2u;
2535 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2536 constraint2.SetTag( constraint2Tag );
2537 constraint2.Apply();
2539 application.GetScene().Add( actor );
2540 // flush the queue and render once
2541 application.SendNotification();
2542 application.Render();
2544 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2545 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2547 // 2. Remove Constraint1 and test...
2550 actor.RemoveConstraints(constraint1Tag);
2551 // make color property dirty, which will trigger constraints to be reapplied.
2552 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2553 // flush the queue and render once
2554 application.SendNotification();
2555 application.Render();
2557 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2558 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2560 // 3. Re-Apply Constraint1 and test...
2563 constraint1.Apply();
2564 // make color property dirty, which will trigger constraints to be reapplied.
2565 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2566 // flush the queue and render once
2567 application.SendNotification();
2568 application.Render();
2570 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2571 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2573 // 2. Remove Constraint2 and test...
2576 actor.RemoveConstraints(constraint2Tag);
2577 // make color property dirty, which will trigger constraints to be reapplied.
2578 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2579 // flush the queue and render once
2580 application.SendNotification();
2581 application.Render();
2583 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2584 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2586 // 2. Remove Constraint1 as well and test...
2589 actor.RemoveConstraints(constraint1Tag);
2590 // make color property dirty, which will trigger constraints to be reapplied.
2591 actor.SetProperty( Actor::Property::COLOR, Color::WHITE );
2592 // flush the queue and render once
2593 application.SendNotification();
2594 application.Render();
2596 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2597 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2601 int UtcDaliActorTouchedSignal(void)
2603 TestApplication application;
2605 ResetTouchCallbacks();
2607 // get the root layer
2608 Actor actor = application.GetScene().GetRootLayer();
2609 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2611 application.SendNotification();
2612 application.Render();
2614 // connect to its touch signal
2615 actor.TouchedSignal().Connect( TestCallback );
2617 // simulate a touch event in the middle of the screen
2618 Vector2 touchPoint( application.GetScene().GetSize() * 0.5 );
2619 Dali::Integration::Point point;
2620 point.SetDeviceId( 1 );
2621 point.SetState( PointState::DOWN );
2622 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2623 Dali::Integration::TouchEvent touchEvent;
2624 touchEvent.AddPoint( point );
2625 application.ProcessEvent( touchEvent );
2627 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2631 int UtcDaliActorHoveredSignal(void)
2633 TestApplication application;
2635 gHoverCallBackCalled = false;
2637 // get the root layer
2638 Actor actor = application.GetScene().GetRootLayer();
2639 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2641 application.SendNotification();
2642 application.Render();
2644 // connect to its hover signal
2645 actor.HoveredSignal().Connect( TestCallback3 );
2647 // simulate a hover event in the middle of the screen
2648 Vector2 touchPoint( application.GetScene().GetSize() * 0.5 );
2649 Dali::Integration::Point point;
2650 point.SetDeviceId( 1 );
2651 point.SetState( PointState::MOTION );
2652 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2653 Dali::Integration::HoverEvent hoverEvent;
2654 hoverEvent.AddPoint( point );
2655 application.ProcessEvent( hoverEvent );
2657 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2661 int UtcDaliActorOnOffStageSignal(void)
2663 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2665 TestApplication application;
2668 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2669 gActorNamesOnOffStage.clear();
2671 Actor parent = Actor::New();
2672 parent.SetProperty( Actor::Property::NAME, "parent" );
2673 parent.OnStageSignal().Connect( OnStageCallback );
2674 parent.OffStageSignal().Connect( OffStageCallback );
2676 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2677 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2679 // add parent to stage
2680 application.GetScene().Add( parent );
2681 // onstage emitted, offstage not
2682 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2683 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2684 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2686 // test adding a child, should get onstage emitted
2688 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2689 gActorNamesOnOffStage.clear();
2691 Actor child = Actor::New();
2692 child.SetProperty( Actor::Property::NAME, "child" );
2693 child.OnStageSignal().Connect( OnStageCallback );
2694 child.OffStageSignal().Connect( OffStageCallback );
2695 parent.Add( child ); // add child
2696 // onstage emitted, offstage not
2697 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2698 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2699 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2701 // test removing parent from stage
2703 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2704 gActorNamesOnOffStage.clear();
2706 application.GetScene().Remove( parent );
2707 // onstage not emitted, offstage is
2708 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2709 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2710 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2711 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2713 // test adding parent back to stage
2715 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2716 gActorNamesOnOffStage.clear();
2718 application.GetScene().Add( parent );
2719 // onstage emitted, offstage not
2720 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2721 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2722 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2723 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2725 // test removing child
2727 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2728 gActorNamesOnOffStage.clear();
2730 parent.Remove( child );
2731 // onstage not emitted, offstage is
2732 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2733 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2734 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2736 // test removing parent
2738 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2739 gActorNamesOnOffStage.clear();
2741 application.GetScene().Remove( parent );
2742 // onstage not emitted, offstage is
2743 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2744 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2745 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2749 int UtcDaliActorFindChildByName(void)
2751 tet_infoline("Testing Dali::Actor::FindChildByName()");
2752 TestApplication application;
2754 Actor parent = Actor::New();
2755 parent.SetProperty( Actor::Property::NAME, "parent" );
2756 Actor first = Actor::New();
2757 first .SetProperty( Actor::Property::NAME, "first" );
2758 Actor second = Actor::New();
2759 second.SetProperty( Actor::Property::NAME, "second" );
2764 Actor found = parent.FindChildByName( "foo" );
2765 DALI_TEST_CHECK( !found );
2767 found = parent.FindChildByName( "parent" );
2768 DALI_TEST_CHECK( found == parent );
2770 found = parent.FindChildByName( "first" );
2771 DALI_TEST_CHECK( found == first );
2773 found = parent.FindChildByName( "second" );
2774 DALI_TEST_CHECK( found == second );
2778 int UtcDaliActorFindChildById(void)
2780 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2781 TestApplication application;
2783 Actor parent = Actor::New();
2784 Actor first = Actor::New();
2785 Actor second = Actor::New();
2790 Actor found = parent.FindChildById( 100000 );
2791 DALI_TEST_CHECK( !found );
2793 found = parent.FindChildById( parent.GetProperty< int >( Actor::Property::ID ) );
2794 DALI_TEST_CHECK( found == parent );
2796 found = parent.FindChildById( first.GetProperty< int >( Actor::Property::ID ) );
2797 DALI_TEST_CHECK( found == first );
2799 found = parent.FindChildById( second.GetProperty< int >( Actor::Property::ID ) );
2800 DALI_TEST_CHECK( found == second );
2804 int UtcDaliActorHitTest(void)
2809 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2811 mTouchPoint( touchPoint ),
2816 Vector2 mTouchPoint;
2820 TestApplication application;
2821 tet_infoline(" UtcDaliActorHitTest");
2823 // Fill a vector with different hit tests.
2824 struct HitTestData* hitTestData[] = {
2825 // scale touch point result
2826 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2827 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2828 new HitTestData( Vector3( 110.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), true ), // same point as above with a wider scale. Should be inside.
2829 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2830 new HitTestData( Vector3( 100.f, 110.f, 1.f ), Vector2( 200.f, 451.f ), true ), // same point as above with a wider scale. Should be inside.
2834 // get the root layer
2835 Actor actor = Actor::New();
2836 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2837 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2839 application.GetScene().Add( actor );
2841 ResetTouchCallbacks();
2843 unsigned int index = 0;
2844 while( NULL != hitTestData[index] )
2846 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.f, 1.f ) );
2847 actor.SetProperty( Actor::Property::SCALE, Vector3( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z ) );
2849 // flush the queue and render once
2850 application.SendNotification();
2851 application.Render();
2853 DALI_TEST_CHECK( !gTouchCallBackCalled );
2855 // connect to its touch signal
2856 actor.TouchedSignal().Connect(TestCallback);
2858 Dali::Integration::Point point;
2859 point.SetState( PointState::DOWN );
2860 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2861 Dali::Integration::TouchEvent event;
2862 event.AddPoint( point );
2864 // flush the queue and render once
2865 application.SendNotification();
2866 application.Render();
2867 application.ProcessEvent( event );
2869 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2871 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2872 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2873 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2874 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2875 hitTestData[index]->mResult );
2877 ResetTouchCallbacks();
2883 int UtcDaliActorSetDrawMode(void)
2885 TestApplication application;
2886 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2888 Actor a = Actor::New();
2890 application.GetScene().Add(a);
2891 application.SendNotification();
2892 application.Render(0);
2893 application.SendNotification();
2894 application.Render(1);
2896 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Ensure overlay is off by default
2898 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
2899 application.SendNotification();
2900 application.Render(1);
2902 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is overlay
2904 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
2905 application.SendNotification();
2906 application.Render(1);
2908 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) ); // Check Actor is normal
2912 int UtcDaliActorSetDrawModeOverlayRender(void)
2914 TestApplication application;
2915 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2917 application.SendNotification();
2918 application.Render(1);
2920 std::vector<GLuint> ids;
2921 ids.push_back( 8 ); // first rendered actor
2922 ids.push_back( 9 ); // second rendered actor
2923 ids.push_back( 10 ); // third rendered actor
2924 application.GetGlAbstraction().SetNextTextureIds( ids );
2926 Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2927 Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2928 Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2929 Actor a = CreateRenderableActor( imageA );
2930 Actor b = CreateRenderableActor( imageB );
2931 Actor c = CreateRenderableActor( imageC );
2933 application.SendNotification();
2934 application.Render(1);
2936 //Textures are bound when first created. Clear bound textures vector
2937 application.GetGlAbstraction().ClearBoundTextures();
2939 // Render a,b,c as regular non-overlays. so order will be:
2943 application.GetScene().Add(a);
2944 application.GetScene().Add(b);
2945 application.GetScene().Add(c);
2947 application.SendNotification();
2948 application.Render(1);
2950 // Should be 3 textures changes.
2951 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2952 typedef std::vector<GLuint>::size_type TextureSize;
2953 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2954 if( boundTextures.size() == 3 )
2956 DALI_TEST_CHECK( boundTextures[0] == 8u );
2957 DALI_TEST_CHECK( boundTextures[1] == 9u );
2958 DALI_TEST_CHECK( boundTextures[2] == 10u );
2961 // Now texture ids have been set, we can monitor their render order.
2962 // render a as an overlay (last), so order will be:
2966 a.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
2967 application.GetGlAbstraction().ClearBoundTextures();
2969 application.SendNotification();
2970 application.Render(1);
2972 // Should be 3 texture changes.
2973 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2974 if( boundTextures.size() == 3 )
2976 DALI_TEST_CHECK( boundTextures[0] == 9u );
2977 DALI_TEST_CHECK( boundTextures[1] == 10u );
2978 DALI_TEST_CHECK( boundTextures[2] == 8u );
2983 int UtcDaliActorGetCurrentWorldMatrix(void)
2985 TestApplication application;
2986 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2988 Actor parent = Actor::New();
2989 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
2990 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
2991 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2992 Radian rotationAngle(Degree(85.0f));
2993 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2994 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2995 parent.SetProperty( Actor::Property::POSITION, parentPosition );
2996 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
2997 parent.SetProperty( Actor::Property::SCALE, parentScale );
2998 application.GetScene().Add( parent );
3000 Actor child = Actor::New();
3001 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3002 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
3003 Radian childRotationAngle(Degree(23.0f));
3004 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
3005 Vector3 childScale( 2.0f, 2.0f, 2.0f );
3006 child.SetProperty( Actor::Property::POSITION, childPosition );
3007 child.SetProperty( Actor::Property::ORIENTATION, childRotation );
3008 child.SetProperty( Actor::Property::SCALE, childScale );
3009 parent.Add( child );
3011 application.SendNotification();
3012 application.Render(0);
3013 application.Render();
3014 application.SendNotification();
3016 Matrix parentMatrix(false);
3017 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3019 Matrix childMatrix(false);
3020 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
3022 //Child matrix should be the composition of child and parent
3023 Matrix childWorldMatrix(false);
3024 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
3026 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3027 DALI_TEST_EQUALS( child.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), childWorldMatrix, 0.001, TEST_LOCATION );
3033 int UtcDaliActorConstrainedToWorldMatrix(void)
3035 TestApplication application;
3036 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3038 Actor parent = Actor::New();
3039 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3040 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3041 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3042 Radian rotationAngle(Degree(85.0f));
3043 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3044 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3045 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3046 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3047 parent.SetProperty( Actor::Property::SCALE, parentScale );
3048 application.GetScene().Add( parent );
3050 Actor child = Actor::New();
3051 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3052 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
3053 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
3054 posConstraint.Apply();
3056 application.GetScene().Add( child );
3058 application.SendNotification();
3059 application.Render(0);
3060 application.Render();
3061 application.SendNotification();
3063 Matrix parentMatrix(false);
3064 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3066 DALI_TEST_EQUALS( parent.GetCurrentProperty< Matrix >( Actor::Property::WORLD_MATRIX ), parentMatrix, 0.001, TEST_LOCATION );
3067 DALI_TEST_EQUALS( child.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), parent.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), 0.001, TEST_LOCATION );
3071 int UtcDaliActorConstrainedToOrientation(void)
3073 TestApplication application;
3074 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3076 Actor parent = Actor::New();
3077 parent.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3078 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
3079 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3080 Radian rotationAngle(Degree(85.0f));
3081 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3082 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3083 parent.SetProperty( Actor::Property::POSITION, parentPosition );
3084 parent.SetProperty( Actor::Property::ORIENTATION, parentRotation );
3085 parent.SetProperty( Actor::Property::SCALE, parentScale );
3086 application.GetScene().Add( parent );
3088 Actor child = Actor::New();
3089 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
3090 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3091 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3092 posConstraint.Apply();
3094 application.GetScene().Add( child );
3096 application.SendNotification();
3097 application.Render(0);
3098 application.Render();
3099 application.SendNotification();
3101 DALI_TEST_EQUALS( child.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), parent.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION );
3105 int UtcDaliActorConstrainedToOpacity(void)
3107 TestApplication application;
3108 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3110 Actor parent = Actor::New();
3111 parent.SetProperty( Actor::Property::OPACITY, 0.7f );
3112 application.GetScene().Add( parent );
3114 Actor child = Actor::New();
3115 Constraint opacityConstraint = Constraint::New<float>( child, Actor::Property::OPACITY, EqualToConstraint() );
3116 opacityConstraint.AddSource( Source( parent, Actor::Property::OPACITY ) );
3117 opacityConstraint.Apply();
3119 application.GetScene().Add( child );
3121 application.SendNotification();
3122 application.Render(0);
3123 application.Render();
3124 application.SendNotification();
3126 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( Actor::Property::OPACITY ), parent.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3128 parent.SetProperty( Actor::Property::OPACITY, 0.3f );
3130 application.SendNotification();
3131 application.Render(0);
3132 application.Render();
3133 application.SendNotification();
3135 DALI_TEST_EQUALS( child.GetCurrentProperty< float >( Actor::Property::OPACITY ), parent.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.001f, TEST_LOCATION );
3140 int UtcDaliActorUnparent(void)
3142 TestApplication application;
3143 tet_infoline(" UtcDaliActorUnparent");
3145 Actor parent = Actor::New();
3146 application.GetScene().Add( parent );
3148 Actor child = Actor::New();
3150 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3151 DALI_TEST_CHECK( !child.GetParent() );
3153 // Test that calling Unparent with no parent is a NOOP
3156 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3157 DALI_TEST_CHECK( !child.GetParent() );
3159 // Test that Unparent works
3160 parent.Add( child );
3162 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3163 DALI_TEST_CHECK( parent == child.GetParent() );
3167 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3168 DALI_TEST_CHECK( !child.GetParent() );
3170 // Test that UnparentAndReset works
3171 parent.Add( child );
3173 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3174 DALI_TEST_CHECK( parent == child.GetParent() );
3176 UnparentAndReset( child );
3178 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3179 DALI_TEST_CHECK( !child );
3181 // Test that UnparentAndReset is a NOOP with empty handle
3182 UnparentAndReset( child );
3184 DALI_TEST_CHECK( !child );
3188 int UtcDaliActorGetChildAt(void)
3190 TestApplication application;
3191 tet_infoline(" UtcDaliActorGetChildAt");
3193 Actor parent = Actor::New();
3194 application.GetScene().Add( parent );
3196 Actor child0 = Actor::New();
3197 parent.Add( child0 );
3199 Actor child1 = Actor::New();
3200 parent.Add( child1 );
3202 Actor child2 = Actor::New();
3203 parent.Add( child2 );
3205 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3206 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3207 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3211 int UtcDaliActorSetGetOverlay(void)
3213 TestApplication application;
3214 tet_infoline(" UtcDaliActorSetGetOverlay");
3216 Actor parent = Actor::New();
3217 parent.SetProperty( Actor::Property::DRAW_MODE,DrawMode::OVERLAY_2D );
3218 DALI_TEST_CHECK( parent.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ) == DrawMode::OVERLAY_2D );
3223 int UtcDaliActorCreateDestroy(void)
3225 Actor* actor = new Actor;
3226 DALI_TEST_CHECK( actor );
3233 struct PropertyStringIndex
3235 const char * const name;
3236 const Property::Index index;
3237 const Property::Type type;
3240 const PropertyStringIndex PROPERTY_TABLE[] =
3242 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3243 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3244 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3245 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3246 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3247 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3248 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3249 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3250 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3251 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3252 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3253 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3254 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3255 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3256 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3257 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3258 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3259 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3260 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3261 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3262 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3263 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3264 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3265 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3266 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3267 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3268 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3269 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3270 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3271 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3272 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3273 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3274 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3275 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3276 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3277 { "name", Actor::Property::NAME, Property::STRING },
3278 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3279 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3280 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3281 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3282 { "colorMode", Actor::Property::COLOR_MODE, Property::INTEGER },
3283 { "drawMode", Actor::Property::DRAW_MODE, Property::INTEGER },
3284 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3285 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3286 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3287 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER },
3288 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3289 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3290 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3291 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3292 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3293 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3294 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3295 { "opacity", Actor::Property::OPACITY, Property::FLOAT },
3297 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3298 } // unnamed namespace
3300 int UtcDaliActorProperties(void)
3302 TestApplication application;
3304 Actor actor = Actor::New();
3306 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3308 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3309 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3310 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3311 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3316 int UtcDaliRelayoutProperties_ResizePolicies(void)
3318 TestApplication application;
3320 Actor actor = Actor::New();
3323 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3324 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3326 // Set resize policy for all dimensions
3327 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3328 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3330 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3333 // Set individual dimensions
3334 const char* const widthPolicy = "FILL_TO_PARENT";
3335 const char* const heightPolicy = "FIXED";
3337 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3338 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3340 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3341 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3343 // Set individual dimensions using enums
3344 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3345 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3347 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3348 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3350 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3351 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3356 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3358 TestApplication application;
3360 Actor actor = Actor::New();
3363 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3365 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3366 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy );
3367 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy, TEST_LOCATION );
3370 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3371 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3373 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3374 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy1, TEST_LOCATION );
3376 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3377 DALI_TEST_EQUALS( actor.GetProperty< SizeScalePolicy::Type >( Actor::Property::SIZE_SCALE_POLICY ), policy2, TEST_LOCATION );
3382 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3384 TestApplication application;
3386 Actor actor = Actor::New();
3389 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3390 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3392 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3393 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode );
3394 DALI_TEST_EQUALS( actor.GetProperty< Vector3 >( Actor::Property::SIZE_MODE_FACTOR ), sizeMode, TEST_LOCATION );
3397 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3399 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3400 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3405 int UtcDaliRelayoutProperties_DimensionDependency(void)
3407 TestApplication application;
3409 Actor actor = Actor::New();
3412 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3413 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3416 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3417 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3419 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3420 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3422 // Test setting another resize policy
3423 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3424 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3429 int UtcDaliRelayoutProperties_Padding(void)
3431 TestApplication application;
3433 Actor actor = Actor::New();
3436 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3439 actor.SetProperty( Actor::Property::PADDING, padding );
3440 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3442 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3447 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3449 TestApplication application;
3451 Actor actor = Actor::New();
3454 Vector2 minSize( 1.0f, 2.0f );
3456 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3457 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3459 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3461 Vector2 maxSize( 3.0f, 4.0f );
3463 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3464 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3466 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3471 int UtcDaliActorGetHeightForWidth(void)
3473 TestApplication application;
3475 Actor actor = Actor::New();
3477 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3482 int UtcDaliActorGetWidthForHeight(void)
3484 TestApplication application;
3486 Actor actor = Actor::New();
3488 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3493 int UtcDaliActorGetRelayoutSize(void)
3495 TestApplication application;
3497 Actor actor = Actor::New();
3499 // Add actor to stage
3500 application.GetScene().Add( actor );
3502 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3504 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3505 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 0.0f ) );
3507 // Flush the queue and render once
3508 application.SendNotification();
3509 application.Render();
3511 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3516 int UtcDaliActorSetPadding(void)
3518 TestApplication application;
3520 Actor actor = Actor::New();
3523 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3525 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3526 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3527 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3528 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3530 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3531 actor.SetProperty( Actor::Property::PADDING, padding2 );
3533 padding = actor.GetProperty<Vector4>( Actor::Property::PADDING );
3535 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3536 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3537 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3538 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3543 int UtcDaliActorSetMinimumSize(void)
3545 TestApplication application;
3547 Actor actor = Actor::New();
3549 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3551 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3552 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3554 Vector2 size2( 1.0f, 2.0f );
3555 actor.SetProperty( Actor::Property::MINIMUM_SIZE, size2 );
3557 size = actor.GetProperty< Vector2 >( Actor::Property::MINIMUM_SIZE );
3559 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3560 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3565 int UtcDaliActorSetMaximumSize(void)
3567 TestApplication application;
3569 Actor actor = Actor::New();
3571 Vector2 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3573 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3574 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3576 Vector2 size2( 1.0f, 2.0f );
3577 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, size2 );
3579 size = actor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE );
3581 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3582 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3587 int UtcDaliActorOnRelayoutSignal(void)
3589 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3591 TestApplication application;
3594 gOnRelayoutCallBackCalled = false;
3595 gActorNamesRelayout.clear();
3597 Actor actor = Actor::New();
3598 actor.SetProperty( Actor::Property::NAME, "actor" );
3599 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3602 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3604 // Add actor to stage
3605 application.GetScene().Add( actor );
3607 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3608 actor.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 2.0 ) );
3610 // Flush the queue and render once
3611 application.SendNotification();
3612 application.Render();
3614 // OnRelayout emitted
3615 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3616 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3621 int UtcDaliActorGetHierachyDepth(void)
3623 TestApplication application;
3624 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3627 /* Build tree of actors:
3637 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3639 Integration::Scene stage( application.GetScene() );
3641 Actor actorA = Actor::New();
3642 Actor actorB = Actor::New();
3643 Actor actorC = Actor::New();
3644 Actor actorD = Actor::New();
3645 Actor actorE = Actor::New();
3646 Actor actorF = Actor::New();
3648 //Test that root actor has depth equal 0
3649 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3651 //Test actors return depth -1 when not connected to the tree
3652 DALI_TEST_EQUALS( -1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3653 DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3654 DALI_TEST_EQUALS( -1, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3655 DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3656 DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3657 DALI_TEST_EQUALS( -1, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3659 //Create the hierarchy
3660 stage.Add( actorA );
3661 actorA.Add( actorB );
3662 actorA.Add( actorC );
3663 actorB.Add( actorD );
3664 actorB.Add( actorE );
3665 actorC.Add( actorF );
3667 //Test actors return correct depth
3668 DALI_TEST_EQUALS( 1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3669 DALI_TEST_EQUALS( 2, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3670 DALI_TEST_EQUALS( 2, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3671 DALI_TEST_EQUALS( 3, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3672 DALI_TEST_EQUALS( 3, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3673 DALI_TEST_EQUALS( 3, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3675 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3676 actorA.Remove( actorB );
3678 DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3679 DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3680 DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3682 //Removing actorA from the stage. All actors should have depth equal -1
3683 stage.Remove( actorA );
3685 DALI_TEST_EQUALS( -1, actorA.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3686 DALI_TEST_EQUALS( -1, actorB.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3687 DALI_TEST_EQUALS( -1, actorC.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3688 DALI_TEST_EQUALS( -1, actorD.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3689 DALI_TEST_EQUALS( -1, actorE.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3690 DALI_TEST_EQUALS( -1, actorF.GetProperty< int >( Actor::Property::HIERARCHY_DEPTH ), TEST_LOCATION );
3695 int UtcDaliActorAnchorPointPropertyAsString(void)
3697 TestApplication application;
3699 Actor actor = Actor::New();
3701 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3702 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3704 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3705 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3707 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3708 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3710 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3711 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3713 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3714 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER, TEST_LOCATION );
3716 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3717 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3719 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3720 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3722 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3723 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3725 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3726 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3728 // Invalid should not change anything
3729 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3730 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3735 int UtcDaliActorParentOriginPropertyAsString(void)
3737 TestApplication application;
3739 Actor actor = Actor::New();
3741 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3742 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3744 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3745 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3747 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3748 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3750 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3751 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3753 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3754 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER, TEST_LOCATION );
3756 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3757 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3759 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3760 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3762 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3763 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3765 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3766 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3768 // Invalid should not change anything
3769 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3770 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3775 int UtcDaliActorColorModePropertyAsString(void)
3777 TestApplication application;
3779 Actor actor = Actor::New();
3781 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3782 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3784 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3785 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3787 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3788 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3790 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3791 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3793 // Invalid should not change anything
3794 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3795 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3800 int UtcDaliActorDrawModePropertyAsString(void)
3802 TestApplication application;
3804 Actor actor = Actor::New();
3806 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3807 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3809 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3810 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3812 // Invalid should not change anything
3813 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3814 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3819 int UtcDaliActorColorModePropertyAsEnum(void)
3821 TestApplication application;
3823 Actor actor = Actor::New();
3825 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3826 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_COLOR, TEST_LOCATION );
3828 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3829 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
3831 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3832 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3834 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3835 DALI_TEST_EQUALS( actor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3840 int UtcDaliActorDrawModePropertyAsEnum(void)
3842 TestApplication application;
3844 Actor actor = Actor::New();
3846 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3847 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::NORMAL, TEST_LOCATION );
3849 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3850 DALI_TEST_EQUALS( actor.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
3855 int UtcDaliActorAddRendererP(void)
3857 tet_infoline("Testing Actor::AddRenderer");
3858 TestApplication application;
3860 Actor actor = Actor::New();
3862 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3864 Geometry geometry = CreateQuadGeometry();
3865 Shader shader = CreateShader();
3866 Renderer renderer = Renderer::New(geometry, shader);
3868 actor.AddRenderer( renderer );
3869 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3870 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3875 int UtcDaliActorAddRendererN01(void)
3877 tet_infoline("Testing Actor::AddRenderer");
3878 TestApplication application;
3880 Actor actor = Actor::New();
3886 actor.AddRenderer( renderer );
3887 tet_printf("Assertion test failed - no Exception\n" );
3888 tet_result(TET_FAIL);
3890 catch(Dali::DaliException& e)
3892 DALI_TEST_PRINT_ASSERT( e );
3893 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3894 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3898 tet_printf("Assertion test failed - wrong Exception\n" );
3899 tet_result(TET_FAIL);
3905 int UtcDaliActorAddRendererN02(void)
3907 tet_infoline( "UtcDaliActorAddRendererN02" );
3913 TestApplication application;
3915 Geometry geometry = CreateQuadGeometry();
3916 Shader shader = CreateShader();
3917 renderer = Renderer::New( geometry, shader );
3919 actor = Actor::New();
3922 // try illegal AddRenderer
3925 actor.AddRenderer( renderer );
3926 tet_printf( "Assertion test failed - no Exception\n" );
3927 tet_result( TET_FAIL );
3929 catch( Dali::DaliException& e )
3931 DALI_TEST_PRINT_ASSERT( e );
3932 DALI_TEST_ASSERT( e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION );
3936 tet_printf( "Assertion test failed - wrong Exception\n" );
3937 tet_result( TET_FAIL );
3943 int UtcDaliActorAddRendererOnStage(void)
3945 tet_infoline("Testing Actor::AddRenderer");
3946 TestApplication application;
3948 Actor actor = Actor::New();
3949 application.GetScene().Add(actor);
3951 application.SendNotification();
3952 application.Render(0);
3954 Geometry geometry = CreateQuadGeometry();
3955 Shader shader = CreateShader();
3956 Renderer renderer = Renderer::New(geometry, shader);
3958 application.SendNotification();
3959 application.Render(0);
3963 actor.AddRenderer( renderer );
3964 tet_result(TET_PASS);
3968 tet_result(TET_FAIL);
3974 int UtcDaliActorRemoveRendererP1(void)
3976 tet_infoline("Testing Actor::RemoveRenderer");
3977 TestApplication application;
3979 Actor actor = Actor::New();
3981 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3984 Geometry geometry = CreateQuadGeometry();
3985 Shader shader = CreateShader();
3986 Renderer renderer = Renderer::New(geometry, shader);
3988 actor.AddRenderer( renderer );
3989 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3990 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3992 application.SendNotification();
3993 application.Render();
3997 Renderer renderer = actor.GetRendererAt(0);
3998 actor.RemoveRenderer(renderer);
3999 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4001 application.SendNotification();
4002 application.Render();
4005 // Call one final time to ensure that the renderer is actually removed after
4006 // the handle goes out of scope, and excercises the deletion code path in
4007 // scene graph and render.
4008 application.SendNotification();
4009 application.Render();
4014 int UtcDaliActorRemoveRendererP2(void)
4016 tet_infoline("Testing Actor::RemoveRenderer");
4017 TestApplication application;
4019 Actor actor = Actor::New();
4021 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4023 Geometry geometry = CreateQuadGeometry();
4024 Shader shader = CreateShader();
4025 Renderer renderer = Renderer::New(geometry, shader);
4027 actor.AddRenderer( renderer );
4028 application.SendNotification();
4029 application.Render();
4031 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4032 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4034 actor.RemoveRenderer(0);
4035 application.SendNotification();
4036 application.Render();
4038 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4040 // Shut down whilst holding onto the renderer handle.
4045 int UtcDaliActorRemoveRendererN(void)
4047 tet_infoline("Testing Actor::RemoveRenderer");
4048 TestApplication application;
4050 Actor actor = Actor::New();
4052 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4054 Geometry geometry = CreateQuadGeometry();
4055 Shader shader = CreateShader();
4056 Renderer renderer = Renderer::New(geometry, shader);
4058 actor.AddRenderer( renderer );
4059 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4060 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4062 actor.RemoveRenderer(10);
4063 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4064 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4069 // Clipping test helper functions:
4070 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4072 Texture image = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
4073 Actor actor = CreateRenderableActor( image );
4075 // Setup dimensions and position so actor is not skipped by culling.
4076 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4077 actor.SetProperty( Actor::Property::SIZE, Vector2( width, height ) );
4078 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4079 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4084 Actor CreateActorWithContent16x16()
4086 return CreateActorWithContent( 16, 16 );
4089 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4091 enabledDisableTrace.Reset();
4092 stencilTrace.Reset();
4093 enabledDisableTrace.Enable( true );
4094 stencilTrace.Enable( true );
4096 application.SendNotification();
4097 application.Render();
4099 enabledDisableTrace.Enable( false );
4100 stencilTrace.Enable( false );
4103 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4105 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4107 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4108 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4109 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4110 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4113 int UtcDaliActorPropertyClippingP(void)
4115 // This test checks the clippingMode property.
4116 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4117 TestApplication application;
4119 Actor actor = Actor::New();
4121 // Check default clippingEnabled value.
4122 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4125 bool getValueResult = getValue.Get( value );
4126 DALI_TEST_CHECK( getValueResult );
4128 if( getValueResult )
4130 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4133 // Check setting the property to the stencil mode.
4134 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4136 // Check the new value was set.
4137 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4138 getValueResult = getValue.Get( value );
4139 DALI_TEST_CHECK( getValueResult );
4141 if( getValueResult )
4143 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4146 // Check setting the property to the scissor mode.
4147 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4149 // Check the new value was set.
4150 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4151 getValueResult = getValue.Get( value );
4152 DALI_TEST_CHECK( getValueResult );
4154 if( getValueResult )
4156 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4161 int UtcDaliActorPropertyClippingN(void)
4163 // Negative test case for Clipping.
4164 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4165 TestApplication application;
4167 Actor actor = Actor::New();
4169 // Check default clippingEnabled value.
4170 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4173 bool getValueResult = getValue.Get( value );
4174 DALI_TEST_CHECK( getValueResult );
4176 if( getValueResult )
4178 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4181 // Check setting an invalid property value won't change the current property value.
4182 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4184 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4185 getValueResult = getValue.Get( value );
4186 DALI_TEST_CHECK( getValueResult );
4188 if( getValueResult )
4190 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4196 int UtcDaliActorPropertyClippingActor(void)
4198 // This test checks that an actor is correctly setup for clipping.
4199 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4200 TestApplication application;
4202 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4203 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4204 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4205 size_t startIndex = 0u;
4207 // Create a clipping actor.
4208 Actor actorDepth1Clip = CreateActorWithContent16x16();
4209 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4210 application.GetScene().Add( actorDepth1Clip );
4212 // Gather the call trace.
4213 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4215 // Check we are writing to the color buffer.
4216 CheckColorMask( glAbstraction, true );
4218 // Check the stencil buffer was enabled.
4219 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4221 // Check the stencil buffer was cleared.
4222 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4224 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4225 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4226 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4227 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4232 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4234 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4235 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4236 TestApplication application;
4238 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4239 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4240 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4241 size_t startIndex = 0u;
4243 // Create a clipping actor.
4244 Actor actorDepth1Clip = CreateActorWithContent16x16();
4245 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4246 application.GetScene().Add( actorDepth1Clip );
4248 // Gather the call trace.
4249 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4251 // Check we are writing to the color buffer.
4252 CheckColorMask( glAbstraction, true );
4254 // Check the stencil buffer was enabled.
4255 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4257 // Check the stencil buffer was cleared.
4258 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4260 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4261 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4262 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4263 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4265 // Now disable the clipping
4266 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4268 // Gather the call trace.
4269 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4271 // Check the stencil buffer was disabled.
4272 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4274 // Ensure all values in stencil-mask are set to 1.
4276 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4281 int UtcDaliActorPropertyClippingNestedChildren(void)
4283 // This test checks that a hierarchy of actors are clipped correctly by
4284 // writing to and reading from the correct bit-planes of the stencil buffer.
4285 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4286 TestApplication application;
4287 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4288 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4289 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4291 // Create a clipping actor.
4292 Actor actorDepth1Clip = CreateActorWithContent16x16();
4293 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4294 application.GetScene().Add( actorDepth1Clip );
4296 // Create a child actor.
4297 Actor childDepth2 = CreateActorWithContent16x16();
4298 actorDepth1Clip.Add( childDepth2 );
4300 // Create another clipping actor.
4301 Actor childDepth2Clip = CreateActorWithContent16x16();
4302 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4303 childDepth2.Add( childDepth2Clip );
4305 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4306 // This tests the sort algorithm.
4307 Actor childDepth3 = CreateActorWithContent16x16();
4308 childDepth2Clip.Add( childDepth3 );
4309 Actor childDepth4 = CreateActorWithContent16x16();
4310 childDepth3.Add( childDepth4 );
4312 // Gather the call trace.
4313 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4315 // Check we are writing to the color buffer.
4316 CheckColorMask( glAbstraction, true );
4318 // Check the stencil buffer was enabled.
4319 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4321 // Perform the test twice, once for 2D layer, and once for 3D.
4322 for( unsigned int i = 0u ; i < 2u; ++i )
4324 size_t startIndex = 0u;
4326 // Check the stencil buffer was cleared.
4327 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4329 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4330 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4331 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4332 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4334 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4335 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4336 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4338 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4339 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4340 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4341 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4343 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4344 // (Both must be set to pass the check).
4345 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4346 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4348 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4351 application.GetScene().GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
4352 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4359 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4361 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4362 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4363 TestApplication application;
4364 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4365 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4367 /* We create a small tree of actors as follows:
4371 Clipping enabled -> B D
4375 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4378 for( int i = 0; i < 5; ++i )
4380 Texture image = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u );
4381 Actor actor = CreateRenderableActor( image );
4383 // Setup dimensions and position so actor is not skipped by culling.
4384 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4385 actor.SetProperty( Actor::Property::SIZE, Vector2( 16.0f, 16.0f ) );
4389 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4393 float b = i > 2 ? 1.0f : -1.0f;
4394 actor.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4400 // Enable clipping on the actor at the top of the left branch.
4401 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4403 // Build the scene graph.
4404 application.GetScene().Add( actors[0] );
4407 actors[0].Add( actors[1] );
4408 actors[1].Add( actors[2] );
4411 actors[0].Add( actors[3] );
4412 actors[3].Add( actors[4] );
4414 // Gather the call trace.
4415 enabledDisableTrace.Reset();
4416 enabledDisableTrace.Enable( true );
4417 application.SendNotification();
4418 application.Render();
4419 enabledDisableTrace.Enable( false );
4421 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4423 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
4424 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4426 size_t startIndex = 0u;
4427 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4428 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4429 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4431 // Swap the clipping actor from top of left branch to top of right branch.
4432 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4433 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4435 // Gather the call trace.
4436 enabledDisableTrace.Reset();
4437 enabledDisableTrace.Enable( true );
4438 application.SendNotification();
4439 application.Render();
4440 enabledDisableTrace.Enable( false );
4442 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4443 // This proves the draw order has remained the same.
4445 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4446 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4451 int UtcDaliActorPropertyScissorClippingActor(void)
4453 // This test checks that an actor is correctly setup for clipping.
4454 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4455 TestApplication application;
4457 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4458 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4459 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4461 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4462 const Vector2 imageSize( 16.0f, 16.0f );
4464 // Create a clipping actor.
4465 Actor clippingActorA = CreateActorWithContent16x16();
4466 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4467 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4468 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
4469 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
4470 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4471 application.GetScene().Add( clippingActorA );
4473 // Gather the call trace.
4474 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4476 // Check we are writing to the color buffer.
4477 CheckColorMask( glAbstraction, true );
4479 // Check scissor test was enabled.
4480 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4482 // Check the scissor was set, and the coordinates are correct.
4483 std::stringstream compareParametersString;
4484 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4485 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4487 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
4488 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT );
4490 // Gather the call trace.
4491 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4493 // Check the scissor was set, and the coordinates are correct.
4494 compareParametersString.str( std::string() );
4495 compareParametersString.clear();
4496 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4497 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4502 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4504 // This test checks that an actor is correctly setup for clipping.
4505 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4506 TestApplication application;
4509 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4510 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4511 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4513 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4514 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4515 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4517 // Create a clipping actors.
4518 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4519 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4521 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4522 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4523 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4525 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4526 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4527 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4529 clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4530 clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4532 application.GetScene().Add( clippingActorA );
4533 application.GetScene().Add( clippingActorB );
4535 // Gather the call trace.
4536 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4538 // Check we are writing to the color buffer.
4539 CheckColorMask( glAbstraction, true );
4541 // Check scissor test was enabled.
4542 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4544 // Check the scissor was set, and the coordinates are correct.
4545 std::stringstream compareParametersString;
4547 std::string clipA( "0, 500, 480, 200" );
4548 std::string clipB( "0, 380, 480, 40" );
4550 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4551 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4556 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4558 // This test checks that an actor is correctly setup for clipping.
4559 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4560 TestApplication application;
4562 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4563 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4564 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4566 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4567 const Vector2 imageSize( 16.0f, 16.0f );
4569 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4571 A is drawn first - with scissor clipping on
4572 B is drawn second - also with scissor clipping on
4573 C is the generated clipping region, the intersection ( A ∩ B )
4577 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4578 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4579 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4583 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4586 // Create a clipping actor.
4587 Actor clippingActorA = CreateActorWithContent16x16();
4588 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4589 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4590 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4591 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4592 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4593 application.GetScene().Add( clippingActorA );
4595 // Create a child clipping actor.
4596 Actor clippingActorB = CreateActorWithContent16x16();
4597 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4598 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4599 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4600 clippingActorA.Add( clippingActorB );
4602 // positionModifiers is an array of positions to position B around.
4603 // expect is an array of expected scissor clip coordinate results.
4604 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4605 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4607 // Loop through each overlap combination.
4608 for( unsigned int test = 0u; test < 4u; ++test )
4610 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4611 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4612 clippingActorB.SetProperty( Actor::Property::POSITION, Vector2( position.x, position.y ));
4614 // Gather the call trace.
4615 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4617 // Check we are writing to the color buffer.
4618 CheckColorMask( glAbstraction, true );
4620 // Check scissor test was enabled.
4621 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4623 // Check the scissor was set, and the coordinates are correct.
4624 const Vector4& expectResults( expect[test] );
4625 std::stringstream compareParametersString;
4626 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4627 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4633 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4635 // This test checks that an actor is correctly setup for clipping.
4636 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4637 TestApplication application;
4639 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4640 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4641 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4643 /* Create a nest of 2 scissors and siblings of the parent.
4653 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4654 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4655 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4656 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4657 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4658 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4660 // Create a clipping actors.
4661 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4662 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4663 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4664 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4665 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4667 clippingActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4668 clippingActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4669 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4671 clippingActorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4672 clippingActorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4673 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4675 clippingActorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4676 clippingActorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4677 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4679 clippingActorD.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4680 clippingActorD.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4681 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4683 clippingActorE.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
4684 clippingActorE.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
4686 clippingActorA.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, -200.0f, 0.0f ));
4687 clippingActorB.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4688 clippingActorC.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 100.0f, 0.0f ));
4689 clippingActorD.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4690 clippingActorE.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
4692 application.GetScene().Add( clippingActorA );
4693 clippingActorA.Add( clippingActorB );
4694 application.GetScene().Add( clippingActorC );
4695 application.GetScene().Add( clippingActorD );
4696 clippingActorD.Add( clippingActorE );
4698 // Gather the call trace.
4699 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4701 // Check we are writing to the color buffer.
4702 CheckColorMask( glAbstraction, true );
4704 // Check scissor test was enabled.
4705 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4707 // Check the scissor was set, and the coordinates are correct.
4708 std::string clipA( "0, 500, 480, 200" );
4709 std::string clipB( "0, 580, 480, 40" );
4710 std::string clipC( "0, 200, 480, 200" );
4711 std::string clipD( "0, 300, 480, 200" );
4713 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4714 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4715 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4716 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4717 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4722 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4724 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4725 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4726 TestApplication application;
4728 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4729 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4730 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4732 // Create a clipping actor.
4733 Actor actorDepth1Clip = CreateActorWithContent16x16();
4734 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4735 application.GetScene().Add( actorDepth1Clip );
4737 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4738 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4740 // Gather the call trace.
4741 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4743 // Check we are writing to the color buffer.
4744 CheckColorMask( glAbstraction, true );
4746 // Check the stencil buffer was not enabled.
4747 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4749 // Check stencil functions are not called.
4750 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4751 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4752 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4754 // Check that scissor clipping is overriden by the renderer properties.
4755 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4757 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4759 // Gather the call trace.
4760 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4762 // Check the stencil buffer was not enabled.
4763 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4765 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4770 int UtcDaliGetPropertyN(void)
4772 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4773 TestApplication application;
4775 Actor actor = Actor::New();
4777 unsigned int propertyCount = actor.GetPropertyCount();
4778 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4782 int UtcDaliActorRaiseLower(void)
4784 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4786 TestApplication application;
4788 Debug::Filter::SetGlobalLogLevel( Debug::Verbose );
4790 Integration::Scene stage( application.GetScene() );
4792 Actor actorA = Actor::New();
4793 Actor actorB = Actor::New();
4794 Actor actorC = Actor::New();
4796 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4797 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4799 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4800 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4802 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4803 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4805 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4806 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4808 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4809 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4811 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4812 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4814 stage.Add( actorA );
4815 stage.Add( actorB );
4816 stage.Add( actorC );
4818 ResetTouchCallbacks();
4820 application.SendNotification();
4821 application.Render();
4823 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4824 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4825 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4827 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4828 // Only top actor will get touched.
4829 actorA.TouchSignal().Connect( TestTouchCallback );
4830 actorB.TouchSignal().Connect( TestTouchCallback2 );
4831 actorC.TouchSignal().Connect( TestTouchCallback3 );
4833 // Connect ChildOrderChangedSignal
4834 bool orderChangedSignal( false );
4835 Actor orderChangedActor;
4836 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4837 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4839 Dali::Integration::Point point;
4840 point.SetDeviceId( 1 );
4841 point.SetState( PointState::DOWN );
4842 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4843 Dali::Integration::TouchEvent touchEvent;
4844 touchEvent.AddPoint( point );
4846 application.ProcessEvent( touchEvent );
4848 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4849 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4850 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4852 ResetTouchCallbacks();
4854 tet_printf( "Testing Raising of Actor\n" );
4856 int preActorOrder( 0 );
4857 int postActorOrder( 0 );
4859 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4860 value.Get( preActorOrder );
4862 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4864 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4865 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4867 // Ensure sort order is calculated before next touch event
4868 application.SendNotification();
4870 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4871 value.Get( postActorOrder );
4873 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4875 application.ProcessEvent( touchEvent );
4877 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4878 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4879 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4881 ResetTouchCallbacks();
4883 tet_printf( "Testing Lowering of Actor\n" );
4885 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4886 value.Get( preActorOrder );
4888 orderChangedSignal = false;
4890 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
4892 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
4893 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
4895 application.SendNotification(); // ensure sort order calculated before next touch event
4897 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4898 value.Get( postActorOrder );
4900 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4902 application.ProcessEvent( touchEvent );
4904 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4905 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4906 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4908 ResetTouchCallbacks();
4910 Debug::Filter::SetGlobalLogLevel( Debug::NoLogging );
4915 int UtcDaliActorRaiseToTopLowerToBottom(void)
4917 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4919 TestApplication application;
4921 Integration::Scene stage( application.GetScene() );
4923 Actor actorA = Actor::New();
4924 Actor actorB = Actor::New();
4925 Actor actorC = Actor::New();
4927 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4928 // enables checking of which actor the uniform is assigned too
4929 Shader shaderA = CreateShader();
4930 shaderA.RegisterProperty( "uRendererColor",1.f);
4932 Shader shaderB = CreateShader();
4933 shaderB.RegisterProperty( "uRendererColor", 2.f );
4935 Shader shaderC = CreateShader();
4936 shaderC.RegisterProperty( "uRendererColor", 3.f );
4938 Geometry geometry = CreateQuadGeometry();
4940 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4941 Renderer rendererA = Renderer::New(geometry, shaderA);
4942 actorA.AddRenderer(rendererA);
4944 Renderer rendererB = Renderer::New(geometry, shaderB);
4945 actorB.AddRenderer(rendererB);
4947 Renderer rendererC = Renderer::New(geometry, shaderC);
4948 actorC.AddRenderer(rendererC);
4950 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4951 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4953 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4954 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4956 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
4957 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
4959 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4960 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4962 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4963 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4965 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4966 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4968 stage.Add( actorA );
4969 stage.Add( actorB );
4970 stage.Add( actorC );
4972 ResetTouchCallbacks();
4974 // Connect ChildOrderChangedSignal
4975 bool orderChangedSignal( false );
4976 Actor orderChangedActor;
4977 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
4978 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
4980 // Set up gl abstraction trace so can query the set uniform order
4981 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4982 glAbstraction.EnableSetUniformCallTrace(true);
4983 glAbstraction.ResetSetUniformCallStack();
4985 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4987 application.SendNotification();
4988 application.Render();
4990 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4993 // Test order of uniforms in stack
4994 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4995 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4996 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4998 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5000 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5002 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5003 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5004 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5006 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5007 // Only top actor will get touched.
5008 actorA.TouchSignal().Connect( TestTouchCallback );
5009 actorB.TouchSignal().Connect( TestTouchCallback2 );
5010 actorC.TouchSignal().Connect( TestTouchCallback3 );
5012 Dali::Integration::Point point;
5013 point.SetDeviceId( 1 );
5014 point.SetState( PointState::DOWN );
5015 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5016 Dali::Integration::TouchEvent touchEvent;
5017 touchEvent.AddPoint( point );
5019 application.ProcessEvent( touchEvent );
5021 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5022 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5023 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5025 ResetTouchCallbacks();
5027 tet_printf( "RaiseToTop ActorA\n" );
5029 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5030 actorA.RaiseToTop();
5031 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5032 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5034 application.SendNotification(); // ensure sorting order is calculated before next touch event
5036 application.ProcessEvent( touchEvent );
5038 glAbstraction.ResetSetUniformCallStack();
5039 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5041 application.SendNotification();
5042 application.Render();
5044 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5046 // Test order of uniforms in stack
5047 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5048 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5049 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5051 tet_infoline( "Testing A above C and B at bottom\n" );
5052 bool ACB = ( indexA > indexC) && ( indexC > indexB );
5054 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
5056 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5057 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5058 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5060 ResetTouchCallbacks();
5062 tet_printf( "RaiseToTop ActorB\n" );
5064 orderChangedSignal = false;
5066 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5067 actorB.RaiseToTop();
5068 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5069 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5071 application.SendNotification(); // Ensure sort order is calculated before next touch event
5073 application.ProcessEvent( touchEvent );
5075 glAbstraction.ResetSetUniformCallStack();
5076 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5078 application.SendNotification();
5079 application.Render();
5081 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5083 // Test order of uniforms in stack
5084 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5085 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5086 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5088 tet_infoline( "Testing B above A and C at bottom\n" );
5089 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5091 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5093 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5094 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5095 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5097 ResetTouchCallbacks();
5099 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5101 orderChangedSignal = false;
5103 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5104 actorA.LowerToBottom();
5105 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5106 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5108 application.SendNotification();
5109 application.Render();
5111 orderChangedSignal = false;
5113 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5114 actorB.LowerToBottom();
5115 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5116 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5118 application.SendNotification();
5119 application.Render();
5121 application.ProcessEvent( touchEvent );
5123 glAbstraction.ResetSetUniformCallStack();
5124 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5126 application.SendNotification();
5127 application.Render();
5129 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5131 // Test order of uniforms in stack
5132 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5133 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5134 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5136 tet_infoline( "Testing C above A and B at bottom\n" );
5137 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5139 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5141 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5142 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5143 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5145 ResetTouchCallbacks();
5150 int UtcDaliActorRaiseAbove(void)
5152 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5154 TestApplication application;
5156 Integration::Scene stage( application.GetScene() );
5158 Actor actorA = Actor::New();
5159 Actor actorB = Actor::New();
5160 Actor actorC = Actor::New();
5162 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5163 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5165 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5166 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5168 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5169 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5171 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5172 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5174 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5175 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5177 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5178 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5180 stage.Add( actorA );
5181 stage.Add( actorB );
5182 stage.Add( actorC );
5184 ResetTouchCallbacks();
5186 application.SendNotification();
5187 application.Render();
5189 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5190 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5191 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5193 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5194 // Only top actor will get touched.
5195 actorA.TouchSignal().Connect( TestTouchCallback );
5196 actorB.TouchSignal().Connect( TestTouchCallback2 );
5197 actorC.TouchSignal().Connect( TestTouchCallback3 );
5199 bool orderChangedSignal( false );
5200 Actor orderChangedActor;
5201 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5202 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5204 Dali::Integration::Point point;
5205 point.SetDeviceId( 1 );
5206 point.SetState( PointState::DOWN );
5207 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5208 Dali::Integration::TouchEvent touchEvent;
5209 touchEvent.AddPoint( point );
5211 application.ProcessEvent( touchEvent );
5213 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5214 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5215 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5217 ResetTouchCallbacks();
5219 tet_printf( "Raise actor B Above Actor C\n" );
5221 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5222 actorB.RaiseAbove( actorC );
5223 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5224 DALI_TEST_EQUALS( orderChangedActor, actorB, TEST_LOCATION );
5226 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5227 application.SendNotification();
5228 application.ProcessEvent( touchEvent );
5230 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5231 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5232 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5234 ResetTouchCallbacks();
5236 tet_printf( "Raise actor A Above Actor B\n" );
5238 orderChangedSignal = false;
5240 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5241 actorA.RaiseAbove( actorB );
5242 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5243 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5245 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5246 application.SendNotification();
5248 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5250 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5251 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5252 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5254 ResetTouchCallbacks();
5259 int UtcDaliActorLowerBelow(void)
5261 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5263 TestApplication application;
5265 Integration::Scene stage( application.GetScene() );
5267 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5268 // enables checking of which actor the uniform is assigned too
5269 Shader shaderA = CreateShader();
5270 shaderA.RegisterProperty( "uRendererColor",1.f);
5272 Shader shaderB = CreateShader();
5273 shaderB.RegisterProperty( "uRendererColor", 2.f );
5275 Shader shaderC = CreateShader();
5276 shaderC.RegisterProperty( "uRendererColor", 3.f );
5278 Actor actorA = Actor::New();
5279 Actor actorB = Actor::New();
5280 Actor actorC = Actor::New();
5282 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5283 Geometry geometry = CreateQuadGeometry();
5285 Renderer rendererA = Renderer::New(geometry, shaderA);
5286 actorA.AddRenderer(rendererA);
5288 Renderer rendererB = Renderer::New(geometry, shaderB);
5289 actorB.AddRenderer(rendererB);
5291 Renderer rendererC = Renderer::New(geometry, shaderC);
5292 actorC.AddRenderer(rendererC);
5294 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5295 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5297 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5298 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5300 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5301 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5303 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5304 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5306 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5307 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5309 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5310 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5312 Actor container = Actor::New();
5313 container.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5314 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5315 stage.Add( container );
5317 container.Add( actorA );
5318 container.Add( actorB );
5319 container.Add( actorC );
5321 ResetTouchCallbacks();
5323 // Connect ChildOrderChangedSignal
5324 bool orderChangedSignal( false );
5325 Actor orderChangedActor;
5326 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5327 DevelActor::ChildOrderChangedSignal( container ).Connect( &application, f ) ;
5329 // Set up gl abstraction trace so can query the set uniform order
5330 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5331 glAbstraction.EnableSetUniformCallTrace(true);
5332 glAbstraction.ResetSetUniformCallStack();
5333 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5335 glAbstraction.ResetSetUniformCallStack();
5337 application.SendNotification();
5338 application.Render();
5340 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5342 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5344 // Test order of uniforms in stack
5345 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5346 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5347 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5349 tet_infoline( "Testing C above B and A at bottom\n" );
5350 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5352 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5354 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5355 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5356 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5358 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5359 // Only top actor will get touched.
5360 actorA.TouchSignal().Connect( TestTouchCallback );
5361 actorB.TouchSignal().Connect( TestTouchCallback2 );
5362 actorC.TouchSignal().Connect( TestTouchCallback3 );
5364 Dali::Integration::Point point;
5365 point.SetDeviceId( 1 );
5366 point.SetState( PointState::DOWN );
5367 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5368 Dali::Integration::TouchEvent touchEvent;
5369 touchEvent.AddPoint( point );
5371 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5373 application.ProcessEvent( touchEvent );
5375 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5376 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5377 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5379 ResetTouchCallbacks();
5381 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" );
5383 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5384 actorC.LowerBelow( actorB );
5385 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5386 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5388 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5389 application.SendNotification();
5390 application.Render();
5392 application.ProcessEvent( touchEvent ); // touch event
5394 glAbstraction.ResetSetUniformCallStack();
5395 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5397 application.SendNotification();
5398 application.Render();
5400 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5402 // Test order of uniforms in stack
5403 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5404 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5405 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5407 tet_infoline( "Testing render order is A, C, B" );
5408 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5409 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5411 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5412 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5413 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5415 ResetTouchCallbacks();
5417 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5419 orderChangedSignal = false;
5421 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5422 actorC.LowerBelow( actorA );
5423 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5424 DALI_TEST_EQUALS( orderChangedActor, actorC, TEST_LOCATION );
5426 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5427 application.SendNotification();
5428 application.Render();
5430 application.ProcessEvent( touchEvent );
5432 glAbstraction.ResetSetUniformCallStack();
5433 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5435 application.Render();
5436 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5438 // Test order of uniforms in stack
5439 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5440 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5441 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5443 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5444 DALI_TEST_EQUALS( indexB > indexA, 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 B below Actor C leaving A on top\n" );
5454 orderChangedSignal = false;
5456 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5457 actorB.LowerBelow( actorC );
5458 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5459 DALI_TEST_EQUALS( orderChangedActor, actorB, 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( indexC > indexB, true, TEST_LOCATION );
5479 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5485 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5487 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5489 TestApplication application;
5491 Integration::Scene stage( application.GetScene() );
5493 Actor parentA = Actor::New();
5494 Actor parentB = Actor::New();
5495 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5496 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5497 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5498 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5500 parentA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5501 parentA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5503 parentB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5504 parentB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5506 stage.Add( parentA );
5507 stage.Add( parentB );
5509 Actor actorA = Actor::New();
5510 Actor actorB = Actor::New();
5511 Actor actorC = Actor::New();
5513 parentA.Add( actorA );
5514 parentA.Add( actorB );
5516 tet_printf( "Actor C added to different parent from A and B \n" );
5517 parentB.Add( actorC );
5519 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5520 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5522 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5523 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5525 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5526 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5528 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5529 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5531 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5532 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5534 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5535 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5537 ResetTouchCallbacks();
5539 // Connect ChildOrderChangedSignal
5540 bool orderChangedSignal( false );
5541 Actor orderChangedActor;
5542 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5543 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5545 application.SendNotification();
5546 application.Render();
5548 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5549 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5550 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5552 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5553 // Only top actor will get touched.
5554 actorA.TouchSignal().Connect( TestTouchCallback );
5555 actorB.TouchSignal().Connect( TestTouchCallback2 );
5556 actorC.TouchSignal().Connect( TestTouchCallback3 );
5558 Dali::Integration::Point point;
5559 point.SetDeviceId( 1 );
5560 point.SetState( PointState::DOWN );
5561 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5562 Dali::Integration::TouchEvent touchEvent;
5563 touchEvent.AddPoint( point );
5565 application.ProcessEvent( touchEvent );
5567 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5568 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5569 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5571 ResetTouchCallbacks();
5573 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5575 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5576 actorA.RaiseAbove( actorC );
5577 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5579 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5580 application.SendNotification();
5582 application.ProcessEvent( touchEvent ); // touch event
5584 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5585 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5586 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5588 ResetTouchCallbacks();
5593 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5595 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5597 TestApplication application;
5599 Integration::Scene stage( application.GetScene() );
5601 Actor actorA = Actor::New();
5602 Actor actorB = Actor::New();
5603 Actor actorC = Actor::New();
5605 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5606 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5608 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5609 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5611 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5612 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5614 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5615 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5617 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5618 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5620 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5621 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5623 ResetTouchCallbacks();
5625 // Connect ChildOrderChangedSignal
5626 bool orderChangedSignal( false );
5627 Actor orderChangedActor;
5628 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5629 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5631 application.SendNotification();
5632 application.Render();
5634 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5635 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5636 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5638 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5639 // Only top actor will get touched.
5640 actorA.TouchSignal().Connect( TestTouchCallback );
5641 actorB.TouchSignal().Connect( TestTouchCallback2 );
5642 actorC.TouchSignal().Connect( TestTouchCallback3 );
5644 Dali::Integration::Point point;
5645 point.SetDeviceId( 1 );
5646 point.SetState( PointState::DOWN );
5647 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5648 Dali::Integration::TouchEvent touchEvent;
5649 touchEvent.AddPoint( point );
5651 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5653 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5654 actorA.RaiseAbove( actorC );
5655 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5657 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5658 application.SendNotification();
5660 application.ProcessEvent( touchEvent );
5662 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5664 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5665 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5666 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5668 ResetTouchCallbacks();
5670 orderChangedSignal = false;
5672 stage.Add ( actorB );
5673 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5675 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5676 actorA.LowerBelow( actorC );
5677 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5679 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5680 application.SendNotification();
5681 application.Render();
5683 application.ProcessEvent( touchEvent );
5685 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5686 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5687 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5688 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5690 ResetTouchCallbacks();
5692 orderChangedSignal = false;
5694 tet_printf( "Adding Actor A to stage, will be on top\n" );
5696 stage.Add ( actorA );
5697 application.SendNotification();
5698 application.Render();
5700 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5702 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5703 actorB.RaiseAbove( actorC );
5704 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5706 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5707 application.SendNotification();
5709 application.ProcessEvent( touchEvent );
5711 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5712 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5713 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5714 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5716 ResetTouchCallbacks();
5718 orderChangedSignal = false;
5720 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5722 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5723 actorA.LowerBelow( actorC );
5724 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5726 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5727 application.SendNotification();
5729 application.ProcessEvent( touchEvent );
5731 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5732 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5733 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5734 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5736 ResetTouchCallbacks();
5738 orderChangedSignal = false;
5740 stage.Add ( actorC );
5742 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5743 actorA.RaiseAbove( actorC );
5744 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5745 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5747 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5748 application.SendNotification();
5749 application.Render();
5751 application.ProcessEvent( touchEvent );
5753 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5754 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5755 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5756 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5761 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5763 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5765 TestApplication application;
5767 Integration::Scene stage( application.GetScene() );
5769 Actor actorA = Actor::New();
5770 Actor actorB = Actor::New();
5771 Actor actorC = Actor::New();
5773 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5774 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5776 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5777 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5779 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5780 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5782 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5783 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5785 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5786 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5788 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5789 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5791 ResetTouchCallbacks();
5793 // Connect ChildOrderChangedSignal
5794 bool orderChangedSignal( false );
5795 Actor orderChangedActor;
5796 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5797 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5799 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5800 // Only top actor will get touched.
5801 actorA.TouchSignal().Connect( TestTouchCallback );
5802 actorB.TouchSignal().Connect( TestTouchCallback2 );
5803 actorC.TouchSignal().Connect( TestTouchCallback3 );
5805 Dali::Integration::Point point;
5806 point.SetDeviceId( 1 );
5807 point.SetState( PointState::DOWN );
5808 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5809 Dali::Integration::TouchEvent touchEvent;
5810 touchEvent.AddPoint( point );
5812 stage.Add ( actorA );
5813 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5815 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5817 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5819 application.SendNotification();
5820 application.Render();
5822 application.ProcessEvent( touchEvent );
5824 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5826 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5827 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5828 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5830 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5831 ResetTouchCallbacks();
5833 orderChangedSignal = false;
5835 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5837 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5839 // Sort actor tree before next touch event
5840 application.SendNotification();
5841 application.Render();
5843 application.ProcessEvent( touchEvent );
5845 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5847 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5848 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5849 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5850 ResetTouchCallbacks();
5852 orderChangedSignal = false;
5854 tet_printf( "Lower actor C below B but C not parented\n" );
5856 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5858 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5860 // Sort actor tree before next touch event
5861 application.SendNotification();
5862 application.Render();
5864 application.ProcessEvent( touchEvent );
5866 tet_printf( "Not parented so Lower should show no effect\n" );
5868 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5869 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5870 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5871 ResetTouchCallbacks();
5873 orderChangedSignal = false;
5875 tet_printf( "Raise actor B to top\n" );
5877 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5878 actorB.RaiseToTop();
5879 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5881 // Sort actor tree before next touch event
5882 application.SendNotification();
5883 application.Render();
5885 application.ProcessEvent( touchEvent );
5887 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5889 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5890 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5891 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5892 ResetTouchCallbacks();
5894 orderChangedSignal = false;
5896 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5898 stage.Add ( actorB );
5900 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5902 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5903 actorC.LowerToBottom();
5904 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5906 application.SendNotification();
5907 application.Render();
5909 application.ProcessEvent( touchEvent );
5911 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5913 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5914 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5915 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5916 ResetTouchCallbacks();
5922 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5924 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5926 TestApplication application;
5928 Integration::Scene stage( application.GetScene() );
5930 Actor actorA = Actor::New();
5931 Actor actorB = Actor::New();
5932 Actor actorC = Actor::New();
5934 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5935 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5937 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5938 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5940 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
5941 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
5943 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5944 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5946 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5947 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5949 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5950 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5952 stage.Add( actorA );
5953 stage.Add( actorB );
5954 stage.Add( actorC );
5956 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5957 // Only top actor will get touched.
5958 actorA.TouchSignal().Connect( TestTouchCallback );
5959 actorB.TouchSignal().Connect( TestTouchCallback2 );
5960 actorC.TouchSignal().Connect( TestTouchCallback3 );
5962 ResetTouchCallbacks();
5964 // Connect ChildOrderChangedSignal
5965 bool orderChangedSignal( false );
5966 Actor orderChangedActor;
5967 ChildOrderChangedFunctor f( orderChangedSignal, orderChangedActor );
5968 DevelActor::ChildOrderChangedSignal( stage.GetRootLayer() ).Connect( &application, f ) ;
5970 application.SendNotification();
5971 application.Render();
5973 Dali::Integration::Point point;
5974 point.SetDeviceId( 1 );
5975 point.SetState( PointState::DOWN );
5976 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5977 Dali::Integration::TouchEvent touchEvent;
5978 touchEvent.AddPoint( point );
5980 application.ProcessEvent( touchEvent );
5982 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5983 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5984 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5986 ResetTouchCallbacks();
5988 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5990 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
5991 actorA.RaiseAbove( actorA );
5992 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
5993 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
5995 application.SendNotification();
5996 application.Render();
5998 application.ProcessEvent( touchEvent );
6000 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
6002 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
6003 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6004 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
6006 ResetTouchCallbacks();
6008 orderChangedSignal = false;
6010 DALI_TEST_EQUALS( orderChangedSignal, false, TEST_LOCATION );
6011 actorA.RaiseAbove( actorC );
6012 DALI_TEST_EQUALS( orderChangedSignal, true, TEST_LOCATION );
6013 DALI_TEST_EQUALS( orderChangedActor, actorA, TEST_LOCATION );
6015 application.SendNotification();
6016 application.Render();
6018 application.ProcessEvent( touchEvent );
6020 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
6021 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
6022 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
6023 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
6028 int UtcDaliActorGetScreenPosition(void)
6030 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
6032 TestApplication application;
6034 Integration::Scene stage( application.GetScene() );
6036 Actor actorA = Actor::New();
6037 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6039 Vector2 size2( 10.0f, 20.0f );
6040 actorA.SetProperty( Actor::Property::SIZE, size2 );
6042 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6044 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
6046 stage.Add( actorA );
6048 application.SendNotification();
6049 application.Render();
6051 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6052 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6054 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6055 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
6057 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6058 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6060 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
6062 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6064 application.SendNotification();
6065 application.Render();
6067 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6068 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6070 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6071 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
6073 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6074 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6076 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
6078 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6080 application.SendNotification();
6081 application.Render();
6083 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6084 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6086 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6087 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
6089 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6090 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6092 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
6094 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 0.0 ));
6096 application.SendNotification();
6097 application.Render();
6099 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6100 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6102 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
6103 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6105 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6106 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6108 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
6110 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 420.0 ));
6112 application.SendNotification();
6113 application.Render();
6115 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6116 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6118 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
6119 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
6121 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
6122 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
6124 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
6126 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6127 actorA.SetProperty( Actor::Property::POSITION, Vector2( 30.0, 30.0 ));
6129 Actor actorB = Actor::New();
6130 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6131 actorB.SetProperty( Actor::Property::SIZE, size2 );
6132 actorB.SetProperty( Actor::Property::POSITION, Vector2( 10.f, 10.f ));
6133 actorA.Add( actorB );
6135 actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6137 application.SendNotification();
6138 application.Render();
6140 actorScreenPosition = actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6142 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
6143 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
6148 int UtcDaliActorGetScreenPositionAfterScaling(void)
6150 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
6152 TestApplication application;
6154 Integration::Scene stage( application.GetScene() );
6156 Actor actorA = Actor::New();
6157 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6159 Vector2 size2( 10.0f, 20.0f );
6160 actorA.SetProperty( Actor::Property::SIZE, size2 );
6161 actorA.SetProperty( Actor::Property::SCALE, 1.5f );
6162 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6164 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
6166 stage.Add( actorA );
6168 application.SendNotification();
6169 application.Render();
6171 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6172 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6174 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6175 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6177 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
6178 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
6180 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
6182 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6184 application.SendNotification();
6185 application.Render();
6187 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6188 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6190 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6191 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6193 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
6194 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6199 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6201 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
6203 TestApplication application;
6205 Integration::Scene stage( application.GetScene() );
6207 Actor actorA = Actor::New();
6208 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6209 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6210 Vector2 size2( 10.0f, 20.0f );
6211 actorA.SetProperty( Actor::Property::SIZE, size2 );
6212 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6214 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6216 stage.Add( actorA );
6218 application.SendNotification();
6219 application.Render();
6221 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6222 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6224 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6225 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6227 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6228 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6230 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6232 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
6233 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6235 application.SendNotification();
6236 application.Render();
6238 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6239 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6241 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6242 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6244 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6245 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6251 int UtcDaliActorGetScreenPositionWithChildActors(void)
6253 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6255 TestApplication application;
6257 Integration::Scene stage( application.GetScene() );
6259 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6261 Actor actorA = Actor::New();
6262 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6263 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6264 Vector2 size1( 10.0f, 20.0f );
6265 actorA.SetProperty( Actor::Property::SIZE, size1 );
6266 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6268 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6270 Actor parentActorA = Actor::New();
6271 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6272 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6273 Vector2 size2( 30.0f, 60.0f );
6274 parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6275 parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6277 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6279 stage.Add( parentActorA );
6280 parentActorA.Add ( actorA );
6282 application.SendNotification();
6283 application.Render();
6285 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6286 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6288 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6289 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6291 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6292 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6294 tet_infoline( "Test 2\n");
6296 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6298 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6299 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
6301 application.SendNotification();
6302 application.Render();
6304 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6305 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6307 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6308 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6310 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6311 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6316 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6318 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6320 TestApplication application;
6322 Integration::Scene stage( application.GetScene() );
6324 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6326 Actor actorA = Actor::New();
6327 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6328 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6329 Vector2 size1( 10.0f, 20.0f );
6330 actorA.SetProperty( Actor::Property::SIZE, size1 );
6331 actorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6333 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6335 Actor parentActorA = Actor::New();
6336 parentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6337 parentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6338 Vector2 size2( 30.0f, 60.0f );
6339 parentActorA.SetProperty( Actor::Property::SIZE, size2 );
6340 parentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6342 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6344 Actor grandParentActorA = Actor::New();
6345 grandParentActorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT );
6346 grandParentActorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
6347 Vector2 size3( 60.0f, 120.0f );
6348 grandParentActorA.SetProperty( Actor::Property::SIZE, size3 );
6349 grandParentActorA.SetProperty( Actor::Property::POSITION, Vector2( 0.f, 0.f ));
6351 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6353 stage.Add( grandParentActorA );
6354 grandParentActorA.Add ( parentActorA );
6356 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6358 parentActorA.Add ( actorA );
6360 application.SendNotification();
6361 application.Render();
6363 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6364 Vector2 actorScreenPosition = actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >();
6366 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6367 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6369 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6370 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6375 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6377 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6379 TestApplication application;
6381 Integration::Scene stage( application.GetScene() );
6383 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6385 Actor actorA = Actor::New();
6386 actorA.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6387 actorA.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6388 actorA.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6389 actorA.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 20.0f ) );
6390 stage.Add( actorA );
6392 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6394 Actor actorB = Actor::New();
6395 actorB.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6396 actorB.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6397 actorB.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6398 Vector2 actorBSize( 30.0f, 60.0f );
6399 actorB.SetProperty( Actor::Property::SIZE, actorBSize );
6400 stage.Add( actorB );
6402 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6404 Actor actorC = Actor::New();
6405 actorC.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6406 actorC.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6407 actorC.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6408 Vector2 actorCSize( 60.0f, 120.0f );
6409 actorC.SetProperty( Actor::Property::SIZE, actorCSize );
6410 stage.Add( actorC );
6412 application.SendNotification();
6413 application.Render();
6415 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6417 Vector2 center( stage.GetSize() * 0.5f );
6419 DALI_TEST_EQUALS( actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6420 DALI_TEST_EQUALS( actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6421 DALI_TEST_EQUALS( actorC.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6423 tet_infoline( "Add scale to all actors" );
6425 actorA.SetProperty( Actor::Property::SCALE, 2.0f );
6426 actorB.SetProperty( Actor::Property::SCALE, 2.0f );
6427 actorC.SetProperty( Actor::Property::SCALE, 2.0f );
6429 application.SendNotification();
6430 application.Render();
6432 DALI_TEST_EQUALS( actorA.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6433 DALI_TEST_EQUALS( actorB.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6434 DALI_TEST_EQUALS( actorC.GetProperty( Actor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6439 int utcDaliActorPositionUsesAnchorPoint(void)
6441 TestApplication application;
6442 tet_infoline( "Check default behaviour\n" );
6444 Actor actor = Actor::New();
6445 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6446 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6447 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6448 application.GetScene().Add( actor );
6450 application.SendNotification();
6451 application.Render();
6453 tet_infoline( "Check that the world position is in the center\n" );
6454 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6456 tet_infoline( "Set the position uses anchor point property to false\n" );
6457 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6459 application.SendNotification();
6460 application.Render();
6462 tet_infoline( "Check that the world position has changed appropriately\n" );
6463 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6468 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6470 TestApplication application;
6471 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6473 Actor actor = Actor::New();
6474 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6475 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6476 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6477 actor.SetProperty( Actor::Property::SCALE, 2.0f );
6478 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6479 application.GetScene().Add( actor );
6481 application.SendNotification();
6482 application.Render();
6484 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6485 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6487 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6488 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6489 application.SendNotification();
6490 application.Render();
6491 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6493 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6494 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6495 application.SendNotification();
6496 application.Render();
6497 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6502 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6504 TestApplication application;
6505 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6507 Actor actor = Actor::New();
6508 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6509 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6510 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6511 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6512 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6513 application.GetScene().Add( actor );
6515 application.SendNotification();
6516 application.Render();
6518 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6519 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6521 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6522 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6523 application.SendNotification();
6524 application.Render();
6525 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6527 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6528 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6529 application.SendNotification();
6530 application.Render();
6531 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6536 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6538 TestApplication application;
6539 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6541 Actor actor = Actor::New();
6542 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6543 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6544 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6545 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( 90.0f), Vector3::ZAXIS ) );
6546 actor.SetProperty( Actor::Property::SCALE, 2.0f );
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 scale and 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( -100.0f, 100.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( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6571 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6573 TestApplication application;
6574 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6576 Actor parent = Actor::New();
6578 application.GetScene().Add( parent );
6579 Vector2 stageSize( application.GetScene().GetSize() );
6581 Actor actor = Actor::New();
6582 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
6583 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
6584 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
6585 actor.SetProperty( Actor::Property::INHERIT_SCALE, false );
6586 actor.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
6587 actor.SetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT, false );
6588 parent.Add( actor );
6590 application.SendNotification();
6591 application.Render();
6593 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6595 tet_infoline( "Check the world position is in the right place\n" );
6596 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6598 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6599 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
6600 application.SendNotification();
6601 application.Render();
6602 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6604 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6605 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT );
6606 application.SendNotification();
6607 application.Render();
6608 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION ), expectedWorldPosition, TEST_LOCATION );
6613 int utcDaliActorVisibilityChangeSignalSelf(void)
6615 TestApplication application;
6616 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6618 Actor actor = Actor::New();
6620 VisibilityChangedFunctorData data;
6621 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6623 actor.SetProperty( Actor::Property::VISIBLE, false );
6625 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6627 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6630 actor.SetProperty( Actor::Property::VISIBLE, false );
6631 data.Check( false /* not called */, TEST_LOCATION );
6633 tet_infoline( "Change the visibility using properties, ensure called" );
6636 actor.SetProperty( Actor::Property::VISIBLE, true );
6637 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6639 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6642 actor.SetProperty( Actor::Property::VISIBLE, true );
6643 data.Check( false /* not called */, TEST_LOCATION );
6648 int utcDaliActorVisibilityChangeSignalChildren(void)
6650 TestApplication application;
6651 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6653 Actor parent = Actor::New();
6654 Actor child = Actor::New();
6655 parent.Add( child );
6657 Actor grandChild = Actor::New();
6658 child.Add( grandChild );
6660 VisibilityChangedFunctorData parentData;
6661 VisibilityChangedFunctorData childData;
6662 VisibilityChangedFunctorData grandChildData;
6664 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6665 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6666 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6668 parent.SetProperty( Actor::Property::VISIBLE, false );
6669 parentData.Check( false /* not called */, TEST_LOCATION );
6670 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6671 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6673 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6676 grandChildData.Reset();
6678 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6680 parent.SetProperty( Actor::Property::VISIBLE, true );
6681 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6682 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6683 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6685 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6688 grandChildData.Reset();
6690 parent.SetProperty( Actor::Property::VISIBLE, true );
6691 parentData.Check( false /* not called */, TEST_LOCATION );
6692 childData.Check( false /* not called */, TEST_LOCATION );
6693 grandChildData.Check( false /* not called */, TEST_LOCATION );
6698 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6700 TestApplication application;
6701 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6703 Actor actor = Actor::New();
6704 application.GetScene().Add( actor );
6706 application.SendNotification();
6707 application.Render();
6709 VisibilityChangedFunctorData data;
6710 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6712 Animation animation = Animation::New( 1.0f );
6713 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6715 data.Check( false, TEST_LOCATION );
6716 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6717 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6719 tet_infoline( "Play the animation and check the property value" );
6722 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6723 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6725 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6726 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6728 application.SendNotification();
6729 application.Render( 1100 ); // After the animation
6731 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6737 int utcDaliActorVisibilityChangeSignalByName(void)
6739 TestApplication application;
6740 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6742 Actor actor = Actor::New();
6744 bool signalCalled=false;
6745 actor.ConnectSignal( &application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled) );
6746 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6747 actor.SetProperty( Actor::Property::VISIBLE, false );
6748 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6750 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6751 signalCalled = false;
6752 actor.SetProperty( Actor::Property::VISIBLE, false );
6753 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6755 tet_infoline( "Change the visibility using properties, ensure called" );
6756 actor.SetProperty( Actor::Property::VISIBLE, true );
6757 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6759 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6760 signalCalled = false;
6762 actor.SetProperty( Actor::Property::VISIBLE, true );
6763 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6769 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6771 gLayoutDirectionType = type;
6774 int UtcDaliActorLayoutDirectionProperty(void)
6776 TestApplication application;
6777 tet_infoline( "Check layout direction property" );
6779 Actor actor0 = Actor::New();
6780 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6781 application.GetScene().Add( actor0 );
6783 application.SendNotification();
6784 application.Render();
6786 Actor actor1 = Actor::New();
6787 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6788 Actor actor2 = Actor::New();
6789 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6790 Actor actor3 = Actor::New();
6791 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6792 Actor actor4 = Actor::New();
6793 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6794 Actor actor5 = Actor::New();
6795 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6796 Actor actor6 = Actor::New();
6797 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6798 Actor actor7 = Actor::New();
6799 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6800 Actor actor8 = Actor::New();
6801 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6802 Actor actor9 = Actor::New();
6803 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6805 actor1.Add( actor2 );
6806 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6807 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6809 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6810 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6811 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6813 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6814 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6815 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6817 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6818 actor0.Add( actor1 );
6819 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6820 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6822 application.GetScene().Add( actor3 );
6823 actor3.Add( actor4 );
6824 actor4.Add( actor5 );
6825 actor5.Add( actor6 );
6826 actor5.Add( actor7 );
6827 actor7.Add( actor8 );
6828 actor8.Add( actor9 );
6829 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6830 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6832 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6833 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6834 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6836 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6838 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6839 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6840 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6841 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6842 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6843 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6844 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6846 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6847 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6848 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6850 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6851 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6852 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6853 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6855 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6856 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6857 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6863 struct LayoutDirectionFunctor
6865 LayoutDirectionFunctor(bool& signalCalled)
6866 : mSignalCalled( signalCalled )
6870 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6871 : mSignalCalled( rhs.mSignalCalled )
6877 mSignalCalled = true;
6880 bool& mSignalCalled;
6883 int UtcDaliActorLayoutDirectionSignal(void)
6885 TestApplication application;
6886 tet_infoline( "Check changing layout direction property sends a signal" );
6888 Actor actor = Actor::New();
6889 DALI_TEST_EQUALS( actor.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6890 application.GetScene().Add( actor );
6891 bool signalCalled = false;
6892 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6894 actor.ConnectSignal( &application, "layoutDirectionChanged", layoutDirectionFunctor );
6895 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6897 // Test that writing the same value doesn't send a signal
6898 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6899 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6901 // Test that writing a different value sends the signal
6902 signalCalled = false;
6903 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6904 DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
6906 signalCalled = false;
6907 actor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6908 DALI_TEST_EQUALS( signalCalled, false, TEST_LOCATION );
6913 struct ChildAddedSignalCheck
6915 ChildAddedSignalCheck( bool& signalReceived, Actor& childHandle )
6916 : mSignalReceived( signalReceived ),
6917 mChildHandle( childHandle )
6921 void operator() ( Actor childHandle )
6923 mSignalReceived = true;
6924 mChildHandle = childHandle;
6928 mSignalReceived = true;
6929 mChildHandle = Actor();
6932 bool& mSignalReceived;
6933 Actor& mChildHandle;
6936 int UtcDaliChildAddedSignalP1(void)
6938 TestApplication application;
6939 auto stage = application.GetScene();
6941 bool signalReceived=false;
6944 ChildAddedSignalCheck signal( signalReceived, childActor );
6945 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
6946 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6948 auto actorA = Actor::New();
6949 stage.Add( actorA );
6950 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6951 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
6952 signalReceived = false;
6954 auto actorB = Actor::New();
6955 stage.Add( actorB );
6956 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6957 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
6963 int UtcDaliChildAddedSignalP2(void)
6965 TestApplication application;
6966 auto stage = application.GetScene();
6968 bool signalReceived=false;
6971 ChildAddedSignalCheck signal( signalReceived, childActor );
6972 tet_infoline( "Connect to childAdded signal by name" );
6974 stage.GetRootLayer().ConnectSignal( &application, "childAdded", signal );
6975 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
6977 auto actorA = Actor::New();
6978 stage.Add( actorA );
6979 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6981 // Can't test which actor was added; signal signature is void() when connecting via name.
6982 signalReceived = false;
6984 auto actorB = Actor::New();
6985 stage.Add( actorB );
6986 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
6991 int UtcDaliChildAddedSignalN(void)
6993 TestApplication application;
6994 auto stage = application.GetScene();
6996 bool signalReceived=false;
6999 ChildAddedSignalCheck signal( signalReceived, childActor );
7000 DevelActor::ChildAddedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7001 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7003 auto actorA = Actor::New();
7004 stage.Add( actorA );
7005 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7006 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7007 signalReceived = false;
7009 auto actorB = Actor::New();
7010 actorA.Add( actorB );
7011 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7016 struct ChildRemovedSignalCheck
7018 ChildRemovedSignalCheck( bool& signalReceived, Actor& childHandle )
7019 : mSignalReceived( signalReceived ),
7020 mChildHandle( childHandle )
7024 void operator() ( Actor childHandle )
7026 mSignalReceived = true;
7027 mChildHandle = childHandle;
7032 mSignalReceived = true;
7035 bool& mSignalReceived;
7036 Actor& mChildHandle;
7039 int UtcDaliChildRemovedSignalP1(void)
7041 TestApplication application;
7042 auto stage = application.GetScene();
7044 bool signalReceived=false;
7047 ChildRemovedSignalCheck signal( signalReceived, childActor );
7048 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7049 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7051 auto actorA = Actor::New();
7052 stage.Add( actorA );
7053 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7054 DALI_TEST_CHECK( !childActor );
7056 stage.Remove( actorA );
7057 DALI_TEST_EQUALS( childActor, actorA, TEST_LOCATION );
7058 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7060 signalReceived = false;
7061 auto actorB = Actor::New();
7062 stage.Add( actorB );
7063 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7065 stage.Remove( actorB );
7066 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7067 DALI_TEST_EQUALS( childActor, actorB, TEST_LOCATION );
7072 int UtcDaliChildRemovedSignalP2(void)
7074 TestApplication application;
7075 auto stage = application.GetScene();
7077 bool signalReceived=false;
7080 ChildAddedSignalCheck signal( signalReceived, childActor );
7081 tet_infoline( "Connect to childRemoved signal by name" );
7083 stage.GetRootLayer().ConnectSignal( &application, "childRemoved", 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 );
7090 stage.Remove( actorA );
7091 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7093 signalReceived = false;
7094 auto actorB = Actor::New();
7095 stage.Add( actorB );
7096 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7098 stage.Remove( actorB );
7099 DALI_TEST_EQUALS( signalReceived, true, TEST_LOCATION );
7105 int UtcDaliChildRemovedSignalN(void)
7107 TestApplication application;
7108 auto stage = application.GetScene();
7110 bool signalReceived=false;
7113 ChildRemovedSignalCheck signal( signalReceived, childActor );
7114 DevelActor::ChildRemovedSignal( stage.GetRootLayer() ).Connect( &application, signal );
7115 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7117 auto actorA = Actor::New();
7118 stage.Add( actorA );
7120 auto actorB = Actor::New();
7121 actorA.Add( actorB );
7123 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7124 DALI_TEST_CHECK( ! childActor );
7126 actorA.Remove( actorB );
7127 DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
7132 int UtcDaliChildMovedSignalP(void)
7134 TestApplication application;
7135 auto stage = application.GetScene();
7137 bool addedASignalReceived = false;
7138 bool removedASignalReceived = false;
7139 bool addedBSignalReceived = false;
7140 bool removedBSignalReceived = false;
7143 auto actorA = Actor::New();
7144 auto actorB = Actor::New();
7145 stage.Add( actorA );
7146 stage.Add( actorB );
7148 ChildAddedSignalCheck addedSignalA( addedASignalReceived, childActor );
7149 ChildRemovedSignalCheck removedSignalA( removedASignalReceived, childActor );
7150 ChildAddedSignalCheck addedSignalB( addedBSignalReceived, childActor );
7151 ChildRemovedSignalCheck removedSignalB( removedBSignalReceived, childActor );
7153 DevelActor::ChildAddedSignal( actorA ).Connect( &application, addedSignalA );
7154 DevelActor::ChildRemovedSignal( actorA ).Connect( &application, removedSignalA );
7155 DevelActor::ChildAddedSignal( actorB ).Connect( &application, addedSignalB );
7156 DevelActor::ChildRemovedSignal( actorB ).Connect( &application, removedSignalB );
7158 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7159 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7160 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7161 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7163 // Create a child of A
7165 auto child = Actor::New();
7166 actorA.Add( child );
7168 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7169 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7170 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7171 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7172 DALI_TEST_EQUALS( childActor, child, TEST_LOCATION );
7175 addedASignalReceived = false;
7176 addedBSignalReceived = false;
7177 removedASignalReceived = false;
7178 removedBSignalReceived = false;
7180 actorB.Add( child ); // Expect this child to be re-parented
7181 DALI_TEST_EQUALS( addedASignalReceived, false, TEST_LOCATION );
7182 DALI_TEST_EQUALS( removedASignalReceived, true, TEST_LOCATION );
7183 DALI_TEST_EQUALS( addedBSignalReceived, true, TEST_LOCATION );
7184 DALI_TEST_EQUALS( removedBSignalReceived, false, TEST_LOCATION );
7186 // Move child back to A:
7187 addedASignalReceived = false;
7188 addedBSignalReceived = false;
7189 removedASignalReceived = false;
7190 removedBSignalReceived = false;
7192 actorA.Add( child ); // Expect this child to be re-parented
7193 DALI_TEST_EQUALS( addedASignalReceived, true, TEST_LOCATION );
7194 DALI_TEST_EQUALS( removedASignalReceived, false, TEST_LOCATION );
7195 DALI_TEST_EQUALS( addedBSignalReceived, false, TEST_LOCATION );
7196 DALI_TEST_EQUALS( removedBSignalReceived, true, TEST_LOCATION );
7202 int utcDaliActorCulled(void)
7204 TestApplication application;
7205 auto stage = application.GetScene();
7207 tet_infoline( "Check that the actor is culled if the actor is out of the screen" );
7209 Actor actor = Actor::New();
7210 actor.SetProperty( Actor::Property::SIZE, Vector2( 10.0f, 10.0f ) );
7212 Geometry geometry = CreateQuadGeometry();
7213 Shader shader = CreateShader();
7214 Renderer renderer = Renderer::New(geometry, shader);
7215 actor.AddRenderer( renderer );
7219 application.SendNotification();
7220 application.Render( 0 );
7222 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::CULLED ), false, TEST_LOCATION );
7224 PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::CULLED, LessThanCondition( 0.5f ) );
7225 notification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
7227 // Connect NotifySignal
7228 bool propertyNotificationSignal( false );
7229 PropertyNotification source;
7230 CulledPropertyNotificationFunctor f( propertyNotificationSignal, source );
7231 notification.NotifySignal().Connect( &application, f ) ;
7233 actor.SetProperty( Actor::Property::POSITION, Vector2( 1000.0f, 1000.0f ));
7235 application.SendNotification();
7236 application.Render();
7238 application.SendNotification();
7240 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::CULLED ), true, TEST_LOCATION );
7242 DALI_TEST_EQUALS( propertyNotificationSignal, true, TEST_LOCATION );
7243 DALI_TEST_EQUALS( source.GetTargetProperty(), static_cast< int >( Actor::Property::CULLED ), TEST_LOCATION );
7244 DALI_TEST_EQUALS( source.GetTarget().GetProperty< bool >( source.GetTargetProperty() ), true, TEST_LOCATION );
7249 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7251 TestApplication application;
7252 auto stage = application.GetScene();
7254 tet_infoline( "Ensure we clear the screen when the last actor is removed" );
7256 Actor actor = CreateRenderableActor();
7257 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7260 application.SendNotification();
7261 application.Render();
7263 auto& glAbstraction = application.GetGlAbstraction();
7264 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7268 application.SendNotification();
7269 application.Render();
7271 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7276 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7278 TestApplication application;
7279 auto stage = application.GetScene();
7281 tet_infoline( "Ensure we clear the screen when the last actor is made invisible" );
7283 Actor actor = CreateRenderableActor();
7284 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
7287 application.SendNotification();
7288 application.Render();
7290 auto& glAbstraction = application.GetGlAbstraction();
7291 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7293 actor.SetProperty( Actor::Property::VISIBLE, false );
7295 application.SendNotification();
7296 application.Render();
7298 DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
7303 int utcDaliActorGetSizeAfterAnimation(void)
7305 TestApplication application;
7306 tet_infoline( "Check the actor size before / after an animation is finished" );
7308 Vector3 actorSize( 100.0f, 100.0f, 0.0f );
7310 Actor actor = Actor::New();
7311 actor.SetProperty( Actor::Property::SIZE, actorSize );
7312 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
7313 application.GetScene().Add( actor );
7315 // Size should be updated without rendering.
7316 Vector3 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7317 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7319 application.SendNotification();
7320 application.Render();
7322 // Size and current size should be updated.
7323 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7324 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7325 DALI_TEST_EQUALS( actorSize.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7326 DALI_TEST_EQUALS( actorSize.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7327 DALI_TEST_EQUALS( actorSize.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7329 Vector3 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7330 DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7331 DALI_TEST_EQUALS( actorSize.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7332 DALI_TEST_EQUALS( actorSize.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7333 DALI_TEST_EQUALS( actorSize.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7336 actorSize = Vector3( 200.0f, 200.0f, 0.0f );
7337 actor.SetProperty( Actor::Property::SIZE, actorSize );
7339 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7340 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7342 Vector3 targetValue( 10.0f, 20.0f, 0.0f );
7344 Animation animation = Animation::New( 1.0f );
7345 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
7348 // Size should be updated without rendering.
7349 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7350 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7352 application.SendNotification();
7353 application.Render( 1100 ); // After the animation
7355 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7356 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7357 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7358 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7359 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7361 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7362 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7363 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7364 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7365 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7367 targetValue.width = 50.0f;
7370 animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetValue.width );
7373 application.SendNotification();
7374 application.Render( 1100 ); // After the animation
7376 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7377 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7378 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7379 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7380 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7382 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7383 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7384 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7385 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7386 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7388 targetValue.height = 70.0f;
7391 animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetValue.height );
7394 application.SendNotification();
7395 application.Render( 1100 ); // After the animation
7397 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7398 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7399 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7400 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7401 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7403 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7404 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7405 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7406 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7407 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7409 Vector3 offset( 10.0f, 20.0f, 0.0f );
7412 animation.AnimateBy( Property( actor, Actor::Property::SIZE ), offset );
7415 application.SendNotification();
7416 application.Render( 1100 ); // After the animation
7418 targetValue += offset;
7420 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7421 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7422 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7423 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7424 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7426 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7427 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7428 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7429 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7430 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7432 offset.width = 20.0f;
7435 animation.AnimateBy( Property( actor, Actor::Property::SIZE_WIDTH ), offset.width );
7438 application.SendNotification();
7439 application.Render( 1100 ); // After the animation
7441 targetValue.width += offset.width;
7443 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7444 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7445 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7446 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7447 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7449 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7450 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7451 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7452 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7453 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7455 offset.height = 10.0f;
7458 animation.AnimateBy( Property( actor, Actor::Property::SIZE_HEIGHT ), offset.height );
7461 application.SendNotification();
7462 application.Render( 1100 ); // After the animation
7464 targetValue.height += offset.height;
7466 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7467 DALI_TEST_EQUALS( size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7468 DALI_TEST_EQUALS( targetValue.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7469 DALI_TEST_EQUALS( targetValue.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7470 DALI_TEST_EQUALS( targetValue.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7472 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7473 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7474 DALI_TEST_EQUALS( targetValue.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
7475 DALI_TEST_EQUALS( targetValue.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
7476 DALI_TEST_EQUALS( targetValue.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
7479 actorSize = Vector3( 300.0f, 300.0f, 0.0f );
7481 actor.SetProperty( Actor::Property::SIZE, actorSize );
7483 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7484 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7486 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7487 DALI_TEST_EQUALS( currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7489 application.SendNotification();
7490 application.Render();
7492 size = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
7493 DALI_TEST_EQUALS( size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7495 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
7496 DALI_TEST_EQUALS( currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
7501 int utcDaliActorPartialUpdate(void)
7503 TestApplication application(
7504 TestApplication::DEFAULT_SURFACE_WIDTH,
7505 TestApplication::DEFAULT_SURFACE_HEIGHT,
7506 TestApplication::DEFAULT_HORIZONTAL_DPI,
7507 TestApplication::DEFAULT_VERTICAL_DPI,
7511 tet_infoline("Check the damaged area");
7513 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7515 std::vector<Rect<int>> damagedRects;
7516 Rect<int> clippingRect;
7517 application.SendNotification();
7518 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7520 // First render pass, nothing to render, adaptor would just do swap buffer.
7521 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7522 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7524 Actor actor = CreateRenderableActor();
7525 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7526 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7527 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7528 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7529 application.GetScene().Add(actor);
7531 application.SendNotification();
7533 // 1. Actor added, damaged rect is added size of actor
7534 damagedRects.clear();
7535 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7536 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7539 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7540 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7541 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7542 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7543 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7544 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7545 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7548 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7549 application.SendNotification();
7551 damagedRects.clear();
7552 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7553 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7556 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7557 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7558 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7559 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7560 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7561 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7562 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7564 // 3. Set new position
7565 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7566 application.SendNotification();
7568 damagedRects.clear();
7569 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7570 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7573 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7574 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7575 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7576 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7577 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7578 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7579 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7581 application.GetScene().Remove(actor);
7582 application.SendNotification();
7584 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7585 damagedRects.clear();
7586 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7587 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7589 clippingRect = damagedRects[0];
7590 clippingRect.Merge(damagedRects[1]);
7591 clippingRect.Merge(damagedRects[2]);
7593 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7594 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7595 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7597 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7598 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7599 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7600 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7601 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7606 int utcDaliActorPartialUpdateSetColor(void)
7608 TestApplication application(
7609 TestApplication::DEFAULT_SURFACE_WIDTH,
7610 TestApplication::DEFAULT_SURFACE_HEIGHT,
7611 TestApplication::DEFAULT_HORIZONTAL_DPI,
7612 TestApplication::DEFAULT_VERTICAL_DPI,
7616 tet_infoline("Check uniform update");
7618 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7620 std::vector<Rect<int>> damagedRects;
7621 Rect<int> clippingRect;
7622 application.SendNotification();
7623 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7625 // First render pass, nothing to render, adaptor would just do swap buffer.
7626 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7627 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7629 Actor actor = CreateRenderableActor();
7630 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7631 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7632 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7633 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7634 application.GetScene().Add(actor);
7636 application.SendNotification();
7638 // 1. Actor added, damaged rect is added size of actor
7639 damagedRects.clear();
7640 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7641 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7644 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7645 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7646 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7647 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7648 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7649 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7650 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7652 damagedRects.clear();
7653 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7655 damagedRects.clear();
7656 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7659 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
7660 application.SendNotification();
7662 damagedRects.clear();
7663 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7664 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7667 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7668 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7669 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7670 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7671 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7672 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7673 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7678 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
7679 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
7680 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
7681 const char* const RENDER_SHADOW_VERTEX_SOURCE =
7682 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
7683 " uniform mediump mat4 uLightCameraViewMatrix;\n"
7687 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
7688 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
7689 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
7692 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
7693 "uniform lowp vec4 uShadowColor;\n"
7696 " lowp float alpha;\n"
7697 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
7698 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
7701 int utcDaliActorPartialUpdateSetProperty(void)
7703 TestApplication application(
7704 TestApplication::DEFAULT_SURFACE_WIDTH,
7705 TestApplication::DEFAULT_SURFACE_HEIGHT,
7706 TestApplication::DEFAULT_HORIZONTAL_DPI,
7707 TestApplication::DEFAULT_VERTICAL_DPI,
7711 tet_infoline( "Set/Update property with partial update" );
7713 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7715 std::vector<Rect<int>> damagedRects;
7716 Rect<int> clippingRect;
7717 application.SendNotification();
7718 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7720 // First render pass, nothing to render, adaptor would just do swap buffer.
7721 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7722 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7724 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
7725 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
7726 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7727 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7728 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7729 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7730 application.GetScene().Add(actor);
7732 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
7734 damagedRects.clear();
7735 application.SendNotification();
7736 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7737 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7740 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7741 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7742 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7743 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7744 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7745 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7746 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7748 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex( SHADER_SHADOW_COLOR_PROPERTY_NAME );
7749 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
7751 damagedRects.clear();
7752 application.SendNotification();
7753 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7754 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7756 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7757 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7758 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7759 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7760 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7761 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7763 damagedRects.clear();
7764 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7765 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7767 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7768 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7769 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7770 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7771 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7772 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7774 damagedRects.clear();
7775 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7776 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7781 int utcDaliActorPartialUpdateTwoActors(void)
7783 TestApplication application(
7784 TestApplication::DEFAULT_SURFACE_WIDTH,
7785 TestApplication::DEFAULT_SURFACE_HEIGHT,
7786 TestApplication::DEFAULT_HORIZONTAL_DPI,
7787 TestApplication::DEFAULT_VERTICAL_DPI,
7791 tet_infoline("Check the damaged rects with partial update and two actors");
7793 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7795 Actor actor = CreateRenderableActor();
7796 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
7797 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
7798 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7799 application.GetScene().Add(actor);
7801 Actor actor2 = CreateRenderableActor();
7802 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
7803 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
7804 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7805 application.GetScene().Add(actor2);
7807 application.SendNotification();
7808 std::vector<Rect<int>> damagedRects;
7809 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7811 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
7812 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
7813 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
7815 // in screen coordinates, adaptor would calculate it using previous frames information
7816 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
7817 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7819 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7820 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7821 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7822 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7827 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
7829 TestApplication application(
7830 TestApplication::DEFAULT_SURFACE_WIDTH,
7831 TestApplication::DEFAULT_SURFACE_HEIGHT,
7832 TestApplication::DEFAULT_HORIZONTAL_DPI,
7833 TestApplication::DEFAULT_VERTICAL_DPI,
7837 tet_infoline( "Check the damaged rect with partial update and actor size hint" );
7839 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
7841 Actor actor = CreateRenderableActor();
7842 actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f));
7843 actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f));
7844 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0));
7845 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7846 application.GetScene().Add(actor);
7848 application.SendNotification();
7849 std::vector<Rect<int>> damagedRects;
7850 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7852 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7854 Rect<int> clippingRect = Rect<int>(0, 496, 160, 320);
7855 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7857 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7859 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7860 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7861 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7862 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);