2 * Copyright (c) 2017 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.
19 #include <dali/public-api/dali-core.h>
21 #include <cfloat> // For FLT_MAX
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/devel-api/object/handle-devel.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26 #include <dali-test-suite-utils.h>
27 #include <mesh-builder.h>
35 void utc_dali_actor_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_actor_cleanup(void)
42 test_return_value = TET_PASS;
47 bool gTouchCallBackCalled=false;
48 bool gTouchCallBackCalled2=false;
49 bool gTouchCallBackCalled3=false;
51 bool gHoverCallBackCalled=false;
53 static bool gTestConstraintCalled;
57 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
59 gTestConstraintCalled = true;
64 * TestConstraint reference.
65 * When constraint is called, the resultRef is updated
66 * with the value supplied.
69 struct TestConstraintRef
71 TestConstraintRef(unsigned int& resultRef, unsigned int value)
72 : mResultRef(resultRef),
77 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
82 unsigned int& mResultRef;
86 static bool TestCallback(Actor actor, const TouchEvent& event)
88 gTouchCallBackCalled = true;
93 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
95 gTouchCallBackCalled = true;
100 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
102 gTouchCallBackCalled2 = true;
107 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
109 gTouchCallBackCalled3 = true;
114 static void ResetTouchCallbacks()
116 gTouchCallBackCalled = false;
117 gTouchCallBackCalled2 = false;
118 gTouchCallBackCalled3 = false;
121 static bool TestCallback3(Actor actor, const HoverEvent& event)
123 gHoverCallBackCalled = true;
128 // validation stuff for onstage & offstage signals
129 static std::vector< std::string > gActorNamesOnOffStage;
130 static int gOnStageCallBackCalled;
131 void OnStageCallback( Actor actor )
133 ++gOnStageCallBackCalled;
134 gActorNamesOnOffStage.push_back( actor.GetName() );
135 DALI_TEST_CHECK( actor.OnStage() == true );
137 static int gOffStageCallBackCalled;
138 void OffStageCallback( Actor actor )
140 ++gOffStageCallBackCalled;
141 gActorNamesOnOffStage.push_back( actor.GetName() );
142 DALI_TEST_CHECK( actor.OnStage() == false );
145 struct PositionComponentConstraint
147 PositionComponentConstraint(){}
149 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
151 const Matrix& m = inputs[0]->GetMatrix();
154 m.GetTransformComponents(pos, rot, scale);
158 struct OrientationComponentConstraint
160 OrientationComponentConstraint(){}
162 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
164 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
167 orientation = parentOrientation;
172 static bool gOnRelayoutCallBackCalled = false;
173 static std::vector< std::string > gActorNamesRelayout;
175 void OnRelayoutCallback( Actor actor )
177 gOnRelayoutCallBackCalled = true;
178 gActorNamesRelayout.push_back( actor.GetName() );
181 struct VisibilityChangedFunctorData
183 VisibilityChangedFunctorData()
186 type( DevelActor::VisibilityChange::SELF ),
195 type = DevelActor::VisibilityChange::SELF;
199 void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
201 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
202 DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
203 DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
204 DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
207 void Check( bool compareCalled, const std::string& location )
209 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
214 DevelActor::VisibilityChange::Type type;
218 struct VisibilityChangedFunctor
220 VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
222 void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
225 data.visible = visible;
230 VisibilityChangedFunctorData& data;
233 } // anonymous namespace
236 //& purpose: Testing New API
237 int UtcDaliActorNew(void)
239 TestApplication application;
241 Actor actor = Actor::New();
243 DALI_TEST_CHECK(actor);
247 //& purpose: Testing Dali::Actor::DownCast()
248 int UtcDaliActorDownCastP(void)
250 TestApplication application;
251 tet_infoline("Testing Dali::Actor::DownCast()");
253 Actor actor = Actor::New();
254 BaseHandle object(actor);
255 Actor actor2 = Actor::DownCast(object);
256 DALI_TEST_CHECK(actor2);
260 //& purpose: Testing Dali::Actor::DownCast()
261 int UtcDaliActorDownCastN(void)
263 TestApplication application;
264 tet_infoline("Testing Dali::Actor::DownCast()");
266 BaseHandle unInitializedObject;
267 Actor actor = Actor::DownCast(unInitializedObject);
268 DALI_TEST_CHECK(!actor);
272 //& purpose: Testing Dali::Actor::GetName()
273 int UtcDaliActorGetName(void)
275 TestApplication application;
277 Actor actor = Actor::New();
279 DALI_TEST_CHECK(actor.GetName().empty());
283 //& purpose: Testing Dali::Actor::SetName()
284 int UtcDaliActorSetName(void)
286 TestApplication application;
288 string str("ActorName");
289 Actor actor = Actor::New();
292 DALI_TEST_CHECK(actor.GetName() == str);
296 int UtcDaliActorGetId(void)
298 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
299 TestApplication application;
301 Actor first = Actor::New();
302 Actor second = Actor::New();
303 Actor third = Actor::New();
305 DALI_TEST_CHECK(first.GetId() != second.GetId());
306 DALI_TEST_CHECK(second.GetId() != third.GetId());
310 int UtcDaliActorIsRoot(void)
312 TestApplication application;
314 Actor actor = Actor::New();
315 DALI_TEST_CHECK(!actor.IsRoot());
317 // get the root layer
318 actor = Stage::GetCurrent().GetLayer( 0 );
319 DALI_TEST_CHECK( actor.IsRoot() );
323 int UtcDaliActorOnStage(void)
325 TestApplication application;
327 Actor actor = Actor::New();
328 DALI_TEST_CHECK( !actor.OnStage() );
330 // get the root layer
331 actor = Stage::GetCurrent().GetLayer( 0 );
332 DALI_TEST_CHECK( actor.OnStage() );
336 int UtcDaliActorIsLayer(void)
338 TestApplication application;
340 Actor actor = Actor::New();
341 DALI_TEST_CHECK( !actor.IsLayer() );
343 // get the root layer
344 actor = Stage::GetCurrent().GetLayer( 0 );
345 DALI_TEST_CHECK( actor.IsLayer() );
349 int UtcDaliActorGetLayer(void)
351 TestApplication application;
353 Actor actor = Actor::New();
354 Stage::GetCurrent().Add(actor);
355 Layer layer = actor.GetLayer();
357 DALI_TEST_CHECK(layer);
359 // get the root layers layer
360 actor = Stage::GetCurrent().GetLayer( 0 );
361 DALI_TEST_CHECK( actor.GetLayer() );
365 int UtcDaliActorAddP(void)
367 tet_infoline("Testing Actor::Add");
368 TestApplication application;
370 Actor parent = Actor::New();
371 Actor child = Actor::New();
373 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
377 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
379 Actor parent2 = Actor::New();
380 parent2.Add( child );
382 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
383 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
385 // try Adding to same parent again, works
386 parent2.Add( child );
387 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
389 // try reparenting an orphaned child
391 Actor temporaryParent = Actor::New();
392 temporaryParent.Add( child );
393 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
395 // temporaryParent has now died, reparent the orphaned child
396 parent2.Add( child );
397 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
402 int UtcDaliActorAddN(void)
404 tet_infoline("Testing Actor::Add");
405 TestApplication application;
407 Actor child = Actor::New();
409 Actor parent2 = Actor::New();
410 parent2.Add( child );
415 parent2.Add( parent2 );
416 tet_printf("Assertion test failed - no Exception\n" );
417 tet_result(TET_FAIL);
419 catch(Dali::DaliException& e)
421 DALI_TEST_PRINT_ASSERT( e );
422 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
423 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
427 tet_printf("Assertion test failed - wrong Exception\n" );
428 tet_result(TET_FAIL);
431 // try reparenting root
434 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
435 tet_printf("Assertion test failed - no Exception\n" );
436 tet_result(TET_FAIL);
438 catch(Dali::DaliException& e)
440 DALI_TEST_PRINT_ASSERT( e );
441 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
442 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
446 tet_printf("Assertion test failed - wrong Exception\n" );
447 tet_result(TET_FAIL);
454 parent2.Add( empty );
455 tet_printf("Assertion test failed - no Exception\n" );
456 tet_result(TET_FAIL);
458 catch(Dali::DaliException& e)
460 DALI_TEST_PRINT_ASSERT( e );
461 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
462 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
466 tet_printf("Assertion test failed - wrong Exception\n" );
467 tet_result(TET_FAIL);
473 int UtcDaliActorRemoveN(void)
475 tet_infoline("Testing Actor::Remove");
476 TestApplication application;
478 Actor parent = Actor::New();
479 Actor child = Actor::New();
480 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
483 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
485 parent.Remove(child);
486 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
488 // remove again, no problem
489 parent.Remove(child);
490 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
494 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
495 // try Remove self, its a no-op
496 parent.Remove( parent );
497 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
503 parent.Remove( empty );
504 tet_printf("Assertion test failed - no Exception\n" );
505 tet_result(TET_FAIL);
507 catch(Dali::DaliException& e)
509 DALI_TEST_PRINT_ASSERT( e );
510 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
511 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
515 tet_printf("Assertion test failed - wrong Exception\n" );
516 tet_result(TET_FAIL);
521 int UtcDaliActorRemoveP(void)
523 TestApplication application;
525 Actor parent = Actor::New();
526 Actor child = Actor::New();
527 Actor random = Actor::New();
529 Stage::GetCurrent().Add( parent );
531 DALI_TEST_CHECK(parent.GetChildCount() == 0);
535 DALI_TEST_CHECK(parent.GetChildCount() == 1);
537 parent.Remove(random);
539 DALI_TEST_CHECK(parent.GetChildCount() == 1);
541 Stage::GetCurrent().Remove( parent );
543 DALI_TEST_CHECK(parent.GetChildCount() == 1);
547 int UtcDaliActorGetChildCount(void)
549 TestApplication application;
551 Actor parent = Actor::New();
552 Actor child = Actor::New();
554 DALI_TEST_CHECK(parent.GetChildCount() == 0);
558 DALI_TEST_CHECK(parent.GetChildCount() == 1);
562 int UtcDaliActorGetChildren01(void)
564 TestApplication application;
566 Actor parent = Actor::New();
567 Actor first = Actor::New();
568 Actor second = Actor::New();
569 Actor third = Actor::New();
575 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
576 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
577 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
581 int UtcDaliActorGetChildren02(void)
583 TestApplication application;
585 Actor parent = Actor::New();
586 Actor first = Actor::New();
587 Actor second = Actor::New();
588 Actor third = Actor::New();
594 const Actor& constParent = parent;
596 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
597 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
598 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
602 int UtcDaliActorGetParent01(void)
604 TestApplication application;
606 Actor parent = Actor::New();
607 Actor child = Actor::New();
611 DALI_TEST_CHECK(child.GetParent() == parent);
615 int UtcDaliActorGetParent02(void)
617 TestApplication application;
619 Actor actor = Actor::New();
621 DALI_TEST_CHECK(!actor.GetParent());
625 int UtcDaliActorSetParentOrigin(void)
627 TestApplication application;
629 Actor actor = Actor::New();
631 Vector3 vector(0.7f, 0.8f, 0.9f);
632 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
634 actor.SetParentOrigin(vector);
636 // flush the queue and render once
637 application.SendNotification();
638 application.Render();
640 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
642 Stage::GetCurrent().Add( actor );
644 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
646 // flush the queue and render once
647 application.SendNotification();
648 application.Render();
650 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
652 Stage::GetCurrent().Remove( actor );
656 int UtcDaliActorSetParentOriginIndividual(void)
658 TestApplication application;
660 Actor actor = Actor::New();
662 Vector3 vector(0.7f, 0.8f, 0.9f);
663 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
665 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
667 // flush the queue and render once
668 application.SendNotification();
669 application.Render();
671 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
673 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
675 // flush the queue and render once
676 application.SendNotification();
677 application.Render();
679 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
681 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
683 // flush the queue and render once
684 application.SendNotification();
685 application.Render();
687 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
692 int UtcDaliActorGetCurrentParentOrigin(void)
694 TestApplication application;
696 Actor actor = Actor::New();
698 Vector3 vector(0.7f, 0.8f, 0.9f);
699 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
701 actor.SetParentOrigin(vector);
703 // flush the queue and render once
704 application.SendNotification();
705 application.Render();
707 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
711 int UtcDaliActorSetAnchorPoint(void)
713 TestApplication application;
715 Actor actor = Actor::New();
717 Vector3 vector(0.7f, 0.8f, 0.9f);
718 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
720 actor.SetAnchorPoint(vector);
722 // flush the queue and render once
723 application.SendNotification();
724 application.Render();
726 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
728 Stage::GetCurrent().Add( actor );
730 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
731 // flush the queue and render once
732 application.SendNotification();
733 application.Render();
735 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
737 Stage::GetCurrent().Remove( actor );
741 int UtcDaliActorSetAnchorPointIndividual(void)
743 TestApplication application;
745 Actor actor = Actor::New();
747 Vector3 vector(0.7f, 0.8f, 0.9f);
748 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
750 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
752 // flush the queue and render once
753 application.SendNotification();
754 application.Render();
756 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
758 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
760 // flush the queue and render once
761 application.SendNotification();
762 application.Render();
764 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
766 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
768 // flush the queue and render once
769 application.SendNotification();
770 application.Render();
772 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
777 int UtcDaliActorGetCurrentAnchorPoint(void)
779 TestApplication application;
781 Actor actor = Actor::New();
783 Vector3 vector(0.7f, 0.8f, 0.9f);
784 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
786 actor.SetAnchorPoint(vector);
788 // flush the queue and render once
789 application.SendNotification();
790 application.Render();
792 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
796 // SetSize(float width, float height)
797 int UtcDaliActorSetSize01(void)
799 TestApplication application;
801 Actor actor = Actor::New();
802 Vector3 vector(100.0f, 100.0f, 0.0f);
804 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
806 actor.SetSize(vector.x, vector.y);
808 // Immediately retrieve the size after setting
809 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
810 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
811 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
812 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
813 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
815 // Flush the queue and render once
816 application.SendNotification();
817 application.Render();
819 // Check the size in the new frame
820 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
822 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
823 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
824 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
825 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
826 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
828 // Check async behaviour
829 currentSize = DevelHandle::GetCurrentProperty( actor, Actor::Property::SIZE ).Get< Vector3 >();
830 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
831 DALI_TEST_EQUALS( vector.width, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
832 DALI_TEST_EQUALS( vector.height, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
833 DALI_TEST_EQUALS( vector.depth, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
835 // Change the resize policy and check whether the size stays the same
836 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
838 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
839 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
841 // Set a new size after resize policy is changed and check the new size
842 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
844 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
845 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
847 // Change the resize policy again and check whether the new size stays the same
848 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
850 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
851 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
853 // Set another new size after resize policy is changed and check the new size
854 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
856 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
857 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
862 // SetSize(float width, float height, float depth)
863 int UtcDaliActorSetSize02(void)
865 TestApplication application;
867 Actor actor = Actor::New();
868 Vector3 vector(100.0f, 100.0f, 100.0f);
870 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
872 actor.SetSize(vector.x, vector.y, vector.z);
874 // Immediately check the size after setting
875 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
876 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
878 // flush the queue and render once
879 application.SendNotification();
880 application.Render();
882 // Check the size in the new frame
883 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
885 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
886 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
891 // SetSize(Vector2 size)
892 int UtcDaliActorSetSize03(void)
894 TestApplication application;
896 Actor actor = Actor::New();
897 Vector3 vector(100.0f, 100.0f, 0.0f);
899 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
901 actor.SetSize(Vector2(vector.x, vector.y));
903 // Immediately check the size after setting
904 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
905 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
907 // flush the queue and render once
908 application.SendNotification();
909 application.Render();
911 // Check the size in the new frame
912 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
914 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
915 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
920 // SetSize(Vector3 size)
921 int UtcDaliActorSetSize04(void)
923 TestApplication application;
925 Actor actor = Actor::New();
926 Vector3 vector(100.0f, 100.0f, 100.0f);
928 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
930 actor.SetSize(vector);
932 // Immediately check the size after setting
933 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
934 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
936 // flush the queue and render once
937 application.SendNotification();
938 application.Render();
940 // Check the size in the new frame
941 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
943 Stage::GetCurrent().Add( actor );
944 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
946 // Immediately check the size after setting
947 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
948 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
950 // flush the queue and render once
951 application.SendNotification();
952 application.Render();
954 // Check the size in the new frame
955 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
957 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
958 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
960 Stage::GetCurrent().Remove( actor );
964 int UtcDaliActorSetSizeIndividual(void)
966 TestApplication application;
968 Actor actor = Actor::New();
970 Vector3 vector(0.7f, 0.8f, 0.9f);
971 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
973 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
975 // Immediately check the width after setting
976 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
977 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
979 // flush the queue and render once
980 application.SendNotification();
981 application.Render();
983 // Check the width in the new frame
984 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
986 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
987 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
989 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
991 // Immediately check the height after setting
992 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
993 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
995 // flush the queue and render once
996 application.SendNotification();
997 application.Render();
999 // Check the height in the new frame
1000 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1002 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1003 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1005 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1007 // Immediately check the depth after setting
1008 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1009 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1011 // flush the queue and render once
1012 application.SendNotification();
1013 application.Render();
1015 // Check the depth in the new frame
1016 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1018 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1019 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1021 // Change the resize policy and check whether the size stays the same
1022 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1024 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1025 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1027 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1028 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1030 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1031 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1033 // Change the resize policy again and check whether the size stays the same
1034 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1036 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1037 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1039 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1040 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1042 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1043 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1048 int UtcDaliActorSetSizeIndividual02(void)
1050 TestApplication application;
1052 Actor actor = Actor::New();
1053 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1054 Stage::GetCurrent().Add( actor );
1056 Vector3 vector( 100.0f, 200.0f, 400.0f );
1057 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1059 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1060 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1062 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1063 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1065 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1066 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1068 // flush the queue and render once
1069 application.SendNotification();
1070 application.Render();
1072 // Check the width in the new frame
1073 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1074 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1080 int UtcDaliActorGetCurrentSize(void)
1082 TestApplication application;
1084 Actor actor = Actor::New();
1085 Vector3 vector(100.0f, 100.0f, 20.0f);
1087 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1089 actor.SetSize(vector);
1091 // flush the queue and render once
1092 application.SendNotification();
1093 application.Render();
1095 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1099 int UtcDaliActorGetNaturalSize(void)
1101 TestApplication application;
1103 Actor actor = Actor::New();
1104 Vector3 vector( 0.0f, 0.0f, 0.0f );
1106 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1111 int UtcDaliActorGetCurrentSizeImmediate(void)
1113 TestApplication application;
1115 Actor actor = Actor::New();
1116 Vector3 vector(100.0f, 100.0f, 20.0f);
1118 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1119 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1121 actor.SetSize(vector);
1123 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1124 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1126 // flush the queue and render once
1127 application.SendNotification();
1128 application.Render();
1130 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1131 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1134 // Build the animation
1135 const float durationSeconds = 2.0f;
1136 Animation animation = Animation::New( durationSeconds );
1137 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1138 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1140 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1142 // Start the animation
1145 application.SendNotification();
1146 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1148 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1153 // SetPosition(float x, float y)
1154 int UtcDaliActorSetPosition01(void)
1156 TestApplication application;
1158 Actor actor = Actor::New();
1160 // Set to random to start off with
1161 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1163 Vector3 vector(100.0f, 100.0f, 0.0f);
1165 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1167 actor.SetPosition(vector.x, vector.y);
1168 // flush the queue and render once
1169 application.SendNotification();
1170 application.Render();
1171 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1173 Stage::GetCurrent().Add( actor );
1174 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1175 // flush the queue and render once
1176 application.SendNotification();
1177 application.Render();
1178 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1183 // flush the queue and render once
1184 application.SendNotification();
1185 application.Render();
1186 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1188 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1189 // flush the queue and render once
1190 application.SendNotification();
1191 application.Render();
1192 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1194 Stage::GetCurrent().Remove( actor );
1198 // SetPosition(float x, float y, float z)
1199 int UtcDaliActorSetPosition02(void)
1201 TestApplication application;
1203 Actor actor = Actor::New();
1205 // Set to random to start off with
1206 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1208 Vector3 vector(100.0f, 100.0f, 100.0f);
1210 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1212 actor.SetPosition(vector.x, vector.y, vector.z);
1214 // flush the queue and render once
1215 application.SendNotification();
1216 application.Render();
1218 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1222 // SetPosition(Vector3 position)
1223 int UtcDaliActorSetPosition03(void)
1225 TestApplication application;
1227 Actor actor = Actor::New();
1229 // Set to random to start off with
1230 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1232 Vector3 vector(100.0f, 100.0f, 100.0f);
1234 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1236 actor.SetPosition(vector);
1238 // flush the queue and render once
1239 application.SendNotification();
1240 application.Render();
1242 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1246 int UtcDaliActorSetX(void)
1248 TestApplication application;
1250 Actor actor = Actor::New();
1252 Vector3 vector(100.0f, 0.0f, 0.0f);
1254 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1258 // flush the queue and render once
1259 application.SendNotification();
1260 application.Render();
1262 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1266 int UtcDaliActorSetY(void)
1268 TestApplication application;
1270 Actor actor = Actor::New();
1272 Vector3 vector(0.0f, 100.0f, 0.0f);
1274 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1278 // flush the queue and render once
1279 application.SendNotification();
1280 application.Render();
1282 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1286 int UtcDaliActorSetZ(void)
1288 TestApplication application;
1290 Actor actor = Actor::New();
1292 Vector3 vector(0.0f, 0.0f, 100.0f);
1294 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1298 // flush the queue and render once
1299 application.SendNotification();
1300 application.Render();
1302 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1306 int UtcDaliActorSetPositionProperties(void)
1308 TestApplication application;
1310 Actor actor = Actor::New();
1312 Vector3 vector(0.7f, 0.8f, 0.9f);
1313 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1315 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1316 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1317 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1319 // flush the queue and render once
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1324 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1325 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1326 DALI_TEST_EQUALS( vector.x, DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ).x, TEST_LOCATION );
1327 DALI_TEST_EQUALS( vector.x, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_X ), TEST_LOCATION );
1329 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1330 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1331 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1333 // flush the queue and render once
1334 application.SendNotification();
1335 application.Render();
1337 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1338 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1339 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1340 DALI_TEST_EQUALS( vector.y, DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ).y, TEST_LOCATION );
1341 DALI_TEST_EQUALS( vector.y, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_Y ), TEST_LOCATION );
1343 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1344 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1345 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1347 // flush the queue and render once
1348 application.SendNotification();
1349 application.Render();
1351 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1352 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1353 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1354 DALI_TEST_EQUALS( vector.z, DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::POSITION ).z, TEST_LOCATION );
1355 DALI_TEST_EQUALS( vector.z, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::POSITION_Z ), TEST_LOCATION );
1360 int UtcDaliActorTranslateBy(void)
1362 TestApplication application;
1364 Actor actor = Actor::New();
1365 Vector3 vector(100.0f, 100.0f, 100.0f);
1367 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1369 actor.SetPosition(vector);
1371 // flush the queue and render once
1372 application.SendNotification();
1373 application.Render();
1375 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1377 actor.TranslateBy(vector);
1379 // flush the queue and render once
1380 application.SendNotification();
1381 application.Render();
1383 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1387 int UtcDaliActorGetCurrentPosition(void)
1389 TestApplication application;
1391 Actor actor = Actor::New();
1392 Vector3 setVector(100.0f, 100.0f, 0.0f);
1393 actor.SetPosition(setVector);
1395 // flush the queue and render once
1396 application.SendNotification();
1397 application.Render();
1399 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1403 int UtcDaliActorGetCurrentWorldPosition(void)
1405 TestApplication application;
1407 Actor parent = Actor::New();
1408 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1409 parent.SetPosition( parentPosition );
1410 parent.SetParentOrigin( ParentOrigin::CENTER );
1411 parent.SetAnchorPoint( AnchorPoint::CENTER );
1412 Stage::GetCurrent().Add( parent );
1414 Actor child = Actor::New();
1415 child.SetParentOrigin( ParentOrigin::CENTER );
1416 child.SetAnchorPoint( AnchorPoint::CENTER );
1417 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1418 child.SetPosition( childPosition );
1419 parent.Add( child );
1421 // The actors should not have a world position yet
1422 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1423 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1425 application.SendNotification();
1426 application.Render(0);
1428 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1429 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1431 // The actors should have a world position now
1432 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1433 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1437 int UtcDaliActorInheritPosition(void)
1439 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1440 TestApplication application;
1442 Actor parent = Actor::New();
1443 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1444 parent.SetPosition( parentPosition );
1445 parent.SetParentOrigin( ParentOrigin::CENTER );
1446 parent.SetAnchorPoint( AnchorPoint::CENTER );
1447 Stage::GetCurrent().Add( parent );
1449 Actor child = Actor::New();
1450 child.SetParentOrigin( ParentOrigin::CENTER );
1451 child.SetAnchorPoint( AnchorPoint::CENTER );
1452 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1453 child.SetPosition( childPosition );
1454 parent.Add( child );
1456 // The actors should not have a world position yet
1457 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1458 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1460 // first test default, which is to inherit position
1461 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1462 application.SendNotification();
1463 application.Render(0); // should only really call Update as Render is not required to update scene
1464 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1465 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1466 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1467 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1470 //Change child position
1471 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1472 child.SetPosition( childOffset );
1474 // Change inheritance mode to not inherit
1475 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1476 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1477 application.SendNotification();
1478 application.Render(0); // should only really call Update as Render is not required to update scene
1479 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1480 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1481 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1482 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1486 int UtcDaliActorSetInheritPosition(void)
1488 tet_infoline("Testing Actor::SetInheritPosition");
1489 TestApplication application;
1491 Actor parent = Actor::New();
1492 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1493 parent.SetPosition( parentPosition );
1494 parent.SetParentOrigin( ParentOrigin::CENTER );
1495 parent.SetAnchorPoint( AnchorPoint::CENTER );
1496 Stage::GetCurrent().Add( parent );
1498 Actor child = Actor::New();
1499 child.SetParentOrigin( ParentOrigin::CENTER );
1500 child.SetAnchorPoint( AnchorPoint::CENTER );
1501 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1502 child.SetPosition( childPosition );
1503 parent.Add( child );
1505 // The actors should not have a world position yet
1506 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1507 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1509 // first test default, which is to inherit position
1510 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1511 application.SendNotification();
1512 application.Render(0); // should only really call Update as Render is not required to update scene
1513 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1514 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1515 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1516 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1518 //Change child position
1519 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1520 child.SetPosition( childOffset );
1522 // Use local position as world postion
1523 child.SetInheritPosition( false );
1524 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1525 application.SendNotification();
1526 application.Render(0); // should only really call Update as Render is not required to update scene
1527 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1528 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1529 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1530 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1532 //Change back to inherit position from parent
1533 child.SetInheritPosition( true );
1534 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1535 application.SendNotification();
1536 application.Render(0); // should only really call Update as Render is not required to update scene
1537 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1538 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1539 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1540 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1544 // SetOrientation(float angleRadians, Vector3 axis)
1545 int UtcDaliActorSetOrientation01(void)
1547 TestApplication application;
1549 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1550 Actor actor = Actor::New();
1552 actor.SetOrientation(rotation);
1554 // flush the queue and render once
1555 application.SendNotification();
1556 application.Render();
1558 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1562 int UtcDaliActorSetOrientation02(void)
1564 TestApplication application;
1566 Actor actor = Actor::New();
1568 Radian angle( 0.785f );
1569 Vector3 axis(1.0f, 1.0f, 0.0f);
1571 actor.SetOrientation( angle, axis);
1572 Quaternion rotation( angle, axis );
1573 // flush the queue and render once
1574 application.SendNotification();
1575 application.Render();
1576 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1578 Stage::GetCurrent().Add( actor );
1579 actor.RotateBy( Degree( 360 ), axis);
1580 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1582 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1583 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1584 // flush the queue and render once
1585 application.SendNotification();
1586 application.Render();
1587 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1589 actor.SetOrientation( angle, axis);
1590 // flush the queue and render once
1591 application.SendNotification();
1592 application.Render();
1593 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1595 Stage::GetCurrent().Remove( actor );
1599 // SetOrientation(float angleRadians, Vector3 axis)
1600 int UtcDaliActorSetOrientationProperty(void)
1602 TestApplication application;
1604 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1605 Actor actor = Actor::New();
1607 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1608 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1610 // flush the queue and render once
1611 application.SendNotification();
1612 application.Render();
1614 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1615 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1616 DALI_TEST_EQUALS(rotation, DevelHandle::GetCurrentProperty< Quaternion >( actor, Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1620 // RotateBy(float angleRadians, Vector3 axis)
1621 int UtcDaliActorRotateBy01(void)
1623 TestApplication application;
1625 Actor actor = Actor::New();
1627 Radian angle( M_PI * 0.25f );
1628 actor.RotateBy(( angle ), Vector3::ZAXIS);
1629 // flush the queue and render once
1630 application.SendNotification();
1631 application.Render();
1632 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1634 Stage::GetCurrent().Add( actor );
1636 actor.RotateBy( angle, Vector3::ZAXIS);
1637 // flush the queue and render once
1638 application.SendNotification();
1639 application.Render();
1640 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1642 Stage::GetCurrent().Remove( actor );
1646 // RotateBy(Quaternion relativeRotation)
1647 int UtcDaliActorRotateBy02(void)
1649 TestApplication application;
1651 Actor actor = Actor::New();
1653 Radian angle( M_PI * 0.25f );
1654 Quaternion rotation(angle, Vector3::ZAXIS);
1655 actor.RotateBy(rotation);
1656 // flush the queue and render once
1657 application.SendNotification();
1658 application.Render();
1659 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1661 actor.RotateBy(rotation);
1662 // flush the queue and render once
1663 application.SendNotification();
1664 application.Render();
1665 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1669 int UtcDaliActorGetCurrentOrientation(void)
1671 TestApplication application;
1672 Actor actor = Actor::New();
1674 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1675 actor.SetOrientation(rotation);
1676 // flush the queue and render once
1677 application.SendNotification();
1678 application.Render();
1679 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1683 int UtcDaliActorGetCurrentWorldOrientation(void)
1685 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1686 TestApplication application;
1688 Actor parent = Actor::New();
1689 Radian rotationAngle( Degree(90.0f) );
1690 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1691 parent.SetOrientation( rotation );
1692 Stage::GetCurrent().Add( parent );
1694 Actor child = Actor::New();
1695 child.SetOrientation( rotation );
1696 parent.Add( child );
1698 // The actors should not have a world rotation yet
1699 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1700 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1702 application.SendNotification();
1703 application.Render(0);
1705 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1706 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1708 // The actors should have a world rotation now
1709 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1710 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1712 // turn off child rotation inheritance
1713 child.SetInheritOrientation( false );
1714 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1715 application.SendNotification();
1716 application.Render(0);
1718 // The actors should have a world rotation now
1719 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1720 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1724 // SetScale(float scale)
1725 int UtcDaliActorSetScale01(void)
1727 TestApplication application;
1729 Actor actor = Actor::New();
1731 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1732 actor.SetScale(0.25f);
1734 Vector3 scale(10.0f, 10.0f, 10.0f);
1735 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1737 actor.SetScale(scale.x);
1739 // flush the queue and render once
1740 application.SendNotification();
1741 application.Render();
1743 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1747 // SetScale(float scaleX, float scaleY, float scaleZ)
1748 int UtcDaliActorSetScale02(void)
1750 TestApplication application;
1751 Vector3 scale(10.0f, 10.0f, 10.0f);
1753 Actor actor = Actor::New();
1755 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1756 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1758 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1760 actor.SetScale(scale.x, scale.y, scale.z);
1761 // flush the queue and render once
1762 application.SendNotification();
1763 application.Render();
1764 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1766 // add to stage and test
1767 Stage::GetCurrent().Add( actor );
1768 actor.SetScale( 2.0f, 2.0f, 2.0f );
1769 // flush the queue and render once
1770 application.SendNotification();
1771 application.Render();
1772 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1774 Stage::GetCurrent().Remove( actor );
1779 // SetScale(Vector3 scale)
1780 int UtcDaliActorSetScale03(void)
1782 TestApplication application;
1783 Vector3 scale(10.0f, 10.0f, 10.0f);
1785 Actor actor = Actor::New();
1787 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1788 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1790 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1792 actor.SetScale(scale);
1794 // flush the queue and render once
1795 application.SendNotification();
1796 application.Render();
1798 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1802 int UtcDaliActorSetScaleIndividual(void)
1804 TestApplication application;
1806 Actor actor = Actor::New();
1808 Vector3 vector(0.7f, 0.8f, 0.9f);
1809 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1811 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1812 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1814 // flush the queue and render once
1815 application.SendNotification();
1816 application.Render();
1818 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1819 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1820 DALI_TEST_EQUALS( vector.x, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::SCALE_X ), TEST_LOCATION );
1822 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1823 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1825 // flush the queue and render once
1826 application.SendNotification();
1827 application.Render();
1829 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1830 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1831 DALI_TEST_EQUALS( vector.y, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::SCALE_Y ), TEST_LOCATION );
1833 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1834 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1836 // flush the queue and render once
1837 application.SendNotification();
1838 application.Render();
1840 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1841 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1842 DALI_TEST_EQUALS( vector.z, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::SCALE_Z ), TEST_LOCATION );
1844 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1845 DALI_TEST_EQUALS( vector, DevelHandle::GetCurrentProperty< Vector3 >( actor, Actor::Property::SCALE ), TEST_LOCATION );
1850 int UtcDaliActorScaleBy(void)
1852 TestApplication application;
1853 Actor actor = Actor::New();
1854 Vector3 vector(100.0f, 100.0f, 100.0f);
1856 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1858 actor.SetScale(vector);
1860 // flush the queue and render once
1861 application.SendNotification();
1862 application.Render();
1864 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1866 actor.ScaleBy(vector);
1868 // flush the queue and render once
1869 application.SendNotification();
1870 application.Render();
1872 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1876 int UtcDaliActorGetCurrentScale(void)
1878 TestApplication application;
1879 Vector3 scale(12.0f, 1.0f, 2.0f);
1881 Actor actor = Actor::New();
1883 actor.SetScale(scale);
1885 // flush the queue and render once
1886 application.SendNotification();
1887 application.Render();
1889 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1893 int UtcDaliActorGetCurrentWorldScale(void)
1895 TestApplication application;
1897 Actor parent = Actor::New();
1898 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1899 parent.SetScale( parentScale );
1900 Stage::GetCurrent().Add( parent );
1902 Actor child = Actor::New();
1903 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1904 child.SetScale( childScale );
1905 parent.Add( child );
1907 // The actors should not have a scale yet
1908 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1909 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1911 // The actors should not have a world scale yet
1912 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1913 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1915 application.SendNotification();
1916 application.Render(0);
1918 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1919 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1921 // The actors should have a world scale now
1922 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1923 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1927 int UtcDaliActorInheritScale(void)
1929 tet_infoline("Testing Actor::SetInheritScale");
1930 TestApplication application;
1932 Actor parent = Actor::New();
1933 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1934 parent.SetScale( parentScale );
1935 Stage::GetCurrent().Add( parent );
1937 Actor child = Actor::New();
1938 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1939 child.SetScale( childScale );
1940 parent.Add( child );
1942 application.SendNotification();
1943 application.Render(0);
1945 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1946 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1948 child.SetInheritScale( false );
1949 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1951 application.SendNotification();
1952 application.Render(0);
1954 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1958 int UtcDaliActorSetVisible(void)
1960 TestApplication application;
1962 Actor actor = Actor::New();
1963 actor.SetVisible(false);
1964 // flush the queue and render once
1965 application.SendNotification();
1966 application.Render();
1967 DALI_TEST_CHECK(actor.IsVisible() == false);
1969 actor.SetVisible(true);
1970 // flush the queue and render once
1971 application.SendNotification();
1972 application.Render();
1973 DALI_TEST_CHECK(actor.IsVisible() == true);
1975 // put actor on stage
1976 Stage::GetCurrent().Add( actor );
1977 actor.SetVisible(false);
1978 // flush the queue and render once
1979 application.SendNotification();
1980 application.Render();
1981 DALI_TEST_CHECK(actor.IsVisible() == false);
1985 int UtcDaliActorIsVisible(void)
1987 TestApplication application;
1989 Actor actor = Actor::New();
1991 DALI_TEST_CHECK(actor.IsVisible() == true);
1995 int UtcDaliActorSetOpacity(void)
1997 TestApplication application;
1999 Actor actor = Actor::New();
2000 // initial opacity is 1
2001 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2003 actor.SetOpacity( 0.4f);
2004 // flush the queue and render once
2005 application.SendNotification();
2006 application.Render();
2007 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2009 // change opacity, actor is on stage to change is not immediate
2010 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2011 // flush the queue and render once
2012 application.SendNotification();
2013 application.Render();
2014 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2016 // put actor on stage
2017 Stage::GetCurrent().Add( actor );
2019 // change opacity, actor is on stage to change is not immediate
2020 actor.SetOpacity( 0.9f );
2021 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2022 // flush the queue and render once
2023 application.SendNotification();
2024 application.Render();
2025 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2027 // change opacity, actor is on stage to change is not immediate
2028 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2029 // flush the queue and render once
2030 application.SendNotification();
2031 application.Render();
2032 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2036 int UtcDaliActorGetCurrentOpacity(void)
2038 TestApplication application;
2040 Actor actor = Actor::New();
2041 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2043 actor.SetOpacity(0.5f);
2044 // flush the queue and render once
2045 application.SendNotification();
2046 application.Render();
2047 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2051 int UtcDaliActorSetSensitive(void)
2053 TestApplication application;
2054 Actor actor = Actor::New();
2056 bool sensitive = !actor.IsSensitive();
2058 actor.SetSensitive(sensitive);
2060 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2064 int UtcDaliActorIsSensitive(void)
2066 TestApplication application;
2067 Actor actor = Actor::New();
2068 actor.SetSensitive(false);
2070 DALI_TEST_CHECK(false == actor.IsSensitive());
2074 int UtcDaliActorSetColor(void)
2076 TestApplication application;
2077 Actor actor = Actor::New();
2078 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2080 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2082 actor.SetColor(color);
2083 // flush the queue and render once
2084 application.SendNotification();
2085 application.Render();
2086 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2088 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2089 // flush the queue and render once
2090 application.SendNotification();
2091 application.Render();
2092 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2094 Stage::GetCurrent().Add( actor );
2095 actor.SetColor( color );
2096 // flush the queue and render once
2097 application.SendNotification();
2098 application.Render();
2099 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2101 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2102 // flush the queue and render once
2103 application.SendNotification();
2104 application.Render();
2105 // Actor color is not clamped
2106 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2107 // world color is clamped
2108 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2110 Stage::GetCurrent().Remove( actor );
2114 int UtcDaliActorSetColorIndividual(void)
2116 TestApplication application;
2118 Actor actor = Actor::New();
2120 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2121 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2123 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2124 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2126 // flush the queue and render once
2127 application.SendNotification();
2128 application.Render();
2130 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2131 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2132 DALI_TEST_EQUALS( vector.r, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::COLOR_RED ), TEST_LOCATION );
2134 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2135 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2137 // flush the queue and render once
2138 application.SendNotification();
2139 application.Render();
2141 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2142 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2143 DALI_TEST_EQUALS( vector.g, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2145 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2146 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2148 // flush the queue and render once
2149 application.SendNotification();
2150 application.Render();
2152 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2153 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2154 DALI_TEST_EQUALS( vector.b, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2157 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2158 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2160 // flush the queue and render once
2161 application.SendNotification();
2162 application.Render();
2164 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2165 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2166 DALI_TEST_EQUALS( vector.a, DevelHandle::GetCurrentProperty< float >( actor, Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2168 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2169 DALI_TEST_EQUALS( vector, DevelHandle::GetCurrentProperty< Vector4 >( actor, Actor::Property::COLOR ), TEST_LOCATION );
2171 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2174 // flush the queue and render once
2175 application.SendNotification();
2176 application.Render();
2178 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2184 int UtcDaliActorGetCurrentColor(void)
2186 TestApplication application;
2187 Actor actor = Actor::New();
2188 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2190 actor.SetColor(color);
2191 // flush the queue and render once
2192 application.SendNotification();
2193 application.Render();
2194 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2198 int UtcDaliActorGetCurrentWorldColor(void)
2200 tet_infoline("Actor::GetCurrentWorldColor");
2201 TestApplication application;
2203 Actor parent = Actor::New();
2204 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2205 parent.SetColor( parentColor );
2206 Stage::GetCurrent().Add( parent );
2208 Actor child = Actor::New();
2209 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2210 child.SetColor( childColor );
2211 parent.Add( child );
2213 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2214 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2216 // verify the default color mode
2217 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2219 // The actors should not have a world color yet
2220 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2221 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2223 application.SendNotification();
2224 application.Render(0);
2226 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2227 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2229 // The actors should have a world color now
2230 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2231 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2234 child.SetColorMode( USE_OWN_COLOR );
2235 application.SendNotification();
2236 application.Render(0);
2237 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2240 child.SetColorMode( USE_PARENT_COLOR );
2241 application.SendNotification();
2242 application.Render(0);
2243 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2244 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2247 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2248 application.SendNotification();
2249 application.Render(0);
2250 Vector4 expectedColor( childColor );
2251 expectedColor.a *= parentColor.a;
2252 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2253 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2257 int UtcDaliActorSetColorMode(void)
2259 tet_infoline("Actor::SetColorMode");
2260 TestApplication application;
2261 Actor actor = Actor::New();
2262 Actor child = Actor::New();
2265 actor.SetColorMode( USE_OWN_COLOR );
2266 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2268 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2269 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2271 actor.SetColorMode( USE_PARENT_COLOR );
2272 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2274 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2275 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2279 int UtcDaliActorScreenToLocal(void)
2281 TestApplication application;
2282 Actor actor = Actor::New();
2283 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2284 actor.SetSize(100.0f, 100.0f);
2285 actor.SetPosition(10.0f, 10.0f);
2286 Stage::GetCurrent().Add(actor);
2288 // flush the queue and render once
2289 application.SendNotification();
2290 application.Render();
2295 application.SendNotification();
2296 application.Render();
2298 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2300 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2301 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2305 int UtcDaliActorSetLeaveRequired(void)
2307 TestApplication application;
2309 Actor actor = Actor::New();
2311 actor.SetLeaveRequired(false);
2312 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2314 actor.SetLeaveRequired(true);
2315 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2319 int UtcDaliActorGetLeaveRequired(void)
2321 TestApplication application;
2323 Actor actor = Actor::New();
2325 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2329 int UtcDaliActorSetKeyboardFocusable(void)
2331 TestApplication application;
2333 Actor actor = Actor::New();
2335 actor.SetKeyboardFocusable(true);
2336 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2338 actor.SetKeyboardFocusable(false);
2339 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2343 int UtcDaliActorIsKeyboardFocusable(void)
2345 TestApplication application;
2347 Actor actor = Actor::New();
2349 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2353 int UtcDaliActorRemoveConstraints(void)
2355 tet_infoline(" UtcDaliActorRemoveConstraints");
2356 TestApplication application;
2358 gTestConstraintCalled = false;
2360 Actor actor = Actor::New();
2362 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2364 actor.RemoveConstraints();
2366 DALI_TEST_CHECK( gTestConstraintCalled == false );
2368 Stage::GetCurrent().Add( actor );
2371 // flush the queue and render once
2372 application.SendNotification();
2373 application.Render();
2375 actor.RemoveConstraints();
2377 DALI_TEST_CHECK( gTestConstraintCalled == true );
2381 int UtcDaliActorRemoveConstraintTag(void)
2383 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2384 TestApplication application;
2386 Actor actor = Actor::New();
2388 // 1. Apply Constraint1 and Constraint2, and test...
2389 unsigned int result1 = 0u;
2390 unsigned int result2 = 0u;
2392 unsigned constraint1Tag = 1u;
2393 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2394 constraint1.SetTag( constraint1Tag );
2395 constraint1.Apply();
2397 unsigned constraint2Tag = 2u;
2398 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2399 constraint2.SetTag( constraint2Tag );
2400 constraint2.Apply();
2402 Stage::GetCurrent().Add( actor );
2403 // flush the queue and render once
2404 application.SendNotification();
2405 application.Render();
2407 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2408 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2410 // 2. Remove Constraint1 and test...
2413 actor.RemoveConstraints(constraint1Tag);
2414 // make color property dirty, which will trigger constraints to be reapplied.
2415 actor.SetColor( Color::WHITE );
2416 // flush the queue and render once
2417 application.SendNotification();
2418 application.Render();
2420 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2421 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2423 // 3. Re-Apply Constraint1 and test...
2426 constraint1.Apply();
2427 // make color property dirty, which will trigger constraints to be reapplied.
2428 actor.SetColor( Color::WHITE );
2429 // flush the queue and render once
2430 application.SendNotification();
2431 application.Render();
2433 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2434 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2436 // 2. Remove Constraint2 and test...
2439 actor.RemoveConstraints(constraint2Tag);
2440 // make color property dirty, which will trigger constraints to be reapplied.
2441 actor.SetColor( Color::WHITE );
2442 // flush the queue and render once
2443 application.SendNotification();
2444 application.Render();
2446 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2447 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2449 // 2. Remove Constraint1 as well and test...
2452 actor.RemoveConstraints(constraint1Tag);
2453 // make color property dirty, which will trigger constraints to be reapplied.
2454 actor.SetColor( Color::WHITE );
2455 // flush the queue and render once
2456 application.SendNotification();
2457 application.Render();
2459 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2460 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2464 int UtcDaliActorTouchedSignal(void)
2466 TestApplication application;
2468 ResetTouchCallbacks();
2470 // get the root layer
2471 Actor actor = Stage::GetCurrent().GetRootLayer();
2472 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2474 application.SendNotification();
2475 application.Render();
2477 // connect to its touch signal
2478 actor.TouchedSignal().Connect( TestCallback );
2480 // simulate a touch event in the middle of the screen
2481 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2482 Dali::Integration::Point point;
2483 point.SetDeviceId( 1 );
2484 point.SetState( PointState::DOWN );
2485 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2486 Dali::Integration::TouchEvent touchEvent;
2487 touchEvent.AddPoint( point );
2488 application.ProcessEvent( touchEvent );
2490 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2494 int UtcDaliActorHoveredSignal(void)
2496 TestApplication application;
2498 gHoverCallBackCalled = false;
2500 // get the root layer
2501 Actor actor = Stage::GetCurrent().GetRootLayer();
2502 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2504 application.SendNotification();
2505 application.Render();
2507 // connect to its hover signal
2508 actor.HoveredSignal().Connect( TestCallback3 );
2510 // simulate a hover event in the middle of the screen
2511 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2512 Dali::Integration::Point point;
2513 point.SetDeviceId( 1 );
2514 point.SetState( PointState::MOTION );
2515 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2516 Dali::Integration::HoverEvent hoverEvent;
2517 hoverEvent.AddPoint( point );
2518 application.ProcessEvent( hoverEvent );
2520 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2524 int UtcDaliActorOnOffStageSignal(void)
2526 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2528 TestApplication application;
2531 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2532 gActorNamesOnOffStage.clear();
2534 Actor parent = Actor::New();
2535 parent.SetName( "parent" );
2536 parent.OnStageSignal().Connect( OnStageCallback );
2537 parent.OffStageSignal().Connect( OffStageCallback );
2539 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2540 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2542 // add parent to stage
2543 Stage::GetCurrent().Add( parent );
2544 // onstage emitted, offstage not
2545 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2546 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2547 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2549 // test adding a child, should get onstage emitted
2551 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2552 gActorNamesOnOffStage.clear();
2554 Actor child = Actor::New();
2555 child.SetName( "child" );
2556 child.OnStageSignal().Connect( OnStageCallback );
2557 child.OffStageSignal().Connect( OffStageCallback );
2558 parent.Add( child ); // add child
2559 // onstage emitted, offstage not
2560 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2561 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2562 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2564 // test removing parent from stage
2566 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2567 gActorNamesOnOffStage.clear();
2569 Stage::GetCurrent().Remove( parent );
2570 // onstage not emitted, offstage is
2571 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2572 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2573 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2574 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2576 // test adding parent back to stage
2578 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2579 gActorNamesOnOffStage.clear();
2581 Stage::GetCurrent().Add( parent );
2582 // onstage emitted, offstage not
2583 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2584 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2585 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2586 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2588 // test removing child
2590 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2591 gActorNamesOnOffStage.clear();
2593 parent.Remove( child );
2594 // onstage not emitted, offstage is
2595 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2596 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2597 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2599 // test removing parent
2601 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2602 gActorNamesOnOffStage.clear();
2604 Stage::GetCurrent().Remove( parent );
2605 // onstage not emitted, offstage is
2606 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2607 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2608 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2612 int UtcDaliActorFindChildByName(void)
2614 tet_infoline("Testing Dali::Actor::FindChildByName()");
2615 TestApplication application;
2617 Actor parent = Actor::New();
2618 parent.SetName( "parent" );
2619 Actor first = Actor::New();
2620 first .SetName( "first" );
2621 Actor second = Actor::New();
2622 second.SetName( "second" );
2627 Actor found = parent.FindChildByName( "foo" );
2628 DALI_TEST_CHECK( !found );
2630 found = parent.FindChildByName( "parent" );
2631 DALI_TEST_CHECK( found == parent );
2633 found = parent.FindChildByName( "first" );
2634 DALI_TEST_CHECK( found == first );
2636 found = parent.FindChildByName( "second" );
2637 DALI_TEST_CHECK( found == second );
2641 int UtcDaliActorFindChildById(void)
2643 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2644 TestApplication application;
2646 Actor parent = Actor::New();
2647 Actor first = Actor::New();
2648 Actor second = Actor::New();
2653 Actor found = parent.FindChildById( 100000 );
2654 DALI_TEST_CHECK( !found );
2656 found = parent.FindChildById( parent.GetId() );
2657 DALI_TEST_CHECK( found == parent );
2659 found = parent.FindChildById( first.GetId() );
2660 DALI_TEST_CHECK( found == first );
2662 found = parent.FindChildById( second.GetId() );
2663 DALI_TEST_CHECK( found == second );
2667 int UtcDaliActorHitTest(void)
2672 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2674 mTouchPoint( touchPoint ),
2679 Vector2 mTouchPoint;
2683 TestApplication application;
2684 tet_infoline(" UtcDaliActorHitTest");
2686 // Fill a vector with different hit tests.
2687 struct HitTestData* hitTestData[] = {
2688 // scale touch point result
2689 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2690 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2691 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.
2692 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2693 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.
2697 // get the root layer
2698 Actor actor = Actor::New();
2699 actor.SetAnchorPoint( AnchorPoint::CENTER );
2700 actor.SetParentOrigin( ParentOrigin::CENTER );
2702 Stage::GetCurrent().Add( actor );
2704 ResetTouchCallbacks();
2706 unsigned int index = 0;
2707 while( NULL != hitTestData[index] )
2709 actor.SetSize( 1.f, 1.f );
2710 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2712 // flush the queue and render once
2713 application.SendNotification();
2714 application.Render();
2716 DALI_TEST_CHECK( !gTouchCallBackCalled );
2718 // connect to its touch signal
2719 actor.TouchedSignal().Connect(TestCallback);
2721 Dali::Integration::Point point;
2722 point.SetState( PointState::DOWN );
2723 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2724 Dali::Integration::TouchEvent event;
2725 event.AddPoint( point );
2727 // flush the queue and render once
2728 application.SendNotification();
2729 application.Render();
2730 application.ProcessEvent( event );
2732 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2734 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2735 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2736 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2737 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2738 hitTestData[index]->mResult );
2740 ResetTouchCallbacks();
2746 int UtcDaliActorSetDrawMode(void)
2748 TestApplication app;
2749 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2751 Actor a = Actor::New();
2753 Stage::GetCurrent().Add(a);
2754 app.SendNotification();
2756 app.SendNotification();
2759 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2761 a.SetDrawMode( DrawMode::OVERLAY_2D );
2762 app.SendNotification();
2765 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2767 a.SetDrawMode( DrawMode::NORMAL );
2768 app.SendNotification();
2771 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2775 int UtcDaliActorSetDrawModeOverlayRender(void)
2777 TestApplication app;
2778 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2780 app.SendNotification();
2783 std::vector<GLuint> ids;
2784 ids.push_back( 8 ); // first rendered actor
2785 ids.push_back( 9 ); // second rendered actor
2786 ids.push_back( 10 ); // third rendered actor
2787 app.GetGlAbstraction().SetNextTextureIds( ids );
2789 BufferImage imageA = BufferImage::New(16, 16);
2790 BufferImage imageB = BufferImage::New(16, 16);
2791 BufferImage imageC = BufferImage::New(16, 16);
2792 Actor a = CreateRenderableActor( imageA );
2793 Actor b = CreateRenderableActor( imageB );
2794 Actor c = CreateRenderableActor( imageC );
2796 app.SendNotification();
2799 //Textures are bound when first created. Clear bound textures vector
2800 app.GetGlAbstraction().ClearBoundTextures();
2802 // Render a,b,c as regular non-overlays. so order will be:
2806 Stage::GetCurrent().Add(a);
2807 Stage::GetCurrent().Add(b);
2808 Stage::GetCurrent().Add(c);
2810 app.SendNotification();
2813 // Should be 3 textures changes.
2814 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2815 typedef std::vector<GLuint>::size_type TextureSize;
2816 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2817 if( boundTextures.size() == 3 )
2819 DALI_TEST_CHECK( boundTextures[0] == 8u );
2820 DALI_TEST_CHECK( boundTextures[1] == 9u );
2821 DALI_TEST_CHECK( boundTextures[2] == 10u );
2824 // Now texture ids have been set, we can monitor their render order.
2825 // render a as an overlay (last), so order will be:
2829 a.SetDrawMode( DrawMode::OVERLAY_2D );
2830 app.GetGlAbstraction().ClearBoundTextures();
2832 app.SendNotification();
2835 // Should be 3 texture changes.
2836 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2837 if( boundTextures.size() == 3 )
2839 DALI_TEST_CHECK( boundTextures[0] == 9u );
2840 DALI_TEST_CHECK( boundTextures[1] == 10u );
2841 DALI_TEST_CHECK( boundTextures[2] == 8u );
2846 int UtcDaliActorGetCurrentWorldMatrix(void)
2848 TestApplication app;
2849 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2851 Actor parent = Actor::New();
2852 parent.SetParentOrigin(ParentOrigin::CENTER);
2853 parent.SetAnchorPoint(AnchorPoint::CENTER);
2854 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2855 Radian rotationAngle(Degree(85.0f));
2856 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2857 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2858 parent.SetPosition( parentPosition );
2859 parent.SetOrientation( parentRotation );
2860 parent.SetScale( parentScale );
2861 Stage::GetCurrent().Add( parent );
2863 Actor child = Actor::New();
2864 child.SetParentOrigin(ParentOrigin::CENTER);
2865 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2866 Radian childRotationAngle(Degree(23.0f));
2867 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2868 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2869 child.SetPosition( childPosition );
2870 child.SetOrientation( childRotation );
2871 child.SetScale( childScale );
2872 parent.Add( child );
2874 app.SendNotification();
2877 app.SendNotification();
2879 Matrix parentMatrix(false);
2880 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2882 Matrix childMatrix(false);
2883 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2885 //Child matrix should be the composition of child and parent
2886 Matrix childWorldMatrix(false);
2887 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2889 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2890 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2896 int UtcDaliActorConstrainedToWorldMatrix(void)
2898 TestApplication app;
2899 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2901 Actor parent = Actor::New();
2902 parent.SetParentOrigin(ParentOrigin::CENTER);
2903 parent.SetAnchorPoint(AnchorPoint::CENTER);
2904 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2905 Radian rotationAngle(Degree(85.0f));
2906 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2907 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2908 parent.SetPosition( parentPosition );
2909 parent.SetOrientation( parentRotation );
2910 parent.SetScale( parentScale );
2911 Stage::GetCurrent().Add( parent );
2913 Actor child = Actor::New();
2914 child.SetParentOrigin(ParentOrigin::CENTER);
2915 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2916 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2917 posConstraint.Apply();
2919 Stage::GetCurrent().Add( child );
2921 app.SendNotification();
2924 app.SendNotification();
2926 Matrix parentMatrix(false);
2927 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2929 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2930 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2934 int UtcDaliActorConstrainedToOrientation(void)
2936 TestApplication app;
2937 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2939 Actor parent = Actor::New();
2940 parent.SetParentOrigin(ParentOrigin::CENTER);
2941 parent.SetAnchorPoint(AnchorPoint::CENTER);
2942 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2943 Radian rotationAngle(Degree(85.0f));
2944 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2945 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2946 parent.SetPosition( parentPosition );
2947 parent.SetOrientation( parentRotation );
2948 parent.SetScale( parentScale );
2949 Stage::GetCurrent().Add( parent );
2951 Actor child = Actor::New();
2952 child.SetParentOrigin(ParentOrigin::CENTER);
2953 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2954 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2955 posConstraint.Apply();
2957 Stage::GetCurrent().Add( child );
2959 app.SendNotification();
2962 app.SendNotification();
2964 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2968 int UtcDaliActorConstrainedToOpacity(void)
2970 TestApplication app;
2971 tet_infoline(" UtcDaliActorConstrainedToOpacity");
2973 Actor parent = Actor::New();
2974 parent.SetOpacity( 0.7f );
2975 Stage::GetCurrent().Add( parent );
2977 Actor child = Actor::New();
2978 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2979 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2980 opacityConstraint.Apply();
2982 Stage::GetCurrent().Add( child );
2984 app.SendNotification();
2987 app.SendNotification();
2989 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2991 parent.SetOpacity( 0.3f );
2993 app.SendNotification();
2996 app.SendNotification();
2998 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3003 int UtcDaliActorUnparent(void)
3005 TestApplication app;
3006 tet_infoline(" UtcDaliActorUnparent");
3008 Actor parent = Actor::New();
3009 Stage::GetCurrent().Add( parent );
3011 Actor child = Actor::New();
3013 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3014 DALI_TEST_CHECK( !child.GetParent() );
3016 // Test that calling Unparent with no parent is a NOOP
3019 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3020 DALI_TEST_CHECK( !child.GetParent() );
3022 // Test that Unparent works
3023 parent.Add( child );
3025 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3026 DALI_TEST_CHECK( parent == child.GetParent() );
3030 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3031 DALI_TEST_CHECK( !child.GetParent() );
3033 // Test that UnparentAndReset works
3034 parent.Add( child );
3036 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3037 DALI_TEST_CHECK( parent == child.GetParent() );
3039 UnparentAndReset( child );
3041 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3042 DALI_TEST_CHECK( !child );
3044 // Test that UnparentAndReset is a NOOP with empty handle
3045 UnparentAndReset( child );
3047 DALI_TEST_CHECK( !child );
3051 int UtcDaliActorGetChildAt(void)
3053 TestApplication app;
3054 tet_infoline(" UtcDaliActorGetChildAt");
3056 Actor parent = Actor::New();
3057 Stage::GetCurrent().Add( parent );
3059 Actor child0 = Actor::New();
3060 parent.Add( child0 );
3062 Actor child1 = Actor::New();
3063 parent.Add( child1 );
3065 Actor child2 = Actor::New();
3066 parent.Add( child2 );
3068 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3069 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3070 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3074 int UtcDaliActorSetGetOverlay(void)
3076 TestApplication app;
3077 tet_infoline(" UtcDaliActorSetGetOverlay");
3079 Actor parent = Actor::New();
3080 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3081 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3086 int UtcDaliActorCreateDestroy(void)
3088 Actor* actor = new Actor;
3089 DALI_TEST_CHECK( actor );
3096 struct PropertyStringIndex
3098 const char * const name;
3099 const Property::Index index;
3100 const Property::Type type;
3103 const PropertyStringIndex PROPERTY_TABLE[] =
3105 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3106 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3107 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3108 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3109 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3110 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3111 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3112 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3113 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3114 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3115 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3116 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3117 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3118 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3119 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3120 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3121 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3122 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3123 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3124 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3125 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3126 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3127 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3128 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3129 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3130 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3131 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3132 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3133 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3134 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3135 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3136 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3137 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3138 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3139 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3140 { "name", Actor::Property::NAME, Property::STRING },
3141 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3142 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3143 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3144 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3145 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3146 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3147 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3148 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3149 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3150 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3151 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3152 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3153 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3154 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3155 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3156 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3157 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3158 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3159 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3161 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3162 } // unnamed namespace
3164 int UtcDaliActorProperties(void)
3166 TestApplication app;
3168 Actor actor = Actor::New();
3170 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3172 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3173 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3174 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3175 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3180 int UtcDaliRelayoutProperties_ResizePolicies(void)
3182 TestApplication app;
3184 Actor actor = Actor::New();
3187 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3188 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3190 // Set resize policy for all dimensions
3191 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3192 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3194 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3197 // Set individual dimensions
3198 const char* const widthPolicy = "FILL_TO_PARENT";
3199 const char* const heightPolicy = "FIXED";
3201 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3202 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3204 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3205 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3207 // Set individual dimensions using enums
3208 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3209 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3211 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3212 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3214 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3215 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3220 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3222 TestApplication app;
3224 Actor actor = Actor::New();
3227 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3228 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3230 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3231 actor.SetSizeScalePolicy( policy );
3232 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3235 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3236 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3238 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3239 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3241 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3242 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3247 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3249 TestApplication app;
3251 Actor actor = Actor::New();
3254 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3255 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3257 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3258 actor.SetSizeModeFactor( sizeMode );
3259 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3262 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3264 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3265 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3270 int UtcDaliRelayoutProperties_DimensionDependency(void)
3272 TestApplication app;
3274 Actor actor = Actor::New();
3277 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3278 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3281 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3282 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3284 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3285 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3287 // Test setting another resize policy
3288 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3289 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3294 int UtcDaliRelayoutProperties_Padding(void)
3296 TestApplication app;
3298 Actor actor = Actor::New();
3301 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3304 actor.SetProperty( Actor::Property::PADDING, padding );
3305 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3307 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3312 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3314 TestApplication app;
3316 Actor actor = Actor::New();
3319 Vector2 minSize( 1.0f, 2.0f );
3321 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3322 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3324 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3326 Vector2 maxSize( 3.0f, 4.0f );
3328 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3329 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3331 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3336 int UtcDaliActorGetHeightForWidth(void)
3338 TestApplication app;
3340 Actor actor = Actor::New();
3342 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3347 int UtcDaliActorGetWidthForHeight(void)
3349 TestApplication app;
3351 Actor actor = Actor::New();
3353 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3358 int UtcDaliActorGetRelayoutSize(void)
3360 TestApplication app;
3362 Actor actor = Actor::New();
3364 // Add actor to stage
3365 Stage::GetCurrent().Add( actor );
3367 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3369 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3370 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3372 // Flush the queue and render once
3373 app.SendNotification();
3376 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3381 int UtcDaliActorSetPadding(void)
3383 TestApplication app;
3385 Actor actor = Actor::New();
3388 actor.GetPadding( padding );
3390 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3391 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3392 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3393 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3395 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3396 actor.SetPadding( padding2 );
3398 actor.GetPadding( padding );
3400 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3401 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3402 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3403 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3408 int UtcDaliActorSetMinimumSize(void)
3410 TestApplication app;
3412 Actor actor = Actor::New();
3414 Vector2 size = actor.GetMinimumSize();
3416 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3417 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3419 Vector2 size2( 1.0f, 2.0f );
3420 actor.SetMinimumSize( size2 );
3422 size = actor.GetMinimumSize();
3424 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3425 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3430 int UtcDaliActorSetMaximumSize(void)
3432 TestApplication app;
3434 Actor actor = Actor::New();
3436 Vector2 size = actor.GetMaximumSize();
3438 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3439 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3441 Vector2 size2( 1.0f, 2.0f );
3442 actor.SetMaximumSize( size2 );
3444 size = actor.GetMaximumSize();
3446 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3447 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3452 int UtcDaliActorOnRelayoutSignal(void)
3454 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3456 TestApplication application;
3459 gOnRelayoutCallBackCalled = false;
3460 gActorNamesRelayout.clear();
3462 Actor actor = Actor::New();
3463 actor.SetName( "actor" );
3464 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3467 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3469 // Add actor to stage
3470 Stage::GetCurrent().Add( actor );
3472 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3473 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3475 // Flush the queue and render once
3476 application.SendNotification();
3477 application.Render();
3479 // OnRelayout emitted
3480 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3481 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3486 int UtcDaliActorGetHierachyDepth(void)
3488 TestApplication application;
3489 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3492 /* Build tree of actors:
3502 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3504 Stage stage( Stage::GetCurrent() );
3506 Actor actorA = Actor::New();
3507 Actor actorB = Actor::New();
3508 Actor actorC = Actor::New();
3509 Actor actorD = Actor::New();
3510 Actor actorE = Actor::New();
3511 Actor actorF = Actor::New();
3513 //Test that root actor has depth equal 0
3514 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3516 //Test actors return depth -1 when not connected to the tree
3517 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3518 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3519 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3520 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3521 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3522 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3524 //Create the hierarchy
3525 stage.Add( actorA );
3526 actorA.Add( actorB );
3527 actorA.Add( actorC );
3528 actorB.Add( actorD );
3529 actorB.Add( actorE );
3530 actorC.Add( actorF );
3532 //Test actors return correct depth
3533 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3534 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3535 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3536 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3537 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3538 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3540 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3541 actorA.Remove( actorB );
3543 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3544 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3545 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3547 //Removing actorA from the stage. All actors should have depth equal -1
3548 stage.Remove( actorA );
3550 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3551 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3552 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3553 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3554 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3555 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3560 int UtcDaliActorAnchorPointPropertyAsString(void)
3562 TestApplication application;
3564 Actor actor = Actor::New();
3566 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3567 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3569 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3570 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3572 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3573 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3575 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3576 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3578 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3579 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3581 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3582 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3584 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3585 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3587 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3588 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3590 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3591 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3593 // Invalid should not change anything
3594 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3595 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3600 int UtcDaliActorParentOriginPropertyAsString(void)
3602 TestApplication application;
3604 Actor actor = Actor::New();
3606 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3607 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3609 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3610 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3612 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3613 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3615 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3616 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3618 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3619 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3621 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3622 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3624 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3625 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3627 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3628 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3630 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3631 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3633 // Invalid should not change anything
3634 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3635 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3640 int UtcDaliActorColorModePropertyAsString(void)
3642 TestApplication application;
3644 Actor actor = Actor::New();
3646 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3647 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3649 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3650 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3652 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3653 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3655 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3656 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3658 // Invalid should not change anything
3659 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3660 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3665 int UtcDaliActorPositionInheritancePropertyAsString(void)
3667 TestApplication application;
3669 Actor actor = Actor::New();
3671 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3672 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3674 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3675 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3677 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3678 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3680 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3681 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3683 // Invalid should not change anything
3684 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3685 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3690 int UtcDaliActorDrawModePropertyAsString(void)
3692 TestApplication application;
3694 Actor actor = Actor::New();
3696 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3697 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3699 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3700 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3702 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3703 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3705 // Invalid should not change anything
3706 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3707 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3712 int UtcDaliActorColorModePropertyAsEnum(void)
3714 TestApplication application;
3716 Actor actor = Actor::New();
3718 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3719 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3721 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3722 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3724 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3725 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3727 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3728 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3733 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3735 TestApplication application;
3737 Actor actor = Actor::New();
3739 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3740 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3742 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3743 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3745 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3746 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3748 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3749 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3754 int UtcDaliActorDrawModePropertyAsEnum(void)
3756 TestApplication application;
3758 Actor actor = Actor::New();
3760 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3761 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3763 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3764 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3766 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3767 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3772 int UtcDaliActorAddRendererP(void)
3774 tet_infoline("Testing Actor::AddRenderer");
3775 TestApplication application;
3777 Actor actor = Actor::New();
3779 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3781 Geometry geometry = CreateQuadGeometry();
3782 Shader shader = CreateShader();
3783 Renderer renderer = Renderer::New(geometry, shader);
3785 actor.AddRenderer( renderer );
3786 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3787 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3792 int UtcDaliActorAddRendererN(void)
3794 tet_infoline("Testing Actor::AddRenderer");
3795 TestApplication application;
3797 Actor actor = Actor::New();
3803 actor.AddRenderer( renderer );
3804 tet_printf("Assertion test failed - no Exception\n" );
3805 tet_result(TET_FAIL);
3807 catch(Dali::DaliException& e)
3809 DALI_TEST_PRINT_ASSERT( e );
3810 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3811 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3815 tet_printf("Assertion test failed - wrong Exception\n" );
3816 tet_result(TET_FAIL);
3822 int UtcDaliActorAddRendererOnStage(void)
3824 tet_infoline("Testing Actor::AddRenderer");
3825 TestApplication application;
3827 Actor actor = Actor::New();
3828 Stage::GetCurrent().Add(actor);
3830 application.SendNotification();
3831 application.Render(0);
3833 Geometry geometry = CreateQuadGeometry();
3834 Shader shader = CreateShader();
3835 Renderer renderer = Renderer::New(geometry, shader);
3837 application.SendNotification();
3838 application.Render(0);
3842 actor.AddRenderer( renderer );
3843 tet_result(TET_PASS);
3847 tet_result(TET_FAIL);
3853 int UtcDaliActorRemoveRendererP1(void)
3855 tet_infoline("Testing Actor::RemoveRenderer");
3856 TestApplication application;
3858 Actor actor = Actor::New();
3860 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3862 Geometry geometry = CreateQuadGeometry();
3863 Shader shader = CreateShader();
3864 Renderer renderer = Renderer::New(geometry, shader);
3866 actor.AddRenderer( renderer );
3867 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3868 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3870 actor.RemoveRenderer(renderer);
3871 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3877 int UtcDaliActorRemoveRendererP2(void)
3879 tet_infoline("Testing Actor::RemoveRenderer");
3880 TestApplication application;
3882 Actor actor = Actor::New();
3884 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3886 Geometry geometry = CreateQuadGeometry();
3887 Shader shader = CreateShader();
3888 Renderer renderer = Renderer::New(geometry, shader);
3890 actor.AddRenderer( renderer );
3891 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3892 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3894 actor.RemoveRenderer(0);
3895 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3902 int UtcDaliActorRemoveRendererN(void)
3904 tet_infoline("Testing Actor::RemoveRenderer");
3905 TestApplication application;
3907 Actor actor = Actor::New();
3909 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3911 Geometry geometry = CreateQuadGeometry();
3912 Shader shader = CreateShader();
3913 Renderer renderer = Renderer::New(geometry, shader);
3915 actor.AddRenderer( renderer );
3916 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3917 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3919 actor.RemoveRenderer(10);
3920 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3921 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3926 // Clipping test helper functions:
3927 Actor CreateActorWithContent()
3929 BufferImage image = BufferImage::New( 16u, 16u );
3930 Actor actor = CreateRenderableActor( image );
3932 // Setup dimensions and position so actor is not skipped by culling.
3933 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3934 actor.SetSize( 16.0f, 16.0f );
3935 actor.SetParentOrigin( ParentOrigin::CENTER );
3936 actor.SetAnchorPoint( AnchorPoint::CENTER );
3941 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3943 enabledDisableTrace.Reset();
3944 stencilTrace.Reset();
3945 enabledDisableTrace.Enable( true );
3946 stencilTrace.Enable( true );
3948 application.SendNotification();
3949 application.Render();
3951 enabledDisableTrace.Enable( false );
3952 stencilTrace.Enable( false );
3955 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3957 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3959 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3960 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3961 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3962 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3965 int UtcDaliActorPropertyClippingP(void)
3967 // This test checks the clippingMode property.
3968 tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3969 TestApplication application;
3971 Actor actor = Actor::New();
3973 // Check default clippingEnabled value.
3974 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3977 bool getValueResult = getValue.Get( value );
3978 DALI_TEST_CHECK( getValueResult );
3980 if( getValueResult )
3982 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3985 // Check setting the property.
3986 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3988 // Check the new value was set.
3989 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3990 getValueResult = getValue.Get( value );
3991 DALI_TEST_CHECK( getValueResult );
3993 if( getValueResult )
3995 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4001 int UtcDaliActorPropertyClippingN(void)
4003 // Negative test case for Clipping.
4004 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
4005 TestApplication application;
4007 Actor actor = Actor::New();
4009 // Check default clippingEnabled value.
4010 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4013 bool getValueResult = getValue.Get( value );
4014 DALI_TEST_CHECK( getValueResult );
4016 if( getValueResult )
4018 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4021 // Check setting an invalid property value won't change the current property value.
4022 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4024 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4025 getValueResult = getValue.Get( value );
4026 DALI_TEST_CHECK( getValueResult );
4028 if( getValueResult )
4030 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4036 int UtcDaliActorPropertyClippingActor(void)
4038 // This test checks that an actor is correctly setup for clipping.
4039 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
4040 TestApplication application;
4042 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4043 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4044 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4045 size_t startIndex = 0u;
4047 // Create a clipping actor.
4048 Actor actorDepth1Clip = CreateActorWithContent();
4049 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4050 Stage::GetCurrent().Add( actorDepth1Clip );
4052 // Gather the call trace.
4053 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4055 // Check we are writing to the color buffer.
4056 CheckColorMask( glAbstraction, true );
4058 // Check the stencil buffer was enabled.
4059 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4061 // Check the stencil buffer was cleared.
4062 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4064 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4065 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4066 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4067 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4072 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4074 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4075 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
4076 TestApplication application;
4078 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4079 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4080 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4081 size_t startIndex = 0u;
4083 // Create a clipping actor.
4084 Actor actorDepth1Clip = CreateActorWithContent();
4085 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4086 Stage::GetCurrent().Add( actorDepth1Clip );
4088 // Gather the call trace.
4089 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4091 // Check we are writing to the color buffer.
4092 CheckColorMask( glAbstraction, true );
4094 // Check the stencil buffer was enabled.
4095 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4097 // Check the stencil buffer was cleared.
4098 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4100 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4101 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4102 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4103 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4105 // Now disable the clipping
4106 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4108 // Gather the call trace.
4109 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4111 // Check the stencil buffer was disabled.
4112 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4114 // Ensure all values in stencil-mask are set to 1.
4116 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4122 int UtcDaliActorPropertyClippingNestedChildren(void)
4124 // This test checks that a hierarchy of actors are clipped correctly by
4125 // writing to and reading from the correct bit-planes of the stencil buffer.
4126 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
4127 TestApplication application;
4128 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4129 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4130 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4132 // Create a clipping actor.
4133 Actor actorDepth1Clip = CreateActorWithContent();
4134 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4135 Stage::GetCurrent().Add( actorDepth1Clip );
4137 // Create a child actor.
4138 Actor childDepth2 = CreateActorWithContent();
4139 actorDepth1Clip.Add( childDepth2 );
4141 // Create another clipping actor.
4142 Actor childDepth2Clip = CreateActorWithContent();
4143 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4144 childDepth2.Add( childDepth2Clip );
4146 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4147 // This tests the sort algorithm.
4148 Actor childDepth3 = CreateActorWithContent();
4149 childDepth2Clip.Add( childDepth3 );
4150 Actor childDepth4 = CreateActorWithContent();
4151 childDepth3.Add( childDepth4 );
4153 // Gather the call trace.
4154 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4156 // Check we are writing to the color buffer.
4157 CheckColorMask( glAbstraction, true );
4159 // Check the stencil buffer was enabled.
4160 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4162 // Perform the test twice, once for 2D layer, and once for 3D.
4163 for( unsigned int i = 0u ; i < 2u; ++i )
4165 size_t startIndex = 0u;
4167 // Check the stencil buffer was cleared.
4168 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4170 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4171 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4172 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4173 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4175 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4176 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4177 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4179 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4180 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4181 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4182 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4184 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4185 // (Both must be set to pass the check).
4186 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4187 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4189 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4192 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4193 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4200 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4202 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4203 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4204 TestApplication application;
4206 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4207 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4208 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4210 // Create a clipping actor.
4211 Actor actorDepth1Clip = CreateActorWithContent();
4212 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4213 Stage::GetCurrent().Add( actorDepth1Clip );
4215 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4216 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4218 // Gather the call trace.
4219 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4221 // Check we are writing to the color buffer.
4222 CheckColorMask( glAbstraction, true );
4224 // Check the stencil buffer was not enabled.
4225 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4227 // Check stencil functions are not called.
4228 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4229 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4230 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4235 int UtcDaliGetPropertyN(void)
4237 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4238 TestApplication app;
4240 Actor actor = Actor::New();
4242 unsigned int propertyCount = actor.GetPropertyCount();
4243 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4247 int UtcDaliActorRaiseLower(void)
4249 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4251 TestApplication application;
4253 Stage stage( Stage::GetCurrent() );
4255 Actor actorA = Actor::New();
4256 Actor actorB = Actor::New();
4257 Actor actorC = Actor::New();
4259 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4260 actorA.SetParentOrigin( ParentOrigin::CENTER );
4262 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4263 actorB.SetParentOrigin( ParentOrigin::CENTER );
4265 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4266 actorC.SetParentOrigin( ParentOrigin::CENTER );
4268 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4269 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4271 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4272 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4274 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4275 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4277 stage.Add( actorA );
4278 stage.Add( actorB );
4279 stage.Add( actorC );
4281 ResetTouchCallbacks();
4283 application.SendNotification();
4284 application.Render();
4286 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4287 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4288 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4290 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4291 // Only top actor will get touched.
4292 actorA.TouchSignal().Connect( TestTouchCallback );
4293 actorB.TouchSignal().Connect( TestTouchCallback2 );
4294 actorC.TouchSignal().Connect( TestTouchCallback3 );
4296 Dali::Integration::Point point;
4297 point.SetDeviceId( 1 );
4298 point.SetState( PointState::DOWN );
4299 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4300 Dali::Integration::TouchEvent touchEvent;
4301 touchEvent.AddPoint( point );
4303 application.ProcessEvent( touchEvent );
4305 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4306 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4307 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4309 ResetTouchCallbacks();
4311 tet_printf( "Testing Raising of Actor\n" );
4313 int preActorOrder( 0 );
4314 int postActorOrder( 0 );
4316 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4317 value.Get( preActorOrder );
4319 DevelActor::Raise( actorB );
4320 // Ensure sort order is calculated before next touch event
4321 application.SendNotification();
4323 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4324 value.Get( postActorOrder );
4326 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4328 application.ProcessEvent( touchEvent );
4330 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4331 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4332 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4334 ResetTouchCallbacks();
4336 tet_printf( "Testing Lowering of Actor\n" );
4338 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4339 value.Get( preActorOrder );
4341 DevelActor::Lower( actorB );
4342 application.SendNotification(); // ensure sort order calculated before next touch event
4344 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4345 value.Get( postActorOrder );
4347 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4349 application.ProcessEvent( touchEvent );
4351 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4352 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4353 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4355 ResetTouchCallbacks();
4360 int UtcDaliActorRaiseToTopLowerToBottom(void)
4362 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4364 TestApplication application;
4366 Stage stage( Stage::GetCurrent() );
4368 Actor actorA = Actor::New();
4369 Actor actorB = Actor::New();
4370 Actor actorC = Actor::New();
4372 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4373 // enables checking of which actor the uniform is assigned too
4374 Shader shaderA = CreateShader();
4375 shaderA.RegisterProperty( "uRendererColor",1.f);
4377 Shader shaderB = CreateShader();
4378 shaderB.RegisterProperty( "uRendererColor", 2.f );
4380 Shader shaderC = CreateShader();
4381 shaderC.RegisterProperty( "uRendererColor", 3.f );
4383 Geometry geometry = CreateQuadGeometry();
4385 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4386 Renderer rendererA = Renderer::New(geometry, shaderA);
4387 actorA.AddRenderer(rendererA);
4389 Renderer rendererB = Renderer::New(geometry, shaderB);
4390 actorB.AddRenderer(rendererB);
4392 Renderer rendererC = Renderer::New(geometry, shaderC);
4393 actorC.AddRenderer(rendererC);
4395 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4396 actorA.SetParentOrigin( ParentOrigin::CENTER );
4398 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4399 actorB.SetParentOrigin( ParentOrigin::CENTER );
4401 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4402 actorC.SetParentOrigin( ParentOrigin::CENTER );
4404 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4405 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4407 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4408 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4410 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4411 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4413 stage.Add( actorA );
4414 stage.Add( actorB );
4415 stage.Add( actorC );
4417 ResetTouchCallbacks();
4419 // Set up gl abstraction trace so can query the set uniform order
4420 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4421 glAbstraction.EnableSetUniformCallTrace(true);
4422 glAbstraction.ResetSetUniformCallStack();
4424 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4426 application.SendNotification();
4427 application.Render();
4429 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4432 // Test order of uniforms in stack
4433 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4434 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4435 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4437 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4439 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4441 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4442 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4443 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4445 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4446 // Only top actor will get touched.
4447 actorA.TouchSignal().Connect( TestTouchCallback );
4448 actorB.TouchSignal().Connect( TestTouchCallback2 );
4449 actorC.TouchSignal().Connect( TestTouchCallback3 );
4451 Dali::Integration::Point point;
4452 point.SetDeviceId( 1 );
4453 point.SetState( PointState::DOWN );
4454 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4455 Dali::Integration::TouchEvent touchEvent;
4456 touchEvent.AddPoint( point );
4458 application.ProcessEvent( touchEvent );
4460 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4461 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4462 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4464 ResetTouchCallbacks();
4466 tet_printf( "RaiseToTop ActorA\n" );
4468 DevelActor::RaiseToTop( actorA );
4469 application.SendNotification(); // ensure sorting order is calculated before next touch event
4471 application.ProcessEvent( touchEvent );
4473 glAbstraction.ResetSetUniformCallStack();
4474 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4476 application.SendNotification();
4477 application.Render();
4479 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4481 // Test order of uniforms in stack
4482 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4483 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4484 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4486 tet_infoline( "Testing A above C and B at bottom\n" );
4487 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4489 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4491 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4492 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4493 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4495 ResetTouchCallbacks();
4497 tet_printf( "RaiseToTop ActorB\n" );
4499 DevelActor::RaiseToTop( actorB );
4500 application.SendNotification(); // Ensure sort order is calculated before next touch event
4502 application.ProcessEvent( touchEvent );
4504 glAbstraction.ResetSetUniformCallStack();
4505 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4507 application.SendNotification();
4508 application.Render();
4510 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4512 // Test order of uniforms in stack
4513 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4514 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4515 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4517 tet_infoline( "Testing B above A and C at bottom\n" );
4518 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4520 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4522 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4523 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4524 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4526 ResetTouchCallbacks();
4528 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4530 DevelActor::LowerToBottom( actorA );
4531 application.SendNotification();
4532 application.Render();
4534 DevelActor::LowerToBottom( actorB );
4535 application.SendNotification();
4536 application.Render();
4538 application.ProcessEvent( touchEvent );
4540 glAbstraction.ResetSetUniformCallStack();
4541 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4543 application.SendNotification();
4544 application.Render();
4546 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4548 // Test order of uniforms in stack
4549 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4550 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4551 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4553 tet_infoline( "Testing C above A and B at bottom\n" );
4554 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4556 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4558 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4559 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4560 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4562 ResetTouchCallbacks();
4567 int UtcDaliActorRaiseAbove(void)
4569 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4571 TestApplication application;
4573 Stage stage( Stage::GetCurrent() );
4575 Actor actorA = Actor::New();
4576 Actor actorB = Actor::New();
4577 Actor actorC = Actor::New();
4579 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4580 actorA.SetParentOrigin( ParentOrigin::CENTER );
4582 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4583 actorB.SetParentOrigin( ParentOrigin::CENTER );
4585 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4586 actorC.SetParentOrigin( ParentOrigin::CENTER );
4588 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4589 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4591 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4592 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4594 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4595 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4597 stage.Add( actorA );
4598 stage.Add( actorB );
4599 stage.Add( actorC );
4601 ResetTouchCallbacks();
4603 application.SendNotification();
4604 application.Render();
4606 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4607 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4608 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4610 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4611 // Only top actor will get touched.
4612 actorA.TouchSignal().Connect( TestTouchCallback );
4613 actorB.TouchSignal().Connect( TestTouchCallback2 );
4614 actorC.TouchSignal().Connect( TestTouchCallback3 );
4616 Dali::Integration::Point point;
4617 point.SetDeviceId( 1 );
4618 point.SetState( PointState::DOWN );
4619 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4620 Dali::Integration::TouchEvent touchEvent;
4621 touchEvent.AddPoint( point );
4623 application.ProcessEvent( touchEvent );
4625 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4626 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4627 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4629 ResetTouchCallbacks();
4631 tet_printf( "Raise actor B Above Actor C\n" );
4633 DevelActor::RaiseAbove( actorB, actorC );
4634 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4635 application.SendNotification();
4637 application.ProcessEvent( touchEvent );
4639 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4640 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4641 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4643 ResetTouchCallbacks();
4645 tet_printf( "Raise actor A Above Actor B\n" );
4647 DevelActor::RaiseAbove( actorA, actorB );
4649 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4650 application.SendNotification();
4652 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
4654 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4655 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4656 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4658 ResetTouchCallbacks();
4663 int UtcDaliActorLowerBelow(void)
4665 tet_infoline( "UtcDaliActor LowerBelow test \n" );
4667 TestApplication application;
4669 Stage stage( Stage::GetCurrent() );
4671 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4672 // enables checking of which actor the uniform is assigned too
4673 Shader shaderA = CreateShader();
4674 shaderA.RegisterProperty( "uRendererColor",1.f);
4676 Shader shaderB = CreateShader();
4677 shaderB.RegisterProperty( "uRendererColor", 2.f );
4679 Shader shaderC = CreateShader();
4680 shaderC.RegisterProperty( "uRendererColor", 3.f );
4682 Actor actorA = Actor::New();
4683 Actor actorB = Actor::New();
4684 Actor actorC = Actor::New();
4686 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4687 Geometry geometry = CreateQuadGeometry();
4689 Renderer rendererA = Renderer::New(geometry, shaderA);
4690 actorA.AddRenderer(rendererA);
4692 Renderer rendererB = Renderer::New(geometry, shaderB);
4693 actorB.AddRenderer(rendererB);
4695 Renderer rendererC = Renderer::New(geometry, shaderC);
4696 actorC.AddRenderer(rendererC);
4698 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4699 actorA.SetParentOrigin( ParentOrigin::CENTER );
4701 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4702 actorB.SetParentOrigin( ParentOrigin::CENTER );
4704 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4705 actorC.SetParentOrigin( ParentOrigin::CENTER );
4707 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4708 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4710 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4711 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4713 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4714 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4716 stage.Add( actorA );
4717 stage.Add( actorB );
4718 stage.Add( actorC );
4720 ResetTouchCallbacks();
4722 // Set up gl abstraction trace so can query the set uniform order
4723 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4724 glAbstraction.EnableSetUniformCallTrace(true);
4725 glAbstraction.ResetSetUniformCallStack();
4726 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4728 glAbstraction.ResetSetUniformCallStack();
4730 application.SendNotification();
4731 application.Render();
4733 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4735 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4737 // Test order of uniforms in stack
4738 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4739 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4740 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4742 tet_infoline( "Testing C above B and A at bottom\n" );
4743 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4745 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4747 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4748 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4749 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4751 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4752 // Only top actor will get touched.
4753 actorA.TouchSignal().Connect( TestTouchCallback );
4754 actorB.TouchSignal().Connect( TestTouchCallback2 );
4755 actorC.TouchSignal().Connect( TestTouchCallback3 );
4757 Dali::Integration::Point point;
4758 point.SetDeviceId( 1 );
4759 point.SetState( PointState::DOWN );
4760 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4761 Dali::Integration::TouchEvent touchEvent;
4762 touchEvent.AddPoint( point );
4764 tet_infoline( "UtcDaliActor Test Set up completed \n" );
4766 application.ProcessEvent( touchEvent );
4768 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4769 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4770 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4772 ResetTouchCallbacks();
4774 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" );
4776 DevelActor::LowerBelow( actorC, actorB );
4777 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4778 application.SendNotification();
4779 application.Render();
4781 application.ProcessEvent( touchEvent ); // touch event
4783 glAbstraction.ResetSetUniformCallStack();
4784 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4786 application.SendNotification();
4787 application.Render();
4789 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4791 // Test order of uniforms in stack
4792 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4793 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4794 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4796 tet_infoline( "Testing B above A and C at bottom\n" );
4797 bool BAC = ( indexB > indexA) && ( indexA > indexC ); // B at TOP, then A then C at bottom
4799 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4801 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4802 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4803 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4805 ResetTouchCallbacks();
4807 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4809 DevelActor::LowerBelow( actorB, actorC );
4810 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4811 application.SendNotification();
4812 application.Render();
4814 application.ProcessEvent( touchEvent );
4816 glAbstraction.ResetSetUniformCallStack();
4817 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4819 application.Render();
4820 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4822 // Test order of uniforms in stack
4823 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4824 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4825 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4827 bool ACB = ( indexA > indexC) && ( indexC > indexB ); // A on TOP, then C then B at bottom
4829 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4831 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4832 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4833 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4835 ResetTouchCallbacks();
4837 tet_printf( "Lower actor A below Actor C leaving C on top\n" );
4839 DevelActor::LowerBelow( actorA, actorC );
4840 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4841 application.SendNotification();
4842 application.Render();
4844 application.ProcessEvent( touchEvent );
4846 glAbstraction.ResetSetUniformCallStack();
4847 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4849 application.Render();
4850 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4852 // Test order of uniforms in stack
4853 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4854 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4855 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4857 bool CAB = ( indexC > indexA) && ( indexA > indexB );
4859 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4864 int UtcDaliActorMaxSiblingOrder(void)
4866 tet_infoline( "UtcDaliActor De-fragment of sibling order once max index reached\n" );
4868 TestApplication application;
4870 int testOrders[] = { 0,1,3,5,17,998, 999 };
4871 int resultingOrders[] = { 0,1,2,3,4,6,5 };
4873 const int TEST_ORDERS_COUNT = sizeof( testOrders ) / sizeof( testOrders[0] );
4875 Stage stage( Stage::GetCurrent() );
4877 Actor parent = Actor::New();
4879 for ( int index = 0; index < TEST_ORDERS_COUNT; index++ )
4881 Actor newActor = Actor::New();
4882 newActor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, testOrders[index] );
4883 parent.Add( newActor );
4885 stage.Add( parent );
4887 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4888 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4890 Actor sibling = parent.GetChildAt( index );
4891 int siblingOrder = 0;
4892 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4893 value.Get( siblingOrder );
4894 tet_printf( "%d, ", siblingOrder );
4898 Actor sibling = parent.GetChildAt( 5 );
4899 DevelActor::RaiseToTop( sibling );
4901 // Ensure sorting happens at end of Core::ProcessEvents()
4902 application.SendNotification();
4903 application.Render();
4905 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4906 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4908 Actor sibling = parent.GetChildAt( index );
4909 int siblingOrder = 0;
4910 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4911 value.Get( siblingOrder );
4912 tet_printf( "%d, ", siblingOrder );
4913 DALI_TEST_EQUALS( siblingOrder, resultingOrders[ index] , TEST_LOCATION );
4921 int UtcDaliActorRaiseAboveLowerBelowDifferentParentsN(void)
4923 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4925 TestApplication application;
4927 Stage stage( Stage::GetCurrent() );
4929 Actor parentA = Actor::New();
4930 Actor parentB = Actor::New();
4931 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4932 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4933 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4934 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4936 parentA.SetAnchorPoint( AnchorPoint::CENTER );
4937 parentA.SetParentOrigin( ParentOrigin::CENTER );
4939 parentB.SetAnchorPoint( AnchorPoint::CENTER );
4940 parentB.SetParentOrigin( ParentOrigin::CENTER );
4942 stage.Add( parentA );
4943 stage.Add( parentB );
4945 Actor actorA = Actor::New();
4946 Actor actorB = Actor::New();
4947 Actor actorC = Actor::New();
4949 parentA.Add( actorA );
4950 parentA.Add( actorB );
4952 tet_printf( "Actor C added to different parent from A and B \n" );
4953 parentB.Add( actorC );
4955 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4956 actorA.SetParentOrigin( ParentOrigin::CENTER );
4958 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4959 actorB.SetParentOrigin( ParentOrigin::CENTER );
4961 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4962 actorC.SetParentOrigin( ParentOrigin::CENTER );
4964 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4965 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4967 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4968 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4970 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4971 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4973 ResetTouchCallbacks();
4975 application.SendNotification();
4976 application.Render();
4978 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4979 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4980 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4982 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4983 // Only top actor will get touched.
4984 actorA.TouchSignal().Connect( TestTouchCallback );
4985 actorB.TouchSignal().Connect( TestTouchCallback2 );
4986 actorC.TouchSignal().Connect( TestTouchCallback3 );
4988 Dali::Integration::Point point;
4989 point.SetDeviceId( 1 );
4990 point.SetState( PointState::DOWN );
4991 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4992 Dali::Integration::TouchEvent touchEvent;
4993 touchEvent.AddPoint( point );
4995 application.ProcessEvent( touchEvent );
4997 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4998 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4999 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5001 ResetTouchCallbacks();
5003 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5005 DevelActor::RaiseAbove( actorA, actorC );
5006 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5007 application.SendNotification();
5009 application.ProcessEvent( touchEvent ); // touch event
5011 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5012 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5013 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5015 ResetTouchCallbacks();
5020 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5022 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5024 TestApplication application;
5026 Stage stage( Stage::GetCurrent() );
5028 Actor actorA = Actor::New();
5029 Actor actorB = Actor::New();
5030 Actor actorC = Actor::New();
5032 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5033 actorA.SetParentOrigin( ParentOrigin::CENTER );
5035 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5036 actorB.SetParentOrigin( ParentOrigin::CENTER );
5038 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5039 actorC.SetParentOrigin( ParentOrigin::CENTER );
5041 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5042 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5044 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5045 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5047 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5048 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5050 ResetTouchCallbacks();
5052 application.SendNotification();
5053 application.Render();
5055 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5056 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5057 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5059 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5060 // Only top actor will get touched.
5061 actorA.TouchSignal().Connect( TestTouchCallback );
5062 actorB.TouchSignal().Connect( TestTouchCallback2 );
5063 actorC.TouchSignal().Connect( TestTouchCallback3 );
5065 Dali::Integration::Point point;
5066 point.SetDeviceId( 1 );
5067 point.SetState( PointState::DOWN );
5068 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5069 Dali::Integration::TouchEvent touchEvent;
5070 touchEvent.AddPoint( point );
5072 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5074 DevelActor::RaiseAbove( actorA, actorC );
5075 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5076 application.SendNotification();
5078 application.ProcessEvent( touchEvent );
5080 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5082 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5083 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5084 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5086 ResetTouchCallbacks();
5088 stage.Add ( actorB );
5089 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5090 DevelActor::LowerBelow( actorA, actorC );
5092 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5093 application.SendNotification();
5094 application.Render();
5096 application.ProcessEvent( touchEvent );
5098 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5099 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5100 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5101 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5103 ResetTouchCallbacks();
5105 tet_printf( "Adding Actor A to stage, will be on top\n" );
5107 stage.Add ( actorA );
5108 application.SendNotification();
5109 application.Render();
5111 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5112 DevelActor::RaiseAbove( actorB, actorC );
5113 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5114 application.SendNotification();
5116 application.ProcessEvent( touchEvent );
5118 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5119 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5120 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5121 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5123 ResetTouchCallbacks();
5125 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5126 DevelActor::LowerBelow( actorA, actorC );
5127 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5128 application.SendNotification();
5130 application.ProcessEvent( touchEvent );
5132 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5133 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5134 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5135 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5137 ResetTouchCallbacks();
5139 stage.Add ( actorC );
5140 DevelActor::RaiseAbove( actorA, actorC );
5141 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5142 application.SendNotification();
5143 application.Render();
5145 application.ProcessEvent( touchEvent );
5147 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5148 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5149 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5150 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5155 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5157 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5159 TestApplication application;
5161 Stage stage( Stage::GetCurrent() );
5163 Actor actorA = Actor::New();
5164 Actor actorB = Actor::New();
5165 Actor actorC = Actor::New();
5167 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5168 actorA.SetParentOrigin( ParentOrigin::CENTER );
5170 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5171 actorB.SetParentOrigin( ParentOrigin::CENTER );
5173 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5174 actorC.SetParentOrigin( ParentOrigin::CENTER );
5176 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5177 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5179 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5180 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5182 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5183 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5185 ResetTouchCallbacks();
5187 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5188 // Only top actor will get touched.
5189 actorA.TouchSignal().Connect( TestTouchCallback );
5190 actorB.TouchSignal().Connect( TestTouchCallback2 );
5191 actorC.TouchSignal().Connect( TestTouchCallback3 );
5193 Dali::Integration::Point point;
5194 point.SetDeviceId( 1 );
5195 point.SetState( PointState::DOWN );
5196 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5197 Dali::Integration::TouchEvent touchEvent;
5198 touchEvent.AddPoint( point );
5200 stage.Add ( actorA );
5201 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5202 DevelActor::Raise( actorB );
5204 application.SendNotification();
5205 application.Render();
5207 application.ProcessEvent( touchEvent );
5209 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5211 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5212 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5213 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5215 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5216 ResetTouchCallbacks();
5218 DevelActor::Lower( actorC );
5219 // Sort actor tree before next touch event
5220 application.SendNotification();
5221 application.Render();
5223 application.ProcessEvent( touchEvent );
5225 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5227 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5228 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5229 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5230 ResetTouchCallbacks();
5232 tet_printf( "Lower actor C below B but C not parented\n" );
5234 DevelActor::Lower( actorB );
5235 // Sort actor tree before next touch event
5236 application.SendNotification();
5237 application.Render();
5239 application.ProcessEvent( touchEvent );
5241 tet_printf( "Not parented so Lower should show no effect\n" );
5243 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5244 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5245 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5246 ResetTouchCallbacks();
5248 tet_printf( "Raise actor B to top\n" );
5250 DevelActor::RaiseToTop( actorB );
5251 // Sort actor tree before next touch event
5252 application.SendNotification();
5253 application.Render();
5255 application.ProcessEvent( touchEvent );
5257 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5259 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5260 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5261 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5262 ResetTouchCallbacks();
5264 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5266 stage.Add ( actorB );
5268 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5270 DevelActor::LowerToBottom( actorC );
5271 application.SendNotification();
5272 application.Render();
5274 application.ProcessEvent( touchEvent );
5276 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5278 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5279 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5280 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5281 ResetTouchCallbacks();
5287 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5289 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5291 TestApplication application;
5293 Stage stage( Stage::GetCurrent() );
5295 Actor actorA = Actor::New();
5296 Actor actorB = Actor::New();
5297 Actor actorC = Actor::New();
5299 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5300 actorA.SetParentOrigin( ParentOrigin::CENTER );
5302 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5303 actorB.SetParentOrigin( ParentOrigin::CENTER );
5305 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5306 actorC.SetParentOrigin( ParentOrigin::CENTER );
5308 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5309 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5311 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5312 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5314 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5315 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5317 stage.Add( actorA );
5318 stage.Add( actorB );
5319 stage.Add( actorC );
5321 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5322 // Only top actor will get touched.
5323 actorA.TouchSignal().Connect( TestTouchCallback );
5324 actorB.TouchSignal().Connect( TestTouchCallback2 );
5325 actorC.TouchSignal().Connect( TestTouchCallback3 );
5327 ResetTouchCallbacks();
5329 application.SendNotification();
5330 application.Render();
5332 Dali::Integration::Point point;
5333 point.SetDeviceId( 1 );
5334 point.SetState( PointState::DOWN );
5335 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5336 Dali::Integration::TouchEvent touchEvent;
5337 touchEvent.AddPoint( point );
5339 application.ProcessEvent( touchEvent );
5341 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5342 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5343 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5345 ResetTouchCallbacks();
5347 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5349 DevelActor::RaiseAbove( actorA, actorA );
5350 application.SendNotification();
5351 application.Render();
5353 application.ProcessEvent( touchEvent );
5355 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5357 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5358 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5359 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5361 ResetTouchCallbacks();
5363 DevelActor::RaiseAbove( actorA, actorC );
5364 application.SendNotification();
5365 application.Render();
5367 application.ProcessEvent( touchEvent );
5369 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5370 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5371 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5372 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5377 int UtcDaliActorGetScreenPosition(void)
5379 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5381 TestApplication application;
5383 Stage stage( Stage::GetCurrent() );
5385 Actor actorA = Actor::New();
5386 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5388 Vector2 size2( 10.0f, 20.0f );
5389 actorA.SetSize( size2 );
5391 actorA.SetPosition( 0.f, 0.f );
5393 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5395 stage.Add( actorA );
5397 application.SendNotification();
5398 application.Render();
5400 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5401 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5403 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5404 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5406 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5407 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5409 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5411 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5413 application.SendNotification();
5414 application.Render();
5416 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5417 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5419 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5420 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5422 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5423 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5425 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5427 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5429 application.SendNotification();
5430 application.Render();
5432 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5433 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5435 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5436 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5438 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5439 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5441 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5443 actorA.SetPosition( 30.0, 0.0 );
5445 application.SendNotification();
5446 application.Render();
5448 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5449 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5451 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5452 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5454 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5455 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5457 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5459 actorA.SetPosition( 30.0, 420.0 );
5461 application.SendNotification();
5462 application.Render();
5464 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5465 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5467 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5468 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5470 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5471 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5477 int UtcDaliActorGetScreenPositionAfterScaling(void)
5479 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5481 TestApplication application;
5483 Stage stage( Stage::GetCurrent() );
5485 Actor actorA = Actor::New();
5486 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5488 Vector2 size2( 10.0f, 20.0f );
5489 actorA.SetSize( size2 );
5490 actorA.SetScale( 1.5f );
5491 actorA.SetPosition( 0.f, 0.f );
5493 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5495 stage.Add( actorA );
5497 application.SendNotification();
5498 application.Render();
5500 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5501 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5503 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5504 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5506 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5507 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5509 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5511 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5513 application.SendNotification();
5514 application.Render();
5516 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5517 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5519 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5520 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5522 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5523 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5528 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5530 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5532 TestApplication application;
5534 Stage stage( Stage::GetCurrent() );
5536 Actor actorA = Actor::New();
5537 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5538 actorA.SetParentOrigin( ParentOrigin::CENTER );
5539 Vector2 size2( 10.0f, 20.0f );
5540 actorA.SetSize( size2 );
5541 actorA.SetPosition( 0.f, 0.f );
5543 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5545 stage.Add( actorA );
5547 application.SendNotification();
5548 application.Render();
5550 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5551 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5553 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5554 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5556 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
5557 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
5559 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5561 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5562 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5564 application.SendNotification();
5565 application.Render();
5567 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5568 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5570 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5571 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5573 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5574 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5580 int UtcDaliActorGetScreenPositionWithChildActors(void)
5582 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5584 TestApplication application;
5586 Stage stage( Stage::GetCurrent() );
5588 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5590 Actor actorA = Actor::New();
5591 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5592 actorA.SetParentOrigin( ParentOrigin::CENTER );
5593 Vector2 size1( 10.0f, 20.0f );
5594 actorA.SetSize( size1 );
5595 actorA.SetPosition( 0.f, 0.f );
5597 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5599 Actor parentActorA = Actor::New();
5600 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5601 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5602 Vector2 size2( 30.0f, 60.0f );
5603 parentActorA.SetSize( size2 );
5604 parentActorA.SetPosition( 0.f, 0.f );
5606 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5608 stage.Add( parentActorA );
5609 parentActorA.Add ( actorA );
5611 application.SendNotification();
5612 application.Render();
5614 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5615 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5617 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5618 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5620 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
5621 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
5623 tet_infoline( "Test 2\n");
5625 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5627 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5628 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5630 application.SendNotification();
5631 application.Render();
5633 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5634 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5636 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5637 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5639 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
5640 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
5645 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5647 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5649 TestApplication application;
5651 Stage stage( Stage::GetCurrent() );
5653 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5655 Actor actorA = Actor::New();
5656 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5657 actorA.SetParentOrigin( ParentOrigin::CENTER );
5658 Vector2 size1( 10.0f, 20.0f );
5659 actorA.SetSize( size1 );
5660 actorA.SetPosition( 0.f, 0.f );
5662 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5664 Actor parentActorA = Actor::New();
5665 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5666 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5667 Vector2 size2( 30.0f, 60.0f );
5668 parentActorA.SetSize( size2 );
5669 parentActorA.SetPosition( 0.f, 0.f );
5671 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5673 Actor grandParentActorA = Actor::New();
5674 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5675 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5676 Vector2 size3( 60.0f, 120.0f );
5677 grandParentActorA.SetSize( size3 );
5678 grandParentActorA.SetPosition( 0.f, 0.f );
5680 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5682 stage.Add( grandParentActorA );
5683 grandParentActorA.Add ( parentActorA );
5685 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5687 parentActorA.Add ( actorA );
5689 application.SendNotification();
5690 application.Render();
5692 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5693 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5695 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5696 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5698 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
5699 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
5704 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5706 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
5708 TestApplication application;
5710 Stage stage( Stage::GetCurrent() );
5712 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5714 Actor actorA = Actor::New();
5715 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5716 actorA.SetParentOrigin( ParentOrigin::CENTER );
5717 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5718 actorA.SetSize( 10.0f, 20.0f );
5719 stage.Add( actorA );
5721 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5723 Actor actorB = Actor::New();
5724 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5725 actorB.SetParentOrigin( ParentOrigin::CENTER );
5726 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5727 Vector2 actorBSize( 30.0f, 60.0f );
5728 actorB.SetSize( actorBSize );
5729 stage.Add( actorB );
5731 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5733 Actor actorC = Actor::New();
5734 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5735 actorC.SetParentOrigin( ParentOrigin::CENTER );
5736 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5737 Vector2 actorCSize( 60.0f, 120.0f );
5738 actorC.SetSize( actorCSize );
5739 stage.Add( actorC );
5741 application.SendNotification();
5742 application.Render();
5744 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
5746 Vector2 center( stage.GetSize() * 0.5f );
5748 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5749 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5750 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5752 tet_infoline( "Add scale to all actors" );
5754 actorA.SetScale( 2.0f );
5755 actorB.SetScale( 2.0f );
5756 actorC.SetScale( 2.0f );
5758 application.SendNotification();
5759 application.Render();
5761 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
5762 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
5763 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
5768 int utcDaliActorPositionUsesAnchorPoint(void)
5770 TestApplication application;
5771 tet_infoline( "Check default behaviour\n" );
5773 Actor actor = Actor::New();
5774 actor.SetParentOrigin( ParentOrigin::CENTER );
5775 actor.SetAnchorPoint( AnchorPoint::CENTER );
5776 actor.SetSize( 100.0f, 100.0f );
5777 Stage::GetCurrent().Add( actor );
5779 application.SendNotification();
5780 application.Render();
5782 tet_infoline( "Check that the world position is in the center\n" );
5783 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5785 tet_infoline( "Set the position uses anchor point property to false\n" );
5786 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5788 application.SendNotification();
5789 application.Render();
5791 tet_infoline( "Check that the world position has changed appropriately\n" );
5792 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5797 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
5799 TestApplication application;
5800 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5802 Actor actor = Actor::New();
5803 actor.SetParentOrigin( ParentOrigin::CENTER );
5804 actor.SetAnchorPoint( AnchorPoint::CENTER );
5805 actor.SetSize( 100.0f, 100.0f );
5806 actor.SetScale( 2.0f );
5807 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5808 Stage::GetCurrent().Add( actor );
5810 application.SendNotification();
5811 application.Render();
5813 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
5814 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5816 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5817 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5818 application.SendNotification();
5819 application.Render();
5820 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5822 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5823 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5824 application.SendNotification();
5825 application.Render();
5826 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5831 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
5833 TestApplication application;
5834 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5836 Actor actor = Actor::New();
5837 actor.SetParentOrigin( ParentOrigin::CENTER );
5838 actor.SetAnchorPoint( AnchorPoint::CENTER );
5839 actor.SetSize( 100.0f, 100.0f );
5840 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5841 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5842 Stage::GetCurrent().Add( actor );
5844 application.SendNotification();
5845 application.Render();
5847 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
5848 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5850 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5851 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5852 application.SendNotification();
5853 application.Render();
5854 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5856 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5857 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5858 application.SendNotification();
5859 application.Render();
5860 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
5865 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
5867 TestApplication application;
5868 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5870 Actor actor = Actor::New();
5871 actor.SetParentOrigin( ParentOrigin::CENTER );
5872 actor.SetAnchorPoint( AnchorPoint::CENTER );
5873 actor.SetSize( 100.0f, 100.0f );
5874 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5875 actor.SetScale( 2.0f );
5876 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5877 Stage::GetCurrent().Add( actor );
5879 application.SendNotification();
5880 application.Render();
5882 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
5883 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5885 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5886 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5887 application.SendNotification();
5888 application.Render();
5889 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5891 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5892 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5893 application.SendNotification();
5894 application.Render();
5895 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
5900 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
5902 TestApplication application;
5903 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5905 Actor parent = Actor::New();
5907 Stage::GetCurrent().Add( parent );
5908 Vector2 stageSize( Stage::GetCurrent().GetSize() );
5910 Actor actor = Actor::New();
5911 actor.SetParentOrigin( ParentOrigin::CENTER );
5912 actor.SetAnchorPoint( AnchorPoint::CENTER );
5913 actor.SetSize( 100.0f, 100.0f );
5914 actor.SetInheritScale( false );
5915 actor.SetInheritOrientation( false );
5916 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5917 parent.Add( actor );
5919 application.SendNotification();
5920 application.Render();
5922 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
5924 tet_infoline( "Check the world position is in the right place\n" );
5925 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5927 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
5928 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5929 application.SendNotification();
5930 application.Render();
5931 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5933 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
5934 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5935 application.SendNotification();
5936 application.Render();
5937 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5941 int utcDaliActorVisibilityChangeSignalSelf(void)
5943 TestApplication application;
5944 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
5946 Actor actor = Actor::New();
5948 VisibilityChangedFunctorData data;
5949 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
5951 actor.SetVisible( false );
5953 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5955 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
5958 actor.SetVisible( false );
5959 data.Check( false /* not called */, TEST_LOCATION );
5961 tet_infoline( "Change the visibility using properties, ensure called" );
5964 actor.SetProperty( Actor::Property::VISIBLE, true );
5965 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5967 tet_infoline( "Set the visibility to current using properties, ensure not called" );
5970 actor.SetProperty( Actor::Property::VISIBLE, true );
5971 data.Check( false /* not called */, TEST_LOCATION );
5976 int utcDaliActorVisibilityChangeSignalChildren(void)
5978 TestApplication application;
5979 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
5981 Actor parent = Actor::New();
5982 Actor child = Actor::New();
5983 parent.Add( child );
5985 Actor grandChild = Actor::New();
5986 child.Add( grandChild );
5988 VisibilityChangedFunctorData parentData;
5989 VisibilityChangedFunctorData childData;
5990 VisibilityChangedFunctorData grandChildData;
5992 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
5993 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
5994 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
5996 parent.SetVisible( false );
5997 parentData.Check( false /* not called */, TEST_LOCATION );
5998 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
5999 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6001 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6004 grandChildData.Reset();
6006 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6008 parent.SetVisible( true );
6009 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6010 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6011 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6013 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6016 grandChildData.Reset();
6018 parent.SetVisible( true );
6019 parentData.Check( false /* not called */, TEST_LOCATION );
6020 childData.Check( false /* not called */, TEST_LOCATION );
6021 grandChildData.Check( false /* not called */, TEST_LOCATION );