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 DevelActor::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::CLIPPING_MODE 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.
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 );
4024 int UtcDaliActorPropertyClippingN(void)
4026 // Negative test case for Clipping.
4027 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
4028 TestApplication application;
4030 Actor actor = Actor::New();
4032 // Check default clippingEnabled value.
4033 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4036 bool getValueResult = getValue.Get( value );
4037 DALI_TEST_CHECK( getValueResult );
4039 if( getValueResult )
4041 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4044 // Check setting an invalid property value won't change the current property value.
4045 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4047 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4048 getValueResult = getValue.Get( value );
4049 DALI_TEST_CHECK( getValueResult );
4051 if( getValueResult )
4053 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4059 int UtcDaliActorPropertyClippingActor(void)
4061 // This test checks that an actor is correctly setup for clipping.
4062 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
4063 TestApplication application;
4065 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4066 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4067 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4068 size_t startIndex = 0u;
4070 // Create a clipping actor.
4071 Actor actorDepth1Clip = CreateActorWithContent();
4072 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4073 Stage::GetCurrent().Add( actorDepth1Clip );
4075 // Gather the call trace.
4076 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4078 // Check we are writing to the color buffer.
4079 CheckColorMask( glAbstraction, true );
4081 // Check the stencil buffer was enabled.
4082 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4084 // Check the stencil buffer was cleared.
4085 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4087 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4088 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4089 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4090 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4095 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4097 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4098 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
4099 TestApplication application;
4101 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4102 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4103 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4104 size_t startIndex = 0u;
4106 // Create a clipping actor.
4107 Actor actorDepth1Clip = CreateActorWithContent();
4108 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4109 Stage::GetCurrent().Add( actorDepth1Clip );
4111 // Gather the call trace.
4112 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4114 // Check we are writing to the color buffer.
4115 CheckColorMask( glAbstraction, true );
4117 // Check the stencil buffer was enabled.
4118 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4120 // Check the stencil buffer was cleared.
4121 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4123 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4124 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4125 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4126 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4128 // Now disable the clipping
4129 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4131 // Gather the call trace.
4132 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4134 // Check the stencil buffer was disabled.
4135 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4137 // Ensure all values in stencil-mask are set to 1.
4139 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4145 int UtcDaliActorPropertyClippingNestedChildren(void)
4147 // This test checks that a hierarchy of actors are clipped correctly by
4148 // writing to and reading from the correct bit-planes of the stencil buffer.
4149 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
4150 TestApplication application;
4151 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4152 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4153 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4155 // Create a clipping actor.
4156 Actor actorDepth1Clip = CreateActorWithContent();
4157 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4158 Stage::GetCurrent().Add( actorDepth1Clip );
4160 // Create a child actor.
4161 Actor childDepth2 = CreateActorWithContent();
4162 actorDepth1Clip.Add( childDepth2 );
4164 // Create another clipping actor.
4165 Actor childDepth2Clip = CreateActorWithContent();
4166 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4167 childDepth2.Add( childDepth2Clip );
4169 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4170 // This tests the sort algorithm.
4171 Actor childDepth3 = CreateActorWithContent();
4172 childDepth2Clip.Add( childDepth3 );
4173 Actor childDepth4 = CreateActorWithContent();
4174 childDepth3.Add( childDepth4 );
4176 // Gather the call trace.
4177 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4179 // Check we are writing to the color buffer.
4180 CheckColorMask( glAbstraction, true );
4182 // Check the stencil buffer was enabled.
4183 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4185 // Perform the test twice, once for 2D layer, and once for 3D.
4186 for( unsigned int i = 0u ; i < 2u; ++i )
4188 size_t startIndex = 0u;
4190 // Check the stencil buffer was cleared.
4191 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4193 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4194 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4195 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4196 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4198 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4199 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4200 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4202 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4203 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4204 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4205 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4207 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4208 // (Both must be set to pass the check).
4209 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4210 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4212 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4215 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4216 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4223 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4225 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4226 tet_infoline( "Testing Actor::Property::CLIPPING_MODE draw order" );
4227 TestApplication application;
4228 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4229 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4231 /* We create a small tree of actors as follows:
4235 Clipping enabled -> B D
4239 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4242 for( int i = 0; i < 5; ++i )
4244 BufferImage image = BufferImage::New( 16u, 16u );
4245 Actor actor = CreateRenderableActor( image );
4247 // Setup dimensions and position so actor is not skipped by culling.
4248 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4249 actor.SetSize( 16.0f, 16.0f );
4253 actor.SetParentOrigin( ParentOrigin::CENTER );
4257 float b = i > 2 ? 1.0f : -1.0f;
4258 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4264 // Enable clipping on the actor at the top of the left branch.
4265 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4267 // Build the scene graph.
4268 Stage::GetCurrent().Add( actors[0] );
4271 actors[0].Add( actors[1] );
4272 actors[1].Add( actors[2] );
4275 actors[0].Add( actors[3] );
4276 actors[3].Add( actors[4] );
4278 // Gather the call trace.
4279 enabledDisableTrace.Reset();
4280 enabledDisableTrace.Enable( true );
4281 application.SendNotification();
4282 application.Render();
4283 enabledDisableTrace.Enable( false );
4285 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4287 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
4288 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4290 size_t startIndex = 0u;
4291 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4292 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4293 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4295 // Swap the clipping actor from top of left branch to top of right branch.
4296 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4297 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4299 // Gather the call trace.
4300 enabledDisableTrace.Reset();
4301 enabledDisableTrace.Enable( true );
4302 application.SendNotification();
4303 application.Render();
4304 enabledDisableTrace.Enable( false );
4306 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4307 // This proves the draw order has remained the same.
4309 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4310 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4315 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4317 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4318 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4319 TestApplication application;
4321 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4322 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4323 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4325 // Create a clipping actor.
4326 Actor actorDepth1Clip = CreateActorWithContent();
4327 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4328 Stage::GetCurrent().Add( actorDepth1Clip );
4330 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4331 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4333 // Gather the call trace.
4334 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4336 // Check we are writing to the color buffer.
4337 CheckColorMask( glAbstraction, true );
4339 // Check the stencil buffer was not enabled.
4340 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4342 // Check stencil functions are not called.
4343 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4344 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4345 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4350 int UtcDaliGetPropertyN(void)
4352 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4353 TestApplication app;
4355 Actor actor = Actor::New();
4357 unsigned int propertyCount = actor.GetPropertyCount();
4358 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4362 int UtcDaliActorRaiseLower(void)
4364 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4366 TestApplication application;
4368 Stage stage( Stage::GetCurrent() );
4370 Actor actorA = Actor::New();
4371 Actor actorB = Actor::New();
4372 Actor actorC = Actor::New();
4374 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4375 actorA.SetParentOrigin( ParentOrigin::CENTER );
4377 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4378 actorB.SetParentOrigin( ParentOrigin::CENTER );
4380 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4381 actorC.SetParentOrigin( ParentOrigin::CENTER );
4383 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4384 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4386 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4387 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4389 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4390 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4392 stage.Add( actorA );
4393 stage.Add( actorB );
4394 stage.Add( actorC );
4396 ResetTouchCallbacks();
4398 application.SendNotification();
4399 application.Render();
4401 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4402 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4403 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4405 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4406 // Only top actor will get touched.
4407 actorA.TouchSignal().Connect( TestTouchCallback );
4408 actorB.TouchSignal().Connect( TestTouchCallback2 );
4409 actorC.TouchSignal().Connect( TestTouchCallback3 );
4411 Dali::Integration::Point point;
4412 point.SetDeviceId( 1 );
4413 point.SetState( PointState::DOWN );
4414 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4415 Dali::Integration::TouchEvent touchEvent;
4416 touchEvent.AddPoint( point );
4418 application.ProcessEvent( touchEvent );
4420 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4421 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4422 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4424 ResetTouchCallbacks();
4426 tet_printf( "Testing Raising of Actor\n" );
4428 int preActorOrder( 0 );
4429 int postActorOrder( 0 );
4431 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4432 value.Get( preActorOrder );
4434 DevelActor::Raise( actorB );
4435 // Ensure sort order is calculated before next touch event
4436 application.SendNotification();
4438 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4439 value.Get( postActorOrder );
4441 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4443 application.ProcessEvent( touchEvent );
4445 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4446 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4447 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4449 ResetTouchCallbacks();
4451 tet_printf( "Testing Lowering of Actor\n" );
4453 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4454 value.Get( preActorOrder );
4456 DevelActor::Lower( actorB );
4457 application.SendNotification(); // ensure sort order calculated before next touch event
4459 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4460 value.Get( postActorOrder );
4462 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4464 application.ProcessEvent( touchEvent );
4466 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4467 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4468 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4470 ResetTouchCallbacks();
4475 int UtcDaliActorRaiseToTopLowerToBottom(void)
4477 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4479 TestApplication application;
4481 Stage stage( Stage::GetCurrent() );
4483 Actor actorA = Actor::New();
4484 Actor actorB = Actor::New();
4485 Actor actorC = Actor::New();
4487 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4488 // enables checking of which actor the uniform is assigned too
4489 Shader shaderA = CreateShader();
4490 shaderA.RegisterProperty( "uRendererColor",1.f);
4492 Shader shaderB = CreateShader();
4493 shaderB.RegisterProperty( "uRendererColor", 2.f );
4495 Shader shaderC = CreateShader();
4496 shaderC.RegisterProperty( "uRendererColor", 3.f );
4498 Geometry geometry = CreateQuadGeometry();
4500 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4501 Renderer rendererA = Renderer::New(geometry, shaderA);
4502 actorA.AddRenderer(rendererA);
4504 Renderer rendererB = Renderer::New(geometry, shaderB);
4505 actorB.AddRenderer(rendererB);
4507 Renderer rendererC = Renderer::New(geometry, shaderC);
4508 actorC.AddRenderer(rendererC);
4510 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4511 actorA.SetParentOrigin( ParentOrigin::CENTER );
4513 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4514 actorB.SetParentOrigin( ParentOrigin::CENTER );
4516 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4517 actorC.SetParentOrigin( ParentOrigin::CENTER );
4519 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4520 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4522 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4523 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4525 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4526 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4528 stage.Add( actorA );
4529 stage.Add( actorB );
4530 stage.Add( actorC );
4532 ResetTouchCallbacks();
4534 // Set up gl abstraction trace so can query the set uniform order
4535 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4536 glAbstraction.EnableSetUniformCallTrace(true);
4537 glAbstraction.ResetSetUniformCallStack();
4539 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4541 application.SendNotification();
4542 application.Render();
4544 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4547 // Test order of uniforms in stack
4548 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4549 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4550 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4552 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4554 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4556 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4557 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4558 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4560 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4561 // Only top actor will get touched.
4562 actorA.TouchSignal().Connect( TestTouchCallback );
4563 actorB.TouchSignal().Connect( TestTouchCallback2 );
4564 actorC.TouchSignal().Connect( TestTouchCallback3 );
4566 Dali::Integration::Point point;
4567 point.SetDeviceId( 1 );
4568 point.SetState( PointState::DOWN );
4569 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4570 Dali::Integration::TouchEvent touchEvent;
4571 touchEvent.AddPoint( point );
4573 application.ProcessEvent( touchEvent );
4575 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4576 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4577 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4579 ResetTouchCallbacks();
4581 tet_printf( "RaiseToTop ActorA\n" );
4583 DevelActor::RaiseToTop( actorA );
4584 application.SendNotification(); // ensure sorting order is calculated before next touch event
4586 application.ProcessEvent( touchEvent );
4588 glAbstraction.ResetSetUniformCallStack();
4589 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4591 application.SendNotification();
4592 application.Render();
4594 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4596 // Test order of uniforms in stack
4597 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4598 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4599 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4601 tet_infoline( "Testing A above C and B at bottom\n" );
4602 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4604 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4606 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4607 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4608 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4610 ResetTouchCallbacks();
4612 tet_printf( "RaiseToTop ActorB\n" );
4614 DevelActor::RaiseToTop( actorB );
4615 application.SendNotification(); // Ensure sort order is calculated before next touch event
4617 application.ProcessEvent( touchEvent );
4619 glAbstraction.ResetSetUniformCallStack();
4620 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4622 application.SendNotification();
4623 application.Render();
4625 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4627 // Test order of uniforms in stack
4628 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4629 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4630 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4632 tet_infoline( "Testing B above A and C at bottom\n" );
4633 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4635 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4637 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4638 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4639 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4641 ResetTouchCallbacks();
4643 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4645 DevelActor::LowerToBottom( actorA );
4646 application.SendNotification();
4647 application.Render();
4649 DevelActor::LowerToBottom( actorB );
4650 application.SendNotification();
4651 application.Render();
4653 application.ProcessEvent( touchEvent );
4655 glAbstraction.ResetSetUniformCallStack();
4656 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4658 application.SendNotification();
4659 application.Render();
4661 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4663 // Test order of uniforms in stack
4664 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4665 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4666 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4668 tet_infoline( "Testing C above A and B at bottom\n" );
4669 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4671 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4673 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4674 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4675 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4677 ResetTouchCallbacks();
4682 int UtcDaliActorRaiseAbove(void)
4684 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4686 TestApplication application;
4688 Stage stage( Stage::GetCurrent() );
4690 Actor actorA = Actor::New();
4691 Actor actorB = Actor::New();
4692 Actor actorC = Actor::New();
4694 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4695 actorA.SetParentOrigin( ParentOrigin::CENTER );
4697 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4698 actorB.SetParentOrigin( ParentOrigin::CENTER );
4700 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4701 actorC.SetParentOrigin( ParentOrigin::CENTER );
4703 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4704 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4706 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4707 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4709 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4710 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4712 stage.Add( actorA );
4713 stage.Add( actorB );
4714 stage.Add( actorC );
4716 ResetTouchCallbacks();
4718 application.SendNotification();
4719 application.Render();
4721 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4722 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4723 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4725 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4726 // Only top actor will get touched.
4727 actorA.TouchSignal().Connect( TestTouchCallback );
4728 actorB.TouchSignal().Connect( TestTouchCallback2 );
4729 actorC.TouchSignal().Connect( TestTouchCallback3 );
4731 Dali::Integration::Point point;
4732 point.SetDeviceId( 1 );
4733 point.SetState( PointState::DOWN );
4734 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4735 Dali::Integration::TouchEvent touchEvent;
4736 touchEvent.AddPoint( point );
4738 application.ProcessEvent( touchEvent );
4740 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4741 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4742 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4744 ResetTouchCallbacks();
4746 tet_printf( "Raise actor B Above Actor C\n" );
4748 DevelActor::RaiseAbove( actorB, actorC );
4749 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4750 application.SendNotification();
4752 application.ProcessEvent( touchEvent );
4754 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4755 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4756 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4758 ResetTouchCallbacks();
4760 tet_printf( "Raise actor A Above Actor B\n" );
4762 DevelActor::RaiseAbove( actorA, actorB );
4764 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4765 application.SendNotification();
4767 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
4769 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4770 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4771 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4773 ResetTouchCallbacks();
4778 int UtcDaliActorLowerBelow(void)
4780 tet_infoline( "UtcDaliActor LowerBelow test \n" );
4782 TestApplication application;
4784 Stage stage( Stage::GetCurrent() );
4786 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4787 // enables checking of which actor the uniform is assigned too
4788 Shader shaderA = CreateShader();
4789 shaderA.RegisterProperty( "uRendererColor",1.f);
4791 Shader shaderB = CreateShader();
4792 shaderB.RegisterProperty( "uRendererColor", 2.f );
4794 Shader shaderC = CreateShader();
4795 shaderC.RegisterProperty( "uRendererColor", 3.f );
4797 Actor actorA = Actor::New();
4798 Actor actorB = Actor::New();
4799 Actor actorC = Actor::New();
4801 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4802 Geometry geometry = CreateQuadGeometry();
4804 Renderer rendererA = Renderer::New(geometry, shaderA);
4805 actorA.AddRenderer(rendererA);
4807 Renderer rendererB = Renderer::New(geometry, shaderB);
4808 actorB.AddRenderer(rendererB);
4810 Renderer rendererC = Renderer::New(geometry, shaderC);
4811 actorC.AddRenderer(rendererC);
4813 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4814 actorA.SetParentOrigin( ParentOrigin::CENTER );
4816 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4817 actorB.SetParentOrigin( ParentOrigin::CENTER );
4819 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4820 actorC.SetParentOrigin( ParentOrigin::CENTER );
4822 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4823 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4825 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4826 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4828 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4829 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4831 Actor container = Actor::New();
4832 container.SetParentOrigin( ParentOrigin::CENTER );
4833 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
4834 stage.Add( container );
4836 container.Add( actorA );
4837 container.Add( actorB );
4838 container.Add( actorC );
4840 ResetTouchCallbacks();
4842 // Set up gl abstraction trace so can query the set uniform order
4843 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4844 glAbstraction.EnableSetUniformCallTrace(true);
4845 glAbstraction.ResetSetUniformCallStack();
4846 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4848 glAbstraction.ResetSetUniformCallStack();
4850 application.SendNotification();
4851 application.Render();
4853 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4855 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4857 // Test order of uniforms in stack
4858 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4859 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4860 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4862 tet_infoline( "Testing C above B and A at bottom\n" );
4863 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4865 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4867 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4868 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4869 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4871 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4872 // Only top actor will get touched.
4873 actorA.TouchSignal().Connect( TestTouchCallback );
4874 actorB.TouchSignal().Connect( TestTouchCallback2 );
4875 actorC.TouchSignal().Connect( TestTouchCallback3 );
4877 Dali::Integration::Point point;
4878 point.SetDeviceId( 1 );
4879 point.SetState( PointState::DOWN );
4880 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4881 Dali::Integration::TouchEvent touchEvent;
4882 touchEvent.AddPoint( point );
4884 tet_infoline( "UtcDaliActor Test Set up completed \n" );
4886 application.ProcessEvent( touchEvent );
4888 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4889 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4890 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4892 ResetTouchCallbacks();
4894 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" );
4896 DevelActor::LowerBelow( actorC, actorB );
4897 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4898 application.SendNotification();
4899 application.Render();
4901 application.ProcessEvent( touchEvent ); // touch event
4903 glAbstraction.ResetSetUniformCallStack();
4904 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4906 application.SendNotification();
4907 application.Render();
4909 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4911 // Test order of uniforms in stack
4912 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4913 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4914 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4916 tet_infoline( "Testing render order is A, C, B" );
4917 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
4918 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
4920 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4921 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4922 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4924 ResetTouchCallbacks();
4926 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
4928 DevelActor::LowerBelow( actorC, actorA );
4929 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4930 application.SendNotification();
4931 application.Render();
4933 application.ProcessEvent( touchEvent );
4935 glAbstraction.ResetSetUniformCallStack();
4936 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4938 application.Render();
4939 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4941 // Test order of uniforms in stack
4942 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4943 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4944 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4946 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
4947 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
4949 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4950 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4951 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4953 ResetTouchCallbacks();
4955 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4957 DevelActor::LowerBelow( actorB, actorC );
4958 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4959 application.SendNotification();
4960 application.Render();
4962 application.ProcessEvent( touchEvent );
4964 glAbstraction.ResetSetUniformCallStack();
4965 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4967 application.Render();
4968 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4970 // Test order of uniforms in stack
4971 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4972 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4973 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4975 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
4976 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
4982 int UtcDaliActorRaiseAboveDifferentParentsN(void)
4984 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4986 TestApplication application;
4988 Stage stage( Stage::GetCurrent() );
4990 Actor parentA = Actor::New();
4991 Actor parentB = Actor::New();
4992 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4993 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4994 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4995 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4997 parentA.SetAnchorPoint( AnchorPoint::CENTER );
4998 parentA.SetParentOrigin( ParentOrigin::CENTER );
5000 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5001 parentB.SetParentOrigin( ParentOrigin::CENTER );
5003 stage.Add( parentA );
5004 stage.Add( parentB );
5006 Actor actorA = Actor::New();
5007 Actor actorB = Actor::New();
5008 Actor actorC = Actor::New();
5010 parentA.Add( actorA );
5011 parentA.Add( actorB );
5013 tet_printf( "Actor C added to different parent from A and B \n" );
5014 parentB.Add( actorC );
5016 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5017 actorA.SetParentOrigin( ParentOrigin::CENTER );
5019 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5020 actorB.SetParentOrigin( ParentOrigin::CENTER );
5022 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5023 actorC.SetParentOrigin( ParentOrigin::CENTER );
5025 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5026 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5028 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5029 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5031 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5032 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5034 ResetTouchCallbacks();
5036 application.SendNotification();
5037 application.Render();
5039 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5040 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5041 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5043 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5044 // Only top actor will get touched.
5045 actorA.TouchSignal().Connect( TestTouchCallback );
5046 actorB.TouchSignal().Connect( TestTouchCallback2 );
5047 actorC.TouchSignal().Connect( TestTouchCallback3 );
5049 Dali::Integration::Point point;
5050 point.SetDeviceId( 1 );
5051 point.SetState( PointState::DOWN );
5052 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5053 Dali::Integration::TouchEvent touchEvent;
5054 touchEvent.AddPoint( point );
5056 application.ProcessEvent( touchEvent );
5058 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5059 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5060 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5062 ResetTouchCallbacks();
5064 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5066 DevelActor::RaiseAbove( actorA, actorC );
5067 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5068 application.SendNotification();
5070 application.ProcessEvent( touchEvent ); // touch event
5072 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5073 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5074 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5076 ResetTouchCallbacks();
5081 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5083 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5085 TestApplication application;
5087 Stage stage( Stage::GetCurrent() );
5089 Actor actorA = Actor::New();
5090 Actor actorB = Actor::New();
5091 Actor actorC = Actor::New();
5093 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5094 actorA.SetParentOrigin( ParentOrigin::CENTER );
5096 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5097 actorB.SetParentOrigin( ParentOrigin::CENTER );
5099 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5100 actorC.SetParentOrigin( ParentOrigin::CENTER );
5102 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5103 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5105 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5106 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5108 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5109 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5111 ResetTouchCallbacks();
5113 application.SendNotification();
5114 application.Render();
5116 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5117 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5118 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5120 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5121 // Only top actor will get touched.
5122 actorA.TouchSignal().Connect( TestTouchCallback );
5123 actorB.TouchSignal().Connect( TestTouchCallback2 );
5124 actorC.TouchSignal().Connect( TestTouchCallback3 );
5126 Dali::Integration::Point point;
5127 point.SetDeviceId( 1 );
5128 point.SetState( PointState::DOWN );
5129 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5130 Dali::Integration::TouchEvent touchEvent;
5131 touchEvent.AddPoint( point );
5133 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5135 DevelActor::RaiseAbove( actorA, actorC );
5136 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5137 application.SendNotification();
5139 application.ProcessEvent( touchEvent );
5141 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5143 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5144 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5145 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5147 ResetTouchCallbacks();
5149 stage.Add ( actorB );
5150 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5151 DevelActor::LowerBelow( actorA, actorC );
5153 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5154 application.SendNotification();
5155 application.Render();
5157 application.ProcessEvent( touchEvent );
5159 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5160 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5161 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5162 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5164 ResetTouchCallbacks();
5166 tet_printf( "Adding Actor A to stage, will be on top\n" );
5168 stage.Add ( actorA );
5169 application.SendNotification();
5170 application.Render();
5172 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5173 DevelActor::RaiseAbove( actorB, actorC );
5174 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5175 application.SendNotification();
5177 application.ProcessEvent( touchEvent );
5179 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5180 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5181 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5182 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5184 ResetTouchCallbacks();
5186 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5187 DevelActor::LowerBelow( actorA, actorC );
5188 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5189 application.SendNotification();
5191 application.ProcessEvent( touchEvent );
5193 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5194 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5195 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5196 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5198 ResetTouchCallbacks();
5200 stage.Add ( actorC );
5201 DevelActor::RaiseAbove( actorA, actorC );
5202 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5203 application.SendNotification();
5204 application.Render();
5206 application.ProcessEvent( touchEvent );
5208 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5209 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5210 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5211 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5216 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5218 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5220 TestApplication application;
5222 Stage stage( Stage::GetCurrent() );
5224 Actor actorA = Actor::New();
5225 Actor actorB = Actor::New();
5226 Actor actorC = Actor::New();
5228 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5229 actorA.SetParentOrigin( ParentOrigin::CENTER );
5231 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5232 actorB.SetParentOrigin( ParentOrigin::CENTER );
5234 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5235 actorC.SetParentOrigin( ParentOrigin::CENTER );
5237 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5238 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5240 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5241 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5243 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5244 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5246 ResetTouchCallbacks();
5248 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5249 // Only top actor will get touched.
5250 actorA.TouchSignal().Connect( TestTouchCallback );
5251 actorB.TouchSignal().Connect( TestTouchCallback2 );
5252 actorC.TouchSignal().Connect( TestTouchCallback3 );
5254 Dali::Integration::Point point;
5255 point.SetDeviceId( 1 );
5256 point.SetState( PointState::DOWN );
5257 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5258 Dali::Integration::TouchEvent touchEvent;
5259 touchEvent.AddPoint( point );
5261 stage.Add ( actorA );
5262 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5263 DevelActor::Raise( actorB );
5265 application.SendNotification();
5266 application.Render();
5268 application.ProcessEvent( touchEvent );
5270 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5272 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5273 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5274 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5276 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5277 ResetTouchCallbacks();
5279 DevelActor::Lower( actorC );
5280 // Sort actor tree before next touch event
5281 application.SendNotification();
5282 application.Render();
5284 application.ProcessEvent( touchEvent );
5286 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5288 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5289 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5290 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5291 ResetTouchCallbacks();
5293 tet_printf( "Lower actor C below B but C not parented\n" );
5295 DevelActor::Lower( actorB );
5296 // Sort actor tree before next touch event
5297 application.SendNotification();
5298 application.Render();
5300 application.ProcessEvent( touchEvent );
5302 tet_printf( "Not parented so Lower should show no effect\n" );
5304 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5305 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5306 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5307 ResetTouchCallbacks();
5309 tet_printf( "Raise actor B to top\n" );
5311 DevelActor::RaiseToTop( actorB );
5312 // Sort actor tree before next touch event
5313 application.SendNotification();
5314 application.Render();
5316 application.ProcessEvent( touchEvent );
5318 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5320 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5321 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5322 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5323 ResetTouchCallbacks();
5325 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5327 stage.Add ( actorB );
5329 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5331 DevelActor::LowerToBottom( actorC );
5332 application.SendNotification();
5333 application.Render();
5335 application.ProcessEvent( touchEvent );
5337 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5339 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5340 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5341 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5342 ResetTouchCallbacks();
5348 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5350 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5352 TestApplication application;
5354 Stage stage( Stage::GetCurrent() );
5356 Actor actorA = Actor::New();
5357 Actor actorB = Actor::New();
5358 Actor actorC = Actor::New();
5360 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5361 actorA.SetParentOrigin( ParentOrigin::CENTER );
5363 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5364 actorB.SetParentOrigin( ParentOrigin::CENTER );
5366 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5367 actorC.SetParentOrigin( ParentOrigin::CENTER );
5369 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5370 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5372 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5373 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5375 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5376 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5378 stage.Add( actorA );
5379 stage.Add( actorB );
5380 stage.Add( actorC );
5382 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5383 // Only top actor will get touched.
5384 actorA.TouchSignal().Connect( TestTouchCallback );
5385 actorB.TouchSignal().Connect( TestTouchCallback2 );
5386 actorC.TouchSignal().Connect( TestTouchCallback3 );
5388 ResetTouchCallbacks();
5390 application.SendNotification();
5391 application.Render();
5393 Dali::Integration::Point point;
5394 point.SetDeviceId( 1 );
5395 point.SetState( PointState::DOWN );
5396 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5397 Dali::Integration::TouchEvent touchEvent;
5398 touchEvent.AddPoint( point );
5400 application.ProcessEvent( touchEvent );
5402 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5403 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5404 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5406 ResetTouchCallbacks();
5408 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5410 DevelActor::RaiseAbove( actorA, actorA );
5411 application.SendNotification();
5412 application.Render();
5414 application.ProcessEvent( touchEvent );
5416 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5418 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5419 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5420 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5422 ResetTouchCallbacks();
5424 DevelActor::RaiseAbove( actorA, actorC );
5425 application.SendNotification();
5426 application.Render();
5428 application.ProcessEvent( touchEvent );
5430 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5431 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5432 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5433 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5438 int UtcDaliActorGetScreenPosition(void)
5440 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5442 TestApplication application;
5444 Stage stage( Stage::GetCurrent() );
5446 Actor actorA = Actor::New();
5447 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5449 Vector2 size2( 10.0f, 20.0f );
5450 actorA.SetSize( size2 );
5452 actorA.SetPosition( 0.f, 0.f );
5454 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5456 stage.Add( actorA );
5458 application.SendNotification();
5459 application.Render();
5461 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5462 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5464 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5465 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5467 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5468 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5470 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5472 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5474 application.SendNotification();
5475 application.Render();
5477 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5478 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5480 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5481 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5483 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5484 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5486 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5488 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5490 application.SendNotification();
5491 application.Render();
5493 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5494 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5496 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5497 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5499 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5500 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5502 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5504 actorA.SetPosition( 30.0, 0.0 );
5506 application.SendNotification();
5507 application.Render();
5509 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5510 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5512 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5513 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5515 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5516 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5518 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5520 actorA.SetPosition( 30.0, 420.0 );
5522 application.SendNotification();
5523 application.Render();
5525 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5526 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5528 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5529 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5531 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5532 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5538 int UtcDaliActorGetScreenPositionAfterScaling(void)
5540 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5542 TestApplication application;
5544 Stage stage( Stage::GetCurrent() );
5546 Actor actorA = Actor::New();
5547 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5549 Vector2 size2( 10.0f, 20.0f );
5550 actorA.SetSize( size2 );
5551 actorA.SetScale( 1.5f );
5552 actorA.SetPosition( 0.f, 0.f );
5554 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5556 stage.Add( actorA );
5558 application.SendNotification();
5559 application.Render();
5561 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5562 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5564 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5565 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5567 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5568 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5570 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5572 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5574 application.SendNotification();
5575 application.Render();
5577 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5578 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5580 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5581 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5583 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5584 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5589 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5591 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5593 TestApplication application;
5595 Stage stage( Stage::GetCurrent() );
5597 Actor actorA = Actor::New();
5598 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5599 actorA.SetParentOrigin( ParentOrigin::CENTER );
5600 Vector2 size2( 10.0f, 20.0f );
5601 actorA.SetSize( size2 );
5602 actorA.SetPosition( 0.f, 0.f );
5604 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5606 stage.Add( actorA );
5608 application.SendNotification();
5609 application.Render();
5611 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5612 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5614 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5615 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5617 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
5618 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
5620 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5622 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5623 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5625 application.SendNotification();
5626 application.Render();
5628 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5629 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5631 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5632 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5634 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5635 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5641 int UtcDaliActorGetScreenPositionWithChildActors(void)
5643 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5645 TestApplication application;
5647 Stage stage( Stage::GetCurrent() );
5649 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5651 Actor actorA = Actor::New();
5652 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5653 actorA.SetParentOrigin( ParentOrigin::CENTER );
5654 Vector2 size1( 10.0f, 20.0f );
5655 actorA.SetSize( size1 );
5656 actorA.SetPosition( 0.f, 0.f );
5658 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5660 Actor parentActorA = Actor::New();
5661 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5662 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5663 Vector2 size2( 30.0f, 60.0f );
5664 parentActorA.SetSize( size2 );
5665 parentActorA.SetPosition( 0.f, 0.f );
5667 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5669 stage.Add( parentActorA );
5670 parentActorA.Add ( actorA );
5672 application.SendNotification();
5673 application.Render();
5675 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5676 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5678 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5679 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5681 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
5682 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
5684 tet_infoline( "Test 2\n");
5686 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5688 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5689 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5691 application.SendNotification();
5692 application.Render();
5694 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5695 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5697 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5698 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5700 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
5701 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
5706 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5708 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5710 TestApplication application;
5712 Stage stage( Stage::GetCurrent() );
5714 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5716 Actor actorA = Actor::New();
5717 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5718 actorA.SetParentOrigin( ParentOrigin::CENTER );
5719 Vector2 size1( 10.0f, 20.0f );
5720 actorA.SetSize( size1 );
5721 actorA.SetPosition( 0.f, 0.f );
5723 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5725 Actor parentActorA = Actor::New();
5726 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5727 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5728 Vector2 size2( 30.0f, 60.0f );
5729 parentActorA.SetSize( size2 );
5730 parentActorA.SetPosition( 0.f, 0.f );
5732 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5734 Actor grandParentActorA = Actor::New();
5735 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5736 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5737 Vector2 size3( 60.0f, 120.0f );
5738 grandParentActorA.SetSize( size3 );
5739 grandParentActorA.SetPosition( 0.f, 0.f );
5741 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5743 stage.Add( grandParentActorA );
5744 grandParentActorA.Add ( parentActorA );
5746 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5748 parentActorA.Add ( actorA );
5750 application.SendNotification();
5751 application.Render();
5753 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5754 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5756 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5757 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5759 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
5760 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
5765 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5767 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
5769 TestApplication application;
5771 Stage stage( Stage::GetCurrent() );
5773 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5775 Actor actorA = Actor::New();
5776 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5777 actorA.SetParentOrigin( ParentOrigin::CENTER );
5778 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5779 actorA.SetSize( 10.0f, 20.0f );
5780 stage.Add( actorA );
5782 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5784 Actor actorB = Actor::New();
5785 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5786 actorB.SetParentOrigin( ParentOrigin::CENTER );
5787 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5788 Vector2 actorBSize( 30.0f, 60.0f );
5789 actorB.SetSize( actorBSize );
5790 stage.Add( actorB );
5792 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5794 Actor actorC = Actor::New();
5795 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5796 actorC.SetParentOrigin( ParentOrigin::CENTER );
5797 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5798 Vector2 actorCSize( 60.0f, 120.0f );
5799 actorC.SetSize( actorCSize );
5800 stage.Add( actorC );
5802 application.SendNotification();
5803 application.Render();
5805 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
5807 Vector2 center( stage.GetSize() * 0.5f );
5809 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5810 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5811 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5813 tet_infoline( "Add scale to all actors" );
5815 actorA.SetScale( 2.0f );
5816 actorB.SetScale( 2.0f );
5817 actorC.SetScale( 2.0f );
5819 application.SendNotification();
5820 application.Render();
5822 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
5823 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
5824 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
5829 int utcDaliActorPositionUsesAnchorPoint(void)
5831 TestApplication application;
5832 tet_infoline( "Check default behaviour\n" );
5834 Actor actor = Actor::New();
5835 actor.SetParentOrigin( ParentOrigin::CENTER );
5836 actor.SetAnchorPoint( AnchorPoint::CENTER );
5837 actor.SetSize( 100.0f, 100.0f );
5838 Stage::GetCurrent().Add( actor );
5840 application.SendNotification();
5841 application.Render();
5843 tet_infoline( "Check that the world position is in the center\n" );
5844 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5846 tet_infoline( "Set the position uses anchor point property to false\n" );
5847 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5849 application.SendNotification();
5850 application.Render();
5852 tet_infoline( "Check that the world position has changed appropriately\n" );
5853 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5858 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
5860 TestApplication application;
5861 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5863 Actor actor = Actor::New();
5864 actor.SetParentOrigin( ParentOrigin::CENTER );
5865 actor.SetAnchorPoint( AnchorPoint::CENTER );
5866 actor.SetSize( 100.0f, 100.0f );
5867 actor.SetScale( 2.0f );
5868 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5869 Stage::GetCurrent().Add( actor );
5871 application.SendNotification();
5872 application.Render();
5874 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
5875 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5877 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5878 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5879 application.SendNotification();
5880 application.Render();
5881 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5883 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5884 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5885 application.SendNotification();
5886 application.Render();
5887 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5892 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
5894 TestApplication application;
5895 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5897 Actor actor = Actor::New();
5898 actor.SetParentOrigin( ParentOrigin::CENTER );
5899 actor.SetAnchorPoint( AnchorPoint::CENTER );
5900 actor.SetSize( 100.0f, 100.0f );
5901 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5902 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5903 Stage::GetCurrent().Add( actor );
5905 application.SendNotification();
5906 application.Render();
5908 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
5909 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5911 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5912 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5913 application.SendNotification();
5914 application.Render();
5915 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5917 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5918 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5919 application.SendNotification();
5920 application.Render();
5921 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
5926 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
5928 TestApplication application;
5929 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5931 Actor actor = Actor::New();
5932 actor.SetParentOrigin( ParentOrigin::CENTER );
5933 actor.SetAnchorPoint( AnchorPoint::CENTER );
5934 actor.SetSize( 100.0f, 100.0f );
5935 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5936 actor.SetScale( 2.0f );
5937 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5938 Stage::GetCurrent().Add( actor );
5940 application.SendNotification();
5941 application.Render();
5943 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
5944 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5946 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5947 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5948 application.SendNotification();
5949 application.Render();
5950 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5952 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5953 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5954 application.SendNotification();
5955 application.Render();
5956 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
5961 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
5963 TestApplication application;
5964 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5966 Actor parent = Actor::New();
5968 Stage::GetCurrent().Add( parent );
5969 Vector2 stageSize( Stage::GetCurrent().GetSize() );
5971 Actor actor = Actor::New();
5972 actor.SetParentOrigin( ParentOrigin::CENTER );
5973 actor.SetAnchorPoint( AnchorPoint::CENTER );
5974 actor.SetSize( 100.0f, 100.0f );
5975 actor.SetInheritScale( false );
5976 actor.SetInheritOrientation( false );
5977 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5978 parent.Add( actor );
5980 application.SendNotification();
5981 application.Render();
5983 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
5985 tet_infoline( "Check the world position is in the right place\n" );
5986 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5988 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
5989 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5990 application.SendNotification();
5991 application.Render();
5992 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5994 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
5995 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5996 application.SendNotification();
5997 application.Render();
5998 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6003 int utcDaliActorVisibilityChangeSignalSelf(void)
6005 TestApplication application;
6006 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6008 Actor actor = Actor::New();
6010 VisibilityChangedFunctorData data;
6011 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6013 actor.SetVisible( false );
6015 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6017 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6020 actor.SetVisible( false );
6021 data.Check( false /* not called */, TEST_LOCATION );
6023 tet_infoline( "Change the visibility using properties, ensure called" );
6026 actor.SetProperty( Actor::Property::VISIBLE, true );
6027 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6029 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6032 actor.SetProperty( Actor::Property::VISIBLE, true );
6033 data.Check( false /* not called */, TEST_LOCATION );
6038 int utcDaliActorVisibilityChangeSignalChildren(void)
6040 TestApplication application;
6041 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6043 Actor parent = Actor::New();
6044 Actor child = Actor::New();
6045 parent.Add( child );
6047 Actor grandChild = Actor::New();
6048 child.Add( grandChild );
6050 VisibilityChangedFunctorData parentData;
6051 VisibilityChangedFunctorData childData;
6052 VisibilityChangedFunctorData grandChildData;
6054 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6055 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6056 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6058 parent.SetVisible( false );
6059 parentData.Check( false /* not called */, TEST_LOCATION );
6060 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6061 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6063 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6066 grandChildData.Reset();
6068 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6070 parent.SetVisible( true );
6071 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6072 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6073 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6075 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6078 grandChildData.Reset();
6080 parent.SetVisible( true );
6081 parentData.Check( false /* not called */, TEST_LOCATION );
6082 childData.Check( false /* not called */, TEST_LOCATION );
6083 grandChildData.Check( false /* not called */, TEST_LOCATION );
6088 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6090 TestApplication application;
6091 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6093 Actor actor = Actor::New();
6094 Stage::GetCurrent().Add( actor );
6096 application.SendNotification();
6097 application.Render();
6099 VisibilityChangedFunctorData data;
6100 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6102 Animation animation = Animation::New( 1.0f );
6103 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6105 data.Check( false, TEST_LOCATION );
6106 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6107 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6109 tet_infoline( "Play the animation and check the property value" );
6112 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6113 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6115 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6116 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6118 application.SendNotification();
6119 application.Render( 1100 ); // After the animation
6121 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6127 static void LayoutDirectionChanged( Actor actor, DevelActor::LayoutDirection::Type type )
6129 gLayoutDirectionType = type;
6132 int UtcDaliActorLayoutDirectionProperty(void)
6134 TestApplication application;
6135 tet_infoline( "Check layout direction property" );
6137 Actor actor0 = Actor::New();
6138 DALI_TEST_EQUALS( actor0.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6139 Stage::GetCurrent().Add( actor0 );
6141 application.SendNotification();
6142 application.Render();
6144 Actor actor1 = Actor::New();
6145 DALI_TEST_EQUALS( actor1.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6146 Actor actor2 = Actor::New();
6147 DALI_TEST_EQUALS( actor2.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6148 Actor actor3 = Actor::New();
6149 DALI_TEST_EQUALS( actor3.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6150 Actor actor4 = Actor::New();
6151 DALI_TEST_EQUALS( actor4.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6152 Actor actor5 = Actor::New();
6153 DALI_TEST_EQUALS( actor5.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6154 Actor actor6 = Actor::New();
6155 DALI_TEST_EQUALS( actor6.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6156 Actor actor7 = Actor::New();
6157 DALI_TEST_EQUALS( actor7.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6158 Actor actor8 = Actor::New();
6159 DALI_TEST_EQUALS( actor8.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6160 Actor actor9 = Actor::New();
6161 DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6163 actor1.Add( actor2 );
6164 gLayoutDirectionType = DevelActor::LayoutDirection::LTR;
6165 DevelActor::LayoutDirectionChangedSignal( actor2 ).Connect( LayoutDirectionChanged );
6167 DALI_TEST_EQUALS( actor1.GetProperty< bool >( DevelActor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6168 actor1.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, DevelActor::LayoutDirection::RTL );
6169 DALI_TEST_EQUALS( actor1.GetProperty< bool >( DevelActor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6171 DALI_TEST_EQUALS( actor1.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION );
6172 DALI_TEST_EQUALS( actor2.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION );
6173 DALI_TEST_EQUALS( gLayoutDirectionType, DevelActor::LayoutDirection::RTL, TEST_LOCATION );
6175 actor1.SetProperty( DevelActor::Property::INHERIT_LAYOUT_DIRECTION, true );
6176 actor0.Add( actor1 );
6177 DALI_TEST_EQUALS( actor1.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6178 DALI_TEST_EQUALS( actor2.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6180 Stage::GetCurrent().Add( actor3 );
6181 actor3.Add( actor4 );
6182 actor4.Add( actor5 );
6183 actor5.Add( actor6 );
6184 actor5.Add( actor7 );
6185 actor7.Add( actor8 );
6186 actor8.Add( actor9 );
6187 actor3.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
6188 actor5.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, DevelActor::LayoutDirection::LTR );
6190 DALI_TEST_EQUALS( actor8.GetProperty< bool >( DevelActor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6191 actor8.SetProperty( DevelActor::Property::INHERIT_LAYOUT_DIRECTION, false );
6192 DALI_TEST_EQUALS( actor8.GetProperty< bool >( DevelActor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6194 actor7.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
6196 DALI_TEST_EQUALS( actor3.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION );
6197 DALI_TEST_EQUALS( actor4.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION );
6198 DALI_TEST_EQUALS( actor5.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6199 DALI_TEST_EQUALS( actor6.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6200 DALI_TEST_EQUALS( actor7.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION );
6201 DALI_TEST_EQUALS( actor8.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6202 DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6204 actor8.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
6205 DALI_TEST_EQUALS( actor8.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION );
6206 DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION );
6208 actor7.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, DevelActor::LayoutDirection::LTR );
6209 DALI_TEST_EQUALS( actor7.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6210 DALI_TEST_EQUALS( actor8.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION );
6211 DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::RTL ), TEST_LOCATION );
6213 actor8.SetProperty( DevelActor::Property::INHERIT_LAYOUT_DIRECTION, true );
6214 DALI_TEST_EQUALS( actor8.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );
6215 DALI_TEST_EQUALS( actor9.GetProperty< int >( DevelActor::Property::LAYOUT_DIRECTION ), static_cast< int >( DevelActor::LayoutDirection::LTR ), TEST_LOCATION );