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/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali-test-suite-utils.h>
26 #include <mesh-builder.h>
34 void utc_dali_actor_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_actor_cleanup(void)
41 test_return_value = TET_PASS;
46 bool gTouchCallBackCalled=false;
47 bool gTouchCallBackCalled2=false;
48 bool gTouchCallBackCalled3=false;
50 bool gHoverCallBackCalled=false;
52 static bool gTestConstraintCalled;
54 LayoutDirection::Type gLayoutDirectionType;
58 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
60 gTestConstraintCalled = true;
65 * TestConstraint reference.
66 * When constraint is called, the resultRef is updated
67 * with the value supplied.
70 struct TestConstraintRef
72 TestConstraintRef(unsigned int& resultRef, unsigned int value)
73 : mResultRef(resultRef),
78 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
83 unsigned int& mResultRef;
87 static bool TestCallback(Actor actor, const TouchEvent& event)
89 gTouchCallBackCalled = true;
94 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
96 gTouchCallBackCalled = true;
101 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
103 gTouchCallBackCalled2 = true;
108 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
110 gTouchCallBackCalled3 = true;
115 static void ResetTouchCallbacks()
117 gTouchCallBackCalled = false;
118 gTouchCallBackCalled2 = false;
119 gTouchCallBackCalled3 = false;
122 static bool TestCallback3(Actor actor, const HoverEvent& event)
124 gHoverCallBackCalled = true;
129 // validation stuff for onstage & offstage signals
130 static std::vector< std::string > gActorNamesOnOffStage;
131 static int gOnStageCallBackCalled;
132 void OnStageCallback( Actor actor )
134 ++gOnStageCallBackCalled;
135 gActorNamesOnOffStage.push_back( actor.GetName() );
136 DALI_TEST_CHECK( actor.OnStage() == true );
138 static int gOffStageCallBackCalled;
139 void OffStageCallback( Actor actor )
141 ++gOffStageCallBackCalled;
142 gActorNamesOnOffStage.push_back( actor.GetName() );
143 DALI_TEST_CHECK( actor.OnStage() == false );
146 struct PositionComponentConstraint
148 PositionComponentConstraint(){}
150 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
152 const Matrix& m = inputs[0]->GetMatrix();
155 m.GetTransformComponents(pos, rot, scale);
159 struct OrientationComponentConstraint
161 OrientationComponentConstraint(){}
163 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
165 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
168 orientation = parentOrientation;
173 static bool gOnRelayoutCallBackCalled = false;
174 static std::vector< std::string > gActorNamesRelayout;
176 void OnRelayoutCallback( Actor actor )
178 gOnRelayoutCallBackCalled = true;
179 gActorNamesRelayout.push_back( actor.GetName() );
182 struct VisibilityChangedFunctorData
184 VisibilityChangedFunctorData()
187 type( DevelActor::VisibilityChange::SELF ),
196 type = DevelActor::VisibilityChange::SELF;
200 void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
202 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
203 DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
204 DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
205 DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
208 void Check( bool compareCalled, const std::string& location )
210 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
215 DevelActor::VisibilityChange::Type type;
219 struct VisibilityChangedFunctor
221 VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
223 void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
226 data.visible = visible;
231 VisibilityChangedFunctorData& data;
234 } // anonymous namespace
237 //& purpose: Testing New API
238 int UtcDaliActorNew(void)
240 TestApplication application;
242 Actor actor = Actor::New();
244 DALI_TEST_CHECK(actor);
248 //& purpose: Testing Dali::Actor::DownCast()
249 int UtcDaliActorDownCastP(void)
251 TestApplication application;
252 tet_infoline("Testing Dali::Actor::DownCast()");
254 Actor actor = Actor::New();
255 BaseHandle object(actor);
256 Actor actor2 = Actor::DownCast(object);
257 DALI_TEST_CHECK(actor2);
261 //& purpose: Testing Dali::Actor::DownCast()
262 int UtcDaliActorDownCastN(void)
264 TestApplication application;
265 tet_infoline("Testing Dali::Actor::DownCast()");
267 BaseHandle unInitializedObject;
268 Actor actor = Actor::DownCast(unInitializedObject);
269 DALI_TEST_CHECK(!actor);
273 //& purpose: Testing Dali::Actor::GetName()
274 int UtcDaliActorGetName(void)
276 TestApplication application;
278 Actor actor = Actor::New();
280 DALI_TEST_CHECK(actor.GetName().empty());
284 //& purpose: Testing Dali::Actor::SetName()
285 int UtcDaliActorSetName(void)
287 TestApplication application;
289 string str("ActorName");
290 Actor actor = Actor::New();
293 DALI_TEST_CHECK(actor.GetName() == str);
297 int UtcDaliActorGetId(void)
299 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
300 TestApplication application;
302 Actor first = Actor::New();
303 Actor second = Actor::New();
304 Actor third = Actor::New();
306 DALI_TEST_CHECK(first.GetId() != second.GetId());
307 DALI_TEST_CHECK(second.GetId() != third.GetId());
311 int UtcDaliActorIsRoot(void)
313 TestApplication application;
315 Actor actor = Actor::New();
316 DALI_TEST_CHECK(!actor.IsRoot());
318 // get the root layer
319 actor = Stage::GetCurrent().GetLayer( 0 );
320 DALI_TEST_CHECK( actor.IsRoot() );
324 int UtcDaliActorOnStage(void)
326 TestApplication application;
328 Actor actor = Actor::New();
329 DALI_TEST_CHECK( !actor.OnStage() );
331 // get the root layer
332 actor = Stage::GetCurrent().GetLayer( 0 );
333 DALI_TEST_CHECK( actor.OnStage() );
337 int UtcDaliActorIsLayer(void)
339 TestApplication application;
341 Actor actor = Actor::New();
342 DALI_TEST_CHECK( !actor.IsLayer() );
344 // get the root layer
345 actor = Stage::GetCurrent().GetLayer( 0 );
346 DALI_TEST_CHECK( actor.IsLayer() );
350 int UtcDaliActorGetLayer(void)
352 TestApplication application;
354 Actor actor = Actor::New();
355 Stage::GetCurrent().Add(actor);
356 Layer layer = actor.GetLayer();
358 DALI_TEST_CHECK(layer);
360 // get the root layers layer
361 actor = Stage::GetCurrent().GetLayer( 0 );
362 DALI_TEST_CHECK( actor.GetLayer() );
366 int UtcDaliActorAddP(void)
368 tet_infoline("Testing Actor::Add");
369 TestApplication application;
371 Actor parent = Actor::New();
372 Actor child = Actor::New();
374 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
378 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
380 Actor parent2 = Actor::New();
381 parent2.Add( child );
383 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
384 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
386 // try Adding to same parent again, works
387 parent2.Add( child );
388 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
390 // try reparenting an orphaned child
392 Actor temporaryParent = Actor::New();
393 temporaryParent.Add( child );
394 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
396 // temporaryParent has now died, reparent the orphaned child
397 parent2.Add( child );
398 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
403 int UtcDaliActorAddN(void)
405 tet_infoline("Testing Actor::Add");
406 TestApplication application;
408 Actor child = Actor::New();
410 Actor parent2 = Actor::New();
411 parent2.Add( child );
416 parent2.Add( parent2 );
417 tet_printf("Assertion test failed - no Exception\n" );
418 tet_result(TET_FAIL);
420 catch(Dali::DaliException& e)
422 DALI_TEST_PRINT_ASSERT( e );
423 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
424 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
428 tet_printf("Assertion test failed - wrong Exception\n" );
429 tet_result(TET_FAIL);
432 // try reparenting root
435 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
436 tet_printf("Assertion test failed - no Exception\n" );
437 tet_result(TET_FAIL);
439 catch(Dali::DaliException& e)
441 DALI_TEST_PRINT_ASSERT( e );
442 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
443 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
447 tet_printf("Assertion test failed - wrong Exception\n" );
448 tet_result(TET_FAIL);
455 parent2.Add( empty );
456 tet_printf("Assertion test failed - no Exception\n" );
457 tet_result(TET_FAIL);
459 catch(Dali::DaliException& e)
461 DALI_TEST_PRINT_ASSERT( e );
462 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
463 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
467 tet_printf("Assertion test failed - wrong Exception\n" );
468 tet_result(TET_FAIL);
474 int UtcDaliActorRemoveN(void)
476 tet_infoline("Testing Actor::Remove");
477 TestApplication application;
479 Actor parent = Actor::New();
480 Actor child = Actor::New();
481 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
484 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
486 parent.Remove(child);
487 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
489 // remove again, no problem
490 parent.Remove(child);
491 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
495 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
496 // try Remove self, its a no-op
497 parent.Remove( parent );
498 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
504 parent.Remove( empty );
505 tet_printf("Assertion test failed - no Exception\n" );
506 tet_result(TET_FAIL);
508 catch(Dali::DaliException& e)
510 DALI_TEST_PRINT_ASSERT( e );
511 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
512 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
516 tet_printf("Assertion test failed - wrong Exception\n" );
517 tet_result(TET_FAIL);
522 int UtcDaliActorRemoveP(void)
524 TestApplication application;
526 Actor parent = Actor::New();
527 Actor child = Actor::New();
528 Actor random = Actor::New();
530 Stage::GetCurrent().Add( parent );
532 DALI_TEST_CHECK(parent.GetChildCount() == 0);
536 DALI_TEST_CHECK(parent.GetChildCount() == 1);
538 parent.Remove(random);
540 DALI_TEST_CHECK(parent.GetChildCount() == 1);
542 Stage::GetCurrent().Remove( parent );
544 DALI_TEST_CHECK(parent.GetChildCount() == 1);
548 int UtcDaliActorGetChildCount(void)
550 TestApplication application;
552 Actor parent = Actor::New();
553 Actor child = Actor::New();
555 DALI_TEST_CHECK(parent.GetChildCount() == 0);
559 DALI_TEST_CHECK(parent.GetChildCount() == 1);
563 int UtcDaliActorGetChildren01(void)
565 TestApplication application;
567 Actor parent = Actor::New();
568 Actor first = Actor::New();
569 Actor second = Actor::New();
570 Actor third = Actor::New();
576 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
577 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
578 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
582 int UtcDaliActorGetChildren02(void)
584 TestApplication application;
586 Actor parent = Actor::New();
587 Actor first = Actor::New();
588 Actor second = Actor::New();
589 Actor third = Actor::New();
595 const Actor& constParent = parent;
597 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
598 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
599 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
603 int UtcDaliActorGetParent01(void)
605 TestApplication application;
607 Actor parent = Actor::New();
608 Actor child = Actor::New();
612 DALI_TEST_CHECK(child.GetParent() == parent);
616 int UtcDaliActorGetParent02(void)
618 TestApplication application;
620 Actor actor = Actor::New();
622 DALI_TEST_CHECK(!actor.GetParent());
626 int UtcDaliActorSetParentOrigin(void)
628 TestApplication application;
630 Actor actor = Actor::New();
632 Vector3 vector(0.7f, 0.8f, 0.9f);
633 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
635 actor.SetParentOrigin(vector);
637 // flush the queue and render once
638 application.SendNotification();
639 application.Render();
641 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
643 Stage::GetCurrent().Add( actor );
645 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
647 // flush the queue and render once
648 application.SendNotification();
649 application.Render();
651 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
653 Stage::GetCurrent().Remove( actor );
657 int UtcDaliActorSetParentOriginIndividual(void)
659 TestApplication application;
661 Actor actor = Actor::New();
663 Vector3 vector(0.7f, 0.8f, 0.9f);
664 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
666 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
668 // flush the queue and render once
669 application.SendNotification();
670 application.Render();
672 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
674 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
676 // flush the queue and render once
677 application.SendNotification();
678 application.Render();
680 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
682 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
684 // flush the queue and render once
685 application.SendNotification();
686 application.Render();
688 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
693 int UtcDaliActorGetCurrentParentOrigin(void)
695 TestApplication application;
697 Actor actor = Actor::New();
699 Vector3 vector(0.7f, 0.8f, 0.9f);
700 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
702 actor.SetParentOrigin(vector);
704 // flush the queue and render once
705 application.SendNotification();
706 application.Render();
708 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
712 int UtcDaliActorSetAnchorPoint(void)
714 TestApplication application;
716 Actor actor = Actor::New();
718 Vector3 vector(0.7f, 0.8f, 0.9f);
719 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
721 actor.SetAnchorPoint(vector);
723 // flush the queue and render once
724 application.SendNotification();
725 application.Render();
727 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
729 Stage::GetCurrent().Add( actor );
731 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
732 // flush the queue and render once
733 application.SendNotification();
734 application.Render();
736 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
738 Stage::GetCurrent().Remove( actor );
742 int UtcDaliActorSetAnchorPointIndividual(void)
744 TestApplication application;
746 Actor actor = Actor::New();
748 Vector3 vector(0.7f, 0.8f, 0.9f);
749 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
751 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
753 // flush the queue and render once
754 application.SendNotification();
755 application.Render();
757 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
759 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
761 // flush the queue and render once
762 application.SendNotification();
763 application.Render();
765 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
767 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
769 // flush the queue and render once
770 application.SendNotification();
771 application.Render();
773 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
778 int UtcDaliActorGetCurrentAnchorPoint(void)
780 TestApplication application;
782 Actor actor = Actor::New();
784 Vector3 vector(0.7f, 0.8f, 0.9f);
785 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
787 actor.SetAnchorPoint(vector);
789 // flush the queue and render once
790 application.SendNotification();
791 application.Render();
793 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
797 // SetSize(float width, float height)
798 int UtcDaliActorSetSize01(void)
800 TestApplication application;
802 Actor actor = Actor::New();
803 Vector3 vector(100.0f, 100.0f, 0.0f);
805 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
807 actor.SetSize(vector.x, vector.y);
809 // Immediately retrieve the size after setting
810 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
811 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
812 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
813 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
814 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
816 // Flush the queue and render once
817 application.SendNotification();
818 application.Render();
820 // Check the size in the new frame
821 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
823 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
824 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
825 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
826 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
827 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
829 // Check async behaviour
830 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
831 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
832 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
833 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
834 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
836 // Change the resize policy and check whether the size stays the same
837 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
839 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
840 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
842 // Set a new size after resize policy is changed and check the new size
843 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
845 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
846 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
848 // Change the resize policy again and check whether the new size stays the same
849 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
851 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
852 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
854 // Set another new size after resize policy is changed and check the new size
855 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
857 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
858 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
863 // SetSize(float width, float height, float depth)
864 int UtcDaliActorSetSize02(void)
866 TestApplication application;
868 Actor actor = Actor::New();
869 Vector3 vector(100.0f, 100.0f, 100.0f);
871 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
873 actor.SetSize(vector.x, vector.y, vector.z);
875 // Immediately check the size after setting
876 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
877 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
879 // flush the queue and render once
880 application.SendNotification();
881 application.Render();
883 // Check the size in the new frame
884 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
886 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
887 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
892 // SetSize(Vector2 size)
893 int UtcDaliActorSetSize03(void)
895 TestApplication application;
897 Actor actor = Actor::New();
898 Vector3 vector(100.0f, 100.0f, 0.0f);
900 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
902 actor.SetSize(Vector2(vector.x, vector.y));
904 // Immediately check the size after setting
905 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
906 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
908 // flush the queue and render once
909 application.SendNotification();
910 application.Render();
912 // Check the size in the new frame
913 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
915 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
916 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
921 // SetSize(Vector3 size)
922 int UtcDaliActorSetSize04(void)
924 TestApplication application;
926 Actor actor = Actor::New();
927 Vector3 vector(100.0f, 100.0f, 100.0f);
929 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
931 actor.SetSize(vector);
933 // Immediately check the size after setting
934 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
935 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
937 // flush the queue and render once
938 application.SendNotification();
939 application.Render();
941 // Check the size in the new frame
942 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
944 Stage::GetCurrent().Add( actor );
945 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
947 // Immediately check the size after setting
948 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
949 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
951 // flush the queue and render once
952 application.SendNotification();
953 application.Render();
955 // Check the size in the new frame
956 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
958 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
959 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
961 Stage::GetCurrent().Remove( actor );
965 int UtcDaliActorSetSizeIndividual(void)
967 TestApplication application;
969 Actor actor = Actor::New();
971 Vector3 vector(0.7f, 0.8f, 0.9f);
972 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
974 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
976 // Immediately check the width after setting
977 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
978 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
980 // flush the queue and render once
981 application.SendNotification();
982 application.Render();
984 // Check the width in the new frame
985 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
987 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
988 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
990 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
992 // Immediately check the height after setting
993 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
994 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
996 // flush the queue and render once
997 application.SendNotification();
998 application.Render();
1000 // Check the height in the new frame
1001 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1003 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1004 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1006 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1008 // Immediately check the depth after setting
1009 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1010 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1012 // flush the queue and render once
1013 application.SendNotification();
1014 application.Render();
1016 // Check the depth in the new frame
1017 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1019 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1020 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1022 // Change the resize policy and check whether the size stays the same
1023 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1025 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1026 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1028 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1029 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1031 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1032 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1034 // Change the resize policy again and check whether the size stays the same
1035 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1037 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1038 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1040 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1041 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1043 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1044 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1049 int UtcDaliActorSetSizeIndividual02(void)
1051 TestApplication application;
1053 Actor actor = Actor::New();
1054 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1055 Stage::GetCurrent().Add( actor );
1057 Vector3 vector( 100.0f, 200.0f, 400.0f );
1058 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1060 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1061 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1063 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1064 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1066 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1067 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1069 // flush the queue and render once
1070 application.SendNotification();
1071 application.Render();
1073 // Check the width in the new frame
1074 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1075 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1081 int UtcDaliActorGetCurrentSize(void)
1083 TestApplication application;
1085 Actor actor = Actor::New();
1086 Vector3 vector(100.0f, 100.0f, 20.0f);
1088 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1090 actor.SetSize(vector);
1092 // flush the queue and render once
1093 application.SendNotification();
1094 application.Render();
1096 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1100 int UtcDaliActorGetNaturalSize(void)
1102 TestApplication application;
1104 Actor actor = Actor::New();
1105 Vector3 vector( 0.0f, 0.0f, 0.0f );
1107 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1112 int UtcDaliActorGetCurrentSizeImmediate(void)
1114 TestApplication application;
1116 Actor actor = Actor::New();
1117 Vector3 vector(100.0f, 100.0f, 20.0f);
1119 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1120 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1122 actor.SetSize(vector);
1124 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1125 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1127 // flush the queue and render once
1128 application.SendNotification();
1129 application.Render();
1131 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1132 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1135 // Build the animation
1136 const float durationSeconds = 2.0f;
1137 Animation animation = Animation::New( durationSeconds );
1138 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1139 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1141 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1143 // Start the animation
1146 application.SendNotification();
1147 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1149 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1154 // SetPosition(float x, float y)
1155 int UtcDaliActorSetPosition01(void)
1157 TestApplication application;
1159 Actor actor = Actor::New();
1161 // Set to random to start off with
1162 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1164 Vector3 vector(100.0f, 100.0f, 0.0f);
1166 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1168 actor.SetPosition(vector.x, vector.y);
1169 // flush the queue and render once
1170 application.SendNotification();
1171 application.Render();
1172 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1174 Stage::GetCurrent().Add( actor );
1175 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1176 // flush the queue and render once
1177 application.SendNotification();
1178 application.Render();
1179 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1184 // flush the queue and render once
1185 application.SendNotification();
1186 application.Render();
1187 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1189 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1190 // flush the queue and render once
1191 application.SendNotification();
1192 application.Render();
1193 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1195 Stage::GetCurrent().Remove( actor );
1199 // SetPosition(float x, float y, float z)
1200 int UtcDaliActorSetPosition02(void)
1202 TestApplication application;
1204 Actor actor = Actor::New();
1206 // Set to random to start off with
1207 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1209 Vector3 vector(100.0f, 100.0f, 100.0f);
1211 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1213 actor.SetPosition(vector.x, vector.y, vector.z);
1215 // flush the queue and render once
1216 application.SendNotification();
1217 application.Render();
1219 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1223 // SetPosition(Vector3 position)
1224 int UtcDaliActorSetPosition03(void)
1226 TestApplication application;
1228 Actor actor = Actor::New();
1230 // Set to random to start off with
1231 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1233 Vector3 vector(100.0f, 100.0f, 100.0f);
1235 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1237 actor.SetPosition(vector);
1239 // flush the queue and render once
1240 application.SendNotification();
1241 application.Render();
1243 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1247 int UtcDaliActorSetX(void)
1249 TestApplication application;
1251 Actor actor = Actor::New();
1253 Vector3 vector(100.0f, 0.0f, 0.0f);
1255 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1259 // flush the queue and render once
1260 application.SendNotification();
1261 application.Render();
1263 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1267 int UtcDaliActorSetY(void)
1269 TestApplication application;
1271 Actor actor = Actor::New();
1273 Vector3 vector(0.0f, 100.0f, 0.0f);
1275 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1279 // flush the queue and render once
1280 application.SendNotification();
1281 application.Render();
1283 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1287 int UtcDaliActorSetZ(void)
1289 TestApplication application;
1291 Actor actor = Actor::New();
1293 Vector3 vector(0.0f, 0.0f, 100.0f);
1295 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1299 // flush the queue and render once
1300 application.SendNotification();
1301 application.Render();
1303 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1307 int UtcDaliActorSetPositionProperties(void)
1309 TestApplication application;
1311 Actor actor = Actor::New();
1313 Vector3 vector(0.7f, 0.8f, 0.9f);
1314 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1316 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1317 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1318 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1320 // flush the queue and render once
1321 application.SendNotification();
1322 application.Render();
1324 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1325 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1326 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1327 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1328 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1330 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1331 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1332 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1334 // flush the queue and render once
1335 application.SendNotification();
1336 application.Render();
1338 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1339 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1340 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1341 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1342 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1344 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1345 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1346 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1348 // flush the queue and render once
1349 application.SendNotification();
1350 application.Render();
1352 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1353 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1354 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1355 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1356 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1361 int UtcDaliActorTranslateBy(void)
1363 TestApplication application;
1365 Actor actor = Actor::New();
1366 Vector3 vector(100.0f, 100.0f, 100.0f);
1368 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1370 actor.SetPosition(vector);
1372 // flush the queue and render once
1373 application.SendNotification();
1374 application.Render();
1376 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1378 actor.TranslateBy(vector);
1380 // flush the queue and render once
1381 application.SendNotification();
1382 application.Render();
1384 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1388 int UtcDaliActorGetCurrentPosition(void)
1390 TestApplication application;
1392 Actor actor = Actor::New();
1393 Vector3 setVector(100.0f, 100.0f, 0.0f);
1394 actor.SetPosition(setVector);
1396 // flush the queue and render once
1397 application.SendNotification();
1398 application.Render();
1400 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1404 int UtcDaliActorGetCurrentWorldPosition(void)
1406 TestApplication application;
1408 Actor parent = Actor::New();
1409 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1410 parent.SetPosition( parentPosition );
1411 parent.SetParentOrigin( ParentOrigin::CENTER );
1412 parent.SetAnchorPoint( AnchorPoint::CENTER );
1413 Stage::GetCurrent().Add( parent );
1415 Actor child = Actor::New();
1416 child.SetParentOrigin( ParentOrigin::CENTER );
1417 child.SetAnchorPoint( AnchorPoint::CENTER );
1418 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1419 child.SetPosition( childPosition );
1420 parent.Add( child );
1422 // The actors should not have a world position yet
1423 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1424 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1426 application.SendNotification();
1427 application.Render(0);
1429 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1430 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1432 // The actors should have a world position now
1433 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1434 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1438 int UtcDaliActorInheritPosition(void)
1440 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1441 TestApplication application;
1443 Actor parent = Actor::New();
1444 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1445 parent.SetPosition( parentPosition );
1446 parent.SetParentOrigin( ParentOrigin::CENTER );
1447 parent.SetAnchorPoint( AnchorPoint::CENTER );
1448 Stage::GetCurrent().Add( parent );
1450 Actor child = Actor::New();
1451 child.SetParentOrigin( ParentOrigin::CENTER );
1452 child.SetAnchorPoint( AnchorPoint::CENTER );
1453 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1454 child.SetPosition( childPosition );
1455 parent.Add( child );
1457 // The actors should not have a world position yet
1458 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1459 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1461 // first test default, which is to inherit position
1462 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1463 application.SendNotification();
1464 application.Render(0); // should only really call Update as Render is not required to update scene
1465 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1466 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1467 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1468 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1471 //Change child position
1472 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1473 child.SetPosition( childOffset );
1475 // Change inheritance mode to not inherit
1476 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1477 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1478 application.SendNotification();
1479 application.Render(0); // should only really call Update as Render is not required to update scene
1480 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1481 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1482 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1483 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1487 int UtcDaliActorSetInheritPosition(void)
1489 tet_infoline("Testing Actor::SetInheritPosition");
1490 TestApplication application;
1492 Actor parent = Actor::New();
1493 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1494 parent.SetPosition( parentPosition );
1495 parent.SetParentOrigin( ParentOrigin::CENTER );
1496 parent.SetAnchorPoint( AnchorPoint::CENTER );
1497 Stage::GetCurrent().Add( parent );
1499 Actor child = Actor::New();
1500 child.SetParentOrigin( ParentOrigin::CENTER );
1501 child.SetAnchorPoint( AnchorPoint::CENTER );
1502 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1503 child.SetPosition( childPosition );
1504 parent.Add( child );
1506 // The actors should not have a world position yet
1507 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1508 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1510 // first test default, which is to inherit position
1511 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1512 application.SendNotification();
1513 application.Render(0); // should only really call Update as Render is not required to update scene
1514 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1515 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1516 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1517 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1519 //Change child position
1520 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1521 child.SetPosition( childOffset );
1523 // Use local position as world postion
1524 child.SetInheritPosition( false );
1525 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1526 application.SendNotification();
1527 application.Render(0); // should only really call Update as Render is not required to update scene
1528 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1529 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1530 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1531 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1533 //Change back to inherit position from parent
1534 child.SetInheritPosition( true );
1535 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1536 application.SendNotification();
1537 application.Render(0); // should only really call Update as Render is not required to update scene
1538 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1539 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1540 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1541 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1545 // SetOrientation(float angleRadians, Vector3 axis)
1546 int UtcDaliActorSetOrientation01(void)
1548 TestApplication application;
1550 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1551 Actor actor = Actor::New();
1553 actor.SetOrientation(rotation);
1555 // flush the queue and render once
1556 application.SendNotification();
1557 application.Render();
1559 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1563 int UtcDaliActorSetOrientation02(void)
1565 TestApplication application;
1567 Actor actor = Actor::New();
1569 Radian angle( 0.785f );
1570 Vector3 axis(1.0f, 1.0f, 0.0f);
1572 actor.SetOrientation( angle, axis);
1573 Quaternion rotation( angle, axis );
1574 // flush the queue and render once
1575 application.SendNotification();
1576 application.Render();
1577 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1579 Stage::GetCurrent().Add( actor );
1580 actor.RotateBy( Degree( 360 ), axis);
1581 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1583 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1584 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1585 // flush the queue and render once
1586 application.SendNotification();
1587 application.Render();
1588 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1590 actor.SetOrientation( angle, axis);
1591 // flush the queue and render once
1592 application.SendNotification();
1593 application.Render();
1594 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1596 Stage::GetCurrent().Remove( actor );
1600 // SetOrientation(float angleRadians, Vector3 axis)
1601 int UtcDaliActorSetOrientationProperty(void)
1603 TestApplication application;
1605 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1606 Actor actor = Actor::New();
1608 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1609 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1611 // flush the queue and render once
1612 application.SendNotification();
1613 application.Render();
1615 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1616 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1617 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1621 // RotateBy(float angleRadians, Vector3 axis)
1622 int UtcDaliActorRotateBy01(void)
1624 TestApplication application;
1626 Actor actor = Actor::New();
1628 Radian angle( M_PI * 0.25f );
1629 actor.RotateBy(( angle ), Vector3::ZAXIS);
1630 // flush the queue and render once
1631 application.SendNotification();
1632 application.Render();
1633 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1635 Stage::GetCurrent().Add( actor );
1637 actor.RotateBy( angle, Vector3::ZAXIS);
1638 // flush the queue and render once
1639 application.SendNotification();
1640 application.Render();
1641 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1643 Stage::GetCurrent().Remove( actor );
1647 // RotateBy(Quaternion relativeRotation)
1648 int UtcDaliActorRotateBy02(void)
1650 TestApplication application;
1652 Actor actor = Actor::New();
1654 Radian angle( M_PI * 0.25f );
1655 Quaternion rotation(angle, Vector3::ZAXIS);
1656 actor.RotateBy(rotation);
1657 // flush the queue and render once
1658 application.SendNotification();
1659 application.Render();
1660 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1662 actor.RotateBy(rotation);
1663 // flush the queue and render once
1664 application.SendNotification();
1665 application.Render();
1666 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1670 int UtcDaliActorGetCurrentOrientation(void)
1672 TestApplication application;
1673 Actor actor = Actor::New();
1675 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1676 actor.SetOrientation(rotation);
1677 // flush the queue and render once
1678 application.SendNotification();
1679 application.Render();
1680 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1684 int UtcDaliActorGetCurrentWorldOrientation(void)
1686 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1687 TestApplication application;
1689 Actor parent = Actor::New();
1690 Radian rotationAngle( Degree(90.0f) );
1691 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1692 parent.SetOrientation( rotation );
1693 Stage::GetCurrent().Add( parent );
1695 Actor child = Actor::New();
1696 child.SetOrientation( rotation );
1697 parent.Add( child );
1699 // The actors should not have a world rotation yet
1700 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1701 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1703 application.SendNotification();
1704 application.Render(0);
1706 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1707 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1709 // The actors should have a world rotation now
1710 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1711 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1713 // turn off child rotation inheritance
1714 child.SetInheritOrientation( false );
1715 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1716 application.SendNotification();
1717 application.Render(0);
1719 // The actors should have a world rotation now
1720 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1721 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1725 // SetScale(float scale)
1726 int UtcDaliActorSetScale01(void)
1728 TestApplication application;
1730 Actor actor = Actor::New();
1732 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1733 actor.SetScale(0.25f);
1735 Vector3 scale(10.0f, 10.0f, 10.0f);
1736 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1738 actor.SetScale(scale.x);
1740 // flush the queue and render once
1741 application.SendNotification();
1742 application.Render();
1744 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1748 // SetScale(float scaleX, float scaleY, float scaleZ)
1749 int UtcDaliActorSetScale02(void)
1751 TestApplication application;
1752 Vector3 scale(10.0f, 10.0f, 10.0f);
1754 Actor actor = Actor::New();
1756 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1757 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1759 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1761 actor.SetScale(scale.x, scale.y, scale.z);
1762 // flush the queue and render once
1763 application.SendNotification();
1764 application.Render();
1765 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1767 // add to stage and test
1768 Stage::GetCurrent().Add( actor );
1769 actor.SetScale( 2.0f, 2.0f, 2.0f );
1770 // flush the queue and render once
1771 application.SendNotification();
1772 application.Render();
1773 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1775 Stage::GetCurrent().Remove( actor );
1780 // SetScale(Vector3 scale)
1781 int UtcDaliActorSetScale03(void)
1783 TestApplication application;
1784 Vector3 scale(10.0f, 10.0f, 10.0f);
1786 Actor actor = Actor::New();
1788 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1789 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1791 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1793 actor.SetScale(scale);
1795 // flush the queue and render once
1796 application.SendNotification();
1797 application.Render();
1799 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1803 int UtcDaliActorSetScaleIndividual(void)
1805 TestApplication application;
1807 Actor actor = Actor::New();
1809 Vector3 vector(0.7f, 0.8f, 0.9f);
1810 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1812 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1813 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1815 // flush the queue and render once
1816 application.SendNotification();
1817 application.Render();
1819 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1820 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1821 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1823 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1824 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1826 // flush the queue and render once
1827 application.SendNotification();
1828 application.Render();
1830 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1831 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1832 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1834 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1835 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1837 // flush the queue and render once
1838 application.SendNotification();
1839 application.Render();
1841 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1842 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1843 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1845 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1846 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1851 int UtcDaliActorScaleBy(void)
1853 TestApplication application;
1854 Actor actor = Actor::New();
1855 Vector3 vector(100.0f, 100.0f, 100.0f);
1857 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1859 actor.SetScale(vector);
1861 // flush the queue and render once
1862 application.SendNotification();
1863 application.Render();
1865 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1867 actor.ScaleBy(vector);
1869 // flush the queue and render once
1870 application.SendNotification();
1871 application.Render();
1873 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1877 int UtcDaliActorGetCurrentScale(void)
1879 TestApplication application;
1880 Vector3 scale(12.0f, 1.0f, 2.0f);
1882 Actor actor = Actor::New();
1884 actor.SetScale(scale);
1886 // flush the queue and render once
1887 application.SendNotification();
1888 application.Render();
1890 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1894 int UtcDaliActorGetCurrentWorldScale(void)
1896 TestApplication application;
1898 Actor parent = Actor::New();
1899 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1900 parent.SetScale( parentScale );
1901 Stage::GetCurrent().Add( parent );
1903 Actor child = Actor::New();
1904 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1905 child.SetScale( childScale );
1906 parent.Add( child );
1908 // The actors should not have a scale yet
1909 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1910 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1912 // The actors should not have a world scale yet
1913 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1914 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1916 application.SendNotification();
1917 application.Render(0);
1919 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1920 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1922 // The actors should have a world scale now
1923 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1924 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1928 int UtcDaliActorInheritScale(void)
1930 tet_infoline("Testing Actor::SetInheritScale");
1931 TestApplication application;
1933 Actor parent = Actor::New();
1934 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1935 parent.SetScale( parentScale );
1936 Stage::GetCurrent().Add( parent );
1938 Actor child = Actor::New();
1939 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1940 child.SetScale( childScale );
1941 parent.Add( child );
1943 application.SendNotification();
1944 application.Render(0);
1946 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1947 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1949 child.SetInheritScale( false );
1950 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1952 application.SendNotification();
1953 application.Render(0);
1955 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1959 int UtcDaliActorSetVisible(void)
1961 TestApplication application;
1963 Actor actor = Actor::New();
1964 actor.SetVisible(false);
1965 // flush the queue and render once
1966 application.SendNotification();
1967 application.Render();
1968 DALI_TEST_CHECK(actor.IsVisible() == false);
1970 actor.SetVisible(true);
1971 // flush the queue and render once
1972 application.SendNotification();
1973 application.Render();
1974 DALI_TEST_CHECK(actor.IsVisible() == true);
1976 // put actor on stage
1977 Stage::GetCurrent().Add( actor );
1978 actor.SetVisible(false);
1979 // flush the queue and render once
1980 application.SendNotification();
1981 application.Render();
1982 DALI_TEST_CHECK(actor.IsVisible() == false);
1986 int UtcDaliActorIsVisible(void)
1988 TestApplication application;
1990 Actor actor = Actor::New();
1992 DALI_TEST_CHECK(actor.IsVisible() == true);
1996 int UtcDaliActorSetOpacity(void)
1998 TestApplication application;
2000 Actor actor = Actor::New();
2001 // initial opacity is 1
2002 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2004 actor.SetOpacity( 0.4f);
2005 // flush the queue and render once
2006 application.SendNotification();
2007 application.Render();
2008 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2010 // change opacity, actor is on stage to change is not immediate
2011 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2012 // flush the queue and render once
2013 application.SendNotification();
2014 application.Render();
2015 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2017 // put actor on stage
2018 Stage::GetCurrent().Add( actor );
2020 // change opacity, actor is on stage to change is not immediate
2021 actor.SetOpacity( 0.9f );
2022 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2023 // flush the queue and render once
2024 application.SendNotification();
2025 application.Render();
2026 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2028 // change opacity, actor is on stage to change is not immediate
2029 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2030 // flush the queue and render once
2031 application.SendNotification();
2032 application.Render();
2033 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2037 int UtcDaliActorGetCurrentOpacity(void)
2039 TestApplication application;
2041 Actor actor = Actor::New();
2042 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2044 actor.SetOpacity(0.5f);
2045 // flush the queue and render once
2046 application.SendNotification();
2047 application.Render();
2048 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2052 int UtcDaliActorSetSensitive(void)
2054 TestApplication application;
2055 Actor actor = Actor::New();
2057 bool sensitive = !actor.IsSensitive();
2059 actor.SetSensitive(sensitive);
2061 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2065 int UtcDaliActorIsSensitive(void)
2067 TestApplication application;
2068 Actor actor = Actor::New();
2069 actor.SetSensitive(false);
2071 DALI_TEST_CHECK(false == actor.IsSensitive());
2075 int UtcDaliActorSetColor(void)
2077 TestApplication application;
2078 Actor actor = Actor::New();
2079 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2081 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2083 actor.SetColor(color);
2084 // flush the queue and render once
2085 application.SendNotification();
2086 application.Render();
2087 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2089 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2090 // flush the queue and render once
2091 application.SendNotification();
2092 application.Render();
2093 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2095 Stage::GetCurrent().Add( actor );
2096 actor.SetColor( color );
2097 // flush the queue and render once
2098 application.SendNotification();
2099 application.Render();
2100 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2102 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2103 // flush the queue and render once
2104 application.SendNotification();
2105 application.Render();
2106 // Actor color is not clamped
2107 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2108 // world color is clamped
2109 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2111 Stage::GetCurrent().Remove( actor );
2115 int UtcDaliActorSetColorIndividual(void)
2117 TestApplication application;
2119 Actor actor = Actor::New();
2121 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2122 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2124 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2125 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2127 // flush the queue and render once
2128 application.SendNotification();
2129 application.Render();
2131 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2132 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2133 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2135 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2136 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2138 // flush the queue and render once
2139 application.SendNotification();
2140 application.Render();
2142 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2143 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2144 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2146 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2147 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2149 // flush the queue and render once
2150 application.SendNotification();
2151 application.Render();
2153 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2154 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2155 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2158 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2159 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2161 // flush the queue and render once
2162 application.SendNotification();
2163 application.Render();
2165 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2166 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2167 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2169 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2170 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2172 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2175 // flush the queue and render once
2176 application.SendNotification();
2177 application.Render();
2179 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2185 int UtcDaliActorGetCurrentColor(void)
2187 TestApplication application;
2188 Actor actor = Actor::New();
2189 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2191 actor.SetColor(color);
2192 // flush the queue and render once
2193 application.SendNotification();
2194 application.Render();
2195 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2199 int UtcDaliActorGetCurrentWorldColor(void)
2201 tet_infoline("Actor::GetCurrentWorldColor");
2202 TestApplication application;
2204 Actor parent = Actor::New();
2205 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2206 parent.SetColor( parentColor );
2207 Stage::GetCurrent().Add( parent );
2209 Actor child = Actor::New();
2210 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2211 child.SetColor( childColor );
2212 parent.Add( child );
2214 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2215 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2217 // verify the default color mode
2218 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2220 // The actors should not have a world color yet
2221 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2222 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2224 application.SendNotification();
2225 application.Render(0);
2227 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2228 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2230 // The actors should have a world color now
2231 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2232 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2235 child.SetColorMode( USE_OWN_COLOR );
2236 application.SendNotification();
2237 application.Render(0);
2238 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2241 child.SetColorMode( USE_PARENT_COLOR );
2242 application.SendNotification();
2243 application.Render(0);
2244 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2245 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2248 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2249 application.SendNotification();
2250 application.Render(0);
2251 Vector4 expectedColor( childColor );
2252 expectedColor.a *= parentColor.a;
2253 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2254 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2258 int UtcDaliActorSetColorMode(void)
2260 tet_infoline("Actor::SetColorMode");
2261 TestApplication application;
2262 Actor actor = Actor::New();
2263 Actor child = Actor::New();
2266 actor.SetColorMode( USE_OWN_COLOR );
2267 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2269 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2270 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2272 actor.SetColorMode( USE_PARENT_COLOR );
2273 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2275 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2276 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2280 int UtcDaliActorScreenToLocal(void)
2282 TestApplication application;
2283 Actor actor = Actor::New();
2284 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2285 actor.SetSize(100.0f, 100.0f);
2286 actor.SetPosition(10.0f, 10.0f);
2287 Stage::GetCurrent().Add(actor);
2289 // flush the queue and render once
2290 application.SendNotification();
2291 application.Render();
2296 application.SendNotification();
2297 application.Render();
2299 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2301 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2302 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2306 int UtcDaliActorSetLeaveRequired(void)
2308 TestApplication application;
2310 Actor actor = Actor::New();
2312 actor.SetLeaveRequired(false);
2313 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2315 actor.SetLeaveRequired(true);
2316 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2320 int UtcDaliActorGetLeaveRequired(void)
2322 TestApplication application;
2324 Actor actor = Actor::New();
2326 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2330 int UtcDaliActorSetKeyboardFocusable(void)
2332 TestApplication application;
2334 Actor actor = Actor::New();
2336 actor.SetKeyboardFocusable(true);
2337 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2339 actor.SetKeyboardFocusable(false);
2340 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2344 int UtcDaliActorIsKeyboardFocusable(void)
2346 TestApplication application;
2348 Actor actor = Actor::New();
2350 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2354 int UtcDaliActorRemoveConstraints(void)
2356 tet_infoline(" UtcDaliActorRemoveConstraints");
2357 TestApplication application;
2359 gTestConstraintCalled = false;
2361 Actor actor = Actor::New();
2363 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2365 actor.RemoveConstraints();
2367 DALI_TEST_CHECK( gTestConstraintCalled == false );
2369 Stage::GetCurrent().Add( actor );
2372 // flush the queue and render once
2373 application.SendNotification();
2374 application.Render();
2376 actor.RemoveConstraints();
2378 DALI_TEST_CHECK( gTestConstraintCalled == true );
2382 int UtcDaliActorRemoveConstraintTag(void)
2384 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2385 TestApplication application;
2387 Actor actor = Actor::New();
2389 // 1. Apply Constraint1 and Constraint2, and test...
2390 unsigned int result1 = 0u;
2391 unsigned int result2 = 0u;
2393 unsigned constraint1Tag = 1u;
2394 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2395 constraint1.SetTag( constraint1Tag );
2396 constraint1.Apply();
2398 unsigned constraint2Tag = 2u;
2399 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2400 constraint2.SetTag( constraint2Tag );
2401 constraint2.Apply();
2403 Stage::GetCurrent().Add( actor );
2404 // flush the queue and render once
2405 application.SendNotification();
2406 application.Render();
2408 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2409 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2411 // 2. Remove Constraint1 and test...
2414 actor.RemoveConstraints(constraint1Tag);
2415 // make color property dirty, which will trigger constraints to be reapplied.
2416 actor.SetColor( Color::WHITE );
2417 // flush the queue and render once
2418 application.SendNotification();
2419 application.Render();
2421 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2422 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2424 // 3. Re-Apply Constraint1 and test...
2427 constraint1.Apply();
2428 // make color property dirty, which will trigger constraints to be reapplied.
2429 actor.SetColor( Color::WHITE );
2430 // flush the queue and render once
2431 application.SendNotification();
2432 application.Render();
2434 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2435 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2437 // 2. Remove Constraint2 and test...
2440 actor.RemoveConstraints(constraint2Tag);
2441 // make color property dirty, which will trigger constraints to be reapplied.
2442 actor.SetColor( Color::WHITE );
2443 // flush the queue and render once
2444 application.SendNotification();
2445 application.Render();
2447 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2448 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2450 // 2. Remove Constraint1 as well and test...
2453 actor.RemoveConstraints(constraint1Tag);
2454 // make color property dirty, which will trigger constraints to be reapplied.
2455 actor.SetColor( Color::WHITE );
2456 // flush the queue and render once
2457 application.SendNotification();
2458 application.Render();
2460 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2461 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2465 int UtcDaliActorTouchedSignal(void)
2467 TestApplication application;
2469 ResetTouchCallbacks();
2471 // get the root layer
2472 Actor actor = Stage::GetCurrent().GetRootLayer();
2473 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2475 application.SendNotification();
2476 application.Render();
2478 // connect to its touch signal
2479 actor.TouchedSignal().Connect( TestCallback );
2481 // simulate a touch event in the middle of the screen
2482 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2483 Dali::Integration::Point point;
2484 point.SetDeviceId( 1 );
2485 point.SetState( PointState::DOWN );
2486 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2487 Dali::Integration::TouchEvent touchEvent;
2488 touchEvent.AddPoint( point );
2489 application.ProcessEvent( touchEvent );
2491 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2495 int UtcDaliActorHoveredSignal(void)
2497 TestApplication application;
2499 gHoverCallBackCalled = false;
2501 // get the root layer
2502 Actor actor = Stage::GetCurrent().GetRootLayer();
2503 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2505 application.SendNotification();
2506 application.Render();
2508 // connect to its hover signal
2509 actor.HoveredSignal().Connect( TestCallback3 );
2511 // simulate a hover event in the middle of the screen
2512 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2513 Dali::Integration::Point point;
2514 point.SetDeviceId( 1 );
2515 point.SetState( PointState::MOTION );
2516 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2517 Dali::Integration::HoverEvent hoverEvent;
2518 hoverEvent.AddPoint( point );
2519 application.ProcessEvent( hoverEvent );
2521 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2525 int UtcDaliActorOnOffStageSignal(void)
2527 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2529 TestApplication application;
2532 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2533 gActorNamesOnOffStage.clear();
2535 Actor parent = Actor::New();
2536 parent.SetName( "parent" );
2537 parent.OnStageSignal().Connect( OnStageCallback );
2538 parent.OffStageSignal().Connect( OffStageCallback );
2540 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2541 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2543 // add parent to stage
2544 Stage::GetCurrent().Add( parent );
2545 // onstage emitted, offstage not
2546 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2547 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2548 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2550 // test adding a child, should get onstage emitted
2552 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2553 gActorNamesOnOffStage.clear();
2555 Actor child = Actor::New();
2556 child.SetName( "child" );
2557 child.OnStageSignal().Connect( OnStageCallback );
2558 child.OffStageSignal().Connect( OffStageCallback );
2559 parent.Add( child ); // add child
2560 // onstage emitted, offstage not
2561 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2562 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2563 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2565 // test removing parent from stage
2567 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2568 gActorNamesOnOffStage.clear();
2570 Stage::GetCurrent().Remove( parent );
2571 // onstage not emitted, offstage is
2572 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2573 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2574 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2575 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2577 // test adding parent back to stage
2579 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2580 gActorNamesOnOffStage.clear();
2582 Stage::GetCurrent().Add( parent );
2583 // onstage emitted, offstage not
2584 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2585 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2586 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2587 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2589 // test removing child
2591 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2592 gActorNamesOnOffStage.clear();
2594 parent.Remove( child );
2595 // onstage not emitted, offstage is
2596 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2597 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2598 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2600 // test removing parent
2602 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2603 gActorNamesOnOffStage.clear();
2605 Stage::GetCurrent().Remove( parent );
2606 // onstage not emitted, offstage is
2607 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2608 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2609 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2613 int UtcDaliActorFindChildByName(void)
2615 tet_infoline("Testing Dali::Actor::FindChildByName()");
2616 TestApplication application;
2618 Actor parent = Actor::New();
2619 parent.SetName( "parent" );
2620 Actor first = Actor::New();
2621 first .SetName( "first" );
2622 Actor second = Actor::New();
2623 second.SetName( "second" );
2628 Actor found = parent.FindChildByName( "foo" );
2629 DALI_TEST_CHECK( !found );
2631 found = parent.FindChildByName( "parent" );
2632 DALI_TEST_CHECK( found == parent );
2634 found = parent.FindChildByName( "first" );
2635 DALI_TEST_CHECK( found == first );
2637 found = parent.FindChildByName( "second" );
2638 DALI_TEST_CHECK( found == second );
2642 int UtcDaliActorFindChildById(void)
2644 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2645 TestApplication application;
2647 Actor parent = Actor::New();
2648 Actor first = Actor::New();
2649 Actor second = Actor::New();
2654 Actor found = parent.FindChildById( 100000 );
2655 DALI_TEST_CHECK( !found );
2657 found = parent.FindChildById( parent.GetId() );
2658 DALI_TEST_CHECK( found == parent );
2660 found = parent.FindChildById( first.GetId() );
2661 DALI_TEST_CHECK( found == first );
2663 found = parent.FindChildById( second.GetId() );
2664 DALI_TEST_CHECK( found == second );
2668 int UtcDaliActorHitTest(void)
2673 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2675 mTouchPoint( touchPoint ),
2680 Vector2 mTouchPoint;
2684 TestApplication application;
2685 tet_infoline(" UtcDaliActorHitTest");
2687 // Fill a vector with different hit tests.
2688 struct HitTestData* hitTestData[] = {
2689 // scale touch point result
2690 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2691 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2692 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.
2693 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2694 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.
2698 // get the root layer
2699 Actor actor = Actor::New();
2700 actor.SetAnchorPoint( AnchorPoint::CENTER );
2701 actor.SetParentOrigin( ParentOrigin::CENTER );
2703 Stage::GetCurrent().Add( actor );
2705 ResetTouchCallbacks();
2707 unsigned int index = 0;
2708 while( NULL != hitTestData[index] )
2710 actor.SetSize( 1.f, 1.f );
2711 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2713 // flush the queue and render once
2714 application.SendNotification();
2715 application.Render();
2717 DALI_TEST_CHECK( !gTouchCallBackCalled );
2719 // connect to its touch signal
2720 actor.TouchedSignal().Connect(TestCallback);
2722 Dali::Integration::Point point;
2723 point.SetState( PointState::DOWN );
2724 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2725 Dali::Integration::TouchEvent event;
2726 event.AddPoint( point );
2728 // flush the queue and render once
2729 application.SendNotification();
2730 application.Render();
2731 application.ProcessEvent( event );
2733 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2735 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2736 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2737 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2738 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2739 hitTestData[index]->mResult );
2741 ResetTouchCallbacks();
2747 int UtcDaliActorSetDrawMode(void)
2749 TestApplication app;
2750 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2752 Actor a = Actor::New();
2754 Stage::GetCurrent().Add(a);
2755 app.SendNotification();
2757 app.SendNotification();
2760 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2762 a.SetDrawMode( DrawMode::OVERLAY_2D );
2763 app.SendNotification();
2766 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2768 a.SetDrawMode( DrawMode::NORMAL );
2769 app.SendNotification();
2772 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2776 int UtcDaliActorSetDrawModeOverlayRender(void)
2778 TestApplication app;
2779 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2781 app.SendNotification();
2784 std::vector<GLuint> ids;
2785 ids.push_back( 8 ); // first rendered actor
2786 ids.push_back( 9 ); // second rendered actor
2787 ids.push_back( 10 ); // third rendered actor
2788 app.GetGlAbstraction().SetNextTextureIds( ids );
2790 BufferImage imageA = BufferImage::New(16, 16);
2791 BufferImage imageB = BufferImage::New(16, 16);
2792 BufferImage imageC = BufferImage::New(16, 16);
2793 Actor a = CreateRenderableActor( imageA );
2794 Actor b = CreateRenderableActor( imageB );
2795 Actor c = CreateRenderableActor( imageC );
2797 app.SendNotification();
2800 //Textures are bound when first created. Clear bound textures vector
2801 app.GetGlAbstraction().ClearBoundTextures();
2803 // Render a,b,c as regular non-overlays. so order will be:
2807 Stage::GetCurrent().Add(a);
2808 Stage::GetCurrent().Add(b);
2809 Stage::GetCurrent().Add(c);
2811 app.SendNotification();
2814 // Should be 3 textures changes.
2815 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2816 typedef std::vector<GLuint>::size_type TextureSize;
2817 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2818 if( boundTextures.size() == 3 )
2820 DALI_TEST_CHECK( boundTextures[0] == 8u );
2821 DALI_TEST_CHECK( boundTextures[1] == 9u );
2822 DALI_TEST_CHECK( boundTextures[2] == 10u );
2825 // Now texture ids have been set, we can monitor their render order.
2826 // render a as an overlay (last), so order will be:
2830 a.SetDrawMode( DrawMode::OVERLAY_2D );
2831 app.GetGlAbstraction().ClearBoundTextures();
2833 app.SendNotification();
2836 // Should be 3 texture changes.
2837 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2838 if( boundTextures.size() == 3 )
2840 DALI_TEST_CHECK( boundTextures[0] == 9u );
2841 DALI_TEST_CHECK( boundTextures[1] == 10u );
2842 DALI_TEST_CHECK( boundTextures[2] == 8u );
2847 int UtcDaliActorGetCurrentWorldMatrix(void)
2849 TestApplication app;
2850 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2852 Actor parent = Actor::New();
2853 parent.SetParentOrigin(ParentOrigin::CENTER);
2854 parent.SetAnchorPoint(AnchorPoint::CENTER);
2855 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2856 Radian rotationAngle(Degree(85.0f));
2857 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2858 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2859 parent.SetPosition( parentPosition );
2860 parent.SetOrientation( parentRotation );
2861 parent.SetScale( parentScale );
2862 Stage::GetCurrent().Add( parent );
2864 Actor child = Actor::New();
2865 child.SetParentOrigin(ParentOrigin::CENTER);
2866 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2867 Radian childRotationAngle(Degree(23.0f));
2868 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2869 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2870 child.SetPosition( childPosition );
2871 child.SetOrientation( childRotation );
2872 child.SetScale( childScale );
2873 parent.Add( child );
2875 app.SendNotification();
2878 app.SendNotification();
2880 Matrix parentMatrix(false);
2881 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2883 Matrix childMatrix(false);
2884 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2886 //Child matrix should be the composition of child and parent
2887 Matrix childWorldMatrix(false);
2888 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2890 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2891 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2897 int UtcDaliActorConstrainedToWorldMatrix(void)
2899 TestApplication app;
2900 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2902 Actor parent = Actor::New();
2903 parent.SetParentOrigin(ParentOrigin::CENTER);
2904 parent.SetAnchorPoint(AnchorPoint::CENTER);
2905 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2906 Radian rotationAngle(Degree(85.0f));
2907 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2908 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2909 parent.SetPosition( parentPosition );
2910 parent.SetOrientation( parentRotation );
2911 parent.SetScale( parentScale );
2912 Stage::GetCurrent().Add( parent );
2914 Actor child = Actor::New();
2915 child.SetParentOrigin(ParentOrigin::CENTER);
2916 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2917 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2918 posConstraint.Apply();
2920 Stage::GetCurrent().Add( child );
2922 app.SendNotification();
2925 app.SendNotification();
2927 Matrix parentMatrix(false);
2928 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2930 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2931 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2935 int UtcDaliActorConstrainedToOrientation(void)
2937 TestApplication app;
2938 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2940 Actor parent = Actor::New();
2941 parent.SetParentOrigin(ParentOrigin::CENTER);
2942 parent.SetAnchorPoint(AnchorPoint::CENTER);
2943 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2944 Radian rotationAngle(Degree(85.0f));
2945 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2946 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2947 parent.SetPosition( parentPosition );
2948 parent.SetOrientation( parentRotation );
2949 parent.SetScale( parentScale );
2950 Stage::GetCurrent().Add( parent );
2952 Actor child = Actor::New();
2953 child.SetParentOrigin(ParentOrigin::CENTER);
2954 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2955 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2956 posConstraint.Apply();
2958 Stage::GetCurrent().Add( child );
2960 app.SendNotification();
2963 app.SendNotification();
2965 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2969 int UtcDaliActorConstrainedToOpacity(void)
2971 TestApplication app;
2972 tet_infoline(" UtcDaliActorConstrainedToOpacity");
2974 Actor parent = Actor::New();
2975 parent.SetOpacity( 0.7f );
2976 Stage::GetCurrent().Add( parent );
2978 Actor child = Actor::New();
2979 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2980 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2981 opacityConstraint.Apply();
2983 Stage::GetCurrent().Add( child );
2985 app.SendNotification();
2988 app.SendNotification();
2990 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2992 parent.SetOpacity( 0.3f );
2994 app.SendNotification();
2997 app.SendNotification();
2999 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3004 int UtcDaliActorUnparent(void)
3006 TestApplication app;
3007 tet_infoline(" UtcDaliActorUnparent");
3009 Actor parent = Actor::New();
3010 Stage::GetCurrent().Add( parent );
3012 Actor child = Actor::New();
3014 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3015 DALI_TEST_CHECK( !child.GetParent() );
3017 // Test that calling Unparent with no parent is a NOOP
3020 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3021 DALI_TEST_CHECK( !child.GetParent() );
3023 // Test that Unparent works
3024 parent.Add( child );
3026 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3027 DALI_TEST_CHECK( parent == child.GetParent() );
3031 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3032 DALI_TEST_CHECK( !child.GetParent() );
3034 // Test that UnparentAndReset works
3035 parent.Add( child );
3037 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3038 DALI_TEST_CHECK( parent == child.GetParent() );
3040 UnparentAndReset( child );
3042 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3043 DALI_TEST_CHECK( !child );
3045 // Test that UnparentAndReset is a NOOP with empty handle
3046 UnparentAndReset( child );
3048 DALI_TEST_CHECK( !child );
3052 int UtcDaliActorGetChildAt(void)
3054 TestApplication app;
3055 tet_infoline(" UtcDaliActorGetChildAt");
3057 Actor parent = Actor::New();
3058 Stage::GetCurrent().Add( parent );
3060 Actor child0 = Actor::New();
3061 parent.Add( child0 );
3063 Actor child1 = Actor::New();
3064 parent.Add( child1 );
3066 Actor child2 = Actor::New();
3067 parent.Add( child2 );
3069 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3070 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3071 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3075 int UtcDaliActorSetGetOverlay(void)
3077 TestApplication app;
3078 tet_infoline(" UtcDaliActorSetGetOverlay");
3080 Actor parent = Actor::New();
3081 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3082 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3087 int UtcDaliActorCreateDestroy(void)
3089 Actor* actor = new Actor;
3090 DALI_TEST_CHECK( actor );
3097 struct PropertyStringIndex
3099 const char * const name;
3100 const Property::Index index;
3101 const Property::Type type;
3104 const PropertyStringIndex PROPERTY_TABLE[] =
3106 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3107 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3108 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3109 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3110 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3111 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3112 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3113 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3114 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3115 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3116 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3117 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3118 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3119 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3120 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3121 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3122 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3123 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3124 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3125 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3126 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3127 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3128 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3129 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3130 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3131 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3132 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3133 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3134 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3135 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3136 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3137 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3138 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3139 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3140 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3141 { "name", Actor::Property::NAME, Property::STRING },
3142 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3143 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3144 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3145 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3146 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3147 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3148 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3149 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3150 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3151 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3152 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3153 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3154 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3155 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3156 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3157 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3158 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3159 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3160 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3162 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3163 } // unnamed namespace
3165 int UtcDaliActorProperties(void)
3167 TestApplication app;
3169 Actor actor = Actor::New();
3171 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3173 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3174 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3175 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3176 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3181 int UtcDaliRelayoutProperties_ResizePolicies(void)
3183 TestApplication app;
3185 Actor actor = Actor::New();
3188 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3189 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3191 // Set resize policy for all dimensions
3192 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3193 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3195 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3198 // Set individual dimensions
3199 const char* const widthPolicy = "FILL_TO_PARENT";
3200 const char* const heightPolicy = "FIXED";
3202 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3203 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3205 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3206 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3208 // Set individual dimensions using enums
3209 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3210 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3212 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3213 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3215 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3216 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3221 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3223 TestApplication app;
3225 Actor actor = Actor::New();
3228 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3229 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3231 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3232 actor.SetSizeScalePolicy( policy );
3233 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3236 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3237 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3239 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3240 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3242 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3243 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3248 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3250 TestApplication app;
3252 Actor actor = Actor::New();
3255 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3256 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3258 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3259 actor.SetSizeModeFactor( sizeMode );
3260 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3263 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3265 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3266 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3271 int UtcDaliRelayoutProperties_DimensionDependency(void)
3273 TestApplication app;
3275 Actor actor = Actor::New();
3278 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3279 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3282 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3283 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3285 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3286 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3288 // Test setting another resize policy
3289 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3290 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3295 int UtcDaliRelayoutProperties_Padding(void)
3297 TestApplication app;
3299 Actor actor = Actor::New();
3302 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3305 actor.SetProperty( Actor::Property::PADDING, padding );
3306 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3308 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3313 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3315 TestApplication app;
3317 Actor actor = Actor::New();
3320 Vector2 minSize( 1.0f, 2.0f );
3322 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3323 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3325 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3327 Vector2 maxSize( 3.0f, 4.0f );
3329 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3330 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3332 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3337 int UtcDaliActorGetHeightForWidth(void)
3339 TestApplication app;
3341 Actor actor = Actor::New();
3343 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3348 int UtcDaliActorGetWidthForHeight(void)
3350 TestApplication app;
3352 Actor actor = Actor::New();
3354 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3359 int UtcDaliActorGetRelayoutSize(void)
3361 TestApplication app;
3363 Actor actor = Actor::New();
3365 // Add actor to stage
3366 Stage::GetCurrent().Add( actor );
3368 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3370 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3371 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3373 // Flush the queue and render once
3374 app.SendNotification();
3377 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3382 int UtcDaliActorSetPadding(void)
3384 TestApplication app;
3386 Actor actor = Actor::New();
3389 actor.GetPadding( padding );
3391 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3392 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3393 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3394 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3396 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3397 actor.SetPadding( padding2 );
3399 actor.GetPadding( padding );
3401 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3402 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3403 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3404 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3409 int UtcDaliActorSetMinimumSize(void)
3411 TestApplication app;
3413 Actor actor = Actor::New();
3415 Vector2 size = actor.GetMinimumSize();
3417 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3418 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3420 Vector2 size2( 1.0f, 2.0f );
3421 actor.SetMinimumSize( size2 );
3423 size = actor.GetMinimumSize();
3425 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3426 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3431 int UtcDaliActorSetMaximumSize(void)
3433 TestApplication app;
3435 Actor actor = Actor::New();
3437 Vector2 size = actor.GetMaximumSize();
3439 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3440 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3442 Vector2 size2( 1.0f, 2.0f );
3443 actor.SetMaximumSize( size2 );
3445 size = actor.GetMaximumSize();
3447 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3448 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3453 int UtcDaliActorOnRelayoutSignal(void)
3455 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3457 TestApplication application;
3460 gOnRelayoutCallBackCalled = false;
3461 gActorNamesRelayout.clear();
3463 Actor actor = Actor::New();
3464 actor.SetName( "actor" );
3465 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3468 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3470 // Add actor to stage
3471 Stage::GetCurrent().Add( actor );
3473 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3474 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3476 // Flush the queue and render once
3477 application.SendNotification();
3478 application.Render();
3480 // OnRelayout emitted
3481 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3482 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3487 int UtcDaliActorGetHierachyDepth(void)
3489 TestApplication application;
3490 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3493 /* Build tree of actors:
3503 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3505 Stage stage( Stage::GetCurrent() );
3507 Actor actorA = Actor::New();
3508 Actor actorB = Actor::New();
3509 Actor actorC = Actor::New();
3510 Actor actorD = Actor::New();
3511 Actor actorE = Actor::New();
3512 Actor actorF = Actor::New();
3514 //Test that root actor has depth equal 0
3515 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3517 //Test actors return depth -1 when not connected to the tree
3518 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3519 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3520 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3521 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3522 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3523 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3525 //Create the hierarchy
3526 stage.Add( actorA );
3527 actorA.Add( actorB );
3528 actorA.Add( actorC );
3529 actorB.Add( actorD );
3530 actorB.Add( actorE );
3531 actorC.Add( actorF );
3533 //Test actors return correct depth
3534 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3535 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3536 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3537 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3538 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3539 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3541 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3542 actorA.Remove( actorB );
3544 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3545 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3546 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3548 //Removing actorA from the stage. All actors should have depth equal -1
3549 stage.Remove( actorA );
3551 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3552 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3553 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3554 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3555 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3556 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3561 int UtcDaliActorAnchorPointPropertyAsString(void)
3563 TestApplication application;
3565 Actor actor = Actor::New();
3567 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3568 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3570 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3571 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3573 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3574 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3576 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3577 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3579 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3580 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3582 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3583 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3585 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3586 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3588 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3589 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3591 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3592 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3594 // Invalid should not change anything
3595 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3596 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3601 int UtcDaliActorParentOriginPropertyAsString(void)
3603 TestApplication application;
3605 Actor actor = Actor::New();
3607 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3608 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3610 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3611 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3613 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3614 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3616 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3617 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3619 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3620 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3622 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3623 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3625 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3626 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3628 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3629 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3631 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3632 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3634 // Invalid should not change anything
3635 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3636 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3641 int UtcDaliActorColorModePropertyAsString(void)
3643 TestApplication application;
3645 Actor actor = Actor::New();
3647 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3648 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3650 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3651 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3653 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3654 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3656 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3657 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3659 // Invalid should not change anything
3660 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3661 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3666 int UtcDaliActorPositionInheritancePropertyAsString(void)
3668 TestApplication application;
3670 Actor actor = Actor::New();
3672 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3673 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3675 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3676 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3678 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3679 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3681 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3682 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3684 // Invalid should not change anything
3685 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3686 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3691 int UtcDaliActorDrawModePropertyAsString(void)
3693 TestApplication application;
3695 Actor actor = Actor::New();
3697 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3698 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3700 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3701 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3703 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3704 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3706 // Invalid should not change anything
3707 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3708 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3713 int UtcDaliActorColorModePropertyAsEnum(void)
3715 TestApplication application;
3717 Actor actor = Actor::New();
3719 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3720 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3722 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3723 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3725 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3726 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3728 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3729 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3734 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3736 TestApplication application;
3738 Actor actor = Actor::New();
3740 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3741 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3743 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3744 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3746 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3747 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3749 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3750 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3755 int UtcDaliActorDrawModePropertyAsEnum(void)
3757 TestApplication application;
3759 Actor actor = Actor::New();
3761 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3762 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3764 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3765 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3767 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3768 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3773 int UtcDaliActorAddRendererP(void)
3775 tet_infoline("Testing Actor::AddRenderer");
3776 TestApplication application;
3778 Actor actor = Actor::New();
3780 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3782 Geometry geometry = CreateQuadGeometry();
3783 Shader shader = CreateShader();
3784 Renderer renderer = Renderer::New(geometry, shader);
3786 actor.AddRenderer( renderer );
3787 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3788 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3793 int UtcDaliActorAddRendererN(void)
3795 tet_infoline("Testing Actor::AddRenderer");
3796 TestApplication application;
3798 Actor actor = Actor::New();
3804 actor.AddRenderer( renderer );
3805 tet_printf("Assertion test failed - no Exception\n" );
3806 tet_result(TET_FAIL);
3808 catch(Dali::DaliException& e)
3810 DALI_TEST_PRINT_ASSERT( e );
3811 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3812 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3816 tet_printf("Assertion test failed - wrong Exception\n" );
3817 tet_result(TET_FAIL);
3823 int UtcDaliActorAddRendererOnStage(void)
3825 tet_infoline("Testing Actor::AddRenderer");
3826 TestApplication application;
3828 Actor actor = Actor::New();
3829 Stage::GetCurrent().Add(actor);
3831 application.SendNotification();
3832 application.Render(0);
3834 Geometry geometry = CreateQuadGeometry();
3835 Shader shader = CreateShader();
3836 Renderer renderer = Renderer::New(geometry, shader);
3838 application.SendNotification();
3839 application.Render(0);
3843 actor.AddRenderer( renderer );
3844 tet_result(TET_PASS);
3848 tet_result(TET_FAIL);
3854 int UtcDaliActorRemoveRendererP1(void)
3856 tet_infoline("Testing Actor::RemoveRenderer");
3857 TestApplication application;
3859 Actor actor = Actor::New();
3861 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3864 Geometry geometry = CreateQuadGeometry();
3865 Shader shader = CreateShader();
3866 Renderer renderer = Renderer::New(geometry, shader);
3868 actor.AddRenderer( renderer );
3869 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3870 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3872 application.SendNotification();
3873 application.Render();
3877 Renderer renderer = actor.GetRendererAt(0);
3878 actor.RemoveRenderer(renderer);
3879 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3881 application.SendNotification();
3882 application.Render();
3885 // Call one final time to ensure that the renderer is actually removed after
3886 // the handle goes out of scope, and excercises the deletion code path in
3887 // scene graph and render.
3888 application.SendNotification();
3889 application.Render();
3894 int UtcDaliActorRemoveRendererP2(void)
3896 tet_infoline("Testing Actor::RemoveRenderer");
3897 TestApplication application;
3899 Actor actor = Actor::New();
3901 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3903 Geometry geometry = CreateQuadGeometry();
3904 Shader shader = CreateShader();
3905 Renderer renderer = Renderer::New(geometry, shader);
3907 actor.AddRenderer( renderer );
3908 application.SendNotification();
3909 application.Render();
3911 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3912 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3914 actor.RemoveRenderer(0);
3915 application.SendNotification();
3916 application.Render();
3918 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3920 // Shut down whilst holding onto the renderer handle.
3925 int UtcDaliActorRemoveRendererN(void)
3927 tet_infoline("Testing Actor::RemoveRenderer");
3928 TestApplication application;
3930 Actor actor = Actor::New();
3932 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3934 Geometry geometry = CreateQuadGeometry();
3935 Shader shader = CreateShader();
3936 Renderer renderer = Renderer::New(geometry, shader);
3938 actor.AddRenderer( renderer );
3939 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3940 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3942 actor.RemoveRenderer(10);
3943 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3944 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3949 // Clipping test helper functions:
3950 Actor CreateActorWithContent()
3952 BufferImage image = BufferImage::New( 16u, 16u );
3953 Actor actor = CreateRenderableActor( image );
3955 // Setup dimensions and position so actor is not skipped by culling.
3956 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3957 actor.SetSize( 16.0f, 16.0f );
3958 actor.SetParentOrigin( ParentOrigin::CENTER );
3959 actor.SetAnchorPoint( AnchorPoint::CENTER );
3964 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3966 enabledDisableTrace.Reset();
3967 stencilTrace.Reset();
3968 enabledDisableTrace.Enable( true );
3969 stencilTrace.Enable( true );
3971 application.SendNotification();
3972 application.Render();
3974 enabledDisableTrace.Enable( false );
3975 stencilTrace.Enable( false );
3978 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3980 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3982 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3983 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3984 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3985 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3988 int UtcDaliActorPropertyClippingP(void)
3990 // This test checks the clippingMode property.
3991 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
3992 TestApplication application;
3994 Actor actor = Actor::New();
3996 // Check default clippingEnabled value.
3997 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4000 bool getValueResult = getValue.Get( value );
4001 DALI_TEST_CHECK( getValueResult );
4003 if( getValueResult )
4005 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4008 // Check setting the property to the stencil mode.
4009 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4011 // Check the new value was set.
4012 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4013 getValueResult = getValue.Get( value );
4014 DALI_TEST_CHECK( getValueResult );
4016 if( getValueResult )
4018 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4021 // Check setting the property to the scissor mode.
4022 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4024 // Check the new value was set.
4025 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4026 getValueResult = getValue.Get( value );
4027 DALI_TEST_CHECK( getValueResult );
4029 if( getValueResult )
4031 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4036 int UtcDaliActorPropertyClippingN(void)
4038 // Negative test case for Clipping.
4039 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4040 TestApplication application;
4042 Actor actor = Actor::New();
4044 // Check default clippingEnabled value.
4045 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4048 bool getValueResult = getValue.Get( value );
4049 DALI_TEST_CHECK( getValueResult );
4051 if( getValueResult )
4053 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4056 // Check setting an invalid property value won't change the current property value.
4057 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4059 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4060 getValueResult = getValue.Get( value );
4061 DALI_TEST_CHECK( getValueResult );
4063 if( getValueResult )
4065 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4071 int UtcDaliActorPropertyClippingActor(void)
4073 // This test checks that an actor is correctly setup for clipping.
4074 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4075 TestApplication application;
4077 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4078 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4079 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4080 size_t startIndex = 0u;
4082 // Create a clipping actor.
4083 Actor actorDepth1Clip = CreateActorWithContent();
4084 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4085 Stage::GetCurrent().Add( actorDepth1Clip );
4087 // Gather the call trace.
4088 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4090 // Check we are writing to the color buffer.
4091 CheckColorMask( glAbstraction, true );
4093 // Check the stencil buffer was enabled.
4094 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4096 // Check the stencil buffer was cleared.
4097 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4099 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4100 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4101 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4102 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4107 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4109 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4110 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4111 TestApplication application;
4113 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4114 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4115 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4116 size_t startIndex = 0u;
4118 // Create a clipping actor.
4119 Actor actorDepth1Clip = CreateActorWithContent();
4120 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4121 Stage::GetCurrent().Add( actorDepth1Clip );
4123 // Gather the call trace.
4124 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4126 // Check we are writing to the color buffer.
4127 CheckColorMask( glAbstraction, true );
4129 // Check the stencil buffer was enabled.
4130 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4132 // Check the stencil buffer was cleared.
4133 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4135 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4136 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4137 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4138 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4140 // Now disable the clipping
4141 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4143 // Gather the call trace.
4144 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4146 // Check the stencil buffer was disabled.
4147 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4149 // Ensure all values in stencil-mask are set to 1.
4151 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4156 int UtcDaliActorPropertyClippingNestedChildren(void)
4158 // This test checks that a hierarchy of actors are clipped correctly by
4159 // writing to and reading from the correct bit-planes of the stencil buffer.
4160 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4161 TestApplication application;
4162 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4163 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4164 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4166 // Create a clipping actor.
4167 Actor actorDepth1Clip = CreateActorWithContent();
4168 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4169 Stage::GetCurrent().Add( actorDepth1Clip );
4171 // Create a child actor.
4172 Actor childDepth2 = CreateActorWithContent();
4173 actorDepth1Clip.Add( childDepth2 );
4175 // Create another clipping actor.
4176 Actor childDepth2Clip = CreateActorWithContent();
4177 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4178 childDepth2.Add( childDepth2Clip );
4180 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4181 // This tests the sort algorithm.
4182 Actor childDepth3 = CreateActorWithContent();
4183 childDepth2Clip.Add( childDepth3 );
4184 Actor childDepth4 = CreateActorWithContent();
4185 childDepth3.Add( childDepth4 );
4187 // Gather the call trace.
4188 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4190 // Check we are writing to the color buffer.
4191 CheckColorMask( glAbstraction, true );
4193 // Check the stencil buffer was enabled.
4194 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4196 // Perform the test twice, once for 2D layer, and once for 3D.
4197 for( unsigned int i = 0u ; i < 2u; ++i )
4199 size_t startIndex = 0u;
4201 // Check the stencil buffer was cleared.
4202 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4204 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4205 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4206 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4207 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4209 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4210 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4211 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4213 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4214 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4215 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4216 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4218 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4219 // (Both must be set to pass the check).
4220 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4221 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4223 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4226 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4227 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4234 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4236 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4237 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4238 TestApplication application;
4239 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4240 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4242 /* We create a small tree of actors as follows:
4246 Clipping enabled -> B D
4250 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4253 for( int i = 0; i < 5; ++i )
4255 BufferImage image = BufferImage::New( 16u, 16u );
4256 Actor actor = CreateRenderableActor( image );
4258 // Setup dimensions and position so actor is not skipped by culling.
4259 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4260 actor.SetSize( 16.0f, 16.0f );
4264 actor.SetParentOrigin( ParentOrigin::CENTER );
4268 float b = i > 2 ? 1.0f : -1.0f;
4269 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4275 // Enable clipping on the actor at the top of the left branch.
4276 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4278 // Build the scene graph.
4279 Stage::GetCurrent().Add( actors[0] );
4282 actors[0].Add( actors[1] );
4283 actors[1].Add( actors[2] );
4286 actors[0].Add( actors[3] );
4287 actors[3].Add( actors[4] );
4289 // Gather the call trace.
4290 enabledDisableTrace.Reset();
4291 enabledDisableTrace.Enable( true );
4292 application.SendNotification();
4293 application.Render();
4294 enabledDisableTrace.Enable( false );
4296 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4298 Note: Correct enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
4299 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4301 size_t startIndex = 0u;
4302 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4303 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4304 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4306 // Swap the clipping actor from top of left branch to top of right branch.
4307 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4308 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4310 // Gather the call trace.
4311 enabledDisableTrace.Reset();
4312 enabledDisableTrace.Enable( true );
4313 application.SendNotification();
4314 application.Render();
4315 enabledDisableTrace.Enable( false );
4317 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4318 // This proves the draw order has remained the same.
4320 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4321 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4326 int UtcDaliActorPropertyScissorClippingActor(void)
4328 // This test checks that an actor is correctly setup for clipping.
4329 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4330 TestApplication application;
4332 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4333 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4334 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4336 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4337 const Vector2 imageSize( 16.0f, 16.0f );
4339 // Create a clipping actor.
4340 Actor clippingActorA = CreateActorWithContent();
4341 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4342 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4343 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4344 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4345 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4346 Stage::GetCurrent().Add( clippingActorA );
4348 // Gather the call trace.
4349 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4351 // Check we are writing to the color buffer.
4352 CheckColorMask( glAbstraction, true );
4354 // Check scissor test was enabled.
4355 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4357 // Check the scissor was set, and the coordinates are correct.
4358 std::stringstream compareParametersString;
4359 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4360 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4362 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4363 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4365 // Gather the call trace.
4366 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4368 // Check the scissor was set, and the coordinates are correct.
4369 compareParametersString.str( std::string() );
4370 compareParametersString.clear();
4371 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4372 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4377 int UtcDaliActorPropertyScissorClippingActorNested(void)
4379 // This test checks that an actor is correctly setup for clipping.
4380 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4381 TestApplication application;
4383 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4384 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4385 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4387 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4388 const Vector2 imageSize( 16.0f, 16.0f );
4390 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4392 A is drawn first - with scissor clipping on
4393 B is drawn second - also with scissor clipping on
4394 C is the generated clipping region, the intersection ( A ∩ B )
4398 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4399 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4400 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4404 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4407 // Create a clipping actor.
4408 Actor clippingActorA = CreateActorWithContent();
4409 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4410 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4411 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4412 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4413 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4414 Stage::GetCurrent().Add( clippingActorA );
4416 // Create a child clipping actor.
4417 Actor clippingActorB = CreateActorWithContent();
4418 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4419 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4420 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4421 clippingActorA.Add( clippingActorB );
4423 // positionModifiers is an array of positions to position B around.
4424 // expect is an array of expected scissor clip coordinate results.
4425 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4426 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4428 // Loop through each overlap combination.
4429 for( unsigned int test = 0u; test < 4u; ++test )
4431 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4432 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4433 clippingActorB.SetPosition( position.x, position.y );
4435 // Gather the call trace.
4436 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4438 // Check we are writing to the color buffer.
4439 CheckColorMask( glAbstraction, true );
4441 // Check scissor test was enabled.
4442 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4444 // Check the scissor was set, and the coordinates are correct.
4445 const Vector4& expectResults( expect[test] );
4446 std::stringstream compareParametersString;
4447 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4448 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4454 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4456 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4457 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4458 TestApplication application;
4460 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4461 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4462 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4464 // Create a clipping actor.
4465 Actor actorDepth1Clip = CreateActorWithContent();
4466 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4467 Stage::GetCurrent().Add( actorDepth1Clip );
4469 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4470 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4472 // Gather the call trace.
4473 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4475 // Check we are writing to the color buffer.
4476 CheckColorMask( glAbstraction, true );
4478 // Check the stencil buffer was not enabled.
4479 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4481 // Check stencil functions are not called.
4482 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4483 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4484 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4486 // Check that scissor clipping is overriden by the renderer properties.
4487 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4489 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4491 // Gather the call trace.
4492 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4494 // Check the stencil buffer was not enabled.
4495 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4497 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4502 int UtcDaliGetPropertyN(void)
4504 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4505 TestApplication app;
4507 Actor actor = Actor::New();
4509 unsigned int propertyCount = actor.GetPropertyCount();
4510 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4514 int UtcDaliActorRaiseLower(void)
4516 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4518 TestApplication application;
4520 Stage stage( Stage::GetCurrent() );
4522 Actor actorA = Actor::New();
4523 Actor actorB = Actor::New();
4524 Actor actorC = Actor::New();
4526 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4527 actorA.SetParentOrigin( ParentOrigin::CENTER );
4529 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4530 actorB.SetParentOrigin( ParentOrigin::CENTER );
4532 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4533 actorC.SetParentOrigin( ParentOrigin::CENTER );
4535 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4536 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4538 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4539 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4541 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4542 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4544 stage.Add( actorA );
4545 stage.Add( actorB );
4546 stage.Add( actorC );
4548 ResetTouchCallbacks();
4550 application.SendNotification();
4551 application.Render();
4553 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4554 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4555 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4557 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4558 // Only top actor will get touched.
4559 actorA.TouchSignal().Connect( TestTouchCallback );
4560 actorB.TouchSignal().Connect( TestTouchCallback2 );
4561 actorC.TouchSignal().Connect( TestTouchCallback3 );
4563 Dali::Integration::Point point;
4564 point.SetDeviceId( 1 );
4565 point.SetState( PointState::DOWN );
4566 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4567 Dali::Integration::TouchEvent touchEvent;
4568 touchEvent.AddPoint( point );
4570 application.ProcessEvent( touchEvent );
4572 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4573 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4574 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4576 ResetTouchCallbacks();
4578 tet_printf( "Testing Raising of Actor\n" );
4580 int preActorOrder( 0 );
4581 int postActorOrder( 0 );
4583 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4584 value.Get( preActorOrder );
4587 // Ensure sort order is calculated before next touch event
4588 application.SendNotification();
4590 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4591 value.Get( postActorOrder );
4593 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4595 application.ProcessEvent( touchEvent );
4597 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4598 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4599 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4601 ResetTouchCallbacks();
4603 tet_printf( "Testing Lowering of Actor\n" );
4605 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4606 value.Get( preActorOrder );
4609 application.SendNotification(); // ensure sort order calculated before next touch event
4611 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4612 value.Get( postActorOrder );
4614 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4616 application.ProcessEvent( touchEvent );
4618 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4619 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4620 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4622 ResetTouchCallbacks();
4627 int UtcDaliActorRaiseToTopLowerToBottom(void)
4629 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4631 TestApplication application;
4633 Stage stage( Stage::GetCurrent() );
4635 Actor actorA = Actor::New();
4636 Actor actorB = Actor::New();
4637 Actor actorC = Actor::New();
4639 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4640 // enables checking of which actor the uniform is assigned too
4641 Shader shaderA = CreateShader();
4642 shaderA.RegisterProperty( "uRendererColor",1.f);
4644 Shader shaderB = CreateShader();
4645 shaderB.RegisterProperty( "uRendererColor", 2.f );
4647 Shader shaderC = CreateShader();
4648 shaderC.RegisterProperty( "uRendererColor", 3.f );
4650 Geometry geometry = CreateQuadGeometry();
4652 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4653 Renderer rendererA = Renderer::New(geometry, shaderA);
4654 actorA.AddRenderer(rendererA);
4656 Renderer rendererB = Renderer::New(geometry, shaderB);
4657 actorB.AddRenderer(rendererB);
4659 Renderer rendererC = Renderer::New(geometry, shaderC);
4660 actorC.AddRenderer(rendererC);
4662 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4663 actorA.SetParentOrigin( ParentOrigin::CENTER );
4665 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4666 actorB.SetParentOrigin( ParentOrigin::CENTER );
4668 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4669 actorC.SetParentOrigin( ParentOrigin::CENTER );
4671 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4672 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4674 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4675 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4677 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4678 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4680 stage.Add( actorA );
4681 stage.Add( actorB );
4682 stage.Add( actorC );
4684 ResetTouchCallbacks();
4686 // Set up gl abstraction trace so can query the set uniform order
4687 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4688 glAbstraction.EnableSetUniformCallTrace(true);
4689 glAbstraction.ResetSetUniformCallStack();
4691 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4693 application.SendNotification();
4694 application.Render();
4696 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4699 // Test order of uniforms in stack
4700 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4701 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4702 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4704 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4706 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4708 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4709 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4710 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4712 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4713 // Only top actor will get touched.
4714 actorA.TouchSignal().Connect( TestTouchCallback );
4715 actorB.TouchSignal().Connect( TestTouchCallback2 );
4716 actorC.TouchSignal().Connect( TestTouchCallback3 );
4718 Dali::Integration::Point point;
4719 point.SetDeviceId( 1 );
4720 point.SetState( PointState::DOWN );
4721 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4722 Dali::Integration::TouchEvent touchEvent;
4723 touchEvent.AddPoint( point );
4725 application.ProcessEvent( touchEvent );
4727 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4728 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4729 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4731 ResetTouchCallbacks();
4733 tet_printf( "RaiseToTop ActorA\n" );
4735 actorA.RaiseToTop();
4736 application.SendNotification(); // ensure sorting order is calculated before next touch event
4738 application.ProcessEvent( touchEvent );
4740 glAbstraction.ResetSetUniformCallStack();
4741 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4743 application.SendNotification();
4744 application.Render();
4746 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4748 // Test order of uniforms in stack
4749 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4750 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4751 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4753 tet_infoline( "Testing A above C and B at bottom\n" );
4754 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4756 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4758 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4759 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4760 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4762 ResetTouchCallbacks();
4764 tet_printf( "RaiseToTop ActorB\n" );
4766 actorB.RaiseToTop();
4767 application.SendNotification(); // Ensure sort order is calculated before next touch event
4769 application.ProcessEvent( touchEvent );
4771 glAbstraction.ResetSetUniformCallStack();
4772 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4774 application.SendNotification();
4775 application.Render();
4777 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4779 // Test order of uniforms in stack
4780 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4781 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4782 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4784 tet_infoline( "Testing B above A and C at bottom\n" );
4785 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4787 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4789 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4790 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4791 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4793 ResetTouchCallbacks();
4795 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4797 actorA.LowerToBottom();
4798 application.SendNotification();
4799 application.Render();
4801 actorB.LowerToBottom();
4802 application.SendNotification();
4803 application.Render();
4805 application.ProcessEvent( touchEvent );
4807 glAbstraction.ResetSetUniformCallStack();
4808 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4810 application.SendNotification();
4811 application.Render();
4813 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4815 // Test order of uniforms in stack
4816 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4817 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4818 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4820 tet_infoline( "Testing C above A and B at bottom\n" );
4821 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4823 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4825 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4826 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4827 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4829 ResetTouchCallbacks();
4834 int UtcDaliActorRaiseAbove(void)
4836 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4838 TestApplication application;
4840 Stage stage( Stage::GetCurrent() );
4842 Actor actorA = Actor::New();
4843 Actor actorB = Actor::New();
4844 Actor actorC = Actor::New();
4846 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4847 actorA.SetParentOrigin( ParentOrigin::CENTER );
4849 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4850 actorB.SetParentOrigin( ParentOrigin::CENTER );
4852 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4853 actorC.SetParentOrigin( ParentOrigin::CENTER );
4855 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4856 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4858 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4859 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4861 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4862 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4864 stage.Add( actorA );
4865 stage.Add( actorB );
4866 stage.Add( actorC );
4868 ResetTouchCallbacks();
4870 application.SendNotification();
4871 application.Render();
4873 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4874 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4875 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4877 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4878 // Only top actor will get touched.
4879 actorA.TouchSignal().Connect( TestTouchCallback );
4880 actorB.TouchSignal().Connect( TestTouchCallback2 );
4881 actorC.TouchSignal().Connect( TestTouchCallback3 );
4883 Dali::Integration::Point point;
4884 point.SetDeviceId( 1 );
4885 point.SetState( PointState::DOWN );
4886 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4887 Dali::Integration::TouchEvent touchEvent;
4888 touchEvent.AddPoint( point );
4890 application.ProcessEvent( touchEvent );
4892 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4893 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4894 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4896 ResetTouchCallbacks();
4898 tet_printf( "Raise actor B Above Actor C\n" );
4900 actorB.RaiseAbove( actorC );
4901 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4902 application.SendNotification();
4904 application.ProcessEvent( touchEvent );
4906 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4907 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4908 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4910 ResetTouchCallbacks();
4912 tet_printf( "Raise actor A Above Actor B\n" );
4914 actorA.RaiseAbove( actorB );
4916 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4917 application.SendNotification();
4919 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
4921 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4922 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4923 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4925 ResetTouchCallbacks();
4930 int UtcDaliActorLowerBelow(void)
4932 tet_infoline( "UtcDaliActor LowerBelow test \n" );
4934 TestApplication application;
4936 Stage stage( Stage::GetCurrent() );
4938 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4939 // enables checking of which actor the uniform is assigned too
4940 Shader shaderA = CreateShader();
4941 shaderA.RegisterProperty( "uRendererColor",1.f);
4943 Shader shaderB = CreateShader();
4944 shaderB.RegisterProperty( "uRendererColor", 2.f );
4946 Shader shaderC = CreateShader();
4947 shaderC.RegisterProperty( "uRendererColor", 3.f );
4949 Actor actorA = Actor::New();
4950 Actor actorB = Actor::New();
4951 Actor actorC = Actor::New();
4953 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4954 Geometry geometry = CreateQuadGeometry();
4956 Renderer rendererA = Renderer::New(geometry, shaderA);
4957 actorA.AddRenderer(rendererA);
4959 Renderer rendererB = Renderer::New(geometry, shaderB);
4960 actorB.AddRenderer(rendererB);
4962 Renderer rendererC = Renderer::New(geometry, shaderC);
4963 actorC.AddRenderer(rendererC);
4965 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4966 actorA.SetParentOrigin( ParentOrigin::CENTER );
4968 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4969 actorB.SetParentOrigin( ParentOrigin::CENTER );
4971 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4972 actorC.SetParentOrigin( ParentOrigin::CENTER );
4974 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4975 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4977 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4978 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4980 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4981 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4983 Actor container = Actor::New();
4984 container.SetParentOrigin( ParentOrigin::CENTER );
4985 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
4986 stage.Add( container );
4988 container.Add( actorA );
4989 container.Add( actorB );
4990 container.Add( actorC );
4992 ResetTouchCallbacks();
4994 // Set up gl abstraction trace so can query the set uniform order
4995 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4996 glAbstraction.EnableSetUniformCallTrace(true);
4997 glAbstraction.ResetSetUniformCallStack();
4998 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5000 glAbstraction.ResetSetUniformCallStack();
5002 application.SendNotification();
5003 application.Render();
5005 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5007 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5009 // Test order of uniforms in stack
5010 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5011 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5012 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5014 tet_infoline( "Testing C above B and A at bottom\n" );
5015 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5017 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5019 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5020 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5021 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5023 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5024 // Only top actor will get touched.
5025 actorA.TouchSignal().Connect( TestTouchCallback );
5026 actorB.TouchSignal().Connect( TestTouchCallback2 );
5027 actorC.TouchSignal().Connect( TestTouchCallback3 );
5029 Dali::Integration::Point point;
5030 point.SetDeviceId( 1 );
5031 point.SetState( PointState::DOWN );
5032 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5033 Dali::Integration::TouchEvent touchEvent;
5034 touchEvent.AddPoint( point );
5036 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5038 application.ProcessEvent( touchEvent );
5040 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5041 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5042 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5044 ResetTouchCallbacks();
5046 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" );
5048 actorC.LowerBelow( actorB );
5049 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5050 application.SendNotification();
5051 application.Render();
5053 application.ProcessEvent( touchEvent ); // touch event
5055 glAbstraction.ResetSetUniformCallStack();
5056 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5058 application.SendNotification();
5059 application.Render();
5061 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5063 // Test order of uniforms in stack
5064 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5065 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5066 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5068 tet_infoline( "Testing render order is A, C, B" );
5069 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5070 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5072 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5073 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5074 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5076 ResetTouchCallbacks();
5078 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5080 actorC.LowerBelow( actorA );
5081 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5082 application.SendNotification();
5083 application.Render();
5085 application.ProcessEvent( touchEvent );
5087 glAbstraction.ResetSetUniformCallStack();
5088 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5090 application.Render();
5091 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5093 // Test order of uniforms in stack
5094 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5095 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5096 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5098 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5099 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5101 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5102 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5103 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5105 ResetTouchCallbacks();
5107 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5109 actorB.LowerBelow( actorC );
5110 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5111 application.SendNotification();
5112 application.Render();
5114 application.ProcessEvent( touchEvent );
5116 glAbstraction.ResetSetUniformCallStack();
5117 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5119 application.Render();
5120 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5122 // Test order of uniforms in stack
5123 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5124 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5125 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5127 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5128 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5134 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5136 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5138 TestApplication application;
5140 Stage stage( Stage::GetCurrent() );
5142 Actor parentA = Actor::New();
5143 Actor parentB = Actor::New();
5144 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5145 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5146 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5147 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5149 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5150 parentA.SetParentOrigin( ParentOrigin::CENTER );
5152 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5153 parentB.SetParentOrigin( ParentOrigin::CENTER );
5155 stage.Add( parentA );
5156 stage.Add( parentB );
5158 Actor actorA = Actor::New();
5159 Actor actorB = Actor::New();
5160 Actor actorC = Actor::New();
5162 parentA.Add( actorA );
5163 parentA.Add( actorB );
5165 tet_printf( "Actor C added to different parent from A and B \n" );
5166 parentB.Add( actorC );
5168 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5169 actorA.SetParentOrigin( ParentOrigin::CENTER );
5171 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5172 actorB.SetParentOrigin( ParentOrigin::CENTER );
5174 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5175 actorC.SetParentOrigin( ParentOrigin::CENTER );
5177 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5178 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5180 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5181 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5183 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5184 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5186 ResetTouchCallbacks();
5188 application.SendNotification();
5189 application.Render();
5191 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5192 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5193 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5195 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5196 // Only top actor will get touched.
5197 actorA.TouchSignal().Connect( TestTouchCallback );
5198 actorB.TouchSignal().Connect( TestTouchCallback2 );
5199 actorC.TouchSignal().Connect( TestTouchCallback3 );
5201 Dali::Integration::Point point;
5202 point.SetDeviceId( 1 );
5203 point.SetState( PointState::DOWN );
5204 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5205 Dali::Integration::TouchEvent touchEvent;
5206 touchEvent.AddPoint( point );
5208 application.ProcessEvent( touchEvent );
5210 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5211 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5212 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5214 ResetTouchCallbacks();
5216 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5218 actorA.RaiseAbove( actorC );
5219 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5220 application.SendNotification();
5222 application.ProcessEvent( touchEvent ); // touch event
5224 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5225 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5226 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5228 ResetTouchCallbacks();
5233 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5235 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5237 TestApplication application;
5239 Stage stage( Stage::GetCurrent() );
5241 Actor actorA = Actor::New();
5242 Actor actorB = Actor::New();
5243 Actor actorC = Actor::New();
5245 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5246 actorA.SetParentOrigin( ParentOrigin::CENTER );
5248 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5249 actorB.SetParentOrigin( ParentOrigin::CENTER );
5251 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5252 actorC.SetParentOrigin( ParentOrigin::CENTER );
5254 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5255 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5257 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5258 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5260 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5261 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5263 ResetTouchCallbacks();
5265 application.SendNotification();
5266 application.Render();
5268 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5269 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5270 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5272 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5273 // Only top actor will get touched.
5274 actorA.TouchSignal().Connect( TestTouchCallback );
5275 actorB.TouchSignal().Connect( TestTouchCallback2 );
5276 actorC.TouchSignal().Connect( TestTouchCallback3 );
5278 Dali::Integration::Point point;
5279 point.SetDeviceId( 1 );
5280 point.SetState( PointState::DOWN );
5281 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5282 Dali::Integration::TouchEvent touchEvent;
5283 touchEvent.AddPoint( point );
5285 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5287 actorA.RaiseAbove( actorC );
5288 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5289 application.SendNotification();
5291 application.ProcessEvent( touchEvent );
5293 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5295 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5296 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5297 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5299 ResetTouchCallbacks();
5301 stage.Add ( actorB );
5302 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5303 actorA.LowerBelow( actorC );
5305 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5306 application.SendNotification();
5307 application.Render();
5309 application.ProcessEvent( touchEvent );
5311 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5312 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5313 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5314 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5316 ResetTouchCallbacks();
5318 tet_printf( "Adding Actor A to stage, will be on top\n" );
5320 stage.Add ( actorA );
5321 application.SendNotification();
5322 application.Render();
5324 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5325 actorB.RaiseAbove( actorC );
5326 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5327 application.SendNotification();
5329 application.ProcessEvent( touchEvent );
5331 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5332 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5333 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5334 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5336 ResetTouchCallbacks();
5338 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5339 actorA.LowerBelow( actorC );
5340 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5341 application.SendNotification();
5343 application.ProcessEvent( touchEvent );
5345 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5346 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5347 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5348 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5350 ResetTouchCallbacks();
5352 stage.Add ( actorC );
5353 actorA.RaiseAbove( actorC );
5354 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5355 application.SendNotification();
5356 application.Render();
5358 application.ProcessEvent( touchEvent );
5360 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5361 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5362 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5363 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5368 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5370 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5372 TestApplication application;
5374 Stage stage( Stage::GetCurrent() );
5376 Actor actorA = Actor::New();
5377 Actor actorB = Actor::New();
5378 Actor actorC = Actor::New();
5380 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5381 actorA.SetParentOrigin( ParentOrigin::CENTER );
5383 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5384 actorB.SetParentOrigin( ParentOrigin::CENTER );
5386 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5387 actorC.SetParentOrigin( ParentOrigin::CENTER );
5389 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5390 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5392 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5393 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5395 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5396 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5398 ResetTouchCallbacks();
5400 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5401 // Only top actor will get touched.
5402 actorA.TouchSignal().Connect( TestTouchCallback );
5403 actorB.TouchSignal().Connect( TestTouchCallback2 );
5404 actorC.TouchSignal().Connect( TestTouchCallback3 );
5406 Dali::Integration::Point point;
5407 point.SetDeviceId( 1 );
5408 point.SetState( PointState::DOWN );
5409 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5410 Dali::Integration::TouchEvent touchEvent;
5411 touchEvent.AddPoint( point );
5413 stage.Add ( actorA );
5414 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5417 application.SendNotification();
5418 application.Render();
5420 application.ProcessEvent( touchEvent );
5422 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5424 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5425 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5426 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5428 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5429 ResetTouchCallbacks();
5432 // Sort actor tree before next touch event
5433 application.SendNotification();
5434 application.Render();
5436 application.ProcessEvent( touchEvent );
5438 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5440 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5441 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5442 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5443 ResetTouchCallbacks();
5445 tet_printf( "Lower actor C below B but C not parented\n" );
5448 // Sort actor tree before next touch event
5449 application.SendNotification();
5450 application.Render();
5452 application.ProcessEvent( touchEvent );
5454 tet_printf( "Not parented so Lower should show no effect\n" );
5456 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5457 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5458 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5459 ResetTouchCallbacks();
5461 tet_printf( "Raise actor B to top\n" );
5463 actorB.RaiseToTop();
5464 // Sort actor tree before next touch event
5465 application.SendNotification();
5466 application.Render();
5468 application.ProcessEvent( touchEvent );
5470 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5472 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5473 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5474 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5475 ResetTouchCallbacks();
5477 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5479 stage.Add ( actorB );
5481 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5483 actorC.LowerToBottom();
5484 application.SendNotification();
5485 application.Render();
5487 application.ProcessEvent( touchEvent );
5489 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5491 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5492 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5493 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5494 ResetTouchCallbacks();
5500 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5502 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5504 TestApplication application;
5506 Stage stage( Stage::GetCurrent() );
5508 Actor actorA = Actor::New();
5509 Actor actorB = Actor::New();
5510 Actor actorC = Actor::New();
5512 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5513 actorA.SetParentOrigin( ParentOrigin::CENTER );
5515 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5516 actorB.SetParentOrigin( ParentOrigin::CENTER );
5518 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5519 actorC.SetParentOrigin( ParentOrigin::CENTER );
5521 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5522 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5524 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5525 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5527 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5528 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5530 stage.Add( actorA );
5531 stage.Add( actorB );
5532 stage.Add( actorC );
5534 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5535 // Only top actor will get touched.
5536 actorA.TouchSignal().Connect( TestTouchCallback );
5537 actorB.TouchSignal().Connect( TestTouchCallback2 );
5538 actorC.TouchSignal().Connect( TestTouchCallback3 );
5540 ResetTouchCallbacks();
5542 application.SendNotification();
5543 application.Render();
5545 Dali::Integration::Point point;
5546 point.SetDeviceId( 1 );
5547 point.SetState( PointState::DOWN );
5548 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5549 Dali::Integration::TouchEvent touchEvent;
5550 touchEvent.AddPoint( point );
5552 application.ProcessEvent( touchEvent );
5554 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5555 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5556 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5558 ResetTouchCallbacks();
5560 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5562 actorA.RaiseAbove( actorA );
5563 application.SendNotification();
5564 application.Render();
5566 application.ProcessEvent( touchEvent );
5568 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5570 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5571 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5572 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5574 ResetTouchCallbacks();
5576 actorA.RaiseAbove( actorC );
5577 application.SendNotification();
5578 application.Render();
5580 application.ProcessEvent( touchEvent );
5582 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5583 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5584 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5585 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5590 int UtcDaliActorGetScreenPosition(void)
5592 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5594 TestApplication application;
5596 Stage stage( Stage::GetCurrent() );
5598 Actor actorA = Actor::New();
5599 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5601 Vector2 size2( 10.0f, 20.0f );
5602 actorA.SetSize( size2 );
5604 actorA.SetPosition( 0.f, 0.f );
5606 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5608 stage.Add( actorA );
5610 application.SendNotification();
5611 application.Render();
5613 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5614 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5616 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5617 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5619 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5620 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5622 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5624 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5626 application.SendNotification();
5627 application.Render();
5629 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5630 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5632 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5633 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5635 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5636 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5638 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5640 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5642 application.SendNotification();
5643 application.Render();
5645 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5646 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5648 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5649 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5651 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5652 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5654 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5656 actorA.SetPosition( 30.0, 0.0 );
5658 application.SendNotification();
5659 application.Render();
5661 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5662 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5664 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5665 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5667 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5668 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5670 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5672 actorA.SetPosition( 30.0, 420.0 );
5674 application.SendNotification();
5675 application.Render();
5677 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5678 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5680 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5681 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5683 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5684 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5686 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
5688 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5689 actorA.SetPosition( 30.0, 30.0 );
5691 Actor actorB = Actor::New();
5692 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5693 actorB.SetSize( size2 );
5694 actorB.SetPosition( 10.f, 10.f );
5695 actorA.Add( actorB );
5697 actorA.SetScale( 2.0f );
5699 application.SendNotification();
5700 application.Render();
5702 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5704 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
5705 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
5710 int UtcDaliActorGetScreenPositionAfterScaling(void)
5712 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5714 TestApplication application;
5716 Stage stage( Stage::GetCurrent() );
5718 Actor actorA = Actor::New();
5719 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5721 Vector2 size2( 10.0f, 20.0f );
5722 actorA.SetSize( size2 );
5723 actorA.SetScale( 1.5f );
5724 actorA.SetPosition( 0.f, 0.f );
5726 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5728 stage.Add( actorA );
5730 application.SendNotification();
5731 application.Render();
5733 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5734 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5736 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5737 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5739 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5740 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5742 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5744 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5746 application.SendNotification();
5747 application.Render();
5749 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5750 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5752 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5753 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5755 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5756 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5761 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5763 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5765 TestApplication application;
5767 Stage stage( Stage::GetCurrent() );
5769 Actor actorA = Actor::New();
5770 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5771 actorA.SetParentOrigin( ParentOrigin::CENTER );
5772 Vector2 size2( 10.0f, 20.0f );
5773 actorA.SetSize( size2 );
5774 actorA.SetPosition( 0.f, 0.f );
5776 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5778 stage.Add( actorA );
5780 application.SendNotification();
5781 application.Render();
5783 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5784 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5786 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5787 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5789 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
5790 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
5792 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5794 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5795 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5797 application.SendNotification();
5798 application.Render();
5800 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5801 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5803 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5804 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5806 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5807 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5813 int UtcDaliActorGetScreenPositionWithChildActors(void)
5815 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5817 TestApplication application;
5819 Stage stage( Stage::GetCurrent() );
5821 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5823 Actor actorA = Actor::New();
5824 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5825 actorA.SetParentOrigin( ParentOrigin::CENTER );
5826 Vector2 size1( 10.0f, 20.0f );
5827 actorA.SetSize( size1 );
5828 actorA.SetPosition( 0.f, 0.f );
5830 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5832 Actor parentActorA = Actor::New();
5833 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5834 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5835 Vector2 size2( 30.0f, 60.0f );
5836 parentActorA.SetSize( size2 );
5837 parentActorA.SetPosition( 0.f, 0.f );
5839 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5841 stage.Add( parentActorA );
5842 parentActorA.Add ( actorA );
5844 application.SendNotification();
5845 application.Render();
5847 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5848 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5850 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5851 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5853 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
5854 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
5856 tet_infoline( "Test 2\n");
5858 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5860 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5861 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5863 application.SendNotification();
5864 application.Render();
5866 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5867 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5869 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5870 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5872 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
5873 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
5878 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5880 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5882 TestApplication application;
5884 Stage stage( Stage::GetCurrent() );
5886 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5888 Actor actorA = Actor::New();
5889 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5890 actorA.SetParentOrigin( ParentOrigin::CENTER );
5891 Vector2 size1( 10.0f, 20.0f );
5892 actorA.SetSize( size1 );
5893 actorA.SetPosition( 0.f, 0.f );
5895 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5897 Actor parentActorA = Actor::New();
5898 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5899 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5900 Vector2 size2( 30.0f, 60.0f );
5901 parentActorA.SetSize( size2 );
5902 parentActorA.SetPosition( 0.f, 0.f );
5904 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5906 Actor grandParentActorA = Actor::New();
5907 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5908 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5909 Vector2 size3( 60.0f, 120.0f );
5910 grandParentActorA.SetSize( size3 );
5911 grandParentActorA.SetPosition( 0.f, 0.f );
5913 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5915 stage.Add( grandParentActorA );
5916 grandParentActorA.Add ( parentActorA );
5918 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5920 parentActorA.Add ( actorA );
5922 application.SendNotification();
5923 application.Render();
5925 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5926 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5928 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5929 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5931 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
5932 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
5937 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5939 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
5941 TestApplication application;
5943 Stage stage( Stage::GetCurrent() );
5945 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5947 Actor actorA = Actor::New();
5948 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5949 actorA.SetParentOrigin( ParentOrigin::CENTER );
5950 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5951 actorA.SetSize( 10.0f, 20.0f );
5952 stage.Add( actorA );
5954 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5956 Actor actorB = Actor::New();
5957 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5958 actorB.SetParentOrigin( ParentOrigin::CENTER );
5959 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5960 Vector2 actorBSize( 30.0f, 60.0f );
5961 actorB.SetSize( actorBSize );
5962 stage.Add( actorB );
5964 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5966 Actor actorC = Actor::New();
5967 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5968 actorC.SetParentOrigin( ParentOrigin::CENTER );
5969 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5970 Vector2 actorCSize( 60.0f, 120.0f );
5971 actorC.SetSize( actorCSize );
5972 stage.Add( actorC );
5974 application.SendNotification();
5975 application.Render();
5977 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
5979 Vector2 center( stage.GetSize() * 0.5f );
5981 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5982 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5983 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5985 tet_infoline( "Add scale to all actors" );
5987 actorA.SetScale( 2.0f );
5988 actorB.SetScale( 2.0f );
5989 actorC.SetScale( 2.0f );
5991 application.SendNotification();
5992 application.Render();
5994 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
5995 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
5996 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6001 int utcDaliActorPositionUsesAnchorPoint(void)
6003 TestApplication application;
6004 tet_infoline( "Check default behaviour\n" );
6006 Actor actor = Actor::New();
6007 actor.SetParentOrigin( ParentOrigin::CENTER );
6008 actor.SetAnchorPoint( AnchorPoint::CENTER );
6009 actor.SetSize( 100.0f, 100.0f );
6010 Stage::GetCurrent().Add( actor );
6012 application.SendNotification();
6013 application.Render();
6015 tet_infoline( "Check that the world position is in the center\n" );
6016 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6018 tet_infoline( "Set the position uses anchor point property to false\n" );
6019 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6021 application.SendNotification();
6022 application.Render();
6024 tet_infoline( "Check that the world position has changed appropriately\n" );
6025 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6030 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6032 TestApplication application;
6033 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6035 Actor actor = Actor::New();
6036 actor.SetParentOrigin( ParentOrigin::CENTER );
6037 actor.SetAnchorPoint( AnchorPoint::CENTER );
6038 actor.SetSize( 100.0f, 100.0f );
6039 actor.SetScale( 2.0f );
6040 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6041 Stage::GetCurrent().Add( actor );
6043 application.SendNotification();
6044 application.Render();
6046 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6047 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6049 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6050 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6051 application.SendNotification();
6052 application.Render();
6053 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6055 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6056 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6057 application.SendNotification();
6058 application.Render();
6059 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6064 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6066 TestApplication application;
6067 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6069 Actor actor = Actor::New();
6070 actor.SetParentOrigin( ParentOrigin::CENTER );
6071 actor.SetAnchorPoint( AnchorPoint::CENTER );
6072 actor.SetSize( 100.0f, 100.0f );
6073 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6074 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6075 Stage::GetCurrent().Add( actor );
6077 application.SendNotification();
6078 application.Render();
6080 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6081 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6083 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6084 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6085 application.SendNotification();
6086 application.Render();
6087 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6089 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6090 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6091 application.SendNotification();
6092 application.Render();
6093 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6098 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6100 TestApplication application;
6101 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6103 Actor actor = Actor::New();
6104 actor.SetParentOrigin( ParentOrigin::CENTER );
6105 actor.SetAnchorPoint( AnchorPoint::CENTER );
6106 actor.SetSize( 100.0f, 100.0f );
6107 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6108 actor.SetScale( 2.0f );
6109 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6110 Stage::GetCurrent().Add( actor );
6112 application.SendNotification();
6113 application.Render();
6115 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6116 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6118 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6119 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6120 application.SendNotification();
6121 application.Render();
6122 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6124 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6125 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6126 application.SendNotification();
6127 application.Render();
6128 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6133 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6135 TestApplication application;
6136 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6138 Actor parent = Actor::New();
6140 Stage::GetCurrent().Add( parent );
6141 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6143 Actor actor = Actor::New();
6144 actor.SetParentOrigin( ParentOrigin::CENTER );
6145 actor.SetAnchorPoint( AnchorPoint::CENTER );
6146 actor.SetSize( 100.0f, 100.0f );
6147 actor.SetInheritScale( false );
6148 actor.SetInheritOrientation( false );
6149 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6150 parent.Add( actor );
6152 application.SendNotification();
6153 application.Render();
6155 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6157 tet_infoline( "Check the world position is in the right place\n" );
6158 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6160 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6161 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6162 application.SendNotification();
6163 application.Render();
6164 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6166 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6167 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6168 application.SendNotification();
6169 application.Render();
6170 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6175 int utcDaliActorVisibilityChangeSignalSelf(void)
6177 TestApplication application;
6178 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6180 Actor actor = Actor::New();
6182 VisibilityChangedFunctorData data;
6183 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6185 actor.SetVisible( false );
6187 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6189 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6192 actor.SetVisible( false );
6193 data.Check( false /* not called */, TEST_LOCATION );
6195 tet_infoline( "Change the visibility using properties, ensure called" );
6198 actor.SetProperty( Actor::Property::VISIBLE, true );
6199 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6201 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6204 actor.SetProperty( Actor::Property::VISIBLE, true );
6205 data.Check( false /* not called */, TEST_LOCATION );
6210 int utcDaliActorVisibilityChangeSignalChildren(void)
6212 TestApplication application;
6213 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6215 Actor parent = Actor::New();
6216 Actor child = Actor::New();
6217 parent.Add( child );
6219 Actor grandChild = Actor::New();
6220 child.Add( grandChild );
6222 VisibilityChangedFunctorData parentData;
6223 VisibilityChangedFunctorData childData;
6224 VisibilityChangedFunctorData grandChildData;
6226 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6227 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6228 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6230 parent.SetVisible( false );
6231 parentData.Check( false /* not called */, TEST_LOCATION );
6232 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6233 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6235 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6238 grandChildData.Reset();
6240 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6242 parent.SetVisible( true );
6243 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6244 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6245 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6247 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6250 grandChildData.Reset();
6252 parent.SetVisible( true );
6253 parentData.Check( false /* not called */, TEST_LOCATION );
6254 childData.Check( false /* not called */, TEST_LOCATION );
6255 grandChildData.Check( false /* not called */, TEST_LOCATION );
6260 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6262 TestApplication application;
6263 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6265 Actor actor = Actor::New();
6266 Stage::GetCurrent().Add( actor );
6268 application.SendNotification();
6269 application.Render();
6271 VisibilityChangedFunctorData data;
6272 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6274 Animation animation = Animation::New( 1.0f );
6275 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6277 data.Check( false, TEST_LOCATION );
6278 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6279 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6281 tet_infoline( "Play the animation and check the property value" );
6284 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6285 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6287 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6288 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6290 application.SendNotification();
6291 application.Render( 1100 ); // After the animation
6293 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6299 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6301 gLayoutDirectionType = type;
6304 int UtcDaliActorLayoutDirectionProperty(void)
6306 TestApplication application;
6307 tet_infoline( "Check layout direction property" );
6309 Actor actor0 = Actor::New();
6310 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6311 Stage::GetCurrent().Add( actor0 );
6313 application.SendNotification();
6314 application.Render();
6316 Actor actor1 = Actor::New();
6317 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6318 Actor actor2 = Actor::New();
6319 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6320 Actor actor3 = Actor::New();
6321 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6322 Actor actor4 = Actor::New();
6323 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6324 Actor actor5 = Actor::New();
6325 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6326 Actor actor6 = Actor::New();
6327 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6328 Actor actor7 = Actor::New();
6329 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6330 Actor actor8 = Actor::New();
6331 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6332 Actor actor9 = Actor::New();
6333 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6335 actor1.Add( actor2 );
6336 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6337 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6339 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6340 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6341 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6343 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6344 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6345 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6347 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6348 actor0.Add( actor1 );
6349 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6350 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6352 Stage::GetCurrent().Add( actor3 );
6353 actor3.Add( actor4 );
6354 actor4.Add( actor5 );
6355 actor5.Add( actor6 );
6356 actor5.Add( actor7 );
6357 actor7.Add( actor8 );
6358 actor8.Add( actor9 );
6359 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6360 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6362 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6363 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6364 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6366 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6368 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6369 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6370 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6371 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6372 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6373 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6374 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6376 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6377 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6378 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6380 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6381 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6382 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6383 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6385 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6386 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6387 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );