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 );
3863 Geometry geometry = CreateQuadGeometry();
3864 Shader shader = CreateShader();
3865 Renderer renderer = Renderer::New(geometry, shader);
3867 actor.AddRenderer( renderer );
3868 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3869 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3871 application.SendNotification();
3872 application.Render();
3876 Renderer renderer = actor.GetRendererAt(0);
3877 actor.RemoveRenderer(renderer);
3878 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3880 application.SendNotification();
3881 application.Render();
3884 // Call one final time to ensure that the renderer is actually removed after
3885 // the handle goes out of scope, and excercises the deletion code path in
3886 // scene graph and render.
3887 application.SendNotification();
3888 application.Render();
3893 int UtcDaliActorRemoveRendererP2(void)
3895 tet_infoline("Testing Actor::RemoveRenderer");
3896 TestApplication application;
3898 Actor actor = Actor::New();
3900 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3902 Geometry geometry = CreateQuadGeometry();
3903 Shader shader = CreateShader();
3904 Renderer renderer = Renderer::New(geometry, shader);
3906 actor.AddRenderer( renderer );
3907 application.SendNotification();
3908 application.Render();
3910 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3911 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3913 actor.RemoveRenderer(0);
3914 application.SendNotification();
3915 application.Render();
3917 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3919 // Shut down whilst holding onto the renderer handle.
3924 int UtcDaliActorRemoveRendererN(void)
3926 tet_infoline("Testing Actor::RemoveRenderer");
3927 TestApplication application;
3929 Actor actor = Actor::New();
3931 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3933 Geometry geometry = CreateQuadGeometry();
3934 Shader shader = CreateShader();
3935 Renderer renderer = Renderer::New(geometry, shader);
3937 actor.AddRenderer( renderer );
3938 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3939 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3941 actor.RemoveRenderer(10);
3942 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3943 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3948 // Clipping test helper functions:
3949 Actor CreateActorWithContent()
3951 BufferImage image = BufferImage::New( 16u, 16u );
3952 Actor actor = CreateRenderableActor( image );
3954 // Setup dimensions and position so actor is not skipped by culling.
3955 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3956 actor.SetSize( 16.0f, 16.0f );
3957 actor.SetParentOrigin( ParentOrigin::CENTER );
3958 actor.SetAnchorPoint( AnchorPoint::CENTER );
3963 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3965 enabledDisableTrace.Reset();
3966 stencilTrace.Reset();
3967 enabledDisableTrace.Enable( true );
3968 stencilTrace.Enable( true );
3970 application.SendNotification();
3971 application.Render();
3973 enabledDisableTrace.Enable( false );
3974 stencilTrace.Enable( false );
3977 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3979 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3981 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3982 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3983 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3984 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3987 int UtcDaliActorPropertyClippingP(void)
3989 // This test checks the clippingMode property.
3990 tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3991 TestApplication application;
3993 Actor actor = Actor::New();
3995 // Check default clippingEnabled value.
3996 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3999 bool getValueResult = getValue.Get( value );
4000 DALI_TEST_CHECK( getValueResult );
4002 if( getValueResult )
4004 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4007 // Check setting the property.
4008 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4010 // Check the new value was set.
4011 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4012 getValueResult = getValue.Get( value );
4013 DALI_TEST_CHECK( getValueResult );
4015 if( getValueResult )
4017 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4023 int UtcDaliActorPropertyClippingN(void)
4025 // Negative test case for Clipping.
4026 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
4027 TestApplication application;
4029 Actor actor = Actor::New();
4031 // Check default clippingEnabled value.
4032 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4035 bool getValueResult = getValue.Get( value );
4036 DALI_TEST_CHECK( getValueResult );
4038 if( getValueResult )
4040 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4043 // Check setting an invalid property value won't change the current property value.
4044 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4046 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4047 getValueResult = getValue.Get( value );
4048 DALI_TEST_CHECK( getValueResult );
4050 if( getValueResult )
4052 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4058 int UtcDaliActorPropertyClippingActor(void)
4060 // This test checks that an actor is correctly setup for clipping.
4061 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
4062 TestApplication application;
4064 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4065 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4066 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4067 size_t startIndex = 0u;
4069 // Create a clipping actor.
4070 Actor actorDepth1Clip = CreateActorWithContent();
4071 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4072 Stage::GetCurrent().Add( actorDepth1Clip );
4074 // Gather the call trace.
4075 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4077 // Check we are writing to the color buffer.
4078 CheckColorMask( glAbstraction, true );
4080 // Check the stencil buffer was enabled.
4081 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4083 // Check the stencil buffer was cleared.
4084 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4086 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4087 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4088 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4089 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4094 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4096 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4097 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
4098 TestApplication application;
4100 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4101 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4102 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4103 size_t startIndex = 0u;
4105 // Create a clipping actor.
4106 Actor actorDepth1Clip = CreateActorWithContent();
4107 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4108 Stage::GetCurrent().Add( actorDepth1Clip );
4110 // Gather the call trace.
4111 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4113 // Check we are writing to the color buffer.
4114 CheckColorMask( glAbstraction, true );
4116 // Check the stencil buffer was enabled.
4117 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4119 // Check the stencil buffer was cleared.
4120 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4122 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4123 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4124 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4125 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4127 // Now disable the clipping
4128 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4130 // Gather the call trace.
4131 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4133 // Check the stencil buffer was disabled.
4134 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4136 // Ensure all values in stencil-mask are set to 1.
4138 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4144 int UtcDaliActorPropertyClippingNestedChildren(void)
4146 // This test checks that a hierarchy of actors are clipped correctly by
4147 // writing to and reading from the correct bit-planes of the stencil buffer.
4148 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
4149 TestApplication application;
4150 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4151 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4152 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4154 // Create a clipping actor.
4155 Actor actorDepth1Clip = CreateActorWithContent();
4156 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4157 Stage::GetCurrent().Add( actorDepth1Clip );
4159 // Create a child actor.
4160 Actor childDepth2 = CreateActorWithContent();
4161 actorDepth1Clip.Add( childDepth2 );
4163 // Create another clipping actor.
4164 Actor childDepth2Clip = CreateActorWithContent();
4165 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4166 childDepth2.Add( childDepth2Clip );
4168 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4169 // This tests the sort algorithm.
4170 Actor childDepth3 = CreateActorWithContent();
4171 childDepth2Clip.Add( childDepth3 );
4172 Actor childDepth4 = CreateActorWithContent();
4173 childDepth3.Add( childDepth4 );
4175 // Gather the call trace.
4176 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4178 // Check we are writing to the color buffer.
4179 CheckColorMask( glAbstraction, true );
4181 // Check the stencil buffer was enabled.
4182 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4184 // Perform the test twice, once for 2D layer, and once for 3D.
4185 for( unsigned int i = 0u ; i < 2u; ++i )
4187 size_t startIndex = 0u;
4189 // Check the stencil buffer was cleared.
4190 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4192 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4193 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4194 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4195 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4197 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4198 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4199 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4201 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4202 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4203 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4204 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4206 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4207 // (Both must be set to pass the check).
4208 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4209 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4211 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4214 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4215 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4222 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4224 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4225 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4226 TestApplication application;
4228 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4229 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4230 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4232 // Create a clipping actor.
4233 Actor actorDepth1Clip = CreateActorWithContent();
4234 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4235 Stage::GetCurrent().Add( actorDepth1Clip );
4237 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4238 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4240 // Gather the call trace.
4241 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4243 // Check we are writing to the color buffer.
4244 CheckColorMask( glAbstraction, true );
4246 // Check the stencil buffer was not enabled.
4247 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4249 // Check stencil functions are not called.
4250 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4251 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4252 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4257 int UtcDaliGetPropertyN(void)
4259 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4260 TestApplication app;
4262 Actor actor = Actor::New();
4264 unsigned int propertyCount = actor.GetPropertyCount();
4265 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4269 int UtcDaliActorRaiseLower(void)
4271 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4273 TestApplication application;
4275 Stage stage( Stage::GetCurrent() );
4277 Actor actorA = Actor::New();
4278 Actor actorB = Actor::New();
4279 Actor actorC = Actor::New();
4281 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4282 actorA.SetParentOrigin( ParentOrigin::CENTER );
4284 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4285 actorB.SetParentOrigin( ParentOrigin::CENTER );
4287 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4288 actorC.SetParentOrigin( ParentOrigin::CENTER );
4290 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4291 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4293 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4294 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4296 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4297 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4299 stage.Add( actorA );
4300 stage.Add( actorB );
4301 stage.Add( actorC );
4303 ResetTouchCallbacks();
4305 application.SendNotification();
4306 application.Render();
4308 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4309 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4310 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4312 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4313 // Only top actor will get touched.
4314 actorA.TouchSignal().Connect( TestTouchCallback );
4315 actorB.TouchSignal().Connect( TestTouchCallback2 );
4316 actorC.TouchSignal().Connect( TestTouchCallback3 );
4318 Dali::Integration::Point point;
4319 point.SetDeviceId( 1 );
4320 point.SetState( PointState::DOWN );
4321 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4322 Dali::Integration::TouchEvent touchEvent;
4323 touchEvent.AddPoint( point );
4325 application.ProcessEvent( touchEvent );
4327 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4328 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4329 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4331 ResetTouchCallbacks();
4333 tet_printf( "Testing Raising of Actor\n" );
4335 int preActorOrder( 0 );
4336 int postActorOrder( 0 );
4338 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4339 value.Get( preActorOrder );
4341 DevelActor::Raise( actorB );
4342 // Ensure sort order is calculated before next touch event
4343 application.SendNotification();
4345 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4346 value.Get( postActorOrder );
4348 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4350 application.ProcessEvent( touchEvent );
4352 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4353 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4354 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4356 ResetTouchCallbacks();
4358 tet_printf( "Testing Lowering of Actor\n" );
4360 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4361 value.Get( preActorOrder );
4363 DevelActor::Lower( actorB );
4364 application.SendNotification(); // ensure sort order calculated before next touch event
4366 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4367 value.Get( postActorOrder );
4369 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4371 application.ProcessEvent( touchEvent );
4373 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4374 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4375 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4377 ResetTouchCallbacks();
4382 int UtcDaliActorRaiseToTopLowerToBottom(void)
4384 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4386 TestApplication application;
4388 Stage stage( Stage::GetCurrent() );
4390 Actor actorA = Actor::New();
4391 Actor actorB = Actor::New();
4392 Actor actorC = Actor::New();
4394 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4395 // enables checking of which actor the uniform is assigned too
4396 Shader shaderA = CreateShader();
4397 shaderA.RegisterProperty( "uRendererColor",1.f);
4399 Shader shaderB = CreateShader();
4400 shaderB.RegisterProperty( "uRendererColor", 2.f );
4402 Shader shaderC = CreateShader();
4403 shaderC.RegisterProperty( "uRendererColor", 3.f );
4405 Geometry geometry = CreateQuadGeometry();
4407 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4408 Renderer rendererA = Renderer::New(geometry, shaderA);
4409 actorA.AddRenderer(rendererA);
4411 Renderer rendererB = Renderer::New(geometry, shaderB);
4412 actorB.AddRenderer(rendererB);
4414 Renderer rendererC = Renderer::New(geometry, shaderC);
4415 actorC.AddRenderer(rendererC);
4417 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4418 actorA.SetParentOrigin( ParentOrigin::CENTER );
4420 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4421 actorB.SetParentOrigin( ParentOrigin::CENTER );
4423 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4424 actorC.SetParentOrigin( ParentOrigin::CENTER );
4426 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4427 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4429 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4430 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4432 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4433 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4435 stage.Add( actorA );
4436 stage.Add( actorB );
4437 stage.Add( actorC );
4439 ResetTouchCallbacks();
4441 // Set up gl abstraction trace so can query the set uniform order
4442 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4443 glAbstraction.EnableSetUniformCallTrace(true);
4444 glAbstraction.ResetSetUniformCallStack();
4446 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4448 application.SendNotification();
4449 application.Render();
4451 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4454 // Test order of uniforms in stack
4455 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4456 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4457 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4459 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4461 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4463 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4464 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4465 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4467 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4468 // Only top actor will get touched.
4469 actorA.TouchSignal().Connect( TestTouchCallback );
4470 actorB.TouchSignal().Connect( TestTouchCallback2 );
4471 actorC.TouchSignal().Connect( TestTouchCallback3 );
4473 Dali::Integration::Point point;
4474 point.SetDeviceId( 1 );
4475 point.SetState( PointState::DOWN );
4476 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4477 Dali::Integration::TouchEvent touchEvent;
4478 touchEvent.AddPoint( point );
4480 application.ProcessEvent( touchEvent );
4482 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4483 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4484 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4486 ResetTouchCallbacks();
4488 tet_printf( "RaiseToTop ActorA\n" );
4490 DevelActor::RaiseToTop( actorA );
4491 application.SendNotification(); // ensure sorting order is calculated before next touch event
4493 application.ProcessEvent( touchEvent );
4495 glAbstraction.ResetSetUniformCallStack();
4496 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4498 application.SendNotification();
4499 application.Render();
4501 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4503 // Test order of uniforms in stack
4504 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4505 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4506 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4508 tet_infoline( "Testing A above C and B at bottom\n" );
4509 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4511 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4513 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4514 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4515 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4517 ResetTouchCallbacks();
4519 tet_printf( "RaiseToTop ActorB\n" );
4521 DevelActor::RaiseToTop( actorB );
4522 application.SendNotification(); // Ensure sort order is calculated before next touch event
4524 application.ProcessEvent( touchEvent );
4526 glAbstraction.ResetSetUniformCallStack();
4527 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4529 application.SendNotification();
4530 application.Render();
4532 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4534 // Test order of uniforms in stack
4535 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4536 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4537 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4539 tet_infoline( "Testing B above A and C at bottom\n" );
4540 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4542 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4544 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4545 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4546 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4548 ResetTouchCallbacks();
4550 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4552 DevelActor::LowerToBottom( actorA );
4553 application.SendNotification();
4554 application.Render();
4556 DevelActor::LowerToBottom( actorB );
4557 application.SendNotification();
4558 application.Render();
4560 application.ProcessEvent( touchEvent );
4562 glAbstraction.ResetSetUniformCallStack();
4563 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4565 application.SendNotification();
4566 application.Render();
4568 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4570 // Test order of uniforms in stack
4571 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4572 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4573 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4575 tet_infoline( "Testing C above A and B at bottom\n" );
4576 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4578 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4580 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4581 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4582 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4584 ResetTouchCallbacks();
4589 int UtcDaliActorRaiseAbove(void)
4591 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4593 TestApplication application;
4595 Stage stage( Stage::GetCurrent() );
4597 Actor actorA = Actor::New();
4598 Actor actorB = Actor::New();
4599 Actor actorC = Actor::New();
4601 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4602 actorA.SetParentOrigin( ParentOrigin::CENTER );
4604 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4605 actorB.SetParentOrigin( ParentOrigin::CENTER );
4607 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4608 actorC.SetParentOrigin( ParentOrigin::CENTER );
4610 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4611 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4613 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4614 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4616 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4617 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4619 stage.Add( actorA );
4620 stage.Add( actorB );
4621 stage.Add( actorC );
4623 ResetTouchCallbacks();
4625 application.SendNotification();
4626 application.Render();
4628 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4629 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4630 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4632 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4633 // Only top actor will get touched.
4634 actorA.TouchSignal().Connect( TestTouchCallback );
4635 actorB.TouchSignal().Connect( TestTouchCallback2 );
4636 actorC.TouchSignal().Connect( TestTouchCallback3 );
4638 Dali::Integration::Point point;
4639 point.SetDeviceId( 1 );
4640 point.SetState( PointState::DOWN );
4641 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4642 Dali::Integration::TouchEvent touchEvent;
4643 touchEvent.AddPoint( point );
4645 application.ProcessEvent( touchEvent );
4647 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4648 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4649 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4651 ResetTouchCallbacks();
4653 tet_printf( "Raise actor B Above Actor C\n" );
4655 DevelActor::RaiseAbove( actorB, actorC );
4656 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4657 application.SendNotification();
4659 application.ProcessEvent( touchEvent );
4661 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4662 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4663 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4665 ResetTouchCallbacks();
4667 tet_printf( "Raise actor A Above Actor B\n" );
4669 DevelActor::RaiseAbove( actorA, actorB );
4671 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4672 application.SendNotification();
4674 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
4676 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4677 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4678 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4680 ResetTouchCallbacks();
4685 int UtcDaliActorLowerBelow(void)
4687 tet_infoline( "UtcDaliActor LowerBelow test \n" );
4689 TestApplication application;
4691 Stage stage( Stage::GetCurrent() );
4693 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4694 // enables checking of which actor the uniform is assigned too
4695 Shader shaderA = CreateShader();
4696 shaderA.RegisterProperty( "uRendererColor",1.f);
4698 Shader shaderB = CreateShader();
4699 shaderB.RegisterProperty( "uRendererColor", 2.f );
4701 Shader shaderC = CreateShader();
4702 shaderC.RegisterProperty( "uRendererColor", 3.f );
4704 Actor actorA = Actor::New();
4705 Actor actorB = Actor::New();
4706 Actor actorC = Actor::New();
4708 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4709 Geometry geometry = CreateQuadGeometry();
4711 Renderer rendererA = Renderer::New(geometry, shaderA);
4712 actorA.AddRenderer(rendererA);
4714 Renderer rendererB = Renderer::New(geometry, shaderB);
4715 actorB.AddRenderer(rendererB);
4717 Renderer rendererC = Renderer::New(geometry, shaderC);
4718 actorC.AddRenderer(rendererC);
4720 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4721 actorA.SetParentOrigin( ParentOrigin::CENTER );
4723 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4724 actorB.SetParentOrigin( ParentOrigin::CENTER );
4726 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4727 actorC.SetParentOrigin( ParentOrigin::CENTER );
4729 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4730 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4732 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4733 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4735 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4736 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4738 stage.Add( actorA );
4739 stage.Add( actorB );
4740 stage.Add( actorC );
4742 ResetTouchCallbacks();
4744 // Set up gl abstraction trace so can query the set uniform order
4745 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4746 glAbstraction.EnableSetUniformCallTrace(true);
4747 glAbstraction.ResetSetUniformCallStack();
4748 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4750 glAbstraction.ResetSetUniformCallStack();
4752 application.SendNotification();
4753 application.Render();
4755 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4757 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4759 // Test order of uniforms in stack
4760 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4761 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4762 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4764 tet_infoline( "Testing C above B and A at bottom\n" );
4765 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4767 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4769 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4770 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4771 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4773 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4774 // Only top actor will get touched.
4775 actorA.TouchSignal().Connect( TestTouchCallback );
4776 actorB.TouchSignal().Connect( TestTouchCallback2 );
4777 actorC.TouchSignal().Connect( TestTouchCallback3 );
4779 Dali::Integration::Point point;
4780 point.SetDeviceId( 1 );
4781 point.SetState( PointState::DOWN );
4782 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4783 Dali::Integration::TouchEvent touchEvent;
4784 touchEvent.AddPoint( point );
4786 tet_infoline( "UtcDaliActor Test Set up completed \n" );
4788 application.ProcessEvent( touchEvent );
4790 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4791 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4792 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4794 ResetTouchCallbacks();
4796 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" );
4798 DevelActor::LowerBelow( actorC, actorB );
4799 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4800 application.SendNotification();
4801 application.Render();
4803 application.ProcessEvent( touchEvent ); // touch event
4805 glAbstraction.ResetSetUniformCallStack();
4806 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4808 application.SendNotification();
4809 application.Render();
4811 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4813 // Test order of uniforms in stack
4814 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4815 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4816 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4818 tet_infoline( "Testing B above A and C at bottom\n" );
4819 bool BAC = ( indexB > indexA) && ( indexA > indexC ); // B at TOP, then A then C at bottom
4821 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4823 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4824 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4825 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4827 ResetTouchCallbacks();
4829 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4831 DevelActor::LowerBelow( actorB, actorC );
4832 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4833 application.SendNotification();
4834 application.Render();
4836 application.ProcessEvent( touchEvent );
4838 glAbstraction.ResetSetUniformCallStack();
4839 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4841 application.Render();
4842 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4844 // Test order of uniforms in stack
4845 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4846 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4847 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4849 bool ACB = ( indexA > indexC) && ( indexC > indexB ); // A on TOP, then C then B at bottom
4851 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4853 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4854 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4855 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4857 ResetTouchCallbacks();
4859 tet_printf( "Lower actor A below Actor C leaving C on top\n" );
4861 DevelActor::LowerBelow( actorA, actorC );
4862 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4863 application.SendNotification();
4864 application.Render();
4866 application.ProcessEvent( touchEvent );
4868 glAbstraction.ResetSetUniformCallStack();
4869 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4871 application.Render();
4872 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4874 // Test order of uniforms in stack
4875 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4876 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4877 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4879 bool CAB = ( indexC > indexA) && ( indexA > indexB );
4881 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4886 int UtcDaliActorMaxSiblingOrder(void)
4888 tet_infoline( "UtcDaliActor De-fragment of sibling order once max index reached\n" );
4890 TestApplication application;
4892 int testOrders[] = { 0,1,3,5,17,998, 999 };
4893 int resultingOrders[] = { 0,1,2,3,4,6,5 };
4895 const int TEST_ORDERS_COUNT = sizeof( testOrders ) / sizeof( testOrders[0] );
4897 Stage stage( Stage::GetCurrent() );
4899 Actor parent = Actor::New();
4901 for ( int index = 0; index < TEST_ORDERS_COUNT; index++ )
4903 Actor newActor = Actor::New();
4904 newActor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, testOrders[index] );
4905 parent.Add( newActor );
4907 stage.Add( parent );
4909 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4910 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4912 Actor sibling = parent.GetChildAt( index );
4913 int siblingOrder = 0;
4914 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4915 value.Get( siblingOrder );
4916 tet_printf( "%d, ", siblingOrder );
4920 Actor sibling = parent.GetChildAt( 5 );
4921 DevelActor::RaiseToTop( sibling );
4923 // Ensure sorting happens at end of Core::ProcessEvents()
4924 application.SendNotification();
4925 application.Render();
4927 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4928 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4930 Actor sibling = parent.GetChildAt( index );
4931 int siblingOrder = 0;
4932 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4933 value.Get( siblingOrder );
4934 tet_printf( "%d, ", siblingOrder );
4935 DALI_TEST_EQUALS( siblingOrder, resultingOrders[ index] , TEST_LOCATION );
4943 int UtcDaliActorRaiseAboveLowerBelowDifferentParentsN(void)
4945 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4947 TestApplication application;
4949 Stage stage( Stage::GetCurrent() );
4951 Actor parentA = Actor::New();
4952 Actor parentB = Actor::New();
4953 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4954 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4955 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4956 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4958 parentA.SetAnchorPoint( AnchorPoint::CENTER );
4959 parentA.SetParentOrigin( ParentOrigin::CENTER );
4961 parentB.SetAnchorPoint( AnchorPoint::CENTER );
4962 parentB.SetParentOrigin( ParentOrigin::CENTER );
4964 stage.Add( parentA );
4965 stage.Add( parentB );
4967 Actor actorA = Actor::New();
4968 Actor actorB = Actor::New();
4969 Actor actorC = Actor::New();
4971 parentA.Add( actorA );
4972 parentA.Add( actorB );
4974 tet_printf( "Actor C added to different parent from A and B \n" );
4975 parentB.Add( actorC );
4977 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4978 actorA.SetParentOrigin( ParentOrigin::CENTER );
4980 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4981 actorB.SetParentOrigin( ParentOrigin::CENTER );
4983 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4984 actorC.SetParentOrigin( ParentOrigin::CENTER );
4986 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4987 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4989 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4990 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4992 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4993 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4995 ResetTouchCallbacks();
4997 application.SendNotification();
4998 application.Render();
5000 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5001 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5002 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5004 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5005 // Only top actor will get touched.
5006 actorA.TouchSignal().Connect( TestTouchCallback );
5007 actorB.TouchSignal().Connect( TestTouchCallback2 );
5008 actorC.TouchSignal().Connect( TestTouchCallback3 );
5010 Dali::Integration::Point point;
5011 point.SetDeviceId( 1 );
5012 point.SetState( PointState::DOWN );
5013 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5014 Dali::Integration::TouchEvent touchEvent;
5015 touchEvent.AddPoint( point );
5017 application.ProcessEvent( touchEvent );
5019 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5020 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5021 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5023 ResetTouchCallbacks();
5025 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5027 DevelActor::RaiseAbove( actorA, actorC );
5028 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5029 application.SendNotification();
5031 application.ProcessEvent( touchEvent ); // touch event
5033 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5034 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5035 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5037 ResetTouchCallbacks();
5042 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5044 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5046 TestApplication application;
5048 Stage stage( Stage::GetCurrent() );
5050 Actor actorA = Actor::New();
5051 Actor actorB = Actor::New();
5052 Actor actorC = Actor::New();
5054 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5055 actorA.SetParentOrigin( ParentOrigin::CENTER );
5057 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5058 actorB.SetParentOrigin( ParentOrigin::CENTER );
5060 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5061 actorC.SetParentOrigin( ParentOrigin::CENTER );
5063 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5064 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5066 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5067 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5069 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5070 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5072 ResetTouchCallbacks();
5074 application.SendNotification();
5075 application.Render();
5077 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5078 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5079 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5081 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5082 // Only top actor will get touched.
5083 actorA.TouchSignal().Connect( TestTouchCallback );
5084 actorB.TouchSignal().Connect( TestTouchCallback2 );
5085 actorC.TouchSignal().Connect( TestTouchCallback3 );
5087 Dali::Integration::Point point;
5088 point.SetDeviceId( 1 );
5089 point.SetState( PointState::DOWN );
5090 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5091 Dali::Integration::TouchEvent touchEvent;
5092 touchEvent.AddPoint( point );
5094 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5096 DevelActor::RaiseAbove( actorA, actorC );
5097 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5098 application.SendNotification();
5100 application.ProcessEvent( touchEvent );
5102 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5104 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5105 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5106 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5108 ResetTouchCallbacks();
5110 stage.Add ( actorB );
5111 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5112 DevelActor::LowerBelow( actorA, actorC );
5114 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5115 application.SendNotification();
5116 application.Render();
5118 application.ProcessEvent( touchEvent );
5120 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5121 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5122 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5123 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5125 ResetTouchCallbacks();
5127 tet_printf( "Adding Actor A to stage, will be on top\n" );
5129 stage.Add ( actorA );
5130 application.SendNotification();
5131 application.Render();
5133 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5134 DevelActor::RaiseAbove( actorB, actorC );
5135 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5136 application.SendNotification();
5138 application.ProcessEvent( touchEvent );
5140 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5141 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5142 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5143 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5145 ResetTouchCallbacks();
5147 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5148 DevelActor::LowerBelow( actorA, actorC );
5149 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5150 application.SendNotification();
5152 application.ProcessEvent( touchEvent );
5154 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5155 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5156 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5157 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5159 ResetTouchCallbacks();
5161 stage.Add ( actorC );
5162 DevelActor::RaiseAbove( actorA, actorC );
5163 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5164 application.SendNotification();
5165 application.Render();
5167 application.ProcessEvent( touchEvent );
5169 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5170 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5171 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5172 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5177 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5179 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5181 TestApplication application;
5183 Stage stage( Stage::GetCurrent() );
5185 Actor actorA = Actor::New();
5186 Actor actorB = Actor::New();
5187 Actor actorC = Actor::New();
5189 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5190 actorA.SetParentOrigin( ParentOrigin::CENTER );
5192 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5193 actorB.SetParentOrigin( ParentOrigin::CENTER );
5195 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5196 actorC.SetParentOrigin( ParentOrigin::CENTER );
5198 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5199 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5201 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5202 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5204 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5205 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5207 ResetTouchCallbacks();
5209 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5210 // Only top actor will get touched.
5211 actorA.TouchSignal().Connect( TestTouchCallback );
5212 actorB.TouchSignal().Connect( TestTouchCallback2 );
5213 actorC.TouchSignal().Connect( TestTouchCallback3 );
5215 Dali::Integration::Point point;
5216 point.SetDeviceId( 1 );
5217 point.SetState( PointState::DOWN );
5218 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5219 Dali::Integration::TouchEvent touchEvent;
5220 touchEvent.AddPoint( point );
5222 stage.Add ( actorA );
5223 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5224 DevelActor::Raise( actorB );
5226 application.SendNotification();
5227 application.Render();
5229 application.ProcessEvent( touchEvent );
5231 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5233 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5234 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5235 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5237 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5238 ResetTouchCallbacks();
5240 DevelActor::Lower( actorC );
5241 // Sort actor tree before next touch event
5242 application.SendNotification();
5243 application.Render();
5245 application.ProcessEvent( touchEvent );
5247 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5249 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5250 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5251 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5252 ResetTouchCallbacks();
5254 tet_printf( "Lower actor C below B but C not parented\n" );
5256 DevelActor::Lower( actorB );
5257 // Sort actor tree before next touch event
5258 application.SendNotification();
5259 application.Render();
5261 application.ProcessEvent( touchEvent );
5263 tet_printf( "Not parented so Lower should show no effect\n" );
5265 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5266 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5267 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5268 ResetTouchCallbacks();
5270 tet_printf( "Raise actor B to top\n" );
5272 DevelActor::RaiseToTop( actorB );
5273 // Sort actor tree before next touch event
5274 application.SendNotification();
5275 application.Render();
5277 application.ProcessEvent( touchEvent );
5279 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5281 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5282 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5283 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5284 ResetTouchCallbacks();
5286 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5288 stage.Add ( actorB );
5290 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5292 DevelActor::LowerToBottom( actorC );
5293 application.SendNotification();
5294 application.Render();
5296 application.ProcessEvent( touchEvent );
5298 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5300 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5301 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5302 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5303 ResetTouchCallbacks();
5309 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5311 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5313 TestApplication application;
5315 Stage stage( Stage::GetCurrent() );
5317 Actor actorA = Actor::New();
5318 Actor actorB = Actor::New();
5319 Actor actorC = Actor::New();
5321 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5322 actorA.SetParentOrigin( ParentOrigin::CENTER );
5324 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5325 actorB.SetParentOrigin( ParentOrigin::CENTER );
5327 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5328 actorC.SetParentOrigin( ParentOrigin::CENTER );
5330 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5331 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5333 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5334 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5336 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5337 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5339 stage.Add( actorA );
5340 stage.Add( actorB );
5341 stage.Add( actorC );
5343 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5344 // Only top actor will get touched.
5345 actorA.TouchSignal().Connect( TestTouchCallback );
5346 actorB.TouchSignal().Connect( TestTouchCallback2 );
5347 actorC.TouchSignal().Connect( TestTouchCallback3 );
5349 ResetTouchCallbacks();
5351 application.SendNotification();
5352 application.Render();
5354 Dali::Integration::Point point;
5355 point.SetDeviceId( 1 );
5356 point.SetState( PointState::DOWN );
5357 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5358 Dali::Integration::TouchEvent touchEvent;
5359 touchEvent.AddPoint( point );
5361 application.ProcessEvent( touchEvent );
5363 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5364 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5365 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5367 ResetTouchCallbacks();
5369 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5371 DevelActor::RaiseAbove( actorA, actorA );
5372 application.SendNotification();
5373 application.Render();
5375 application.ProcessEvent( touchEvent );
5377 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5379 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5380 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5381 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5383 ResetTouchCallbacks();
5385 DevelActor::RaiseAbove( actorA, actorC );
5386 application.SendNotification();
5387 application.Render();
5389 application.ProcessEvent( touchEvent );
5391 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5392 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5393 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5394 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5399 int UtcDaliActorGetScreenPosition(void)
5401 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5403 TestApplication application;
5405 Stage stage( Stage::GetCurrent() );
5407 Actor actorA = Actor::New();
5408 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5410 Vector2 size2( 10.0f, 20.0f );
5411 actorA.SetSize( size2 );
5413 actorA.SetPosition( 0.f, 0.f );
5415 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5417 stage.Add( actorA );
5419 application.SendNotification();
5420 application.Render();
5422 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5423 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5425 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5426 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5428 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5429 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5431 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5433 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5435 application.SendNotification();
5436 application.Render();
5438 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5439 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5441 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5442 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5444 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5445 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5447 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5449 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5451 application.SendNotification();
5452 application.Render();
5454 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5455 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5457 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5458 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5460 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5461 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5463 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5465 actorA.SetPosition( 30.0, 0.0 );
5467 application.SendNotification();
5468 application.Render();
5470 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5471 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5473 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5474 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5476 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5477 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5479 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5481 actorA.SetPosition( 30.0, 420.0 );
5483 application.SendNotification();
5484 application.Render();
5486 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5487 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5489 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5490 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5492 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5493 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5499 int UtcDaliActorGetScreenPositionAfterScaling(void)
5501 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5503 TestApplication application;
5505 Stage stage( Stage::GetCurrent() );
5507 Actor actorA = Actor::New();
5508 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5510 Vector2 size2( 10.0f, 20.0f );
5511 actorA.SetSize( size2 );
5512 actorA.SetScale( 1.5f );
5513 actorA.SetPosition( 0.f, 0.f );
5515 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5517 stage.Add( actorA );
5519 application.SendNotification();
5520 application.Render();
5522 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5523 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5525 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5526 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5528 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5529 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5531 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5533 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5535 application.SendNotification();
5536 application.Render();
5538 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5539 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5541 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5542 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5544 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5545 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5550 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5552 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5554 TestApplication application;
5556 Stage stage( Stage::GetCurrent() );
5558 Actor actorA = Actor::New();
5559 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5560 actorA.SetParentOrigin( ParentOrigin::CENTER );
5561 Vector2 size2( 10.0f, 20.0f );
5562 actorA.SetSize( size2 );
5563 actorA.SetPosition( 0.f, 0.f );
5565 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5567 stage.Add( actorA );
5569 application.SendNotification();
5570 application.Render();
5572 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5573 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5575 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5576 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5578 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
5579 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
5581 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5583 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5584 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5586 application.SendNotification();
5587 application.Render();
5589 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5590 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5592 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5593 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5595 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5596 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5602 int UtcDaliActorGetScreenPositionWithChildActors(void)
5604 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5606 TestApplication application;
5608 Stage stage( Stage::GetCurrent() );
5610 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5612 Actor actorA = Actor::New();
5613 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5614 actorA.SetParentOrigin( ParentOrigin::CENTER );
5615 Vector2 size1( 10.0f, 20.0f );
5616 actorA.SetSize( size1 );
5617 actorA.SetPosition( 0.f, 0.f );
5619 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5621 Actor parentActorA = Actor::New();
5622 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5623 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5624 Vector2 size2( 30.0f, 60.0f );
5625 parentActorA.SetSize( size2 );
5626 parentActorA.SetPosition( 0.f, 0.f );
5628 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5630 stage.Add( parentActorA );
5631 parentActorA.Add ( actorA );
5633 application.SendNotification();
5634 application.Render();
5636 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5637 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5639 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5640 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5642 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
5643 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
5645 tet_infoline( "Test 2\n");
5647 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5649 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5650 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5652 application.SendNotification();
5653 application.Render();
5655 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5656 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5658 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5659 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5661 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
5662 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
5667 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5669 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5671 TestApplication application;
5673 Stage stage( Stage::GetCurrent() );
5675 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5677 Actor actorA = Actor::New();
5678 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5679 actorA.SetParentOrigin( ParentOrigin::CENTER );
5680 Vector2 size1( 10.0f, 20.0f );
5681 actorA.SetSize( size1 );
5682 actorA.SetPosition( 0.f, 0.f );
5684 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5686 Actor parentActorA = Actor::New();
5687 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5688 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5689 Vector2 size2( 30.0f, 60.0f );
5690 parentActorA.SetSize( size2 );
5691 parentActorA.SetPosition( 0.f, 0.f );
5693 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5695 Actor grandParentActorA = Actor::New();
5696 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5697 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5698 Vector2 size3( 60.0f, 120.0f );
5699 grandParentActorA.SetSize( size3 );
5700 grandParentActorA.SetPosition( 0.f, 0.f );
5702 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5704 stage.Add( grandParentActorA );
5705 grandParentActorA.Add ( parentActorA );
5707 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5709 parentActorA.Add ( actorA );
5711 application.SendNotification();
5712 application.Render();
5714 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5715 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5717 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5718 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5720 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
5721 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
5726 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5728 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
5730 TestApplication application;
5732 Stage stage( Stage::GetCurrent() );
5734 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5736 Actor actorA = Actor::New();
5737 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5738 actorA.SetParentOrigin( ParentOrigin::CENTER );
5739 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5740 actorA.SetSize( 10.0f, 20.0f );
5741 stage.Add( actorA );
5743 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5745 Actor actorB = Actor::New();
5746 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5747 actorB.SetParentOrigin( ParentOrigin::CENTER );
5748 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5749 Vector2 actorBSize( 30.0f, 60.0f );
5750 actorB.SetSize( actorBSize );
5751 stage.Add( actorB );
5753 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5755 Actor actorC = Actor::New();
5756 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5757 actorC.SetParentOrigin( ParentOrigin::CENTER );
5758 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5759 Vector2 actorCSize( 60.0f, 120.0f );
5760 actorC.SetSize( actorCSize );
5761 stage.Add( actorC );
5763 application.SendNotification();
5764 application.Render();
5766 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
5768 Vector2 center( stage.GetSize() * 0.5f );
5770 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5771 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5772 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5774 tet_infoline( "Add scale to all actors" );
5776 actorA.SetScale( 2.0f );
5777 actorB.SetScale( 2.0f );
5778 actorC.SetScale( 2.0f );
5780 application.SendNotification();
5781 application.Render();
5783 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
5784 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
5785 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
5790 int utcDaliActorPositionUsesAnchorPoint(void)
5792 TestApplication application;
5793 tet_infoline( "Check default behaviour\n" );
5795 Actor actor = Actor::New();
5796 actor.SetParentOrigin( ParentOrigin::CENTER );
5797 actor.SetAnchorPoint( AnchorPoint::CENTER );
5798 actor.SetSize( 100.0f, 100.0f );
5799 Stage::GetCurrent().Add( actor );
5801 application.SendNotification();
5802 application.Render();
5804 tet_infoline( "Check that the world position is in the center\n" );
5805 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5807 tet_infoline( "Set the position uses anchor point property to false\n" );
5808 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5810 application.SendNotification();
5811 application.Render();
5813 tet_infoline( "Check that the world position has changed appropriately\n" );
5814 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5819 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
5821 TestApplication application;
5822 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5824 Actor actor = Actor::New();
5825 actor.SetParentOrigin( ParentOrigin::CENTER );
5826 actor.SetAnchorPoint( AnchorPoint::CENTER );
5827 actor.SetSize( 100.0f, 100.0f );
5828 actor.SetScale( 2.0f );
5829 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5830 Stage::GetCurrent().Add( actor );
5832 application.SendNotification();
5833 application.Render();
5835 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
5836 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5838 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5839 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5840 application.SendNotification();
5841 application.Render();
5842 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5844 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5845 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5846 application.SendNotification();
5847 application.Render();
5848 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5853 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
5855 TestApplication application;
5856 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5858 Actor actor = Actor::New();
5859 actor.SetParentOrigin( ParentOrigin::CENTER );
5860 actor.SetAnchorPoint( AnchorPoint::CENTER );
5861 actor.SetSize( 100.0f, 100.0f );
5862 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5863 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5864 Stage::GetCurrent().Add( actor );
5866 application.SendNotification();
5867 application.Render();
5869 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
5870 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5872 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5873 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5874 application.SendNotification();
5875 application.Render();
5876 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5878 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5879 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5880 application.SendNotification();
5881 application.Render();
5882 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
5887 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
5889 TestApplication application;
5890 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5892 Actor actor = Actor::New();
5893 actor.SetParentOrigin( ParentOrigin::CENTER );
5894 actor.SetAnchorPoint( AnchorPoint::CENTER );
5895 actor.SetSize( 100.0f, 100.0f );
5896 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5897 actor.SetScale( 2.0f );
5898 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5899 Stage::GetCurrent().Add( actor );
5901 application.SendNotification();
5902 application.Render();
5904 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
5905 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5907 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5908 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5909 application.SendNotification();
5910 application.Render();
5911 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5913 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5914 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5915 application.SendNotification();
5916 application.Render();
5917 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
5922 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
5924 TestApplication application;
5925 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5927 Actor parent = Actor::New();
5929 Stage::GetCurrent().Add( parent );
5930 Vector2 stageSize( Stage::GetCurrent().GetSize() );
5932 Actor actor = Actor::New();
5933 actor.SetParentOrigin( ParentOrigin::CENTER );
5934 actor.SetAnchorPoint( AnchorPoint::CENTER );
5935 actor.SetSize( 100.0f, 100.0f );
5936 actor.SetInheritScale( false );
5937 actor.SetInheritOrientation( false );
5938 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5939 parent.Add( actor );
5941 application.SendNotification();
5942 application.Render();
5944 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
5946 tet_infoline( "Check the world position is in the right place\n" );
5947 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5949 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
5950 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5951 application.SendNotification();
5952 application.Render();
5953 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5955 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
5956 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5957 application.SendNotification();
5958 application.Render();
5959 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5963 int utcDaliActorVisibilityChangeSignalSelf(void)
5965 TestApplication application;
5966 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
5968 Actor actor = Actor::New();
5970 VisibilityChangedFunctorData data;
5971 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
5973 actor.SetVisible( false );
5975 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5977 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
5980 actor.SetVisible( false );
5981 data.Check( false /* not called */, TEST_LOCATION );
5983 tet_infoline( "Change the visibility using properties, ensure called" );
5986 actor.SetProperty( Actor::Property::VISIBLE, true );
5987 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5989 tet_infoline( "Set the visibility to current using properties, ensure not called" );
5992 actor.SetProperty( Actor::Property::VISIBLE, true );
5993 data.Check( false /* not called */, TEST_LOCATION );
5998 int utcDaliActorVisibilityChangeSignalChildren(void)
6000 TestApplication application;
6001 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6003 Actor parent = Actor::New();
6004 Actor child = Actor::New();
6005 parent.Add( child );
6007 Actor grandChild = Actor::New();
6008 child.Add( grandChild );
6010 VisibilityChangedFunctorData parentData;
6011 VisibilityChangedFunctorData childData;
6012 VisibilityChangedFunctorData grandChildData;
6014 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6015 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6016 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6018 parent.SetVisible( false );
6019 parentData.Check( false /* not called */, TEST_LOCATION );
6020 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6021 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6023 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6026 grandChildData.Reset();
6028 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6030 parent.SetVisible( true );
6031 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6032 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6033 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6035 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6038 grandChildData.Reset();
6040 parent.SetVisible( true );
6041 parentData.Check( false /* not called */, TEST_LOCATION );
6042 childData.Check( false /* not called */, TEST_LOCATION );
6043 grandChildData.Check( false /* not called */, TEST_LOCATION );