2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/public-api/dali-core.h>
21 #include <cfloat> // For FLT_MAX
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali-test-suite-utils.h>
26 #include <mesh-builder.h>
34 void utc_dali_actor_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_actor_cleanup(void)
41 test_return_value = TET_PASS;
46 bool gTouchCallBackCalled=false;
47 bool gTouchCallBackCalled2=false;
48 bool gTouchCallBackCalled3=false;
50 bool gHoverCallBackCalled=false;
52 static bool gTestConstraintCalled;
54 LayoutDirection::Type gLayoutDirectionType;
58 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
60 gTestConstraintCalled = true;
65 * TestConstraint reference.
66 * When constraint is called, the resultRef is updated
67 * with the value supplied.
70 struct TestConstraintRef
72 TestConstraintRef(unsigned int& resultRef, unsigned int value)
73 : mResultRef(resultRef),
78 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
83 unsigned int& mResultRef;
87 static bool TestCallback(Actor actor, const TouchEvent& event)
89 gTouchCallBackCalled = true;
94 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
96 gTouchCallBackCalled = true;
101 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
103 gTouchCallBackCalled2 = true;
108 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
110 gTouchCallBackCalled3 = true;
115 static void ResetTouchCallbacks()
117 gTouchCallBackCalled = false;
118 gTouchCallBackCalled2 = false;
119 gTouchCallBackCalled3 = false;
122 static bool TestCallback3(Actor actor, const HoverEvent& event)
124 gHoverCallBackCalled = true;
129 // validation stuff for onstage & offstage signals
130 static std::vector< std::string > gActorNamesOnOffStage;
131 static int gOnStageCallBackCalled;
132 void OnStageCallback( Actor actor )
134 ++gOnStageCallBackCalled;
135 gActorNamesOnOffStage.push_back( actor.GetName() );
136 DALI_TEST_CHECK( actor.OnStage() == true );
138 static int gOffStageCallBackCalled;
139 void OffStageCallback( Actor actor )
141 ++gOffStageCallBackCalled;
142 gActorNamesOnOffStage.push_back( actor.GetName() );
143 DALI_TEST_CHECK( actor.OnStage() == false );
146 struct PositionComponentConstraint
148 PositionComponentConstraint(){}
150 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
152 const Matrix& m = inputs[0]->GetMatrix();
155 m.GetTransformComponents(pos, rot, scale);
159 struct OrientationComponentConstraint
161 OrientationComponentConstraint(){}
163 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
165 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
168 orientation = parentOrientation;
173 static bool gOnRelayoutCallBackCalled = false;
174 static std::vector< std::string > gActorNamesRelayout;
176 void OnRelayoutCallback( Actor actor )
178 gOnRelayoutCallBackCalled = true;
179 gActorNamesRelayout.push_back( actor.GetName() );
182 struct VisibilityChangedFunctorData
184 VisibilityChangedFunctorData()
187 type( DevelActor::VisibilityChange::SELF ),
196 type = DevelActor::VisibilityChange::SELF;
200 void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
202 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
203 DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
204 DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
205 DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
208 void Check( bool compareCalled, const std::string& location )
210 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
215 DevelActor::VisibilityChange::Type type;
219 struct VisibilityChangedFunctor
221 VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
223 void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
226 data.visible = visible;
231 VisibilityChangedFunctorData& data;
234 } // anonymous namespace
237 //& purpose: Testing New API
238 int UtcDaliActorNew(void)
240 TestApplication application;
242 Actor actor = Actor::New();
244 DALI_TEST_CHECK(actor);
248 //& purpose: Testing Dali::Actor::DownCast()
249 int UtcDaliActorDownCastP(void)
251 TestApplication application;
252 tet_infoline("Testing Dali::Actor::DownCast()");
254 Actor actor = Actor::New();
255 BaseHandle object(actor);
256 Actor actor2 = Actor::DownCast(object);
257 DALI_TEST_CHECK(actor2);
261 //& purpose: Testing Dali::Actor::DownCast()
262 int UtcDaliActorDownCastN(void)
264 TestApplication application;
265 tet_infoline("Testing Dali::Actor::DownCast()");
267 BaseHandle unInitializedObject;
268 Actor actor = Actor::DownCast(unInitializedObject);
269 DALI_TEST_CHECK(!actor);
273 //& purpose: Testing Dali::Actor::GetName()
274 int UtcDaliActorGetName(void)
276 TestApplication application;
278 Actor actor = Actor::New();
280 DALI_TEST_CHECK(actor.GetName().empty());
284 //& purpose: Testing Dali::Actor::SetName()
285 int UtcDaliActorSetName(void)
287 TestApplication application;
289 string str("ActorName");
290 Actor actor = Actor::New();
293 DALI_TEST_CHECK(actor.GetName() == str);
297 int UtcDaliActorGetId(void)
299 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
300 TestApplication application;
302 Actor first = Actor::New();
303 Actor second = Actor::New();
304 Actor third = Actor::New();
306 DALI_TEST_CHECK(first.GetId() != second.GetId());
307 DALI_TEST_CHECK(second.GetId() != third.GetId());
311 int UtcDaliActorIsRoot(void)
313 TestApplication application;
315 Actor actor = Actor::New();
316 DALI_TEST_CHECK(!actor.IsRoot());
318 // get the root layer
319 actor = Stage::GetCurrent().GetLayer( 0 );
320 DALI_TEST_CHECK( actor.IsRoot() );
324 int UtcDaliActorOnStage(void)
326 TestApplication application;
328 Actor actor = Actor::New();
329 DALI_TEST_CHECK( !actor.OnStage() );
331 // get the root layer
332 actor = Stage::GetCurrent().GetLayer( 0 );
333 DALI_TEST_CHECK( actor.OnStage() );
337 int UtcDaliActorIsLayer(void)
339 TestApplication application;
341 Actor actor = Actor::New();
342 DALI_TEST_CHECK( !actor.IsLayer() );
344 // get the root layer
345 actor = Stage::GetCurrent().GetLayer( 0 );
346 DALI_TEST_CHECK( actor.IsLayer() );
350 int UtcDaliActorGetLayer(void)
352 TestApplication application;
354 Actor actor = Actor::New();
355 Stage::GetCurrent().Add(actor);
356 Layer layer = actor.GetLayer();
358 DALI_TEST_CHECK(layer);
360 // get the root layers layer
361 actor = Stage::GetCurrent().GetLayer( 0 );
362 DALI_TEST_CHECK( actor.GetLayer() );
366 int UtcDaliActorAddP(void)
368 tet_infoline("Testing Actor::Add");
369 TestApplication application;
371 Actor parent = Actor::New();
372 Actor child = Actor::New();
374 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
378 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
380 Actor parent2 = Actor::New();
381 parent2.Add( child );
383 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
384 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
386 // try Adding to same parent again, works
387 parent2.Add( child );
388 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
390 // try reparenting an orphaned child
392 Actor temporaryParent = Actor::New();
393 temporaryParent.Add( child );
394 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
396 // temporaryParent has now died, reparent the orphaned child
397 parent2.Add( child );
398 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
403 int UtcDaliActorAddN(void)
405 tet_infoline("Testing Actor::Add");
406 TestApplication application;
408 Actor child = Actor::New();
410 Actor parent2 = Actor::New();
411 parent2.Add( child );
416 parent2.Add( parent2 );
417 tet_printf("Assertion test failed - no Exception\n" );
418 tet_result(TET_FAIL);
420 catch(Dali::DaliException& e)
422 DALI_TEST_PRINT_ASSERT( e );
423 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
424 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
428 tet_printf("Assertion test failed - wrong Exception\n" );
429 tet_result(TET_FAIL);
432 // try reparenting root
435 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
436 tet_printf("Assertion test failed - no Exception\n" );
437 tet_result(TET_FAIL);
439 catch(Dali::DaliException& e)
441 DALI_TEST_PRINT_ASSERT( e );
442 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
443 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
447 tet_printf("Assertion test failed - wrong Exception\n" );
448 tet_result(TET_FAIL);
455 parent2.Add( empty );
456 tet_printf("Assertion test failed - no Exception\n" );
457 tet_result(TET_FAIL);
459 catch(Dali::DaliException& e)
461 DALI_TEST_PRINT_ASSERT( e );
462 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
463 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
467 tet_printf("Assertion test failed - wrong Exception\n" );
468 tet_result(TET_FAIL);
474 int UtcDaliActorRemoveN(void)
476 tet_infoline("Testing Actor::Remove");
477 TestApplication application;
479 Actor parent = Actor::New();
480 Actor child = Actor::New();
481 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
484 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
486 parent.Remove(child);
487 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
489 // remove again, no problem
490 parent.Remove(child);
491 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
495 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
496 // try Remove self, its a no-op
497 parent.Remove( parent );
498 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
504 parent.Remove( empty );
505 tet_printf("Assertion test failed - no Exception\n" );
506 tet_result(TET_FAIL);
508 catch(Dali::DaliException& e)
510 DALI_TEST_PRINT_ASSERT( e );
511 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
512 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
516 tet_printf("Assertion test failed - wrong Exception\n" );
517 tet_result(TET_FAIL);
522 int UtcDaliActorRemoveP(void)
524 TestApplication application;
526 Actor parent = Actor::New();
527 Actor child = Actor::New();
528 Actor random = Actor::New();
530 Stage::GetCurrent().Add( parent );
532 DALI_TEST_CHECK(parent.GetChildCount() == 0);
536 DALI_TEST_CHECK(parent.GetChildCount() == 1);
538 parent.Remove(random);
540 DALI_TEST_CHECK(parent.GetChildCount() == 1);
542 Stage::GetCurrent().Remove( parent );
544 DALI_TEST_CHECK(parent.GetChildCount() == 1);
548 int UtcDaliActorGetChildCount(void)
550 TestApplication application;
552 Actor parent = Actor::New();
553 Actor child = Actor::New();
555 DALI_TEST_CHECK(parent.GetChildCount() == 0);
559 DALI_TEST_CHECK(parent.GetChildCount() == 1);
563 int UtcDaliActorGetChildren01(void)
565 TestApplication application;
567 Actor parent = Actor::New();
568 Actor first = Actor::New();
569 Actor second = Actor::New();
570 Actor third = Actor::New();
576 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
577 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
578 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
582 int UtcDaliActorGetChildren02(void)
584 TestApplication application;
586 Actor parent = Actor::New();
587 Actor first = Actor::New();
588 Actor second = Actor::New();
589 Actor third = Actor::New();
595 const Actor& constParent = parent;
597 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
598 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
599 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
603 int UtcDaliActorGetParent01(void)
605 TestApplication application;
607 Actor parent = Actor::New();
608 Actor child = Actor::New();
612 DALI_TEST_CHECK(child.GetParent() == parent);
616 int UtcDaliActorGetParent02(void)
618 TestApplication application;
620 Actor actor = Actor::New();
622 DALI_TEST_CHECK(!actor.GetParent());
626 int UtcDaliActorSetParentOrigin(void)
628 TestApplication application;
630 Actor actor = Actor::New();
632 Vector3 vector(0.7f, 0.8f, 0.9f);
633 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
635 actor.SetParentOrigin(vector);
637 // flush the queue and render once
638 application.SendNotification();
639 application.Render();
641 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
643 Stage::GetCurrent().Add( actor );
645 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
647 // flush the queue and render once
648 application.SendNotification();
649 application.Render();
651 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
653 Stage::GetCurrent().Remove( actor );
657 int UtcDaliActorSetParentOriginIndividual(void)
659 TestApplication application;
661 Actor actor = Actor::New();
663 Vector3 vector(0.7f, 0.8f, 0.9f);
664 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
666 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
668 // flush the queue and render once
669 application.SendNotification();
670 application.Render();
672 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
674 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
676 // flush the queue and render once
677 application.SendNotification();
678 application.Render();
680 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
682 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
684 // flush the queue and render once
685 application.SendNotification();
686 application.Render();
688 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
693 int UtcDaliActorGetCurrentParentOrigin(void)
695 TestApplication application;
697 Actor actor = Actor::New();
699 Vector3 vector(0.7f, 0.8f, 0.9f);
700 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
702 actor.SetParentOrigin(vector);
704 // flush the queue and render once
705 application.SendNotification();
706 application.Render();
708 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
712 int UtcDaliActorSetAnchorPoint(void)
714 TestApplication application;
716 Actor actor = Actor::New();
718 Vector3 vector(0.7f, 0.8f, 0.9f);
719 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
721 actor.SetAnchorPoint(vector);
723 // flush the queue and render once
724 application.SendNotification();
725 application.Render();
727 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
729 Stage::GetCurrent().Add( actor );
731 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
732 // flush the queue and render once
733 application.SendNotification();
734 application.Render();
736 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
738 Stage::GetCurrent().Remove( actor );
742 int UtcDaliActorSetAnchorPointIndividual(void)
744 TestApplication application;
746 Actor actor = Actor::New();
748 Vector3 vector(0.7f, 0.8f, 0.9f);
749 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
751 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
753 // flush the queue and render once
754 application.SendNotification();
755 application.Render();
757 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
759 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
761 // flush the queue and render once
762 application.SendNotification();
763 application.Render();
765 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
767 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
769 // flush the queue and render once
770 application.SendNotification();
771 application.Render();
773 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
778 int UtcDaliActorGetCurrentAnchorPoint(void)
780 TestApplication application;
782 Actor actor = Actor::New();
784 Vector3 vector(0.7f, 0.8f, 0.9f);
785 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
787 actor.SetAnchorPoint(vector);
789 // flush the queue and render once
790 application.SendNotification();
791 application.Render();
793 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
797 // SetSize(float width, float height)
798 int UtcDaliActorSetSize01(void)
800 TestApplication application;
802 Actor actor = Actor::New();
803 Vector3 vector(100.0f, 100.0f, 0.0f);
805 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
807 actor.SetSize(vector.x, vector.y);
809 // Immediately retrieve the size after setting
810 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
811 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
812 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
813 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
814 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
816 // Flush the queue and render once
817 application.SendNotification();
818 application.Render();
820 // Check the size in the new frame
821 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
823 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
824 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
825 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
826 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
827 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
829 // Check async behaviour
830 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
831 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
832 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
833 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
834 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
836 // Change the resize policy and check whether the size stays the same
837 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
839 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
840 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
842 // Set a new size after resize policy is changed and check the new size
843 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
845 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
846 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
848 // Change the resize policy again and check whether the new size stays the same
849 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
851 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
852 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
854 // Set another new size after resize policy is changed and check the new size
855 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
857 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
858 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
863 // SetSize(float width, float height, float depth)
864 int UtcDaliActorSetSize02(void)
866 TestApplication application;
868 Actor actor = Actor::New();
869 Vector3 vector(100.0f, 100.0f, 100.0f);
871 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
873 actor.SetSize(vector.x, vector.y, vector.z);
875 // Immediately check the size after setting
876 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
877 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
879 // flush the queue and render once
880 application.SendNotification();
881 application.Render();
883 // Check the size in the new frame
884 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
886 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
887 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
892 // SetSize(Vector2 size)
893 int UtcDaliActorSetSize03(void)
895 TestApplication application;
897 Actor actor = Actor::New();
898 Vector3 vector(100.0f, 100.0f, 0.0f);
900 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
902 actor.SetSize(Vector2(vector.x, vector.y));
904 // Immediately check the size after setting
905 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
906 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
908 // flush the queue and render once
909 application.SendNotification();
910 application.Render();
912 // Check the size in the new frame
913 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
915 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
916 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
921 // SetSize(Vector3 size)
922 int UtcDaliActorSetSize04(void)
924 TestApplication application;
926 Actor actor = Actor::New();
927 Vector3 vector(100.0f, 100.0f, 100.0f);
929 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
931 actor.SetSize(vector);
933 // Immediately check the size after setting
934 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
935 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
937 // flush the queue and render once
938 application.SendNotification();
939 application.Render();
941 // Check the size in the new frame
942 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
944 Stage::GetCurrent().Add( actor );
945 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
947 // Immediately check the size after setting
948 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
949 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
951 // flush the queue and render once
952 application.SendNotification();
953 application.Render();
955 // Check the size in the new frame
956 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
958 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
959 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
961 Stage::GetCurrent().Remove( actor );
965 int UtcDaliActorSetSizeIndividual(void)
967 TestApplication application;
969 Actor actor = Actor::New();
971 Vector3 vector(0.7f, 0.8f, 0.9f);
972 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
974 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
976 // Immediately check the width after setting
977 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
978 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
980 // flush the queue and render once
981 application.SendNotification();
982 application.Render();
984 // Check the width in the new frame
985 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
987 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
988 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
990 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
992 // Immediately check the height after setting
993 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
994 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
996 // flush the queue and render once
997 application.SendNotification();
998 application.Render();
1000 // Check the height in the new frame
1001 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1003 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1004 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1006 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1008 // Immediately check the depth after setting
1009 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1010 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1012 // flush the queue and render once
1013 application.SendNotification();
1014 application.Render();
1016 // Check the depth in the new frame
1017 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1019 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1020 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1022 // Change the resize policy and check whether the size stays the same
1023 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1025 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1026 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1028 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1029 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1031 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1032 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1034 // Change the resize policy again and check whether the size stays the same
1035 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1037 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1038 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1040 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1041 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1043 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1044 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1049 int UtcDaliActorSetSizeIndividual02(void)
1051 TestApplication application;
1053 Actor actor = Actor::New();
1054 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1055 Stage::GetCurrent().Add( actor );
1057 Vector3 vector( 100.0f, 200.0f, 400.0f );
1058 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1060 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1061 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1063 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1064 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1066 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1067 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1069 // flush the queue and render once
1070 application.SendNotification();
1071 application.Render();
1073 // Check the width in the new frame
1074 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1075 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1081 int UtcDaliActorGetCurrentSize(void)
1083 TestApplication application;
1085 Actor actor = Actor::New();
1086 Vector3 vector(100.0f, 100.0f, 20.0f);
1088 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1090 actor.SetSize(vector);
1092 // flush the queue and render once
1093 application.SendNotification();
1094 application.Render();
1096 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1100 int UtcDaliActorGetNaturalSize(void)
1102 TestApplication application;
1104 Actor actor = Actor::New();
1105 Vector3 vector( 0.0f, 0.0f, 0.0f );
1107 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1112 int UtcDaliActorGetCurrentSizeImmediate(void)
1114 TestApplication application;
1116 Actor actor = Actor::New();
1117 Vector3 vector(100.0f, 100.0f, 20.0f);
1119 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1120 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1122 actor.SetSize(vector);
1124 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1125 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1127 // flush the queue and render once
1128 application.SendNotification();
1129 application.Render();
1131 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1132 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1135 // Build the animation
1136 const float durationSeconds = 2.0f;
1137 Animation animation = Animation::New( durationSeconds );
1138 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1139 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1141 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1143 // Start the animation
1146 application.SendNotification();
1147 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1149 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1154 // SetPosition(float x, float y)
1155 int UtcDaliActorSetPosition01(void)
1157 TestApplication application;
1159 Actor actor = Actor::New();
1161 // Set to random to start off with
1162 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1164 Vector3 vector(100.0f, 100.0f, 0.0f);
1166 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1168 actor.SetPosition(vector.x, vector.y);
1169 // flush the queue and render once
1170 application.SendNotification();
1171 application.Render();
1172 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1174 Stage::GetCurrent().Add( actor );
1175 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1176 // flush the queue and render once
1177 application.SendNotification();
1178 application.Render();
1179 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1184 // flush the queue and render once
1185 application.SendNotification();
1186 application.Render();
1187 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1189 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1190 // flush the queue and render once
1191 application.SendNotification();
1192 application.Render();
1193 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1195 Stage::GetCurrent().Remove( actor );
1199 // SetPosition(float x, float y, float z)
1200 int UtcDaliActorSetPosition02(void)
1202 TestApplication application;
1204 Actor actor = Actor::New();
1206 // Set to random to start off with
1207 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1209 Vector3 vector(100.0f, 100.0f, 100.0f);
1211 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1213 actor.SetPosition(vector.x, vector.y, vector.z);
1215 // flush the queue and render once
1216 application.SendNotification();
1217 application.Render();
1219 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1223 // SetPosition(Vector3 position)
1224 int UtcDaliActorSetPosition03(void)
1226 TestApplication application;
1228 Actor actor = Actor::New();
1230 // Set to random to start off with
1231 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1233 Vector3 vector(100.0f, 100.0f, 100.0f);
1235 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1237 actor.SetPosition(vector);
1239 // flush the queue and render once
1240 application.SendNotification();
1241 application.Render();
1243 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1247 int UtcDaliActorSetX(void)
1249 TestApplication application;
1251 Actor actor = Actor::New();
1253 Vector3 vector(100.0f, 0.0f, 0.0f);
1255 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1259 // flush the queue and render once
1260 application.SendNotification();
1261 application.Render();
1263 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1267 int UtcDaliActorSetY(void)
1269 TestApplication application;
1271 Actor actor = Actor::New();
1273 Vector3 vector(0.0f, 100.0f, 0.0f);
1275 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1279 // flush the queue and render once
1280 application.SendNotification();
1281 application.Render();
1283 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1287 int UtcDaliActorSetZ(void)
1289 TestApplication application;
1291 Actor actor = Actor::New();
1293 Vector3 vector(0.0f, 0.0f, 100.0f);
1295 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1299 // flush the queue and render once
1300 application.SendNotification();
1301 application.Render();
1303 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1307 int UtcDaliActorSetPositionProperties(void)
1309 TestApplication application;
1311 Actor actor = Actor::New();
1313 Vector3 vector(0.7f, 0.8f, 0.9f);
1314 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1316 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1317 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1318 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1320 // flush the queue and render once
1321 application.SendNotification();
1322 application.Render();
1324 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1325 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1326 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1327 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1328 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1330 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1331 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1332 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1334 // flush the queue and render once
1335 application.SendNotification();
1336 application.Render();
1338 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1339 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1340 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1341 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1342 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1344 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1345 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1346 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1348 // flush the queue and render once
1349 application.SendNotification();
1350 application.Render();
1352 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1353 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1354 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1355 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1356 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1361 int UtcDaliActorTranslateBy(void)
1363 TestApplication application;
1365 Actor actor = Actor::New();
1366 Vector3 vector(100.0f, 100.0f, 100.0f);
1368 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1370 actor.SetPosition(vector);
1372 // flush the queue and render once
1373 application.SendNotification();
1374 application.Render();
1376 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1378 actor.TranslateBy(vector);
1380 // flush the queue and render once
1381 application.SendNotification();
1382 application.Render();
1384 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1388 int UtcDaliActorGetCurrentPosition(void)
1390 TestApplication application;
1392 Actor actor = Actor::New();
1393 Vector3 setVector(100.0f, 100.0f, 0.0f);
1394 actor.SetPosition(setVector);
1396 // flush the queue and render once
1397 application.SendNotification();
1398 application.Render();
1400 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1404 int UtcDaliActorGetCurrentWorldPosition(void)
1406 TestApplication application;
1408 Actor parent = Actor::New();
1409 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1410 parent.SetPosition( parentPosition );
1411 parent.SetParentOrigin( ParentOrigin::CENTER );
1412 parent.SetAnchorPoint( AnchorPoint::CENTER );
1413 Stage::GetCurrent().Add( parent );
1415 Actor child = Actor::New();
1416 child.SetParentOrigin( ParentOrigin::CENTER );
1417 child.SetAnchorPoint( AnchorPoint::CENTER );
1418 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1419 child.SetPosition( childPosition );
1420 parent.Add( child );
1422 // The actors should not have a world position yet
1423 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1424 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1426 application.SendNotification();
1427 application.Render(0);
1429 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1430 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1432 // The actors should have a world position now
1433 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1434 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1438 int UtcDaliActorInheritPosition(void)
1440 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1441 TestApplication application;
1443 Actor parent = Actor::New();
1444 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1445 parent.SetPosition( parentPosition );
1446 parent.SetParentOrigin( ParentOrigin::CENTER );
1447 parent.SetAnchorPoint( AnchorPoint::CENTER );
1448 Stage::GetCurrent().Add( parent );
1450 Actor child = Actor::New();
1451 child.SetParentOrigin( ParentOrigin::CENTER );
1452 child.SetAnchorPoint( AnchorPoint::CENTER );
1453 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1454 child.SetPosition( childPosition );
1455 parent.Add( child );
1457 // The actors should not have a world position yet
1458 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1459 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1461 // first test default, which is to inherit position
1462 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1463 application.SendNotification();
1464 application.Render(0); // should only really call Update as Render is not required to update scene
1465 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1466 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1467 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1468 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1471 //Change child position
1472 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1473 child.SetPosition( childOffset );
1475 // Change inheritance mode to not inherit
1476 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1477 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1478 application.SendNotification();
1479 application.Render(0); // should only really call Update as Render is not required to update scene
1480 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1481 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1482 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1483 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1487 int UtcDaliActorSetInheritPosition(void)
1489 tet_infoline("Testing Actor::SetInheritPosition");
1490 TestApplication application;
1492 Actor parent = Actor::New();
1493 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1494 parent.SetPosition( parentPosition );
1495 parent.SetParentOrigin( ParentOrigin::CENTER );
1496 parent.SetAnchorPoint( AnchorPoint::CENTER );
1497 Stage::GetCurrent().Add( parent );
1499 Actor child = Actor::New();
1500 child.SetParentOrigin( ParentOrigin::CENTER );
1501 child.SetAnchorPoint( AnchorPoint::CENTER );
1502 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1503 child.SetPosition( childPosition );
1504 parent.Add( child );
1506 // The actors should not have a world position yet
1507 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1508 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1510 // first test default, which is to inherit position
1511 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1512 application.SendNotification();
1513 application.Render(0); // should only really call Update as Render is not required to update scene
1514 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1515 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1516 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1517 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1519 //Change child position
1520 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1521 child.SetPosition( childOffset );
1523 // Use local position as world postion
1524 child.SetInheritPosition( false );
1525 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1526 application.SendNotification();
1527 application.Render(0); // should only really call Update as Render is not required to update scene
1528 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1529 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1530 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1531 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1533 //Change back to inherit position from parent
1534 child.SetInheritPosition( true );
1535 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1536 application.SendNotification();
1537 application.Render(0); // should only really call Update as Render is not required to update scene
1538 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1539 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1540 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1541 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1545 // SetOrientation(float angleRadians, Vector3 axis)
1546 int UtcDaliActorSetOrientation01(void)
1548 TestApplication application;
1550 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1551 Actor actor = Actor::New();
1553 actor.SetOrientation(rotation);
1555 // flush the queue and render once
1556 application.SendNotification();
1557 application.Render();
1559 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1563 int UtcDaliActorSetOrientation02(void)
1565 TestApplication application;
1567 Actor actor = Actor::New();
1569 Radian angle( 0.785f );
1570 Vector3 axis(1.0f, 1.0f, 0.0f);
1572 actor.SetOrientation( angle, axis);
1573 Quaternion rotation( angle, axis );
1574 // flush the queue and render once
1575 application.SendNotification();
1576 application.Render();
1577 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1579 Stage::GetCurrent().Add( actor );
1580 actor.RotateBy( Degree( 360 ), axis);
1581 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1583 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1584 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1585 // flush the queue and render once
1586 application.SendNotification();
1587 application.Render();
1588 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1590 actor.SetOrientation( angle, axis);
1591 // flush the queue and render once
1592 application.SendNotification();
1593 application.Render();
1594 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1596 Stage::GetCurrent().Remove( actor );
1600 // SetOrientation(float angleRadians, Vector3 axis)
1601 int UtcDaliActorSetOrientationProperty(void)
1603 TestApplication application;
1605 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1606 Actor actor = Actor::New();
1608 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1609 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1611 // flush the queue and render once
1612 application.SendNotification();
1613 application.Render();
1615 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1616 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1617 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1621 // RotateBy(float angleRadians, Vector3 axis)
1622 int UtcDaliActorRotateBy01(void)
1624 TestApplication application;
1626 Actor actor = Actor::New();
1628 Radian angle( M_PI * 0.25f );
1629 actor.RotateBy(( angle ), Vector3::ZAXIS);
1630 // flush the queue and render once
1631 application.SendNotification();
1632 application.Render();
1633 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1635 Stage::GetCurrent().Add( actor );
1637 actor.RotateBy( angle, Vector3::ZAXIS);
1638 // flush the queue and render once
1639 application.SendNotification();
1640 application.Render();
1641 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1643 Stage::GetCurrent().Remove( actor );
1647 // RotateBy(Quaternion relativeRotation)
1648 int UtcDaliActorRotateBy02(void)
1650 TestApplication application;
1652 Actor actor = Actor::New();
1654 Radian angle( M_PI * 0.25f );
1655 Quaternion rotation(angle, Vector3::ZAXIS);
1656 actor.RotateBy(rotation);
1657 // flush the queue and render once
1658 application.SendNotification();
1659 application.Render();
1660 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1662 actor.RotateBy(rotation);
1663 // flush the queue and render once
1664 application.SendNotification();
1665 application.Render();
1666 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1670 int UtcDaliActorGetCurrentOrientation(void)
1672 TestApplication application;
1673 Actor actor = Actor::New();
1675 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1676 actor.SetOrientation(rotation);
1677 // flush the queue and render once
1678 application.SendNotification();
1679 application.Render();
1680 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1684 int UtcDaliActorGetCurrentWorldOrientation(void)
1686 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1687 TestApplication application;
1689 Actor parent = Actor::New();
1690 Radian rotationAngle( Degree(90.0f) );
1691 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1692 parent.SetOrientation( rotation );
1693 Stage::GetCurrent().Add( parent );
1695 Actor child = Actor::New();
1696 child.SetOrientation( rotation );
1697 parent.Add( child );
1699 // The actors should not have a world rotation yet
1700 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1701 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1703 application.SendNotification();
1704 application.Render(0);
1706 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1707 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1709 // The actors should have a world rotation now
1710 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1711 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1713 // turn off child rotation inheritance
1714 child.SetInheritOrientation( false );
1715 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1716 application.SendNotification();
1717 application.Render(0);
1719 // The actors should have a world rotation now
1720 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1721 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1725 // SetScale(float scale)
1726 int UtcDaliActorSetScale01(void)
1728 TestApplication application;
1730 Actor actor = Actor::New();
1732 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1733 actor.SetScale(0.25f);
1735 Vector3 scale(10.0f, 10.0f, 10.0f);
1736 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1738 actor.SetScale(scale.x);
1740 // flush the queue and render once
1741 application.SendNotification();
1742 application.Render();
1744 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1748 // SetScale(float scaleX, float scaleY, float scaleZ)
1749 int UtcDaliActorSetScale02(void)
1751 TestApplication application;
1752 Vector3 scale(10.0f, 10.0f, 10.0f);
1754 Actor actor = Actor::New();
1756 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1757 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1759 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1761 actor.SetScale(scale.x, scale.y, scale.z);
1762 // flush the queue and render once
1763 application.SendNotification();
1764 application.Render();
1765 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1767 // add to stage and test
1768 Stage::GetCurrent().Add( actor );
1769 actor.SetScale( 2.0f, 2.0f, 2.0f );
1770 // flush the queue and render once
1771 application.SendNotification();
1772 application.Render();
1773 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1775 Stage::GetCurrent().Remove( actor );
1780 // SetScale(Vector3 scale)
1781 int UtcDaliActorSetScale03(void)
1783 TestApplication application;
1784 Vector3 scale(10.0f, 10.0f, 10.0f);
1786 Actor actor = Actor::New();
1788 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1789 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1791 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1793 actor.SetScale(scale);
1795 // flush the queue and render once
1796 application.SendNotification();
1797 application.Render();
1799 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1803 int UtcDaliActorSetScaleIndividual(void)
1805 TestApplication application;
1807 Actor actor = Actor::New();
1809 Vector3 vector(0.7f, 0.8f, 0.9f);
1810 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1812 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1813 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1815 // flush the queue and render once
1816 application.SendNotification();
1817 application.Render();
1819 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1820 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1821 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1823 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1824 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1826 // flush the queue and render once
1827 application.SendNotification();
1828 application.Render();
1830 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1831 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1832 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1834 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1835 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1837 // flush the queue and render once
1838 application.SendNotification();
1839 application.Render();
1841 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1842 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1843 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1845 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1846 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1851 int UtcDaliActorScaleBy(void)
1853 TestApplication application;
1854 Actor actor = Actor::New();
1855 Vector3 vector(100.0f, 100.0f, 100.0f);
1857 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1859 actor.SetScale(vector);
1861 // flush the queue and render once
1862 application.SendNotification();
1863 application.Render();
1865 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1867 actor.ScaleBy(vector);
1869 // flush the queue and render once
1870 application.SendNotification();
1871 application.Render();
1873 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1877 int UtcDaliActorGetCurrentScale(void)
1879 TestApplication application;
1880 Vector3 scale(12.0f, 1.0f, 2.0f);
1882 Actor actor = Actor::New();
1884 actor.SetScale(scale);
1886 // flush the queue and render once
1887 application.SendNotification();
1888 application.Render();
1890 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1894 int UtcDaliActorGetCurrentWorldScale(void)
1896 TestApplication application;
1898 Actor parent = Actor::New();
1899 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1900 parent.SetScale( parentScale );
1901 Stage::GetCurrent().Add( parent );
1903 Actor child = Actor::New();
1904 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1905 child.SetScale( childScale );
1906 parent.Add( child );
1908 // The actors should not have a scale yet
1909 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1910 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1912 // The actors should not have a world scale yet
1913 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1914 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1916 application.SendNotification();
1917 application.Render(0);
1919 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1920 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1922 // The actors should have a world scale now
1923 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1924 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1928 int UtcDaliActorInheritScale(void)
1930 tet_infoline("Testing Actor::SetInheritScale");
1931 TestApplication application;
1933 Actor parent = Actor::New();
1934 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1935 parent.SetScale( parentScale );
1936 Stage::GetCurrent().Add( parent );
1938 Actor child = Actor::New();
1939 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1940 child.SetScale( childScale );
1941 parent.Add( child );
1943 application.SendNotification();
1944 application.Render(0);
1946 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1947 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1949 child.SetInheritScale( false );
1950 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1952 application.SendNotification();
1953 application.Render(0);
1955 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1959 int UtcDaliActorSetVisible(void)
1961 TestApplication application;
1963 Actor actor = Actor::New();
1964 actor.SetVisible(false);
1965 // flush the queue and render once
1966 application.SendNotification();
1967 application.Render();
1968 DALI_TEST_CHECK(actor.IsVisible() == false);
1970 actor.SetVisible(true);
1971 // flush the queue and render once
1972 application.SendNotification();
1973 application.Render();
1974 DALI_TEST_CHECK(actor.IsVisible() == true);
1976 // put actor on stage
1977 Stage::GetCurrent().Add( actor );
1978 actor.SetVisible(false);
1979 // flush the queue and render once
1980 application.SendNotification();
1981 application.Render();
1982 DALI_TEST_CHECK(actor.IsVisible() == false);
1986 int UtcDaliActorIsVisible(void)
1988 TestApplication application;
1990 Actor actor = Actor::New();
1992 DALI_TEST_CHECK(actor.IsVisible() == true);
1996 int UtcDaliActorSetOpacity(void)
1998 TestApplication application;
2000 Actor actor = Actor::New();
2001 // initial opacity is 1
2002 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2004 actor.SetOpacity( 0.4f);
2005 // flush the queue and render once
2006 application.SendNotification();
2007 application.Render();
2008 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2010 // change opacity, actor is on stage to change is not immediate
2011 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2012 // flush the queue and render once
2013 application.SendNotification();
2014 application.Render();
2015 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2017 // put actor on stage
2018 Stage::GetCurrent().Add( actor );
2020 // change opacity, actor is on stage to change is not immediate
2021 actor.SetOpacity( 0.9f );
2022 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2023 // flush the queue and render once
2024 application.SendNotification();
2025 application.Render();
2026 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2028 // change opacity, actor is on stage to change is not immediate
2029 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2030 // flush the queue and render once
2031 application.SendNotification();
2032 application.Render();
2033 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2037 int UtcDaliActorGetCurrentOpacity(void)
2039 TestApplication application;
2041 Actor actor = Actor::New();
2042 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2044 actor.SetOpacity(0.5f);
2045 // flush the queue and render once
2046 application.SendNotification();
2047 application.Render();
2048 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2052 int UtcDaliActorSetSensitive(void)
2054 TestApplication application;
2055 Actor actor = Actor::New();
2057 bool sensitive = !actor.IsSensitive();
2059 actor.SetSensitive(sensitive);
2061 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2065 int UtcDaliActorIsSensitive(void)
2067 TestApplication application;
2068 Actor actor = Actor::New();
2069 actor.SetSensitive(false);
2071 DALI_TEST_CHECK(false == actor.IsSensitive());
2075 int UtcDaliActorSetColor(void)
2077 TestApplication application;
2078 Actor actor = Actor::New();
2079 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2081 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2083 actor.SetColor(color);
2084 // flush the queue and render once
2085 application.SendNotification();
2086 application.Render();
2087 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2089 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2090 // flush the queue and render once
2091 application.SendNotification();
2092 application.Render();
2093 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2095 Stage::GetCurrent().Add( actor );
2096 actor.SetColor( color );
2097 // flush the queue and render once
2098 application.SendNotification();
2099 application.Render();
2100 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2102 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2103 // flush the queue and render once
2104 application.SendNotification();
2105 application.Render();
2106 // Actor color is not clamped
2107 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2108 // world color is clamped
2109 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2111 Stage::GetCurrent().Remove( actor );
2115 int UtcDaliActorSetColorIndividual(void)
2117 TestApplication application;
2119 Actor actor = Actor::New();
2121 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2122 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2124 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2125 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2127 // flush the queue and render once
2128 application.SendNotification();
2129 application.Render();
2131 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2132 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2133 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2135 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2136 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2138 // flush the queue and render once
2139 application.SendNotification();
2140 application.Render();
2142 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2143 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2144 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2146 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2147 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2149 // flush the queue and render once
2150 application.SendNotification();
2151 application.Render();
2153 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2154 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2155 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2158 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2159 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2161 // flush the queue and render once
2162 application.SendNotification();
2163 application.Render();
2165 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2166 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2167 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2169 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2170 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2172 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2175 // flush the queue and render once
2176 application.SendNotification();
2177 application.Render();
2179 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2185 int UtcDaliActorGetCurrentColor(void)
2187 TestApplication application;
2188 Actor actor = Actor::New();
2189 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2191 actor.SetColor(color);
2192 // flush the queue and render once
2193 application.SendNotification();
2194 application.Render();
2195 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2199 int UtcDaliActorGetCurrentWorldColor(void)
2201 tet_infoline("Actor::GetCurrentWorldColor");
2202 TestApplication application;
2204 Actor parent = Actor::New();
2205 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2206 parent.SetColor( parentColor );
2207 Stage::GetCurrent().Add( parent );
2209 Actor child = Actor::New();
2210 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2211 child.SetColor( childColor );
2212 parent.Add( child );
2214 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2215 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2217 // verify the default color mode
2218 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2220 // The actors should not have a world color yet
2221 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2222 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2224 application.SendNotification();
2225 application.Render(0);
2227 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2228 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2230 // The actors should have a world color now
2231 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2232 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2235 child.SetColorMode( USE_OWN_COLOR );
2236 application.SendNotification();
2237 application.Render(0);
2238 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2241 child.SetColorMode( USE_PARENT_COLOR );
2242 application.SendNotification();
2243 application.Render(0);
2244 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2245 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2248 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2249 application.SendNotification();
2250 application.Render(0);
2251 Vector4 expectedColor( childColor );
2252 expectedColor.a *= parentColor.a;
2253 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2254 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2258 int UtcDaliActorSetColorMode(void)
2260 tet_infoline("Actor::SetColorMode");
2261 TestApplication application;
2262 Actor actor = Actor::New();
2263 Actor child = Actor::New();
2266 actor.SetColorMode( USE_OWN_COLOR );
2267 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2269 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2270 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2272 actor.SetColorMode( USE_PARENT_COLOR );
2273 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2275 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2276 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2280 int UtcDaliActorScreenToLocal(void)
2282 TestApplication application;
2283 Actor actor = Actor::New();
2284 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2285 actor.SetSize(100.0f, 100.0f);
2286 actor.SetPosition(10.0f, 10.0f);
2287 Stage::GetCurrent().Add(actor);
2289 // flush the queue and render once
2290 application.SendNotification();
2291 application.Render();
2296 application.SendNotification();
2297 application.Render();
2299 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2301 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2302 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2306 int UtcDaliActorSetLeaveRequired(void)
2308 TestApplication application;
2310 Actor actor = Actor::New();
2312 actor.SetLeaveRequired(false);
2313 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2315 actor.SetLeaveRequired(true);
2316 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2320 int UtcDaliActorGetLeaveRequired(void)
2322 TestApplication application;
2324 Actor actor = Actor::New();
2326 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2330 int UtcDaliActorSetKeyboardFocusable(void)
2332 TestApplication application;
2334 Actor actor = Actor::New();
2336 actor.SetKeyboardFocusable(true);
2337 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2339 actor.SetKeyboardFocusable(false);
2340 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2344 int UtcDaliActorIsKeyboardFocusable(void)
2346 TestApplication application;
2348 Actor actor = Actor::New();
2350 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2354 int UtcDaliActorRemoveConstraints(void)
2356 tet_infoline(" UtcDaliActorRemoveConstraints");
2357 TestApplication application;
2359 gTestConstraintCalled = false;
2361 Actor actor = Actor::New();
2363 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2365 actor.RemoveConstraints();
2367 DALI_TEST_CHECK( gTestConstraintCalled == false );
2369 Stage::GetCurrent().Add( actor );
2372 // flush the queue and render once
2373 application.SendNotification();
2374 application.Render();
2376 actor.RemoveConstraints();
2378 DALI_TEST_CHECK( gTestConstraintCalled == true );
2382 int UtcDaliActorRemoveConstraintTag(void)
2384 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2385 TestApplication application;
2387 Actor actor = Actor::New();
2389 // 1. Apply Constraint1 and Constraint2, and test...
2390 unsigned int result1 = 0u;
2391 unsigned int result2 = 0u;
2393 unsigned constraint1Tag = 1u;
2394 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2395 constraint1.SetTag( constraint1Tag );
2396 constraint1.Apply();
2398 unsigned constraint2Tag = 2u;
2399 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2400 constraint2.SetTag( constraint2Tag );
2401 constraint2.Apply();
2403 Stage::GetCurrent().Add( actor );
2404 // flush the queue and render once
2405 application.SendNotification();
2406 application.Render();
2408 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2409 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2411 // 2. Remove Constraint1 and test...
2414 actor.RemoveConstraints(constraint1Tag);
2415 // make color property dirty, which will trigger constraints to be reapplied.
2416 actor.SetColor( Color::WHITE );
2417 // flush the queue and render once
2418 application.SendNotification();
2419 application.Render();
2421 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2422 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2424 // 3. Re-Apply Constraint1 and test...
2427 constraint1.Apply();
2428 // make color property dirty, which will trigger constraints to be reapplied.
2429 actor.SetColor( Color::WHITE );
2430 // flush the queue and render once
2431 application.SendNotification();
2432 application.Render();
2434 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2435 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2437 // 2. Remove Constraint2 and test...
2440 actor.RemoveConstraints(constraint2Tag);
2441 // make color property dirty, which will trigger constraints to be reapplied.
2442 actor.SetColor( Color::WHITE );
2443 // flush the queue and render once
2444 application.SendNotification();
2445 application.Render();
2447 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2448 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2450 // 2. Remove Constraint1 as well and test...
2453 actor.RemoveConstraints(constraint1Tag);
2454 // make color property dirty, which will trigger constraints to be reapplied.
2455 actor.SetColor( Color::WHITE );
2456 // flush the queue and render once
2457 application.SendNotification();
2458 application.Render();
2460 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2461 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2465 int UtcDaliActorTouchedSignal(void)
2467 TestApplication application;
2469 ResetTouchCallbacks();
2471 // get the root layer
2472 Actor actor = Stage::GetCurrent().GetRootLayer();
2473 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2475 application.SendNotification();
2476 application.Render();
2478 // connect to its touch signal
2479 actor.TouchedSignal().Connect( TestCallback );
2481 // simulate a touch event in the middle of the screen
2482 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2483 Dali::Integration::Point point;
2484 point.SetDeviceId( 1 );
2485 point.SetState( PointState::DOWN );
2486 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2487 Dali::Integration::TouchEvent touchEvent;
2488 touchEvent.AddPoint( point );
2489 application.ProcessEvent( touchEvent );
2491 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2495 int UtcDaliActorHoveredSignal(void)
2497 TestApplication application;
2499 gHoverCallBackCalled = false;
2501 // get the root layer
2502 Actor actor = Stage::GetCurrent().GetRootLayer();
2503 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2505 application.SendNotification();
2506 application.Render();
2508 // connect to its hover signal
2509 actor.HoveredSignal().Connect( TestCallback3 );
2511 // simulate a hover event in the middle of the screen
2512 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2513 Dali::Integration::Point point;
2514 point.SetDeviceId( 1 );
2515 point.SetState( PointState::MOTION );
2516 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2517 Dali::Integration::HoverEvent hoverEvent;
2518 hoverEvent.AddPoint( point );
2519 application.ProcessEvent( hoverEvent );
2521 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2525 int UtcDaliActorOnOffStageSignal(void)
2527 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2529 TestApplication application;
2532 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2533 gActorNamesOnOffStage.clear();
2535 Actor parent = Actor::New();
2536 parent.SetName( "parent" );
2537 parent.OnStageSignal().Connect( OnStageCallback );
2538 parent.OffStageSignal().Connect( OffStageCallback );
2540 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2541 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2543 // add parent to stage
2544 Stage::GetCurrent().Add( parent );
2545 // onstage emitted, offstage not
2546 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2547 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2548 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2550 // test adding a child, should get onstage emitted
2552 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2553 gActorNamesOnOffStage.clear();
2555 Actor child = Actor::New();
2556 child.SetName( "child" );
2557 child.OnStageSignal().Connect( OnStageCallback );
2558 child.OffStageSignal().Connect( OffStageCallback );
2559 parent.Add( child ); // add child
2560 // onstage emitted, offstage not
2561 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2562 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2563 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2565 // test removing parent from stage
2567 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2568 gActorNamesOnOffStage.clear();
2570 Stage::GetCurrent().Remove( parent );
2571 // onstage not emitted, offstage is
2572 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2573 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2574 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2575 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2577 // test adding parent back to stage
2579 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2580 gActorNamesOnOffStage.clear();
2582 Stage::GetCurrent().Add( parent );
2583 // onstage emitted, offstage not
2584 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2585 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2586 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2587 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2589 // test removing child
2591 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2592 gActorNamesOnOffStage.clear();
2594 parent.Remove( child );
2595 // onstage not emitted, offstage is
2596 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2597 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2598 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2600 // test removing parent
2602 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2603 gActorNamesOnOffStage.clear();
2605 Stage::GetCurrent().Remove( parent );
2606 // onstage not emitted, offstage is
2607 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2608 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2609 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2613 int UtcDaliActorFindChildByName(void)
2615 tet_infoline("Testing Dali::Actor::FindChildByName()");
2616 TestApplication application;
2618 Actor parent = Actor::New();
2619 parent.SetName( "parent" );
2620 Actor first = Actor::New();
2621 first .SetName( "first" );
2622 Actor second = Actor::New();
2623 second.SetName( "second" );
2628 Actor found = parent.FindChildByName( "foo" );
2629 DALI_TEST_CHECK( !found );
2631 found = parent.FindChildByName( "parent" );
2632 DALI_TEST_CHECK( found == parent );
2634 found = parent.FindChildByName( "first" );
2635 DALI_TEST_CHECK( found == first );
2637 found = parent.FindChildByName( "second" );
2638 DALI_TEST_CHECK( found == second );
2642 int UtcDaliActorFindChildById(void)
2644 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2645 TestApplication application;
2647 Actor parent = Actor::New();
2648 Actor first = Actor::New();
2649 Actor second = Actor::New();
2654 Actor found = parent.FindChildById( 100000 );
2655 DALI_TEST_CHECK( !found );
2657 found = parent.FindChildById( parent.GetId() );
2658 DALI_TEST_CHECK( found == parent );
2660 found = parent.FindChildById( first.GetId() );
2661 DALI_TEST_CHECK( found == first );
2663 found = parent.FindChildById( second.GetId() );
2664 DALI_TEST_CHECK( found == second );
2668 int UtcDaliActorHitTest(void)
2673 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2675 mTouchPoint( touchPoint ),
2680 Vector2 mTouchPoint;
2684 TestApplication application;
2685 tet_infoline(" UtcDaliActorHitTest");
2687 // Fill a vector with different hit tests.
2688 struct HitTestData* hitTestData[] = {
2689 // scale touch point result
2690 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2691 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2692 new HitTestData( Vector3( 110.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), true ), // same point as above with a wider scale. Should be inside.
2693 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2694 new HitTestData( Vector3( 100.f, 110.f, 1.f ), Vector2( 200.f, 451.f ), true ), // same point as above with a wider scale. Should be inside.
2698 // get the root layer
2699 Actor actor = Actor::New();
2700 actor.SetAnchorPoint( AnchorPoint::CENTER );
2701 actor.SetParentOrigin( ParentOrigin::CENTER );
2703 Stage::GetCurrent().Add( actor );
2705 ResetTouchCallbacks();
2707 unsigned int index = 0;
2708 while( NULL != hitTestData[index] )
2710 actor.SetSize( 1.f, 1.f );
2711 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2713 // flush the queue and render once
2714 application.SendNotification();
2715 application.Render();
2717 DALI_TEST_CHECK( !gTouchCallBackCalled );
2719 // connect to its touch signal
2720 actor.TouchedSignal().Connect(TestCallback);
2722 Dali::Integration::Point point;
2723 point.SetState( PointState::DOWN );
2724 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2725 Dali::Integration::TouchEvent event;
2726 event.AddPoint( point );
2728 // flush the queue and render once
2729 application.SendNotification();
2730 application.Render();
2731 application.ProcessEvent( event );
2733 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2735 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2736 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2737 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2738 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2739 hitTestData[index]->mResult );
2741 ResetTouchCallbacks();
2747 int UtcDaliActorSetDrawMode(void)
2749 TestApplication app;
2750 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2752 Actor a = Actor::New();
2754 Stage::GetCurrent().Add(a);
2755 app.SendNotification();
2757 app.SendNotification();
2760 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2762 a.SetDrawMode( DrawMode::OVERLAY_2D );
2763 app.SendNotification();
2766 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2768 a.SetDrawMode( DrawMode::NORMAL );
2769 app.SendNotification();
2772 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2776 int UtcDaliActorSetDrawModeOverlayRender(void)
2778 TestApplication app;
2779 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2781 app.SendNotification();
2784 std::vector<GLuint> ids;
2785 ids.push_back( 8 ); // first rendered actor
2786 ids.push_back( 9 ); // second rendered actor
2787 ids.push_back( 10 ); // third rendered actor
2788 app.GetGlAbstraction().SetNextTextureIds( ids );
2790 BufferImage imageA = BufferImage::New(16, 16);
2791 BufferImage imageB = BufferImage::New(16, 16);
2792 BufferImage imageC = BufferImage::New(16, 16);
2793 Actor a = CreateRenderableActor( imageA );
2794 Actor b = CreateRenderableActor( imageB );
2795 Actor c = CreateRenderableActor( imageC );
2797 app.SendNotification();
2800 //Textures are bound when first created. Clear bound textures vector
2801 app.GetGlAbstraction().ClearBoundTextures();
2803 // Render a,b,c as regular non-overlays. so order will be:
2807 Stage::GetCurrent().Add(a);
2808 Stage::GetCurrent().Add(b);
2809 Stage::GetCurrent().Add(c);
2811 app.SendNotification();
2814 // Should be 3 textures changes.
2815 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2816 typedef std::vector<GLuint>::size_type TextureSize;
2817 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2818 if( boundTextures.size() == 3 )
2820 DALI_TEST_CHECK( boundTextures[0] == 8u );
2821 DALI_TEST_CHECK( boundTextures[1] == 9u );
2822 DALI_TEST_CHECK( boundTextures[2] == 10u );
2825 // Now texture ids have been set, we can monitor their render order.
2826 // render a as an overlay (last), so order will be:
2830 a.SetDrawMode( DrawMode::OVERLAY_2D );
2831 app.GetGlAbstraction().ClearBoundTextures();
2833 app.SendNotification();
2836 // Should be 3 texture changes.
2837 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2838 if( boundTextures.size() == 3 )
2840 DALI_TEST_CHECK( boundTextures[0] == 9u );
2841 DALI_TEST_CHECK( boundTextures[1] == 10u );
2842 DALI_TEST_CHECK( boundTextures[2] == 8u );
2847 int UtcDaliActorGetCurrentWorldMatrix(void)
2849 TestApplication app;
2850 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2852 Actor parent = Actor::New();
2853 parent.SetParentOrigin(ParentOrigin::CENTER);
2854 parent.SetAnchorPoint(AnchorPoint::CENTER);
2855 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2856 Radian rotationAngle(Degree(85.0f));
2857 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2858 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2859 parent.SetPosition( parentPosition );
2860 parent.SetOrientation( parentRotation );
2861 parent.SetScale( parentScale );
2862 Stage::GetCurrent().Add( parent );
2864 Actor child = Actor::New();
2865 child.SetParentOrigin(ParentOrigin::CENTER);
2866 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2867 Radian childRotationAngle(Degree(23.0f));
2868 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2869 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2870 child.SetPosition( childPosition );
2871 child.SetOrientation( childRotation );
2872 child.SetScale( childScale );
2873 parent.Add( child );
2875 app.SendNotification();
2878 app.SendNotification();
2880 Matrix parentMatrix(false);
2881 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2883 Matrix childMatrix(false);
2884 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2886 //Child matrix should be the composition of child and parent
2887 Matrix childWorldMatrix(false);
2888 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2890 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2891 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2897 int UtcDaliActorConstrainedToWorldMatrix(void)
2899 TestApplication app;
2900 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2902 Actor parent = Actor::New();
2903 parent.SetParentOrigin(ParentOrigin::CENTER);
2904 parent.SetAnchorPoint(AnchorPoint::CENTER);
2905 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2906 Radian rotationAngle(Degree(85.0f));
2907 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2908 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2909 parent.SetPosition( parentPosition );
2910 parent.SetOrientation( parentRotation );
2911 parent.SetScale( parentScale );
2912 Stage::GetCurrent().Add( parent );
2914 Actor child = Actor::New();
2915 child.SetParentOrigin(ParentOrigin::CENTER);
2916 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2917 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2918 posConstraint.Apply();
2920 Stage::GetCurrent().Add( child );
2922 app.SendNotification();
2925 app.SendNotification();
2927 Matrix parentMatrix(false);
2928 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2930 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2931 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2935 int UtcDaliActorConstrainedToOrientation(void)
2937 TestApplication app;
2938 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2940 Actor parent = Actor::New();
2941 parent.SetParentOrigin(ParentOrigin::CENTER);
2942 parent.SetAnchorPoint(AnchorPoint::CENTER);
2943 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2944 Radian rotationAngle(Degree(85.0f));
2945 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2946 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2947 parent.SetPosition( parentPosition );
2948 parent.SetOrientation( parentRotation );
2949 parent.SetScale( parentScale );
2950 Stage::GetCurrent().Add( parent );
2952 Actor child = Actor::New();
2953 child.SetParentOrigin(ParentOrigin::CENTER);
2954 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2955 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2956 posConstraint.Apply();
2958 Stage::GetCurrent().Add( child );
2960 app.SendNotification();
2963 app.SendNotification();
2965 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2969 int UtcDaliActorConstrainedToOpacity(void)
2971 TestApplication app;
2972 tet_infoline(" UtcDaliActorConstrainedToOpacity");
2974 Actor parent = Actor::New();
2975 parent.SetOpacity( 0.7f );
2976 Stage::GetCurrent().Add( parent );
2978 Actor child = Actor::New();
2979 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2980 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2981 opacityConstraint.Apply();
2983 Stage::GetCurrent().Add( child );
2985 app.SendNotification();
2988 app.SendNotification();
2990 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2992 parent.SetOpacity( 0.3f );
2994 app.SendNotification();
2997 app.SendNotification();
2999 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3004 int UtcDaliActorUnparent(void)
3006 TestApplication app;
3007 tet_infoline(" UtcDaliActorUnparent");
3009 Actor parent = Actor::New();
3010 Stage::GetCurrent().Add( parent );
3012 Actor child = Actor::New();
3014 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3015 DALI_TEST_CHECK( !child.GetParent() );
3017 // Test that calling Unparent with no parent is a NOOP
3020 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3021 DALI_TEST_CHECK( !child.GetParent() );
3023 // Test that Unparent works
3024 parent.Add( child );
3026 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3027 DALI_TEST_CHECK( parent == child.GetParent() );
3031 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3032 DALI_TEST_CHECK( !child.GetParent() );
3034 // Test that UnparentAndReset works
3035 parent.Add( child );
3037 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3038 DALI_TEST_CHECK( parent == child.GetParent() );
3040 UnparentAndReset( child );
3042 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3043 DALI_TEST_CHECK( !child );
3045 // Test that UnparentAndReset is a NOOP with empty handle
3046 UnparentAndReset( child );
3048 DALI_TEST_CHECK( !child );
3052 int UtcDaliActorGetChildAt(void)
3054 TestApplication app;
3055 tet_infoline(" UtcDaliActorGetChildAt");
3057 Actor parent = Actor::New();
3058 Stage::GetCurrent().Add( parent );
3060 Actor child0 = Actor::New();
3061 parent.Add( child0 );
3063 Actor child1 = Actor::New();
3064 parent.Add( child1 );
3066 Actor child2 = Actor::New();
3067 parent.Add( child2 );
3069 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3070 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3071 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3075 int UtcDaliActorSetGetOverlay(void)
3077 TestApplication app;
3078 tet_infoline(" UtcDaliActorSetGetOverlay");
3080 Actor parent = Actor::New();
3081 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3082 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3087 int UtcDaliActorCreateDestroy(void)
3089 Actor* actor = new Actor;
3090 DALI_TEST_CHECK( actor );
3097 struct PropertyStringIndex
3099 const char * const name;
3100 const Property::Index index;
3101 const Property::Type type;
3104 const PropertyStringIndex PROPERTY_TABLE[] =
3106 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3107 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3108 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3109 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3110 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3111 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3112 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3113 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3114 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3115 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3116 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3117 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3118 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3119 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3120 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3121 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3122 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3123 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3124 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3125 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3126 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3127 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3128 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3129 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3130 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3131 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3132 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3133 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3134 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3135 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3136 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3137 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3138 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3139 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3140 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3141 { "name", Actor::Property::NAME, Property::STRING },
3142 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3143 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3144 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3145 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3146 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3147 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3148 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3149 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3150 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3151 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3152 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3153 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3154 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3155 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3156 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3157 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3158 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3159 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3160 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3162 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3163 } // unnamed namespace
3165 int UtcDaliActorProperties(void)
3167 TestApplication app;
3169 Actor actor = Actor::New();
3171 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3173 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3174 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3175 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3176 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3181 int UtcDaliRelayoutProperties_ResizePolicies(void)
3183 TestApplication app;
3185 Actor actor = Actor::New();
3188 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3189 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3191 // Set resize policy for all dimensions
3192 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3193 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3195 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3198 // Set individual dimensions
3199 const char* const widthPolicy = "FILL_TO_PARENT";
3200 const char* const heightPolicy = "FIXED";
3202 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3203 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3205 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3206 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3208 // Set individual dimensions using enums
3209 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3210 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3212 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3213 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3215 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3216 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3221 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3223 TestApplication app;
3225 Actor actor = Actor::New();
3228 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3229 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3231 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3232 actor.SetSizeScalePolicy( policy );
3233 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3236 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3237 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3239 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3240 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3242 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3243 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3248 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3250 TestApplication app;
3252 Actor actor = Actor::New();
3255 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3256 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3258 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3259 actor.SetSizeModeFactor( sizeMode );
3260 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3263 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3265 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3266 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3271 int UtcDaliRelayoutProperties_DimensionDependency(void)
3273 TestApplication app;
3275 Actor actor = Actor::New();
3278 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3279 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3282 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3283 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3285 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3286 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3288 // Test setting another resize policy
3289 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3290 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3295 int UtcDaliRelayoutProperties_Padding(void)
3297 TestApplication app;
3299 Actor actor = Actor::New();
3302 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3305 actor.SetProperty( Actor::Property::PADDING, padding );
3306 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3308 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3313 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3315 TestApplication app;
3317 Actor actor = Actor::New();
3320 Vector2 minSize( 1.0f, 2.0f );
3322 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3323 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3325 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3327 Vector2 maxSize( 3.0f, 4.0f );
3329 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3330 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3332 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3337 int UtcDaliActorGetHeightForWidth(void)
3339 TestApplication app;
3341 Actor actor = Actor::New();
3343 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3348 int UtcDaliActorGetWidthForHeight(void)
3350 TestApplication app;
3352 Actor actor = Actor::New();
3354 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3359 int UtcDaliActorGetRelayoutSize(void)
3361 TestApplication app;
3363 Actor actor = Actor::New();
3365 // Add actor to stage
3366 Stage::GetCurrent().Add( actor );
3368 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3370 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3371 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3373 // Flush the queue and render once
3374 app.SendNotification();
3377 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3382 int UtcDaliActorSetPadding(void)
3384 TestApplication app;
3386 Actor actor = Actor::New();
3389 actor.GetPadding( padding );
3391 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3392 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3393 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3394 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3396 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3397 actor.SetPadding( padding2 );
3399 actor.GetPadding( padding );
3401 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3402 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3403 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3404 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3409 int UtcDaliActorSetMinimumSize(void)
3411 TestApplication app;
3413 Actor actor = Actor::New();
3415 Vector2 size = actor.GetMinimumSize();
3417 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3418 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3420 Vector2 size2( 1.0f, 2.0f );
3421 actor.SetMinimumSize( size2 );
3423 size = actor.GetMinimumSize();
3425 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3426 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3431 int UtcDaliActorSetMaximumSize(void)
3433 TestApplication app;
3435 Actor actor = Actor::New();
3437 Vector2 size = actor.GetMaximumSize();
3439 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3440 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3442 Vector2 size2( 1.0f, 2.0f );
3443 actor.SetMaximumSize( size2 );
3445 size = actor.GetMaximumSize();
3447 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3448 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3453 int UtcDaliActorOnRelayoutSignal(void)
3455 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3457 TestApplication application;
3460 gOnRelayoutCallBackCalled = false;
3461 gActorNamesRelayout.clear();
3463 Actor actor = Actor::New();
3464 actor.SetName( "actor" );
3465 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3468 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3470 // Add actor to stage
3471 Stage::GetCurrent().Add( actor );
3473 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3474 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3476 // Flush the queue and render once
3477 application.SendNotification();
3478 application.Render();
3480 // OnRelayout emitted
3481 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3482 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3487 int UtcDaliActorGetHierachyDepth(void)
3489 TestApplication application;
3490 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3493 /* Build tree of actors:
3503 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3505 Stage stage( Stage::GetCurrent() );
3507 Actor actorA = Actor::New();
3508 Actor actorB = Actor::New();
3509 Actor actorC = Actor::New();
3510 Actor actorD = Actor::New();
3511 Actor actorE = Actor::New();
3512 Actor actorF = Actor::New();
3514 //Test that root actor has depth equal 0
3515 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3517 //Test actors return depth -1 when not connected to the tree
3518 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3519 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3520 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3521 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3522 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3523 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3525 //Create the hierarchy
3526 stage.Add( actorA );
3527 actorA.Add( actorB );
3528 actorA.Add( actorC );
3529 actorB.Add( actorD );
3530 actorB.Add( actorE );
3531 actorC.Add( actorF );
3533 //Test actors return correct depth
3534 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3535 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3536 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3537 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3538 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3539 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3541 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3542 actorA.Remove( actorB );
3544 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3545 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3546 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3548 //Removing actorA from the stage. All actors should have depth equal -1
3549 stage.Remove( actorA );
3551 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3552 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3553 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3554 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3555 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3556 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3561 int UtcDaliActorAnchorPointPropertyAsString(void)
3563 TestApplication application;
3565 Actor actor = Actor::New();
3567 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3568 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3570 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3571 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3573 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3574 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3576 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3577 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3579 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3580 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3582 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3583 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3585 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3586 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3588 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3589 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3591 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3592 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3594 // Invalid should not change anything
3595 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3596 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3601 int UtcDaliActorParentOriginPropertyAsString(void)
3603 TestApplication application;
3605 Actor actor = Actor::New();
3607 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3608 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3610 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3611 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3613 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3614 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3616 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3617 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3619 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3620 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3622 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3623 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3625 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3626 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3628 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3629 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3631 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3632 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3634 // Invalid should not change anything
3635 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3636 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3641 int UtcDaliActorColorModePropertyAsString(void)
3643 TestApplication application;
3645 Actor actor = Actor::New();
3647 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3648 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3650 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3651 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3653 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3654 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3656 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3657 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3659 // Invalid should not change anything
3660 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3661 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3666 int UtcDaliActorPositionInheritancePropertyAsString(void)
3668 TestApplication application;
3670 Actor actor = Actor::New();
3672 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3673 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3675 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3676 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3678 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3679 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3681 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3682 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3684 // Invalid should not change anything
3685 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3686 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3691 int UtcDaliActorDrawModePropertyAsString(void)
3693 TestApplication application;
3695 Actor actor = Actor::New();
3697 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3698 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3700 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3701 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3703 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3704 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3706 // Invalid should not change anything
3707 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3708 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3713 int UtcDaliActorColorModePropertyAsEnum(void)
3715 TestApplication application;
3717 Actor actor = Actor::New();
3719 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3720 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3722 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3723 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3725 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3726 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3728 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3729 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3734 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3736 TestApplication application;
3738 Actor actor = Actor::New();
3740 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3741 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3743 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3744 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3746 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3747 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3749 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3750 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3755 int UtcDaliActorDrawModePropertyAsEnum(void)
3757 TestApplication application;
3759 Actor actor = Actor::New();
3761 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3762 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3764 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3765 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3767 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3768 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3773 int UtcDaliActorAddRendererP(void)
3775 tet_infoline("Testing Actor::AddRenderer");
3776 TestApplication application;
3778 Actor actor = Actor::New();
3780 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3782 Geometry geometry = CreateQuadGeometry();
3783 Shader shader = CreateShader();
3784 Renderer renderer = Renderer::New(geometry, shader);
3786 actor.AddRenderer( renderer );
3787 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3788 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3793 int UtcDaliActorAddRendererN(void)
3795 tet_infoline("Testing Actor::AddRenderer");
3796 TestApplication application;
3798 Actor actor = Actor::New();
3804 actor.AddRenderer( renderer );
3805 tet_printf("Assertion test failed - no Exception\n" );
3806 tet_result(TET_FAIL);
3808 catch(Dali::DaliException& e)
3810 DALI_TEST_PRINT_ASSERT( e );
3811 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3812 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3816 tet_printf("Assertion test failed - wrong Exception\n" );
3817 tet_result(TET_FAIL);
3823 int UtcDaliActorAddRendererOnStage(void)
3825 tet_infoline("Testing Actor::AddRenderer");
3826 TestApplication application;
3828 Actor actor = Actor::New();
3829 Stage::GetCurrent().Add(actor);
3831 application.SendNotification();
3832 application.Render(0);
3834 Geometry geometry = CreateQuadGeometry();
3835 Shader shader = CreateShader();
3836 Renderer renderer = Renderer::New(geometry, shader);
3838 application.SendNotification();
3839 application.Render(0);
3843 actor.AddRenderer( renderer );
3844 tet_result(TET_PASS);
3848 tet_result(TET_FAIL);
3854 int UtcDaliActorRemoveRendererP1(void)
3856 tet_infoline("Testing Actor::RemoveRenderer");
3857 TestApplication application;
3859 Actor actor = Actor::New();
3861 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3864 Geometry geometry = CreateQuadGeometry();
3865 Shader shader = CreateShader();
3866 Renderer renderer = Renderer::New(geometry, shader);
3868 actor.AddRenderer( renderer );
3869 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3870 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3872 application.SendNotification();
3873 application.Render();
3877 Renderer renderer = actor.GetRendererAt(0);
3878 actor.RemoveRenderer(renderer);
3879 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3881 application.SendNotification();
3882 application.Render();
3885 // Call one final time to ensure that the renderer is actually removed after
3886 // the handle goes out of scope, and excercises the deletion code path in
3887 // scene graph and render.
3888 application.SendNotification();
3889 application.Render();
3894 int UtcDaliActorRemoveRendererP2(void)
3896 tet_infoline("Testing Actor::RemoveRenderer");
3897 TestApplication application;
3899 Actor actor = Actor::New();
3901 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3903 Geometry geometry = CreateQuadGeometry();
3904 Shader shader = CreateShader();
3905 Renderer renderer = Renderer::New(geometry, shader);
3907 actor.AddRenderer( renderer );
3908 application.SendNotification();
3909 application.Render();
3911 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3912 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3914 actor.RemoveRenderer(0);
3915 application.SendNotification();
3916 application.Render();
3918 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3920 // Shut down whilst holding onto the renderer handle.
3925 int UtcDaliActorRemoveRendererN(void)
3927 tet_infoline("Testing Actor::RemoveRenderer");
3928 TestApplication application;
3930 Actor actor = Actor::New();
3932 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3934 Geometry geometry = CreateQuadGeometry();
3935 Shader shader = CreateShader();
3936 Renderer renderer = Renderer::New(geometry, shader);
3938 actor.AddRenderer( renderer );
3939 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3940 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3942 actor.RemoveRenderer(10);
3943 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3944 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3949 // Clipping test helper functions:
3950 Actor CreateActorWithContent( uint32_t width, uint32_t height)
3952 BufferImage image = BufferImage::New( width, height );
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( width, height );
3958 actor.SetParentOrigin( ParentOrigin::CENTER );
3959 actor.SetAnchorPoint( AnchorPoint::CENTER );
3964 Actor CreateActorWithContent16x16()
3966 return CreateActorWithContent( 16, 16 );
3969 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3971 enabledDisableTrace.Reset();
3972 stencilTrace.Reset();
3973 enabledDisableTrace.Enable( true );
3974 stencilTrace.Enable( true );
3976 application.SendNotification();
3977 application.Render();
3979 enabledDisableTrace.Enable( false );
3980 stencilTrace.Enable( false );
3983 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3985 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3987 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3988 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3989 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3990 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3993 int UtcDaliActorPropertyClippingP(void)
3995 // This test checks the clippingMode property.
3996 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
3997 TestApplication application;
3999 Actor actor = Actor::New();
4001 // Check default clippingEnabled value.
4002 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4005 bool getValueResult = getValue.Get( value );
4006 DALI_TEST_CHECK( getValueResult );
4008 if( getValueResult )
4010 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4013 // Check setting the property to the stencil mode.
4014 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4016 // Check the new value was set.
4017 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4018 getValueResult = getValue.Get( value );
4019 DALI_TEST_CHECK( getValueResult );
4021 if( getValueResult )
4023 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4026 // Check setting the property to the scissor mode.
4027 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4029 // Check the new value was set.
4030 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4031 getValueResult = getValue.Get( value );
4032 DALI_TEST_CHECK( getValueResult );
4034 if( getValueResult )
4036 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4041 int UtcDaliActorPropertyClippingN(void)
4043 // Negative test case for Clipping.
4044 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4045 TestApplication application;
4047 Actor actor = Actor::New();
4049 // Check default clippingEnabled value.
4050 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4053 bool getValueResult = getValue.Get( value );
4054 DALI_TEST_CHECK( getValueResult );
4056 if( getValueResult )
4058 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4061 // Check setting an invalid property value won't change the current property value.
4062 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4064 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4065 getValueResult = getValue.Get( value );
4066 DALI_TEST_CHECK( getValueResult );
4068 if( getValueResult )
4070 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4076 int UtcDaliActorPropertyClippingActor(void)
4078 // This test checks that an actor is correctly setup for clipping.
4079 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4080 TestApplication application;
4082 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4083 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4084 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4085 size_t startIndex = 0u;
4087 // Create a clipping actor.
4088 Actor actorDepth1Clip = CreateActorWithContent16x16();
4089 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4090 Stage::GetCurrent().Add( actorDepth1Clip );
4092 // Gather the call trace.
4093 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4095 // Check we are writing to the color buffer.
4096 CheckColorMask( glAbstraction, true );
4098 // Check the stencil buffer was enabled.
4099 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4101 // Check the stencil buffer was cleared.
4102 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4104 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4105 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4106 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4107 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4112 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4114 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4115 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4116 TestApplication application;
4118 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4119 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4120 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4121 size_t startIndex = 0u;
4123 // Create a clipping actor.
4124 Actor actorDepth1Clip = CreateActorWithContent16x16();
4125 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4126 Stage::GetCurrent().Add( actorDepth1Clip );
4128 // Gather the call trace.
4129 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4131 // Check we are writing to the color buffer.
4132 CheckColorMask( glAbstraction, true );
4134 // Check the stencil buffer was enabled.
4135 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4137 // Check the stencil buffer was cleared.
4138 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4140 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4141 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4142 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4143 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4145 // Now disable the clipping
4146 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4148 // Gather the call trace.
4149 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4151 // Check the stencil buffer was disabled.
4152 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4154 // Ensure all values in stencil-mask are set to 1.
4156 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4161 int UtcDaliActorPropertyClippingNestedChildren(void)
4163 // This test checks that a hierarchy of actors are clipped correctly by
4164 // writing to and reading from the correct bit-planes of the stencil buffer.
4165 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4166 TestApplication application;
4167 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4168 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4169 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4171 // Create a clipping actor.
4172 Actor actorDepth1Clip = CreateActorWithContent16x16();
4173 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4174 Stage::GetCurrent().Add( actorDepth1Clip );
4176 // Create a child actor.
4177 Actor childDepth2 = CreateActorWithContent16x16();
4178 actorDepth1Clip.Add( childDepth2 );
4180 // Create another clipping actor.
4181 Actor childDepth2Clip = CreateActorWithContent16x16();
4182 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4183 childDepth2.Add( childDepth2Clip );
4185 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4186 // This tests the sort algorithm.
4187 Actor childDepth3 = CreateActorWithContent16x16();
4188 childDepth2Clip.Add( childDepth3 );
4189 Actor childDepth4 = CreateActorWithContent16x16();
4190 childDepth3.Add( childDepth4 );
4192 // Gather the call trace.
4193 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4195 // Check we are writing to the color buffer.
4196 CheckColorMask( glAbstraction, true );
4198 // Check the stencil buffer was enabled.
4199 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4201 // Perform the test twice, once for 2D layer, and once for 3D.
4202 for( unsigned int i = 0u ; i < 2u; ++i )
4204 size_t startIndex = 0u;
4206 // Check the stencil buffer was cleared.
4207 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4209 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4210 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4211 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4212 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4214 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4215 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4216 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4218 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4219 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4220 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4221 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4223 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4224 // (Both must be set to pass the check).
4225 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4226 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4228 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4231 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4232 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4239 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4241 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4242 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4243 TestApplication application;
4244 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4245 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4247 /* We create a small tree of actors as follows:
4251 Clipping enabled -> B D
4255 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4258 for( int i = 0; i < 5; ++i )
4260 BufferImage image = BufferImage::New( 16u, 16u );
4261 Actor actor = CreateRenderableActor( image );
4263 // Setup dimensions and position so actor is not skipped by culling.
4264 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4265 actor.SetSize( 16.0f, 16.0f );
4269 actor.SetParentOrigin( ParentOrigin::CENTER );
4273 float b = i > 2 ? 1.0f : -1.0f;
4274 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4280 // Enable clipping on the actor at the top of the left branch.
4281 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4283 // Build the scene graph.
4284 Stage::GetCurrent().Add( actors[0] );
4287 actors[0].Add( actors[1] );
4288 actors[1].Add( actors[2] );
4291 actors[0].Add( actors[3] );
4292 actors[3].Add( actors[4] );
4294 // Gather the call trace.
4295 enabledDisableTrace.Reset();
4296 enabledDisableTrace.Enable( true );
4297 application.SendNotification();
4298 application.Render();
4299 enabledDisableTrace.Enable( false );
4301 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4303 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
4304 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4306 size_t startIndex = 0u;
4307 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4308 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4309 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4311 // Swap the clipping actor from top of left branch to top of right branch.
4312 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4313 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4315 // Gather the call trace.
4316 enabledDisableTrace.Reset();
4317 enabledDisableTrace.Enable( true );
4318 application.SendNotification();
4319 application.Render();
4320 enabledDisableTrace.Enable( false );
4322 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4323 // This proves the draw order has remained the same.
4325 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4326 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4331 int UtcDaliActorPropertyScissorClippingActor(void)
4333 // This test checks that an actor is correctly setup for clipping.
4334 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4335 TestApplication application;
4337 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4338 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4339 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4341 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4342 const Vector2 imageSize( 16.0f, 16.0f );
4344 // Create a clipping actor.
4345 Actor clippingActorA = CreateActorWithContent16x16();
4346 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4347 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4348 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4349 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4350 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4351 Stage::GetCurrent().Add( clippingActorA );
4353 // Gather the call trace.
4354 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4356 // Check we are writing to the color buffer.
4357 CheckColorMask( glAbstraction, true );
4359 // Check scissor test was enabled.
4360 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4362 // Check the scissor was set, and the coordinates are correct.
4363 std::stringstream compareParametersString;
4364 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4365 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4367 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4368 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4370 // Gather the call trace.
4371 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4373 // Check the scissor was set, and the coordinates are correct.
4374 compareParametersString.str( std::string() );
4375 compareParametersString.clear();
4376 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4377 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4382 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4384 // This test checks that an actor is correctly setup for clipping.
4385 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4386 TestApplication application;
4389 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4390 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4391 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4393 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4394 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4395 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4397 // Create a clipping actors.
4398 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4399 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4401 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4402 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4403 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4405 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4406 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4407 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4409 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4410 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4412 Stage::GetCurrent().Add( clippingActorA );
4413 Stage::GetCurrent().Add( clippingActorB );
4415 // Gather the call trace.
4416 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4418 // Check we are writing to the color buffer.
4419 CheckColorMask( glAbstraction, true );
4421 // Check scissor test was enabled.
4422 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4424 // Check the scissor was set, and the coordinates are correct.
4425 std::stringstream compareParametersString;
4427 std::string clipA( "0, 500, 480, 200" );
4428 std::string clipB( "0, 380, 480, 40" );
4430 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4431 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4436 int UtcDaliActorPropertyScissorClippingActorNested(void)
4438 // This test checks that an actor is correctly setup for clipping.
4439 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4440 TestApplication application;
4442 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4443 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4444 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4446 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4447 const Vector2 imageSize( 16.0f, 16.0f );
4449 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4451 A is drawn first - with scissor clipping on
4452 B is drawn second - also with scissor clipping on
4453 C is the generated clipping region, the intersection ( A ∩ B )
4457 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4458 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4459 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4463 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4466 // Create a clipping actor.
4467 Actor clippingActorA = CreateActorWithContent16x16();
4468 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4469 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4470 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4471 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4472 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4473 Stage::GetCurrent().Add( clippingActorA );
4475 // Create a child clipping actor.
4476 Actor clippingActorB = CreateActorWithContent16x16();
4477 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4478 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4479 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4480 clippingActorA.Add( clippingActorB );
4482 // positionModifiers is an array of positions to position B around.
4483 // expect is an array of expected scissor clip coordinate results.
4484 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4485 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4487 // Loop through each overlap combination.
4488 for( unsigned int test = 0u; test < 4u; ++test )
4490 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4491 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4492 clippingActorB.SetPosition( position.x, position.y );
4494 // Gather the call trace.
4495 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4497 // Check we are writing to the color buffer.
4498 CheckColorMask( glAbstraction, true );
4500 // Check scissor test was enabled.
4501 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4503 // Check the scissor was set, and the coordinates are correct.
4504 const Vector4& expectResults( expect[test] );
4505 std::stringstream compareParametersString;
4506 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4507 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4513 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4515 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4516 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4517 TestApplication application;
4519 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4520 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4521 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4523 // Create a clipping actor.
4524 Actor actorDepth1Clip = CreateActorWithContent16x16();
4525 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4526 Stage::GetCurrent().Add( actorDepth1Clip );
4528 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4529 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4531 // Gather the call trace.
4532 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4534 // Check we are writing to the color buffer.
4535 CheckColorMask( glAbstraction, true );
4537 // Check the stencil buffer was not enabled.
4538 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4540 // Check stencil functions are not called.
4541 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4542 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4543 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4545 // Check that scissor clipping is overriden by the renderer properties.
4546 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4548 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4550 // Gather the call trace.
4551 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4553 // Check the stencil buffer was not enabled.
4554 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4556 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4561 int UtcDaliGetPropertyN(void)
4563 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4564 TestApplication app;
4566 Actor actor = Actor::New();
4568 unsigned int propertyCount = actor.GetPropertyCount();
4569 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4573 int UtcDaliActorRaiseLower(void)
4575 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4577 TestApplication application;
4579 Stage stage( Stage::GetCurrent() );
4581 Actor actorA = Actor::New();
4582 Actor actorB = Actor::New();
4583 Actor actorC = Actor::New();
4585 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4586 actorA.SetParentOrigin( ParentOrigin::CENTER );
4588 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4589 actorB.SetParentOrigin( ParentOrigin::CENTER );
4591 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4592 actorC.SetParentOrigin( ParentOrigin::CENTER );
4594 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4595 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4597 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4598 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4600 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4601 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4603 stage.Add( actorA );
4604 stage.Add( actorB );
4605 stage.Add( actorC );
4607 ResetTouchCallbacks();
4609 application.SendNotification();
4610 application.Render();
4612 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4613 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4614 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4616 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4617 // Only top actor will get touched.
4618 actorA.TouchSignal().Connect( TestTouchCallback );
4619 actorB.TouchSignal().Connect( TestTouchCallback2 );
4620 actorC.TouchSignal().Connect( TestTouchCallback3 );
4622 Dali::Integration::Point point;
4623 point.SetDeviceId( 1 );
4624 point.SetState( PointState::DOWN );
4625 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4626 Dali::Integration::TouchEvent touchEvent;
4627 touchEvent.AddPoint( point );
4629 application.ProcessEvent( touchEvent );
4631 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4632 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4633 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4635 ResetTouchCallbacks();
4637 tet_printf( "Testing Raising of Actor\n" );
4639 int preActorOrder( 0 );
4640 int postActorOrder( 0 );
4642 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4643 value.Get( preActorOrder );
4646 // Ensure sort order is calculated before next touch event
4647 application.SendNotification();
4649 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4650 value.Get( postActorOrder );
4652 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4654 application.ProcessEvent( touchEvent );
4656 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4657 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4658 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4660 ResetTouchCallbacks();
4662 tet_printf( "Testing Lowering of Actor\n" );
4664 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4665 value.Get( preActorOrder );
4668 application.SendNotification(); // ensure sort order calculated before next touch event
4670 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4671 value.Get( postActorOrder );
4673 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4675 application.ProcessEvent( touchEvent );
4677 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4678 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4679 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4681 ResetTouchCallbacks();
4686 int UtcDaliActorRaiseToTopLowerToBottom(void)
4688 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4690 TestApplication application;
4692 Stage stage( Stage::GetCurrent() );
4694 Actor actorA = Actor::New();
4695 Actor actorB = Actor::New();
4696 Actor actorC = Actor::New();
4698 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4699 // enables checking of which actor the uniform is assigned too
4700 Shader shaderA = CreateShader();
4701 shaderA.RegisterProperty( "uRendererColor",1.f);
4703 Shader shaderB = CreateShader();
4704 shaderB.RegisterProperty( "uRendererColor", 2.f );
4706 Shader shaderC = CreateShader();
4707 shaderC.RegisterProperty( "uRendererColor", 3.f );
4709 Geometry geometry = CreateQuadGeometry();
4711 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4712 Renderer rendererA = Renderer::New(geometry, shaderA);
4713 actorA.AddRenderer(rendererA);
4715 Renderer rendererB = Renderer::New(geometry, shaderB);
4716 actorB.AddRenderer(rendererB);
4718 Renderer rendererC = Renderer::New(geometry, shaderC);
4719 actorC.AddRenderer(rendererC);
4721 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4722 actorA.SetParentOrigin( ParentOrigin::CENTER );
4724 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4725 actorB.SetParentOrigin( ParentOrigin::CENTER );
4727 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4728 actorC.SetParentOrigin( ParentOrigin::CENTER );
4730 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4731 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4733 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4734 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4736 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4737 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4739 stage.Add( actorA );
4740 stage.Add( actorB );
4741 stage.Add( actorC );
4743 ResetTouchCallbacks();
4745 // Set up gl abstraction trace so can query the set uniform order
4746 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4747 glAbstraction.EnableSetUniformCallTrace(true);
4748 glAbstraction.ResetSetUniformCallStack();
4750 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4752 application.SendNotification();
4753 application.Render();
4755 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4758 // Test order of uniforms in stack
4759 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4760 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4761 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4763 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4765 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4767 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4768 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4769 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4771 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4772 // Only top actor will get touched.
4773 actorA.TouchSignal().Connect( TestTouchCallback );
4774 actorB.TouchSignal().Connect( TestTouchCallback2 );
4775 actorC.TouchSignal().Connect( TestTouchCallback3 );
4777 Dali::Integration::Point point;
4778 point.SetDeviceId( 1 );
4779 point.SetState( PointState::DOWN );
4780 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4781 Dali::Integration::TouchEvent touchEvent;
4782 touchEvent.AddPoint( point );
4784 application.ProcessEvent( touchEvent );
4786 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4787 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4788 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4790 ResetTouchCallbacks();
4792 tet_printf( "RaiseToTop ActorA\n" );
4794 actorA.RaiseToTop();
4795 application.SendNotification(); // ensure sorting order is calculated before next touch event
4797 application.ProcessEvent( touchEvent );
4799 glAbstraction.ResetSetUniformCallStack();
4800 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4802 application.SendNotification();
4803 application.Render();
4805 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4807 // Test order of uniforms in stack
4808 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4809 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4810 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4812 tet_infoline( "Testing A above C and B at bottom\n" );
4813 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4815 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4817 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4818 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4819 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4821 ResetTouchCallbacks();
4823 tet_printf( "RaiseToTop ActorB\n" );
4825 actorB.RaiseToTop();
4826 application.SendNotification(); // Ensure sort order is calculated before next touch event
4828 application.ProcessEvent( touchEvent );
4830 glAbstraction.ResetSetUniformCallStack();
4831 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4833 application.SendNotification();
4834 application.Render();
4836 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4838 // Test order of uniforms in stack
4839 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4840 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4841 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4843 tet_infoline( "Testing B above A and C at bottom\n" );
4844 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4846 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4848 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4849 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4850 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4852 ResetTouchCallbacks();
4854 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4856 actorA.LowerToBottom();
4857 application.SendNotification();
4858 application.Render();
4860 actorB.LowerToBottom();
4861 application.SendNotification();
4862 application.Render();
4864 application.ProcessEvent( touchEvent );
4866 glAbstraction.ResetSetUniformCallStack();
4867 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4869 application.SendNotification();
4870 application.Render();
4872 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4874 // Test order of uniforms in stack
4875 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4876 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4877 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4879 tet_infoline( "Testing C above A and B at bottom\n" );
4880 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4882 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4884 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4885 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4886 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4888 ResetTouchCallbacks();
4893 int UtcDaliActorRaiseAbove(void)
4895 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4897 TestApplication application;
4899 Stage stage( Stage::GetCurrent() );
4901 Actor actorA = Actor::New();
4902 Actor actorB = Actor::New();
4903 Actor actorC = Actor::New();
4905 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4906 actorA.SetParentOrigin( ParentOrigin::CENTER );
4908 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4909 actorB.SetParentOrigin( ParentOrigin::CENTER );
4911 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4912 actorC.SetParentOrigin( ParentOrigin::CENTER );
4914 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4915 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4917 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4918 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4920 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4921 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4923 stage.Add( actorA );
4924 stage.Add( actorB );
4925 stage.Add( actorC );
4927 ResetTouchCallbacks();
4929 application.SendNotification();
4930 application.Render();
4932 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4933 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4934 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4936 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4937 // Only top actor will get touched.
4938 actorA.TouchSignal().Connect( TestTouchCallback );
4939 actorB.TouchSignal().Connect( TestTouchCallback2 );
4940 actorC.TouchSignal().Connect( TestTouchCallback3 );
4942 Dali::Integration::Point point;
4943 point.SetDeviceId( 1 );
4944 point.SetState( PointState::DOWN );
4945 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4946 Dali::Integration::TouchEvent touchEvent;
4947 touchEvent.AddPoint( point );
4949 application.ProcessEvent( touchEvent );
4951 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4952 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4953 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4955 ResetTouchCallbacks();
4957 tet_printf( "Raise actor B Above Actor C\n" );
4959 actorB.RaiseAbove( actorC );
4960 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4961 application.SendNotification();
4963 application.ProcessEvent( touchEvent );
4965 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4966 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4967 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4969 ResetTouchCallbacks();
4971 tet_printf( "Raise actor A Above Actor B\n" );
4973 actorA.RaiseAbove( actorB );
4975 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4976 application.SendNotification();
4978 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
4980 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4981 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4982 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4984 ResetTouchCallbacks();
4989 int UtcDaliActorLowerBelow(void)
4991 tet_infoline( "UtcDaliActor LowerBelow test \n" );
4993 TestApplication application;
4995 Stage stage( Stage::GetCurrent() );
4997 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4998 // enables checking of which actor the uniform is assigned too
4999 Shader shaderA = CreateShader();
5000 shaderA.RegisterProperty( "uRendererColor",1.f);
5002 Shader shaderB = CreateShader();
5003 shaderB.RegisterProperty( "uRendererColor", 2.f );
5005 Shader shaderC = CreateShader();
5006 shaderC.RegisterProperty( "uRendererColor", 3.f );
5008 Actor actorA = Actor::New();
5009 Actor actorB = Actor::New();
5010 Actor actorC = Actor::New();
5012 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5013 Geometry geometry = CreateQuadGeometry();
5015 Renderer rendererA = Renderer::New(geometry, shaderA);
5016 actorA.AddRenderer(rendererA);
5018 Renderer rendererB = Renderer::New(geometry, shaderB);
5019 actorB.AddRenderer(rendererB);
5021 Renderer rendererC = Renderer::New(geometry, shaderC);
5022 actorC.AddRenderer(rendererC);
5024 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5025 actorA.SetParentOrigin( ParentOrigin::CENTER );
5027 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5028 actorB.SetParentOrigin( ParentOrigin::CENTER );
5030 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5031 actorC.SetParentOrigin( ParentOrigin::CENTER );
5033 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5034 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5036 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5037 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5039 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5040 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5042 Actor container = Actor::New();
5043 container.SetParentOrigin( ParentOrigin::CENTER );
5044 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5045 stage.Add( container );
5047 container.Add( actorA );
5048 container.Add( actorB );
5049 container.Add( actorC );
5051 ResetTouchCallbacks();
5053 // Set up gl abstraction trace so can query the set uniform order
5054 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5055 glAbstraction.EnableSetUniformCallTrace(true);
5056 glAbstraction.ResetSetUniformCallStack();
5057 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5059 glAbstraction.ResetSetUniformCallStack();
5061 application.SendNotification();
5062 application.Render();
5064 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5066 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5068 // Test order of uniforms in stack
5069 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5070 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5071 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5073 tet_infoline( "Testing C above B and A at bottom\n" );
5074 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5076 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5078 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5079 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5080 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5082 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5083 // Only top actor will get touched.
5084 actorA.TouchSignal().Connect( TestTouchCallback );
5085 actorB.TouchSignal().Connect( TestTouchCallback2 );
5086 actorC.TouchSignal().Connect( TestTouchCallback3 );
5088 Dali::Integration::Point point;
5089 point.SetDeviceId( 1 );
5090 point.SetState( PointState::DOWN );
5091 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5092 Dali::Integration::TouchEvent touchEvent;
5093 touchEvent.AddPoint( point );
5095 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5097 application.ProcessEvent( touchEvent );
5099 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5100 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5101 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5103 ResetTouchCallbacks();
5105 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" );
5107 actorC.LowerBelow( actorB );
5108 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5109 application.SendNotification();
5110 application.Render();
5112 application.ProcessEvent( touchEvent ); // touch event
5114 glAbstraction.ResetSetUniformCallStack();
5115 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5117 application.SendNotification();
5118 application.Render();
5120 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5122 // Test order of uniforms in stack
5123 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5124 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5125 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5127 tet_infoline( "Testing render order is A, C, B" );
5128 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5129 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5131 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5132 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5133 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5135 ResetTouchCallbacks();
5137 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5139 actorC.LowerBelow( actorA );
5140 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5141 application.SendNotification();
5142 application.Render();
5144 application.ProcessEvent( touchEvent );
5146 glAbstraction.ResetSetUniformCallStack();
5147 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5149 application.Render();
5150 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5152 // Test order of uniforms in stack
5153 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5154 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5155 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5157 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5158 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
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( "Lower actor B below Actor C leaving A on top\n" );
5168 actorB.LowerBelow( actorC );
5169 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5170 application.SendNotification();
5171 application.Render();
5173 application.ProcessEvent( touchEvent );
5175 glAbstraction.ResetSetUniformCallStack();
5176 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5178 application.Render();
5179 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5181 // Test order of uniforms in stack
5182 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5183 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5184 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5186 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5187 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5193 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5195 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5197 TestApplication application;
5199 Stage stage( Stage::GetCurrent() );
5201 Actor parentA = Actor::New();
5202 Actor parentB = Actor::New();
5203 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5204 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5205 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5206 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5208 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5209 parentA.SetParentOrigin( ParentOrigin::CENTER );
5211 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5212 parentB.SetParentOrigin( ParentOrigin::CENTER );
5214 stage.Add( parentA );
5215 stage.Add( parentB );
5217 Actor actorA = Actor::New();
5218 Actor actorB = Actor::New();
5219 Actor actorC = Actor::New();
5221 parentA.Add( actorA );
5222 parentA.Add( actorB );
5224 tet_printf( "Actor C added to different parent from A and B \n" );
5225 parentB.Add( actorC );
5227 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5228 actorA.SetParentOrigin( ParentOrigin::CENTER );
5230 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5231 actorB.SetParentOrigin( ParentOrigin::CENTER );
5233 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5234 actorC.SetParentOrigin( ParentOrigin::CENTER );
5236 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5237 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5239 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5240 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5242 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5243 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5245 ResetTouchCallbacks();
5247 application.SendNotification();
5248 application.Render();
5250 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5251 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5252 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5254 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5255 // Only top actor will get touched.
5256 actorA.TouchSignal().Connect( TestTouchCallback );
5257 actorB.TouchSignal().Connect( TestTouchCallback2 );
5258 actorC.TouchSignal().Connect( TestTouchCallback3 );
5260 Dali::Integration::Point point;
5261 point.SetDeviceId( 1 );
5262 point.SetState( PointState::DOWN );
5263 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5264 Dali::Integration::TouchEvent touchEvent;
5265 touchEvent.AddPoint( point );
5267 application.ProcessEvent( touchEvent );
5269 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5270 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5271 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5273 ResetTouchCallbacks();
5275 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5277 actorA.RaiseAbove( actorC );
5278 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5279 application.SendNotification();
5281 application.ProcessEvent( touchEvent ); // touch event
5283 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5284 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5285 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5287 ResetTouchCallbacks();
5292 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5294 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5296 TestApplication application;
5298 Stage stage( Stage::GetCurrent() );
5300 Actor actorA = Actor::New();
5301 Actor actorB = Actor::New();
5302 Actor actorC = Actor::New();
5304 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5305 actorA.SetParentOrigin( ParentOrigin::CENTER );
5307 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5308 actorB.SetParentOrigin( ParentOrigin::CENTER );
5310 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5311 actorC.SetParentOrigin( ParentOrigin::CENTER );
5313 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5314 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5316 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5317 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5319 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5320 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5322 ResetTouchCallbacks();
5324 application.SendNotification();
5325 application.Render();
5327 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5328 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5329 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5331 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5332 // Only top actor will get touched.
5333 actorA.TouchSignal().Connect( TestTouchCallback );
5334 actorB.TouchSignal().Connect( TestTouchCallback2 );
5335 actorC.TouchSignal().Connect( TestTouchCallback3 );
5337 Dali::Integration::Point point;
5338 point.SetDeviceId( 1 );
5339 point.SetState( PointState::DOWN );
5340 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5341 Dali::Integration::TouchEvent touchEvent;
5342 touchEvent.AddPoint( point );
5344 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5346 actorA.RaiseAbove( actorC );
5347 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5348 application.SendNotification();
5350 application.ProcessEvent( touchEvent );
5352 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5354 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5355 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5356 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5358 ResetTouchCallbacks();
5360 stage.Add ( actorB );
5361 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5362 actorA.LowerBelow( actorC );
5364 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5365 application.SendNotification();
5366 application.Render();
5368 application.ProcessEvent( touchEvent );
5370 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5371 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5372 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5373 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5375 ResetTouchCallbacks();
5377 tet_printf( "Adding Actor A to stage, will be on top\n" );
5379 stage.Add ( actorA );
5380 application.SendNotification();
5381 application.Render();
5383 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5384 actorB.RaiseAbove( actorC );
5385 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5386 application.SendNotification();
5388 application.ProcessEvent( touchEvent );
5390 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5391 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5392 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5393 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5395 ResetTouchCallbacks();
5397 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5398 actorA.LowerBelow( actorC );
5399 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5400 application.SendNotification();
5402 application.ProcessEvent( touchEvent );
5404 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5405 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5406 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5407 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5409 ResetTouchCallbacks();
5411 stage.Add ( actorC );
5412 actorA.RaiseAbove( actorC );
5413 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5414 application.SendNotification();
5415 application.Render();
5417 application.ProcessEvent( touchEvent );
5419 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5420 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5421 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5422 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5427 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5429 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5431 TestApplication application;
5433 Stage stage( Stage::GetCurrent() );
5435 Actor actorA = Actor::New();
5436 Actor actorB = Actor::New();
5437 Actor actorC = Actor::New();
5439 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5440 actorA.SetParentOrigin( ParentOrigin::CENTER );
5442 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5443 actorB.SetParentOrigin( ParentOrigin::CENTER );
5445 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5446 actorC.SetParentOrigin( ParentOrigin::CENTER );
5448 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5449 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5451 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5452 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5454 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5455 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5457 ResetTouchCallbacks();
5459 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5460 // Only top actor will get touched.
5461 actorA.TouchSignal().Connect( TestTouchCallback );
5462 actorB.TouchSignal().Connect( TestTouchCallback2 );
5463 actorC.TouchSignal().Connect( TestTouchCallback3 );
5465 Dali::Integration::Point point;
5466 point.SetDeviceId( 1 );
5467 point.SetState( PointState::DOWN );
5468 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5469 Dali::Integration::TouchEvent touchEvent;
5470 touchEvent.AddPoint( point );
5472 stage.Add ( actorA );
5473 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5476 application.SendNotification();
5477 application.Render();
5479 application.ProcessEvent( touchEvent );
5481 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5483 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5484 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5485 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5487 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5488 ResetTouchCallbacks();
5491 // Sort actor tree before next touch event
5492 application.SendNotification();
5493 application.Render();
5495 application.ProcessEvent( touchEvent );
5497 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5499 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5500 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5501 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5502 ResetTouchCallbacks();
5504 tet_printf( "Lower actor C below B but C not parented\n" );
5507 // Sort actor tree before next touch event
5508 application.SendNotification();
5509 application.Render();
5511 application.ProcessEvent( touchEvent );
5513 tet_printf( "Not parented so Lower should show no effect\n" );
5515 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5516 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5517 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5518 ResetTouchCallbacks();
5520 tet_printf( "Raise actor B to top\n" );
5522 actorB.RaiseToTop();
5523 // Sort actor tree before next touch event
5524 application.SendNotification();
5525 application.Render();
5527 application.ProcessEvent( touchEvent );
5529 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5531 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5532 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5533 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5534 ResetTouchCallbacks();
5536 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5538 stage.Add ( actorB );
5540 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5542 actorC.LowerToBottom();
5543 application.SendNotification();
5544 application.Render();
5546 application.ProcessEvent( touchEvent );
5548 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5550 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5551 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5552 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5553 ResetTouchCallbacks();
5559 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5561 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5563 TestApplication application;
5565 Stage stage( Stage::GetCurrent() );
5567 Actor actorA = Actor::New();
5568 Actor actorB = Actor::New();
5569 Actor actorC = Actor::New();
5571 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5572 actorA.SetParentOrigin( ParentOrigin::CENTER );
5574 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5575 actorB.SetParentOrigin( ParentOrigin::CENTER );
5577 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5578 actorC.SetParentOrigin( ParentOrigin::CENTER );
5580 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5581 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5583 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5584 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5586 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5587 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5589 stage.Add( actorA );
5590 stage.Add( actorB );
5591 stage.Add( actorC );
5593 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5594 // Only top actor will get touched.
5595 actorA.TouchSignal().Connect( TestTouchCallback );
5596 actorB.TouchSignal().Connect( TestTouchCallback2 );
5597 actorC.TouchSignal().Connect( TestTouchCallback3 );
5599 ResetTouchCallbacks();
5601 application.SendNotification();
5602 application.Render();
5604 Dali::Integration::Point point;
5605 point.SetDeviceId( 1 );
5606 point.SetState( PointState::DOWN );
5607 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5608 Dali::Integration::TouchEvent touchEvent;
5609 touchEvent.AddPoint( point );
5611 application.ProcessEvent( touchEvent );
5613 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5614 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5615 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5617 ResetTouchCallbacks();
5619 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5621 actorA.RaiseAbove( actorA );
5622 application.SendNotification();
5623 application.Render();
5625 application.ProcessEvent( touchEvent );
5627 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5629 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5630 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5631 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5633 ResetTouchCallbacks();
5635 actorA.RaiseAbove( actorC );
5636 application.SendNotification();
5637 application.Render();
5639 application.ProcessEvent( touchEvent );
5641 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5642 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5643 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5644 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5649 int UtcDaliActorGetScreenPosition(void)
5651 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5653 TestApplication application;
5655 Stage stage( Stage::GetCurrent() );
5657 Actor actorA = Actor::New();
5658 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5660 Vector2 size2( 10.0f, 20.0f );
5661 actorA.SetSize( size2 );
5663 actorA.SetPosition( 0.f, 0.f );
5665 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5667 stage.Add( actorA );
5669 application.SendNotification();
5670 application.Render();
5672 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5673 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5675 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5676 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5678 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5679 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5681 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5683 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5685 application.SendNotification();
5686 application.Render();
5688 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5689 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5691 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5692 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5694 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5695 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5697 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5699 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5701 application.SendNotification();
5702 application.Render();
5704 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5705 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5707 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5708 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5710 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5711 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5713 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5715 actorA.SetPosition( 30.0, 0.0 );
5717 application.SendNotification();
5718 application.Render();
5720 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5721 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5723 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5724 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5726 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5727 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5729 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5731 actorA.SetPosition( 30.0, 420.0 );
5733 application.SendNotification();
5734 application.Render();
5736 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5737 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5739 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5740 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5742 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5743 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5745 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
5747 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5748 actorA.SetPosition( 30.0, 30.0 );
5750 Actor actorB = Actor::New();
5751 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5752 actorB.SetSize( size2 );
5753 actorB.SetPosition( 10.f, 10.f );
5754 actorA.Add( actorB );
5756 actorA.SetScale( 2.0f );
5758 application.SendNotification();
5759 application.Render();
5761 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5763 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
5764 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
5769 int UtcDaliActorGetScreenPositionAfterScaling(void)
5771 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5773 TestApplication application;
5775 Stage stage( Stage::GetCurrent() );
5777 Actor actorA = Actor::New();
5778 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5780 Vector2 size2( 10.0f, 20.0f );
5781 actorA.SetSize( size2 );
5782 actorA.SetScale( 1.5f );
5783 actorA.SetPosition( 0.f, 0.f );
5785 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5787 stage.Add( actorA );
5789 application.SendNotification();
5790 application.Render();
5792 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5793 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5795 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5796 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5798 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5799 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5801 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5803 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5805 application.SendNotification();
5806 application.Render();
5808 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5809 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5811 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5812 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5814 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5815 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5820 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5822 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5824 TestApplication application;
5826 Stage stage( Stage::GetCurrent() );
5828 Actor actorA = Actor::New();
5829 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5830 actorA.SetParentOrigin( ParentOrigin::CENTER );
5831 Vector2 size2( 10.0f, 20.0f );
5832 actorA.SetSize( size2 );
5833 actorA.SetPosition( 0.f, 0.f );
5835 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5837 stage.Add( actorA );
5839 application.SendNotification();
5840 application.Render();
5842 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5843 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5845 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5846 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5848 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
5849 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
5851 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5853 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5854 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5856 application.SendNotification();
5857 application.Render();
5859 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5860 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5862 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5863 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5865 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5866 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5872 int UtcDaliActorGetScreenPositionWithChildActors(void)
5874 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5876 TestApplication application;
5878 Stage stage( Stage::GetCurrent() );
5880 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5882 Actor actorA = Actor::New();
5883 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5884 actorA.SetParentOrigin( ParentOrigin::CENTER );
5885 Vector2 size1( 10.0f, 20.0f );
5886 actorA.SetSize( size1 );
5887 actorA.SetPosition( 0.f, 0.f );
5889 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5891 Actor parentActorA = Actor::New();
5892 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5893 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5894 Vector2 size2( 30.0f, 60.0f );
5895 parentActorA.SetSize( size2 );
5896 parentActorA.SetPosition( 0.f, 0.f );
5898 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5900 stage.Add( parentActorA );
5901 parentActorA.Add ( actorA );
5903 application.SendNotification();
5904 application.Render();
5906 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5907 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5909 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5910 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5912 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
5913 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
5915 tet_infoline( "Test 2\n");
5917 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5919 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5920 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5922 application.SendNotification();
5923 application.Render();
5925 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5926 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5928 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5929 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5931 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
5932 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
5937 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5939 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5941 TestApplication application;
5943 Stage stage( Stage::GetCurrent() );
5945 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5947 Actor actorA = Actor::New();
5948 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5949 actorA.SetParentOrigin( ParentOrigin::CENTER );
5950 Vector2 size1( 10.0f, 20.0f );
5951 actorA.SetSize( size1 );
5952 actorA.SetPosition( 0.f, 0.f );
5954 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5956 Actor parentActorA = Actor::New();
5957 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5958 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5959 Vector2 size2( 30.0f, 60.0f );
5960 parentActorA.SetSize( size2 );
5961 parentActorA.SetPosition( 0.f, 0.f );
5963 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5965 Actor grandParentActorA = Actor::New();
5966 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5967 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5968 Vector2 size3( 60.0f, 120.0f );
5969 grandParentActorA.SetSize( size3 );
5970 grandParentActorA.SetPosition( 0.f, 0.f );
5972 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5974 stage.Add( grandParentActorA );
5975 grandParentActorA.Add ( parentActorA );
5977 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5979 parentActorA.Add ( actorA );
5981 application.SendNotification();
5982 application.Render();
5984 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5985 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5987 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5988 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5990 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
5991 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
5996 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5998 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6000 TestApplication application;
6002 Stage stage( Stage::GetCurrent() );
6004 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6006 Actor actorA = Actor::New();
6007 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6008 actorA.SetParentOrigin( ParentOrigin::CENTER );
6009 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6010 actorA.SetSize( 10.0f, 20.0f );
6011 stage.Add( actorA );
6013 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6015 Actor actorB = Actor::New();
6016 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6017 actorB.SetParentOrigin( ParentOrigin::CENTER );
6018 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6019 Vector2 actorBSize( 30.0f, 60.0f );
6020 actorB.SetSize( actorBSize );
6021 stage.Add( actorB );
6023 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6025 Actor actorC = Actor::New();
6026 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6027 actorC.SetParentOrigin( ParentOrigin::CENTER );
6028 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6029 Vector2 actorCSize( 60.0f, 120.0f );
6030 actorC.SetSize( actorCSize );
6031 stage.Add( actorC );
6033 application.SendNotification();
6034 application.Render();
6036 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6038 Vector2 center( stage.GetSize() * 0.5f );
6040 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6041 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6042 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6044 tet_infoline( "Add scale to all actors" );
6046 actorA.SetScale( 2.0f );
6047 actorB.SetScale( 2.0f );
6048 actorC.SetScale( 2.0f );
6050 application.SendNotification();
6051 application.Render();
6053 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6054 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6055 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6060 int utcDaliActorPositionUsesAnchorPoint(void)
6062 TestApplication application;
6063 tet_infoline( "Check default behaviour\n" );
6065 Actor actor = Actor::New();
6066 actor.SetParentOrigin( ParentOrigin::CENTER );
6067 actor.SetAnchorPoint( AnchorPoint::CENTER );
6068 actor.SetSize( 100.0f, 100.0f );
6069 Stage::GetCurrent().Add( actor );
6071 application.SendNotification();
6072 application.Render();
6074 tet_infoline( "Check that the world position is in the center\n" );
6075 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6077 tet_infoline( "Set the position uses anchor point property to false\n" );
6078 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6080 application.SendNotification();
6081 application.Render();
6083 tet_infoline( "Check that the world position has changed appropriately\n" );
6084 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6089 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6091 TestApplication application;
6092 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6094 Actor actor = Actor::New();
6095 actor.SetParentOrigin( ParentOrigin::CENTER );
6096 actor.SetAnchorPoint( AnchorPoint::CENTER );
6097 actor.SetSize( 100.0f, 100.0f );
6098 actor.SetScale( 2.0f );
6099 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6100 Stage::GetCurrent().Add( actor );
6102 application.SendNotification();
6103 application.Render();
6105 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6106 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6108 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6109 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6110 application.SendNotification();
6111 application.Render();
6112 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6114 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6115 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6116 application.SendNotification();
6117 application.Render();
6118 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6123 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6125 TestApplication application;
6126 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6128 Actor actor = Actor::New();
6129 actor.SetParentOrigin( ParentOrigin::CENTER );
6130 actor.SetAnchorPoint( AnchorPoint::CENTER );
6131 actor.SetSize( 100.0f, 100.0f );
6132 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6133 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6134 Stage::GetCurrent().Add( actor );
6136 application.SendNotification();
6137 application.Render();
6139 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6140 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6142 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6143 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6144 application.SendNotification();
6145 application.Render();
6146 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6148 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6149 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6150 application.SendNotification();
6151 application.Render();
6152 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6157 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6159 TestApplication application;
6160 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6162 Actor actor = Actor::New();
6163 actor.SetParentOrigin( ParentOrigin::CENTER );
6164 actor.SetAnchorPoint( AnchorPoint::CENTER );
6165 actor.SetSize( 100.0f, 100.0f );
6166 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6167 actor.SetScale( 2.0f );
6168 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6169 Stage::GetCurrent().Add( actor );
6171 application.SendNotification();
6172 application.Render();
6174 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6175 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6177 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6178 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6179 application.SendNotification();
6180 application.Render();
6181 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6183 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6184 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6185 application.SendNotification();
6186 application.Render();
6187 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6192 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6194 TestApplication application;
6195 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6197 Actor parent = Actor::New();
6199 Stage::GetCurrent().Add( parent );
6200 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6202 Actor actor = Actor::New();
6203 actor.SetParentOrigin( ParentOrigin::CENTER );
6204 actor.SetAnchorPoint( AnchorPoint::CENTER );
6205 actor.SetSize( 100.0f, 100.0f );
6206 actor.SetInheritScale( false );
6207 actor.SetInheritOrientation( false );
6208 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6209 parent.Add( actor );
6211 application.SendNotification();
6212 application.Render();
6214 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6216 tet_infoline( "Check the world position is in the right place\n" );
6217 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6219 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6220 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6221 application.SendNotification();
6222 application.Render();
6223 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6225 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6226 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6227 application.SendNotification();
6228 application.Render();
6229 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6234 int utcDaliActorVisibilityChangeSignalSelf(void)
6236 TestApplication application;
6237 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6239 Actor actor = Actor::New();
6241 VisibilityChangedFunctorData data;
6242 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6244 actor.SetVisible( false );
6246 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6248 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6251 actor.SetVisible( false );
6252 data.Check( false /* not called */, TEST_LOCATION );
6254 tet_infoline( "Change the visibility using properties, ensure called" );
6257 actor.SetProperty( Actor::Property::VISIBLE, true );
6258 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6260 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6263 actor.SetProperty( Actor::Property::VISIBLE, true );
6264 data.Check( false /* not called */, TEST_LOCATION );
6269 int utcDaliActorVisibilityChangeSignalChildren(void)
6271 TestApplication application;
6272 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6274 Actor parent = Actor::New();
6275 Actor child = Actor::New();
6276 parent.Add( child );
6278 Actor grandChild = Actor::New();
6279 child.Add( grandChild );
6281 VisibilityChangedFunctorData parentData;
6282 VisibilityChangedFunctorData childData;
6283 VisibilityChangedFunctorData grandChildData;
6285 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6286 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6287 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6289 parent.SetVisible( false );
6290 parentData.Check( false /* not called */, TEST_LOCATION );
6291 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6292 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6294 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6297 grandChildData.Reset();
6299 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6301 parent.SetVisible( true );
6302 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6303 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6304 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6306 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6309 grandChildData.Reset();
6311 parent.SetVisible( true );
6312 parentData.Check( false /* not called */, TEST_LOCATION );
6313 childData.Check( false /* not called */, TEST_LOCATION );
6314 grandChildData.Check( false /* not called */, TEST_LOCATION );
6319 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6321 TestApplication application;
6322 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6324 Actor actor = Actor::New();
6325 Stage::GetCurrent().Add( actor );
6327 application.SendNotification();
6328 application.Render();
6330 VisibilityChangedFunctorData data;
6331 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6333 Animation animation = Animation::New( 1.0f );
6334 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6336 data.Check( false, TEST_LOCATION );
6337 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6338 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6340 tet_infoline( "Play the animation and check the property value" );
6343 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6344 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6346 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6347 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6349 application.SendNotification();
6350 application.Render( 1100 ); // After the animation
6352 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6358 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6360 gLayoutDirectionType = type;
6363 int UtcDaliActorLayoutDirectionProperty(void)
6365 TestApplication application;
6366 tet_infoline( "Check layout direction property" );
6368 Actor actor0 = Actor::New();
6369 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6370 Stage::GetCurrent().Add( actor0 );
6372 application.SendNotification();
6373 application.Render();
6375 Actor actor1 = Actor::New();
6376 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6377 Actor actor2 = Actor::New();
6378 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6379 Actor actor3 = Actor::New();
6380 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6381 Actor actor4 = Actor::New();
6382 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6383 Actor actor5 = Actor::New();
6384 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6385 Actor actor6 = Actor::New();
6386 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6387 Actor actor7 = Actor::New();
6388 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6389 Actor actor8 = Actor::New();
6390 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6391 Actor actor9 = Actor::New();
6392 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6394 actor1.Add( actor2 );
6395 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6396 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6398 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6399 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6400 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6402 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6403 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6404 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6406 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6407 actor0.Add( actor1 );
6408 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6409 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6411 Stage::GetCurrent().Add( actor3 );
6412 actor3.Add( actor4 );
6413 actor4.Add( actor5 );
6414 actor5.Add( actor6 );
6415 actor5.Add( actor7 );
6416 actor7.Add( actor8 );
6417 actor8.Add( actor9 );
6418 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6419 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6421 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6422 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6423 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6425 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6427 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6428 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6429 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6430 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6431 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6432 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6433 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6435 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6436 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6437 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6439 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6440 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6441 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6442 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6444 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6445 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6446 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );