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 UtcDaliActorCustomProperty(void)
628 TestApplication application;
630 Actor actor = Actor::New();
631 Stage::GetCurrent().Add( actor );
633 float startValue(1.0f);
634 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
635 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
637 application.SendNotification();
638 application.Render(0);
639 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
641 actor.SetProperty( index, 5.0f );
643 application.SendNotification();
644 application.Render(0);
645 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 5.0f );
649 int UtcDaliActorCustomPropertyIntToFloat(void)
651 TestApplication application;
653 Actor actor = Actor::New();
654 Stage::GetCurrent().Add( actor );
656 float startValue(5.0f);
657 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
658 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
660 application.SendNotification();
661 application.Render(0);
662 DALI_TEST_CHECK( actor.GetProperty<float>(index) == startValue );
664 actor.SetProperty( index, int(1) );
666 application.SendNotification();
667 application.Render(0);
668 DALI_TEST_CHECK( actor.GetProperty<float>(index) == 1.0f );
672 int UtcDaliActorCustomPropertyFloatToInt(void)
674 TestApplication application;
676 Actor actor = Actor::New();
677 Stage::GetCurrent().Add( actor );
680 Property::Index index = actor.RegisterProperty( "testProperty", startValue );
681 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
683 application.SendNotification();
684 application.Render(0);
685 DALI_TEST_CHECK( actor.GetProperty<int>(index) == startValue );
687 actor.SetProperty( index, float(1.5) );
689 application.SendNotification();
690 application.Render(0);
691 DALI_TEST_CHECK( actor.GetProperty<int>(index) == 1 );
695 int UtcDaliActorSetParentOrigin(void)
697 TestApplication application;
699 Actor actor = Actor::New();
701 Vector3 vector(0.7f, 0.8f, 0.9f);
702 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
704 actor.SetParentOrigin(vector);
706 // flush the queue and render once
707 application.SendNotification();
708 application.Render();
710 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
712 Stage::GetCurrent().Add( actor );
714 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
716 // flush the queue and render once
717 application.SendNotification();
718 application.Render();
720 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
722 Stage::GetCurrent().Remove( actor );
726 int UtcDaliActorSetParentOriginIndividual(void)
728 TestApplication application;
730 Actor actor = Actor::New();
732 Vector3 vector(0.7f, 0.8f, 0.9f);
733 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
735 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
737 // flush the queue and render once
738 application.SendNotification();
739 application.Render();
741 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
743 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
745 // flush the queue and render once
746 application.SendNotification();
747 application.Render();
749 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
751 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
753 // flush the queue and render once
754 application.SendNotification();
755 application.Render();
757 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
762 int UtcDaliActorGetCurrentParentOrigin(void)
764 TestApplication application;
766 Actor actor = Actor::New();
768 Vector3 vector(0.7f, 0.8f, 0.9f);
769 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
771 actor.SetParentOrigin(vector);
773 // flush the queue and render once
774 application.SendNotification();
775 application.Render();
777 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
781 int UtcDaliActorSetAnchorPoint(void)
783 TestApplication application;
785 Actor actor = Actor::New();
787 Vector3 vector(0.7f, 0.8f, 0.9f);
788 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
790 actor.SetAnchorPoint(vector);
792 // flush the queue and render once
793 application.SendNotification();
794 application.Render();
796 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
798 Stage::GetCurrent().Add( actor );
800 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
801 // flush the queue and render once
802 application.SendNotification();
803 application.Render();
805 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
807 Stage::GetCurrent().Remove( actor );
811 int UtcDaliActorSetAnchorPointIndividual(void)
813 TestApplication application;
815 Actor actor = Actor::New();
817 Vector3 vector(0.7f, 0.8f, 0.9f);
818 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
820 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
822 // flush the queue and render once
823 application.SendNotification();
824 application.Render();
826 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
828 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
830 // flush the queue and render once
831 application.SendNotification();
832 application.Render();
834 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
836 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
838 // flush the queue and render once
839 application.SendNotification();
840 application.Render();
842 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
847 int UtcDaliActorGetCurrentAnchorPoint(void)
849 TestApplication application;
851 Actor actor = Actor::New();
853 Vector3 vector(0.7f, 0.8f, 0.9f);
854 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
856 actor.SetAnchorPoint(vector);
858 // flush the queue and render once
859 application.SendNotification();
860 application.Render();
862 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
866 // SetSize(float width, float height)
867 int UtcDaliActorSetSize01(void)
869 TestApplication application;
871 Actor actor = Actor::New();
872 Vector3 vector(100.0f, 100.0f, 0.0f);
874 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
876 actor.SetSize(vector.x, vector.y);
878 // Immediately retrieve the size after setting
879 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
880 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
881 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
882 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
883 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
885 // Flush the queue and render once
886 application.SendNotification();
887 application.Render();
889 // Check the size in the new frame
890 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
892 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
893 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
894 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
895 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
896 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
898 // Check async behaviour
899 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
900 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
901 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
902 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
903 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
905 // Change the resize policy and check whether the size stays the same
906 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
908 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
909 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
911 // Set a new size after resize policy is changed and check the new size
912 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
914 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
915 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
917 // Change the resize policy again and check whether the new size stays the same
918 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
920 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
921 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
923 // Set another new size after resize policy is changed and check the new size
924 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
926 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
927 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
932 // SetSize(float width, float height, float depth)
933 int UtcDaliActorSetSize02(void)
935 TestApplication application;
937 Actor actor = Actor::New();
938 Vector3 vector(100.0f, 100.0f, 100.0f);
940 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
942 actor.SetSize(vector.x, vector.y, vector.z);
944 // Immediately check the size after setting
945 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
946 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
948 // flush the queue and render once
949 application.SendNotification();
950 application.Render();
952 // Check the size in the new frame
953 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
955 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
956 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
961 // SetSize(Vector2 size)
962 int UtcDaliActorSetSize03(void)
964 TestApplication application;
966 Actor actor = Actor::New();
967 Vector3 vector(100.0f, 100.0f, 0.0f);
969 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
971 actor.SetSize(Vector2(vector.x, vector.y));
973 // Immediately check the size after setting
974 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
975 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
977 // flush the queue and render once
978 application.SendNotification();
979 application.Render();
981 // Check the size in the new frame
982 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
984 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
985 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
990 // SetSize(Vector3 size)
991 int UtcDaliActorSetSize04(void)
993 TestApplication application;
995 Actor actor = Actor::New();
996 Vector3 vector(100.0f, 100.0f, 100.0f);
998 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1000 actor.SetSize(vector);
1002 // Immediately check the size after setting
1003 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1004 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1006 // flush the queue and render once
1007 application.SendNotification();
1008 application.Render();
1010 // Check the size in the new frame
1011 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1013 Stage::GetCurrent().Add( actor );
1014 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
1016 // Immediately check the size after setting
1017 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1018 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1020 // flush the queue and render once
1021 application.SendNotification();
1022 application.Render();
1024 // Check the size in the new frame
1025 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
1027 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
1028 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
1030 Stage::GetCurrent().Remove( actor );
1034 int UtcDaliActorSetSizeIndividual(void)
1036 TestApplication application;
1038 Actor actor = Actor::New();
1040 Vector3 vector(0.7f, 0.8f, 0.9f);
1041 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1043 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1045 // Immediately check the width after setting
1046 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1047 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1049 // flush the queue and render once
1050 application.SendNotification();
1051 application.Render();
1053 // Check the width in the new frame
1054 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1056 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1057 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1059 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1061 // Immediately check the height after setting
1062 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1063 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1065 // flush the queue and render once
1066 application.SendNotification();
1067 application.Render();
1069 // Check the height in the new frame
1070 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1072 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1073 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1075 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1077 // Immediately check the depth after setting
1078 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1079 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1081 // flush the queue and render once
1082 application.SendNotification();
1083 application.Render();
1085 // Check the depth in the new frame
1086 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1088 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1089 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1091 // Change the resize policy and check whether the size stays the same
1092 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1094 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1095 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1097 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1098 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1100 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1101 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1103 // Change the resize policy again and check whether the size stays the same
1104 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1106 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1107 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1109 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1110 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1112 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1113 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1118 int UtcDaliActorSetSizeIndividual02(void)
1120 TestApplication application;
1122 Actor actor = Actor::New();
1123 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1124 Stage::GetCurrent().Add( actor );
1126 Vector3 vector( 100.0f, 200.0f, 400.0f );
1127 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1129 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1130 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1132 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1133 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1135 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1136 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1138 // flush the queue and render once
1139 application.SendNotification();
1140 application.Render();
1142 // Check the width in the new frame
1143 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1144 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1150 int UtcDaliActorGetCurrentSize(void)
1152 TestApplication application;
1154 Actor actor = Actor::New();
1155 Vector3 vector(100.0f, 100.0f, 20.0f);
1157 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1159 actor.SetSize(vector);
1161 // flush the queue and render once
1162 application.SendNotification();
1163 application.Render();
1165 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1169 int UtcDaliActorGetNaturalSize(void)
1171 TestApplication application;
1173 Actor actor = Actor::New();
1174 Vector3 vector( 0.0f, 0.0f, 0.0f );
1176 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1181 int UtcDaliActorGetCurrentSizeImmediate(void)
1183 TestApplication application;
1185 Actor actor = Actor::New();
1186 Vector3 vector(100.0f, 100.0f, 20.0f);
1188 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1189 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1191 actor.SetSize(vector);
1193 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1194 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1196 // flush the queue and render once
1197 application.SendNotification();
1198 application.Render();
1200 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1201 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1204 // Build the animation
1205 const float durationSeconds = 2.0f;
1206 Animation animation = Animation::New( durationSeconds );
1207 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1208 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1210 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1212 // Start the animation
1215 application.SendNotification();
1216 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1218 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1223 // SetPosition(float x, float y)
1224 int UtcDaliActorSetPosition01(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, 0.0f));
1233 Vector3 vector(100.0f, 100.0f, 0.0f);
1235 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1237 actor.SetPosition(vector.x, vector.y);
1238 // flush the queue and render once
1239 application.SendNotification();
1240 application.Render();
1241 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1243 Stage::GetCurrent().Add( actor );
1244 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1245 // flush the queue and render once
1246 application.SendNotification();
1247 application.Render();
1248 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1253 // flush the queue and render once
1254 application.SendNotification();
1255 application.Render();
1256 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1258 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1259 // flush the queue and render once
1260 application.SendNotification();
1261 application.Render();
1262 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1264 Stage::GetCurrent().Remove( actor );
1268 // SetPosition(float x, float y, float z)
1269 int UtcDaliActorSetPosition02(void)
1271 TestApplication application;
1273 Actor actor = Actor::New();
1275 // Set to random to start off with
1276 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1278 Vector3 vector(100.0f, 100.0f, 100.0f);
1280 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1282 actor.SetPosition(vector.x, vector.y, vector.z);
1284 // flush the queue and render once
1285 application.SendNotification();
1286 application.Render();
1288 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1292 // SetPosition(Vector3 position)
1293 int UtcDaliActorSetPosition03(void)
1295 TestApplication application;
1297 Actor actor = Actor::New();
1299 // Set to random to start off with
1300 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1302 Vector3 vector(100.0f, 100.0f, 100.0f);
1304 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1306 actor.SetPosition(vector);
1308 // flush the queue and render once
1309 application.SendNotification();
1310 application.Render();
1312 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1316 int UtcDaliActorSetX(void)
1318 TestApplication application;
1320 Actor actor = Actor::New();
1322 Vector3 vector(100.0f, 0.0f, 0.0f);
1324 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1328 // flush the queue and render once
1329 application.SendNotification();
1330 application.Render();
1332 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1336 int UtcDaliActorSetY(void)
1338 TestApplication application;
1340 Actor actor = Actor::New();
1342 Vector3 vector(0.0f, 100.0f, 0.0f);
1344 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1348 // flush the queue and render once
1349 application.SendNotification();
1350 application.Render();
1352 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1356 int UtcDaliActorSetZ(void)
1358 TestApplication application;
1360 Actor actor = Actor::New();
1362 Vector3 vector(0.0f, 0.0f, 100.0f);
1364 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1368 // flush the queue and render once
1369 application.SendNotification();
1370 application.Render();
1372 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1376 int UtcDaliActorSetPositionProperties(void)
1378 TestApplication application;
1380 Actor actor = Actor::New();
1382 Vector3 vector(0.7f, 0.8f, 0.9f);
1383 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1385 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1386 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1387 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1389 // flush the queue and render once
1390 application.SendNotification();
1391 application.Render();
1393 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1394 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1395 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1396 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1397 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1399 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1400 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1401 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1403 // flush the queue and render once
1404 application.SendNotification();
1405 application.Render();
1407 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1408 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1409 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1410 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1411 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1413 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1414 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1415 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1417 // flush the queue and render once
1418 application.SendNotification();
1419 application.Render();
1421 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1422 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1423 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1424 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1425 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1430 int UtcDaliActorTranslateBy(void)
1432 TestApplication application;
1434 Actor actor = Actor::New();
1435 Vector3 vector(100.0f, 100.0f, 100.0f);
1437 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1439 actor.SetPosition(vector);
1441 // flush the queue and render once
1442 application.SendNotification();
1443 application.Render();
1445 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1447 actor.TranslateBy(vector);
1449 // flush the queue and render once
1450 application.SendNotification();
1451 application.Render();
1453 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1457 int UtcDaliActorGetCurrentPosition(void)
1459 TestApplication application;
1461 Actor actor = Actor::New();
1462 Vector3 setVector(100.0f, 100.0f, 0.0f);
1463 actor.SetPosition(setVector);
1465 // flush the queue and render once
1466 application.SendNotification();
1467 application.Render();
1469 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1473 int UtcDaliActorGetCurrentWorldPosition(void)
1475 TestApplication application;
1477 Actor parent = Actor::New();
1478 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1479 parent.SetPosition( parentPosition );
1480 parent.SetParentOrigin( ParentOrigin::CENTER );
1481 parent.SetAnchorPoint( AnchorPoint::CENTER );
1482 Stage::GetCurrent().Add( parent );
1484 Actor child = Actor::New();
1485 child.SetParentOrigin( ParentOrigin::CENTER );
1486 child.SetAnchorPoint( AnchorPoint::CENTER );
1487 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1488 child.SetPosition( childPosition );
1489 parent.Add( child );
1491 // The actors should not have a world position yet
1492 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1493 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1495 application.SendNotification();
1496 application.Render(0);
1498 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1499 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1501 // The actors should have a world position now
1502 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1503 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1507 int UtcDaliActorInheritPosition(void)
1509 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1510 TestApplication application;
1512 Actor parent = Actor::New();
1513 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1514 parent.SetPosition( parentPosition );
1515 parent.SetParentOrigin( ParentOrigin::CENTER );
1516 parent.SetAnchorPoint( AnchorPoint::CENTER );
1517 Stage::GetCurrent().Add( parent );
1519 Actor child = Actor::New();
1520 child.SetParentOrigin( ParentOrigin::CENTER );
1521 child.SetAnchorPoint( AnchorPoint::CENTER );
1522 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1523 child.SetPosition( childPosition );
1524 parent.Add( child );
1526 // The actors should not have a world position yet
1527 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1528 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1530 // first test default, which is to inherit position
1531 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1532 application.SendNotification();
1533 application.Render(0); // should only really call Update as Render is not required to update scene
1534 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1535 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1536 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1537 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1540 //Change child position
1541 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1542 child.SetPosition( childOffset );
1544 // Change inheritance mode to not inherit
1545 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1546 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1547 application.SendNotification();
1548 application.Render(0); // should only really call Update as Render is not required to update scene
1549 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1550 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1551 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1552 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1556 int UtcDaliActorSetInheritPosition(void)
1558 tet_infoline("Testing Actor::SetInheritPosition");
1559 TestApplication application;
1561 Actor parent = Actor::New();
1562 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1563 parent.SetPosition( parentPosition );
1564 parent.SetParentOrigin( ParentOrigin::CENTER );
1565 parent.SetAnchorPoint( AnchorPoint::CENTER );
1566 Stage::GetCurrent().Add( parent );
1568 Actor child = Actor::New();
1569 child.SetParentOrigin( ParentOrigin::CENTER );
1570 child.SetAnchorPoint( AnchorPoint::CENTER );
1571 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1572 child.SetPosition( childPosition );
1573 parent.Add( child );
1575 // The actors should not have a world position yet
1576 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1577 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1579 // first test default, which is to inherit position
1580 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1581 application.SendNotification();
1582 application.Render(0); // should only really call Update as Render is not required to update scene
1583 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1584 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1585 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1586 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1588 //Change child position
1589 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1590 child.SetPosition( childOffset );
1592 // Use local position as world postion
1593 child.SetInheritPosition( false );
1594 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1595 application.SendNotification();
1596 application.Render(0); // should only really call Update as Render is not required to update scene
1597 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1598 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1599 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1600 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1602 //Change back to inherit position from parent
1603 child.SetInheritPosition( true );
1604 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1605 application.SendNotification();
1606 application.Render(0); // should only really call Update as Render is not required to update scene
1607 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1608 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1609 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1610 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1614 // SetOrientation(float angleRadians, Vector3 axis)
1615 int UtcDaliActorSetOrientation01(void)
1617 TestApplication application;
1619 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1620 Actor actor = Actor::New();
1622 actor.SetOrientation(rotation);
1624 // flush the queue and render once
1625 application.SendNotification();
1626 application.Render();
1628 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1632 int UtcDaliActorSetOrientation02(void)
1634 TestApplication application;
1636 Actor actor = Actor::New();
1638 Radian angle( 0.785f );
1639 Vector3 axis(1.0f, 1.0f, 0.0f);
1641 actor.SetOrientation( angle, axis);
1642 Quaternion rotation( angle, axis );
1643 // flush the queue and render once
1644 application.SendNotification();
1645 application.Render();
1646 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1648 Stage::GetCurrent().Add( actor );
1649 actor.RotateBy( Degree( 360 ), axis);
1650 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1652 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1653 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1654 // flush the queue and render once
1655 application.SendNotification();
1656 application.Render();
1657 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1659 actor.SetOrientation( angle, axis);
1660 // flush the queue and render once
1661 application.SendNotification();
1662 application.Render();
1663 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1665 Stage::GetCurrent().Remove( actor );
1669 // SetOrientation(float angleRadians, Vector3 axis)
1670 int UtcDaliActorSetOrientationProperty(void)
1672 TestApplication application;
1674 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1675 Actor actor = Actor::New();
1677 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1678 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1680 // flush the queue and render once
1681 application.SendNotification();
1682 application.Render();
1684 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1685 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1686 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1690 // RotateBy(float angleRadians, Vector3 axis)
1691 int UtcDaliActorRotateBy01(void)
1693 TestApplication application;
1695 Actor actor = Actor::New();
1697 Radian angle( M_PI * 0.25f );
1698 actor.RotateBy(( angle ), Vector3::ZAXIS);
1699 // flush the queue and render once
1700 application.SendNotification();
1701 application.Render();
1702 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1704 Stage::GetCurrent().Add( actor );
1706 actor.RotateBy( angle, Vector3::ZAXIS);
1707 // flush the queue and render once
1708 application.SendNotification();
1709 application.Render();
1710 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1712 Stage::GetCurrent().Remove( actor );
1716 // RotateBy(Quaternion relativeRotation)
1717 int UtcDaliActorRotateBy02(void)
1719 TestApplication application;
1721 Actor actor = Actor::New();
1723 Radian angle( M_PI * 0.25f );
1724 Quaternion rotation(angle, Vector3::ZAXIS);
1725 actor.RotateBy(rotation);
1726 // flush the queue and render once
1727 application.SendNotification();
1728 application.Render();
1729 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1731 actor.RotateBy(rotation);
1732 // flush the queue and render once
1733 application.SendNotification();
1734 application.Render();
1735 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1739 int UtcDaliActorGetCurrentOrientation(void)
1741 TestApplication application;
1742 Actor actor = Actor::New();
1744 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1745 actor.SetOrientation(rotation);
1746 // flush the queue and render once
1747 application.SendNotification();
1748 application.Render();
1749 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1753 int UtcDaliActorGetCurrentWorldOrientation(void)
1755 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1756 TestApplication application;
1758 Actor parent = Actor::New();
1759 Radian rotationAngle( Degree(90.0f) );
1760 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1761 parent.SetOrientation( rotation );
1762 Stage::GetCurrent().Add( parent );
1764 Actor child = Actor::New();
1765 child.SetOrientation( rotation );
1766 parent.Add( child );
1768 // The actors should not have a world rotation yet
1769 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1770 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1772 application.SendNotification();
1773 application.Render(0);
1775 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1776 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1778 // The actors should have a world rotation now
1779 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1780 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1782 // turn off child rotation inheritance
1783 child.SetInheritOrientation( false );
1784 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1785 application.SendNotification();
1786 application.Render(0);
1788 // The actors should have a world rotation now
1789 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1790 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1794 // SetScale(float scale)
1795 int UtcDaliActorSetScale01(void)
1797 TestApplication application;
1799 Actor actor = Actor::New();
1801 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1802 actor.SetScale(0.25f);
1804 Vector3 scale(10.0f, 10.0f, 10.0f);
1805 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1807 actor.SetScale(scale.x);
1809 // flush the queue and render once
1810 application.SendNotification();
1811 application.Render();
1813 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1817 // SetScale(float scaleX, float scaleY, float scaleZ)
1818 int UtcDaliActorSetScale02(void)
1820 TestApplication application;
1821 Vector3 scale(10.0f, 10.0f, 10.0f);
1823 Actor actor = Actor::New();
1825 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1826 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1828 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1830 actor.SetScale(scale.x, scale.y, scale.z);
1831 // flush the queue and render once
1832 application.SendNotification();
1833 application.Render();
1834 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1836 // add to stage and test
1837 Stage::GetCurrent().Add( actor );
1838 actor.SetScale( 2.0f, 2.0f, 2.0f );
1839 // flush the queue and render once
1840 application.SendNotification();
1841 application.Render();
1842 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1844 Stage::GetCurrent().Remove( actor );
1849 // SetScale(Vector3 scale)
1850 int UtcDaliActorSetScale03(void)
1852 TestApplication application;
1853 Vector3 scale(10.0f, 10.0f, 10.0f);
1855 Actor actor = Actor::New();
1857 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1858 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1860 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1862 actor.SetScale(scale);
1864 // flush the queue and render once
1865 application.SendNotification();
1866 application.Render();
1868 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1872 int UtcDaliActorSetScaleIndividual(void)
1874 TestApplication application;
1876 Actor actor = Actor::New();
1878 Vector3 vector(0.7f, 0.8f, 0.9f);
1879 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1881 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1882 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1884 // flush the queue and render once
1885 application.SendNotification();
1886 application.Render();
1888 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1889 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1890 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1892 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1893 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1895 // flush the queue and render once
1896 application.SendNotification();
1897 application.Render();
1899 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1900 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1901 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1903 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1904 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1906 // flush the queue and render once
1907 application.SendNotification();
1908 application.Render();
1910 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1911 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1912 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1914 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1915 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1920 int UtcDaliActorScaleBy(void)
1922 TestApplication application;
1923 Actor actor = Actor::New();
1924 Vector3 vector(100.0f, 100.0f, 100.0f);
1926 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1928 actor.SetScale(vector);
1930 // flush the queue and render once
1931 application.SendNotification();
1932 application.Render();
1934 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1936 actor.ScaleBy(vector);
1938 // flush the queue and render once
1939 application.SendNotification();
1940 application.Render();
1942 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1946 int UtcDaliActorGetCurrentScale(void)
1948 TestApplication application;
1949 Vector3 scale(12.0f, 1.0f, 2.0f);
1951 Actor actor = Actor::New();
1953 actor.SetScale(scale);
1955 // flush the queue and render once
1956 application.SendNotification();
1957 application.Render();
1959 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1963 int UtcDaliActorGetCurrentWorldScale(void)
1965 TestApplication application;
1967 Actor parent = Actor::New();
1968 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1969 parent.SetScale( parentScale );
1970 Stage::GetCurrent().Add( parent );
1972 Actor child = Actor::New();
1973 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1974 child.SetScale( childScale );
1975 parent.Add( child );
1977 // The actors should not have a scale yet
1978 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1979 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1981 // The actors should not have a world scale yet
1982 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1983 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1985 application.SendNotification();
1986 application.Render(0);
1988 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1989 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1991 // The actors should have a world scale now
1992 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1993 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1997 int UtcDaliActorInheritScale(void)
1999 tet_infoline("Testing Actor::SetInheritScale");
2000 TestApplication application;
2002 Actor parent = Actor::New();
2003 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2004 parent.SetScale( parentScale );
2005 Stage::GetCurrent().Add( parent );
2007 Actor child = Actor::New();
2008 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2009 child.SetScale( childScale );
2010 parent.Add( child );
2012 application.SendNotification();
2013 application.Render(0);
2015 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
2016 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
2018 child.SetInheritScale( false );
2019 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
2021 application.SendNotification();
2022 application.Render(0);
2024 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
2028 int UtcDaliActorSetVisible(void)
2030 TestApplication application;
2032 Actor actor = Actor::New();
2033 actor.SetVisible(false);
2034 // flush the queue and render once
2035 application.SendNotification();
2036 application.Render();
2037 DALI_TEST_CHECK(actor.IsVisible() == false);
2039 actor.SetVisible(true);
2040 // flush the queue and render once
2041 application.SendNotification();
2042 application.Render();
2043 DALI_TEST_CHECK(actor.IsVisible() == true);
2045 // put actor on stage
2046 Stage::GetCurrent().Add( actor );
2047 actor.SetVisible(false);
2048 // flush the queue and render once
2049 application.SendNotification();
2050 application.Render();
2051 DALI_TEST_CHECK(actor.IsVisible() == false);
2055 int UtcDaliActorIsVisible(void)
2057 TestApplication application;
2059 Actor actor = Actor::New();
2061 DALI_TEST_CHECK(actor.IsVisible() == true);
2065 int UtcDaliActorSetOpacity(void)
2067 TestApplication application;
2069 Actor actor = Actor::New();
2070 // initial opacity is 1
2071 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2073 actor.SetOpacity( 0.4f);
2074 // flush the queue and render once
2075 application.SendNotification();
2076 application.Render();
2077 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2079 // change opacity, actor is on stage to change is not immediate
2080 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2081 // flush the queue and render once
2082 application.SendNotification();
2083 application.Render();
2084 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2086 // put actor on stage
2087 Stage::GetCurrent().Add( actor );
2089 // change opacity, actor is on stage to change is not immediate
2090 actor.SetOpacity( 0.9f );
2091 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2092 // flush the queue and render once
2093 application.SendNotification();
2094 application.Render();
2095 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2097 // change opacity, actor is on stage to change is not immediate
2098 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2099 // flush the queue and render once
2100 application.SendNotification();
2101 application.Render();
2102 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2106 int UtcDaliActorGetCurrentOpacity(void)
2108 TestApplication application;
2110 Actor actor = Actor::New();
2111 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2113 actor.SetOpacity(0.5f);
2114 // flush the queue and render once
2115 application.SendNotification();
2116 application.Render();
2117 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2121 int UtcDaliActorSetSensitive(void)
2123 TestApplication application;
2124 Actor actor = Actor::New();
2126 bool sensitive = !actor.IsSensitive();
2128 actor.SetSensitive(sensitive);
2130 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2134 int UtcDaliActorIsSensitive(void)
2136 TestApplication application;
2137 Actor actor = Actor::New();
2138 actor.SetSensitive(false);
2140 DALI_TEST_CHECK(false == actor.IsSensitive());
2144 int UtcDaliActorSetColor(void)
2146 TestApplication application;
2147 Actor actor = Actor::New();
2148 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2150 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2152 actor.SetColor(color);
2153 // flush the queue and render once
2154 application.SendNotification();
2155 application.Render();
2156 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2158 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2159 // flush the queue and render once
2160 application.SendNotification();
2161 application.Render();
2162 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2164 Stage::GetCurrent().Add( actor );
2165 actor.SetColor( color );
2166 // flush the queue and render once
2167 application.SendNotification();
2168 application.Render();
2169 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2171 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2172 // flush the queue and render once
2173 application.SendNotification();
2174 application.Render();
2175 // Actor color is not clamped
2176 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2177 // world color is clamped
2178 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2180 Stage::GetCurrent().Remove( actor );
2184 int UtcDaliActorSetColorIndividual(void)
2186 TestApplication application;
2188 Actor actor = Actor::New();
2190 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2191 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2193 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2194 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2196 // flush the queue and render once
2197 application.SendNotification();
2198 application.Render();
2200 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2201 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2202 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2204 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2205 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2207 // flush the queue and render once
2208 application.SendNotification();
2209 application.Render();
2211 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2212 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2213 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2215 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2216 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2218 // flush the queue and render once
2219 application.SendNotification();
2220 application.Render();
2222 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2223 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2224 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2227 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2228 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2230 // flush the queue and render once
2231 application.SendNotification();
2232 application.Render();
2234 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2235 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2236 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2238 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2239 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2241 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2244 // flush the queue and render once
2245 application.SendNotification();
2246 application.Render();
2248 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2254 int UtcDaliActorGetCurrentColor(void)
2256 TestApplication application;
2257 Actor actor = Actor::New();
2258 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2260 actor.SetColor(color);
2261 // flush the queue and render once
2262 application.SendNotification();
2263 application.Render();
2264 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2268 int UtcDaliActorGetCurrentWorldColor(void)
2270 tet_infoline("Actor::GetCurrentWorldColor");
2271 TestApplication application;
2273 Actor parent = Actor::New();
2274 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2275 parent.SetColor( parentColor );
2276 Stage::GetCurrent().Add( parent );
2278 Actor child = Actor::New();
2279 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2280 child.SetColor( childColor );
2281 parent.Add( child );
2283 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2284 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2286 // verify the default color mode
2287 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2289 // The actors should not have a world color yet
2290 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2291 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2293 application.SendNotification();
2294 application.Render(0);
2296 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2297 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2299 // The actors should have a world color now
2300 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2301 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2304 child.SetColorMode( USE_OWN_COLOR );
2305 application.SendNotification();
2306 application.Render(0);
2307 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2310 child.SetColorMode( USE_PARENT_COLOR );
2311 application.SendNotification();
2312 application.Render(0);
2313 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2314 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2317 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2318 application.SendNotification();
2319 application.Render(0);
2320 Vector4 expectedColor( childColor );
2321 expectedColor.a *= parentColor.a;
2322 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2323 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2327 int UtcDaliActorSetColorMode(void)
2329 tet_infoline("Actor::SetColorMode");
2330 TestApplication application;
2331 Actor actor = Actor::New();
2332 Actor child = Actor::New();
2335 actor.SetColorMode( USE_OWN_COLOR );
2336 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2338 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2339 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2341 actor.SetColorMode( USE_PARENT_COLOR );
2342 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2344 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2345 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2349 int UtcDaliActorScreenToLocal(void)
2351 TestApplication application;
2352 Actor actor = Actor::New();
2353 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2354 actor.SetSize(100.0f, 100.0f);
2355 actor.SetPosition(10.0f, 10.0f);
2356 Stage::GetCurrent().Add(actor);
2358 // flush the queue and render once
2359 application.SendNotification();
2360 application.Render();
2365 application.SendNotification();
2366 application.Render();
2368 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2370 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2371 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2375 int UtcDaliActorSetLeaveRequired(void)
2377 TestApplication application;
2379 Actor actor = Actor::New();
2381 actor.SetLeaveRequired(false);
2382 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2384 actor.SetLeaveRequired(true);
2385 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2389 int UtcDaliActorGetLeaveRequired(void)
2391 TestApplication application;
2393 Actor actor = Actor::New();
2395 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2399 int UtcDaliActorSetKeyboardFocusable(void)
2401 TestApplication application;
2403 Actor actor = Actor::New();
2405 actor.SetKeyboardFocusable(true);
2406 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2408 actor.SetKeyboardFocusable(false);
2409 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2413 int UtcDaliActorIsKeyboardFocusable(void)
2415 TestApplication application;
2417 Actor actor = Actor::New();
2419 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2423 int UtcDaliActorRemoveConstraints(void)
2425 tet_infoline(" UtcDaliActorRemoveConstraints");
2426 TestApplication application;
2428 gTestConstraintCalled = false;
2430 Actor actor = Actor::New();
2432 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2434 actor.RemoveConstraints();
2436 DALI_TEST_CHECK( gTestConstraintCalled == false );
2438 Stage::GetCurrent().Add( actor );
2441 // flush the queue and render once
2442 application.SendNotification();
2443 application.Render();
2445 actor.RemoveConstraints();
2447 DALI_TEST_CHECK( gTestConstraintCalled == true );
2451 int UtcDaliActorRemoveConstraintTag(void)
2453 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2454 TestApplication application;
2456 Actor actor = Actor::New();
2458 // 1. Apply Constraint1 and Constraint2, and test...
2459 unsigned int result1 = 0u;
2460 unsigned int result2 = 0u;
2462 unsigned constraint1Tag = 1u;
2463 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2464 constraint1.SetTag( constraint1Tag );
2465 constraint1.Apply();
2467 unsigned constraint2Tag = 2u;
2468 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2469 constraint2.SetTag( constraint2Tag );
2470 constraint2.Apply();
2472 Stage::GetCurrent().Add( actor );
2473 // flush the queue and render once
2474 application.SendNotification();
2475 application.Render();
2477 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2478 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2480 // 2. Remove Constraint1 and test...
2483 actor.RemoveConstraints(constraint1Tag);
2484 // make color property dirty, which will trigger constraints to be reapplied.
2485 actor.SetColor( Color::WHITE );
2486 // flush the queue and render once
2487 application.SendNotification();
2488 application.Render();
2490 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2491 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2493 // 3. Re-Apply Constraint1 and test...
2496 constraint1.Apply();
2497 // make color property dirty, which will trigger constraints to be reapplied.
2498 actor.SetColor( Color::WHITE );
2499 // flush the queue and render once
2500 application.SendNotification();
2501 application.Render();
2503 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2504 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2506 // 2. Remove Constraint2 and test...
2509 actor.RemoveConstraints(constraint2Tag);
2510 // make color property dirty, which will trigger constraints to be reapplied.
2511 actor.SetColor( Color::WHITE );
2512 // flush the queue and render once
2513 application.SendNotification();
2514 application.Render();
2516 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2517 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2519 // 2. Remove Constraint1 as well and test...
2522 actor.RemoveConstraints(constraint1Tag);
2523 // make color property dirty, which will trigger constraints to be reapplied.
2524 actor.SetColor( Color::WHITE );
2525 // flush the queue and render once
2526 application.SendNotification();
2527 application.Render();
2529 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2530 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2534 int UtcDaliActorTouchedSignal(void)
2536 TestApplication application;
2538 ResetTouchCallbacks();
2540 // get the root layer
2541 Actor actor = Stage::GetCurrent().GetRootLayer();
2542 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2544 application.SendNotification();
2545 application.Render();
2547 // connect to its touch signal
2548 actor.TouchedSignal().Connect( TestCallback );
2550 // simulate a touch event in the middle of the screen
2551 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2552 Dali::Integration::Point point;
2553 point.SetDeviceId( 1 );
2554 point.SetState( PointState::DOWN );
2555 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2556 Dali::Integration::TouchEvent touchEvent;
2557 touchEvent.AddPoint( point );
2558 application.ProcessEvent( touchEvent );
2560 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2564 int UtcDaliActorHoveredSignal(void)
2566 TestApplication application;
2568 gHoverCallBackCalled = false;
2570 // get the root layer
2571 Actor actor = Stage::GetCurrent().GetRootLayer();
2572 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2574 application.SendNotification();
2575 application.Render();
2577 // connect to its hover signal
2578 actor.HoveredSignal().Connect( TestCallback3 );
2580 // simulate a hover event in the middle of the screen
2581 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2582 Dali::Integration::Point point;
2583 point.SetDeviceId( 1 );
2584 point.SetState( PointState::MOTION );
2585 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2586 Dali::Integration::HoverEvent hoverEvent;
2587 hoverEvent.AddPoint( point );
2588 application.ProcessEvent( hoverEvent );
2590 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2594 int UtcDaliActorOnOffStageSignal(void)
2596 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2598 TestApplication application;
2601 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2602 gActorNamesOnOffStage.clear();
2604 Actor parent = Actor::New();
2605 parent.SetName( "parent" );
2606 parent.OnStageSignal().Connect( OnStageCallback );
2607 parent.OffStageSignal().Connect( OffStageCallback );
2609 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2610 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2612 // add parent to stage
2613 Stage::GetCurrent().Add( parent );
2614 // onstage emitted, offstage not
2615 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2616 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2617 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2619 // test adding a child, should get onstage emitted
2621 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2622 gActorNamesOnOffStage.clear();
2624 Actor child = Actor::New();
2625 child.SetName( "child" );
2626 child.OnStageSignal().Connect( OnStageCallback );
2627 child.OffStageSignal().Connect( OffStageCallback );
2628 parent.Add( child ); // add child
2629 // onstage emitted, offstage not
2630 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2631 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2632 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2634 // test removing parent from stage
2636 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2637 gActorNamesOnOffStage.clear();
2639 Stage::GetCurrent().Remove( parent );
2640 // onstage not emitted, offstage is
2641 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2642 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2643 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2644 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2646 // test adding parent back to stage
2648 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2649 gActorNamesOnOffStage.clear();
2651 Stage::GetCurrent().Add( parent );
2652 // onstage emitted, offstage not
2653 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2654 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2655 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2656 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2658 // test removing child
2660 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2661 gActorNamesOnOffStage.clear();
2663 parent.Remove( child );
2664 // onstage not emitted, offstage is
2665 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2666 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2667 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2669 // test removing parent
2671 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2672 gActorNamesOnOffStage.clear();
2674 Stage::GetCurrent().Remove( parent );
2675 // onstage not emitted, offstage is
2676 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2677 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2678 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2682 int UtcDaliActorFindChildByName(void)
2684 tet_infoline("Testing Dali::Actor::FindChildByName()");
2685 TestApplication application;
2687 Actor parent = Actor::New();
2688 parent.SetName( "parent" );
2689 Actor first = Actor::New();
2690 first .SetName( "first" );
2691 Actor second = Actor::New();
2692 second.SetName( "second" );
2697 Actor found = parent.FindChildByName( "foo" );
2698 DALI_TEST_CHECK( !found );
2700 found = parent.FindChildByName( "parent" );
2701 DALI_TEST_CHECK( found == parent );
2703 found = parent.FindChildByName( "first" );
2704 DALI_TEST_CHECK( found == first );
2706 found = parent.FindChildByName( "second" );
2707 DALI_TEST_CHECK( found == second );
2711 int UtcDaliActorFindChildById(void)
2713 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2714 TestApplication application;
2716 Actor parent = Actor::New();
2717 Actor first = Actor::New();
2718 Actor second = Actor::New();
2723 Actor found = parent.FindChildById( 100000 );
2724 DALI_TEST_CHECK( !found );
2726 found = parent.FindChildById( parent.GetId() );
2727 DALI_TEST_CHECK( found == parent );
2729 found = parent.FindChildById( first.GetId() );
2730 DALI_TEST_CHECK( found == first );
2732 found = parent.FindChildById( second.GetId() );
2733 DALI_TEST_CHECK( found == second );
2737 int UtcDaliActorHitTest(void)
2742 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2744 mTouchPoint( touchPoint ),
2749 Vector2 mTouchPoint;
2753 TestApplication application;
2754 tet_infoline(" UtcDaliActorHitTest");
2756 // Fill a vector with different hit tests.
2757 struct HitTestData* hitTestData[] = {
2758 // scale touch point result
2759 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2760 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2761 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.
2762 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2763 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.
2767 // get the root layer
2768 Actor actor = Actor::New();
2769 actor.SetAnchorPoint( AnchorPoint::CENTER );
2770 actor.SetParentOrigin( ParentOrigin::CENTER );
2772 Stage::GetCurrent().Add( actor );
2774 ResetTouchCallbacks();
2776 unsigned int index = 0;
2777 while( NULL != hitTestData[index] )
2779 actor.SetSize( 1.f, 1.f );
2780 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2782 // flush the queue and render once
2783 application.SendNotification();
2784 application.Render();
2786 DALI_TEST_CHECK( !gTouchCallBackCalled );
2788 // connect to its touch signal
2789 actor.TouchedSignal().Connect(TestCallback);
2791 Dali::Integration::Point point;
2792 point.SetState( PointState::DOWN );
2793 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2794 Dali::Integration::TouchEvent event;
2795 event.AddPoint( point );
2797 // flush the queue and render once
2798 application.SendNotification();
2799 application.Render();
2800 application.ProcessEvent( event );
2802 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2804 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2805 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2806 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2807 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2808 hitTestData[index]->mResult );
2810 ResetTouchCallbacks();
2816 int UtcDaliActorSetDrawMode(void)
2818 TestApplication app;
2819 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2821 Actor a = Actor::New();
2823 Stage::GetCurrent().Add(a);
2824 app.SendNotification();
2826 app.SendNotification();
2829 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2831 a.SetDrawMode( DrawMode::OVERLAY_2D );
2832 app.SendNotification();
2835 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2837 a.SetDrawMode( DrawMode::NORMAL );
2838 app.SendNotification();
2841 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2845 int UtcDaliActorSetDrawModeOverlayRender(void)
2847 TestApplication app;
2848 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2850 app.SendNotification();
2853 std::vector<GLuint> ids;
2854 ids.push_back( 8 ); // first rendered actor
2855 ids.push_back( 9 ); // second rendered actor
2856 ids.push_back( 10 ); // third rendered actor
2857 app.GetGlAbstraction().SetNextTextureIds( ids );
2859 BufferImage imageA = BufferImage::New(16, 16);
2860 BufferImage imageB = BufferImage::New(16, 16);
2861 BufferImage imageC = BufferImage::New(16, 16);
2862 Actor a = CreateRenderableActor( imageA );
2863 Actor b = CreateRenderableActor( imageB );
2864 Actor c = CreateRenderableActor( imageC );
2866 app.SendNotification();
2869 //Textures are bound when first created. Clear bound textures vector
2870 app.GetGlAbstraction().ClearBoundTextures();
2872 // Render a,b,c as regular non-overlays. so order will be:
2876 Stage::GetCurrent().Add(a);
2877 Stage::GetCurrent().Add(b);
2878 Stage::GetCurrent().Add(c);
2880 app.SendNotification();
2883 // Should be 3 textures changes.
2884 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2885 typedef std::vector<GLuint>::size_type TextureSize;
2886 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2887 if( boundTextures.size() == 3 )
2889 DALI_TEST_CHECK( boundTextures[0] == 8u );
2890 DALI_TEST_CHECK( boundTextures[1] == 9u );
2891 DALI_TEST_CHECK( boundTextures[2] == 10u );
2894 // Now texture ids have been set, we can monitor their render order.
2895 // render a as an overlay (last), so order will be:
2899 a.SetDrawMode( DrawMode::OVERLAY_2D );
2900 app.GetGlAbstraction().ClearBoundTextures();
2902 app.SendNotification();
2905 // Should be 3 texture changes.
2906 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2907 if( boundTextures.size() == 3 )
2909 DALI_TEST_CHECK( boundTextures[0] == 9u );
2910 DALI_TEST_CHECK( boundTextures[1] == 10u );
2911 DALI_TEST_CHECK( boundTextures[2] == 8u );
2916 int UtcDaliActorGetCurrentWorldMatrix(void)
2918 TestApplication app;
2919 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2921 Actor parent = Actor::New();
2922 parent.SetParentOrigin(ParentOrigin::CENTER);
2923 parent.SetAnchorPoint(AnchorPoint::CENTER);
2924 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2925 Radian rotationAngle(Degree(85.0f));
2926 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2927 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2928 parent.SetPosition( parentPosition );
2929 parent.SetOrientation( parentRotation );
2930 parent.SetScale( parentScale );
2931 Stage::GetCurrent().Add( parent );
2933 Actor child = Actor::New();
2934 child.SetParentOrigin(ParentOrigin::CENTER);
2935 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2936 Radian childRotationAngle(Degree(23.0f));
2937 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2938 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2939 child.SetPosition( childPosition );
2940 child.SetOrientation( childRotation );
2941 child.SetScale( childScale );
2942 parent.Add( child );
2944 app.SendNotification();
2947 app.SendNotification();
2949 Matrix parentMatrix(false);
2950 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2952 Matrix childMatrix(false);
2953 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2955 //Child matrix should be the composition of child and parent
2956 Matrix childWorldMatrix(false);
2957 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2959 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2960 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2966 int UtcDaliActorConstrainedToWorldMatrix(void)
2968 TestApplication app;
2969 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2971 Actor parent = Actor::New();
2972 parent.SetParentOrigin(ParentOrigin::CENTER);
2973 parent.SetAnchorPoint(AnchorPoint::CENTER);
2974 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2975 Radian rotationAngle(Degree(85.0f));
2976 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2977 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2978 parent.SetPosition( parentPosition );
2979 parent.SetOrientation( parentRotation );
2980 parent.SetScale( parentScale );
2981 Stage::GetCurrent().Add( parent );
2983 Actor child = Actor::New();
2984 child.SetParentOrigin(ParentOrigin::CENTER);
2985 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2986 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2987 posConstraint.Apply();
2989 Stage::GetCurrent().Add( child );
2991 app.SendNotification();
2994 app.SendNotification();
2996 Matrix parentMatrix(false);
2997 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2999 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
3000 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
3004 int UtcDaliActorConstrainedToOrientation(void)
3006 TestApplication app;
3007 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3009 Actor parent = Actor::New();
3010 parent.SetParentOrigin(ParentOrigin::CENTER);
3011 parent.SetAnchorPoint(AnchorPoint::CENTER);
3012 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
3013 Radian rotationAngle(Degree(85.0f));
3014 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3015 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
3016 parent.SetPosition( parentPosition );
3017 parent.SetOrientation( parentRotation );
3018 parent.SetScale( parentScale );
3019 Stage::GetCurrent().Add( parent );
3021 Actor child = Actor::New();
3022 child.SetParentOrigin(ParentOrigin::CENTER);
3023 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
3024 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
3025 posConstraint.Apply();
3027 Stage::GetCurrent().Add( child );
3029 app.SendNotification();
3032 app.SendNotification();
3034 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
3038 int UtcDaliActorConstrainedToOpacity(void)
3040 TestApplication app;
3041 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3043 Actor parent = Actor::New();
3044 parent.SetOpacity( 0.7f );
3045 Stage::GetCurrent().Add( parent );
3047 Actor child = Actor::New();
3048 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
3049 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
3050 opacityConstraint.Apply();
3052 Stage::GetCurrent().Add( child );
3054 app.SendNotification();
3057 app.SendNotification();
3059 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3061 parent.SetOpacity( 0.3f );
3063 app.SendNotification();
3066 app.SendNotification();
3068 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3073 int UtcDaliActorUnparent(void)
3075 TestApplication app;
3076 tet_infoline(" UtcDaliActorUnparent");
3078 Actor parent = Actor::New();
3079 Stage::GetCurrent().Add( parent );
3081 Actor child = Actor::New();
3083 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3084 DALI_TEST_CHECK( !child.GetParent() );
3086 // Test that calling Unparent with no parent is a NOOP
3089 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3090 DALI_TEST_CHECK( !child.GetParent() );
3092 // Test that Unparent works
3093 parent.Add( child );
3095 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3096 DALI_TEST_CHECK( parent == child.GetParent() );
3100 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3101 DALI_TEST_CHECK( !child.GetParent() );
3103 // Test that UnparentAndReset works
3104 parent.Add( child );
3106 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3107 DALI_TEST_CHECK( parent == child.GetParent() );
3109 UnparentAndReset( child );
3111 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3112 DALI_TEST_CHECK( !child );
3114 // Test that UnparentAndReset is a NOOP with empty handle
3115 UnparentAndReset( child );
3117 DALI_TEST_CHECK( !child );
3121 int UtcDaliActorGetChildAt(void)
3123 TestApplication app;
3124 tet_infoline(" UtcDaliActorGetChildAt");
3126 Actor parent = Actor::New();
3127 Stage::GetCurrent().Add( parent );
3129 Actor child0 = Actor::New();
3130 parent.Add( child0 );
3132 Actor child1 = Actor::New();
3133 parent.Add( child1 );
3135 Actor child2 = Actor::New();
3136 parent.Add( child2 );
3138 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3139 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3140 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3144 int UtcDaliActorSetGetOverlay(void)
3146 TestApplication app;
3147 tet_infoline(" UtcDaliActorSetGetOverlay");
3149 Actor parent = Actor::New();
3150 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3151 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3156 int UtcDaliActorCreateDestroy(void)
3158 Actor* actor = new Actor;
3159 DALI_TEST_CHECK( actor );
3166 struct PropertyStringIndex
3168 const char * const name;
3169 const Property::Index index;
3170 const Property::Type type;
3173 const PropertyStringIndex PROPERTY_TABLE[] =
3175 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3176 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3177 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3178 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3179 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3180 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3181 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3182 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3183 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3184 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3185 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3186 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3187 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3188 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3189 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3190 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3191 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3192 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3193 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3194 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3195 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3196 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3197 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3198 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3199 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3200 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3201 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3202 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3203 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3204 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3205 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3206 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3207 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3208 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3209 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3210 { "name", Actor::Property::NAME, Property::STRING },
3211 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3212 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3213 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3214 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3215 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3216 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3217 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3218 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3219 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3220 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3221 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3222 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3223 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3224 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3225 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3226 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3227 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3228 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3229 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3231 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3232 } // unnamed namespace
3234 int UtcDaliActorProperties(void)
3236 TestApplication app;
3238 Actor actor = Actor::New();
3240 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3242 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3243 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3244 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3245 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3250 int UtcDaliRelayoutProperties_ResizePolicies(void)
3252 TestApplication app;
3254 Actor actor = Actor::New();
3257 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3258 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3260 // Set resize policy for all dimensions
3261 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3262 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3264 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3267 // Set individual dimensions
3268 const char* const widthPolicy = "FILL_TO_PARENT";
3269 const char* const heightPolicy = "FIXED";
3271 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3272 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3274 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3275 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3277 // Set individual dimensions using enums
3278 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3279 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3281 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3282 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3284 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3285 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3290 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3292 TestApplication app;
3294 Actor actor = Actor::New();
3297 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3298 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3300 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3301 actor.SetSizeScalePolicy( policy );
3302 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3305 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3306 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3308 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3309 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3311 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3312 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3317 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3319 TestApplication app;
3321 Actor actor = Actor::New();
3324 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3325 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3327 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3328 actor.SetSizeModeFactor( sizeMode );
3329 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3332 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3334 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3335 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3340 int UtcDaliRelayoutProperties_DimensionDependency(void)
3342 TestApplication app;
3344 Actor actor = Actor::New();
3347 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3348 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3351 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3352 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3354 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3355 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3357 // Test setting another resize policy
3358 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3359 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3364 int UtcDaliRelayoutProperties_Padding(void)
3366 TestApplication app;
3368 Actor actor = Actor::New();
3371 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3374 actor.SetProperty( Actor::Property::PADDING, padding );
3375 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3377 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3382 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3384 TestApplication app;
3386 Actor actor = Actor::New();
3389 Vector2 minSize( 1.0f, 2.0f );
3391 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3392 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3394 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3396 Vector2 maxSize( 3.0f, 4.0f );
3398 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3399 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3401 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3406 int UtcDaliActorGetHeightForWidth(void)
3408 TestApplication app;
3410 Actor actor = Actor::New();
3412 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3417 int UtcDaliActorGetWidthForHeight(void)
3419 TestApplication app;
3421 Actor actor = Actor::New();
3423 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3428 int UtcDaliActorGetRelayoutSize(void)
3430 TestApplication app;
3432 Actor actor = Actor::New();
3434 // Add actor to stage
3435 Stage::GetCurrent().Add( actor );
3437 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3439 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3440 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3442 // Flush the queue and render once
3443 app.SendNotification();
3446 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3451 int UtcDaliActorSetPadding(void)
3453 TestApplication app;
3455 Actor actor = Actor::New();
3458 actor.GetPadding( padding );
3460 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3461 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3462 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3463 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3465 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3466 actor.SetPadding( padding2 );
3468 actor.GetPadding( padding );
3470 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3471 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3472 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3473 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3478 int UtcDaliActorSetMinimumSize(void)
3480 TestApplication app;
3482 Actor actor = Actor::New();
3484 Vector2 size = actor.GetMinimumSize();
3486 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3487 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3489 Vector2 size2( 1.0f, 2.0f );
3490 actor.SetMinimumSize( size2 );
3492 size = actor.GetMinimumSize();
3494 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3495 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3500 int UtcDaliActorSetMaximumSize(void)
3502 TestApplication app;
3504 Actor actor = Actor::New();
3506 Vector2 size = actor.GetMaximumSize();
3508 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3509 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3511 Vector2 size2( 1.0f, 2.0f );
3512 actor.SetMaximumSize( size2 );
3514 size = actor.GetMaximumSize();
3516 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3517 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3522 int UtcDaliActorOnRelayoutSignal(void)
3524 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3526 TestApplication application;
3529 gOnRelayoutCallBackCalled = false;
3530 gActorNamesRelayout.clear();
3532 Actor actor = Actor::New();
3533 actor.SetName( "actor" );
3534 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3537 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3539 // Add actor to stage
3540 Stage::GetCurrent().Add( actor );
3542 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3543 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3545 // Flush the queue and render once
3546 application.SendNotification();
3547 application.Render();
3549 // OnRelayout emitted
3550 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3551 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3556 int UtcDaliActorGetHierachyDepth(void)
3558 TestApplication application;
3559 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3562 /* Build tree of actors:
3572 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3574 Stage stage( Stage::GetCurrent() );
3576 Actor actorA = Actor::New();
3577 Actor actorB = Actor::New();
3578 Actor actorC = Actor::New();
3579 Actor actorD = Actor::New();
3580 Actor actorE = Actor::New();
3581 Actor actorF = Actor::New();
3583 //Test that root actor has depth equal 0
3584 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3586 //Test actors return depth -1 when not connected to the tree
3587 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3588 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3589 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3590 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3591 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3592 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3594 //Create the hierarchy
3595 stage.Add( actorA );
3596 actorA.Add( actorB );
3597 actorA.Add( actorC );
3598 actorB.Add( actorD );
3599 actorB.Add( actorE );
3600 actorC.Add( actorF );
3602 //Test actors return correct depth
3603 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3604 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3605 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3606 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3607 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3608 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3610 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3611 actorA.Remove( actorB );
3613 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3614 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3615 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3617 //Removing actorA from the stage. All actors should have depth equal -1
3618 stage.Remove( actorA );
3620 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3621 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3622 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3623 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3624 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3625 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3630 int UtcDaliActorAnchorPointPropertyAsString(void)
3632 TestApplication application;
3634 Actor actor = Actor::New();
3636 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3637 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3639 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3640 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3642 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3643 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3645 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3646 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3648 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3649 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3651 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3652 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3654 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3655 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3657 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3658 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3660 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3661 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3663 // Invalid should not change anything
3664 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3665 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3670 int UtcDaliActorParentOriginPropertyAsString(void)
3672 TestApplication application;
3674 Actor actor = Actor::New();
3676 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3677 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3679 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3680 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3682 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3683 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3685 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3686 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3688 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3689 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3691 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3692 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3694 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3695 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3697 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3698 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3700 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3701 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3703 // Invalid should not change anything
3704 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3705 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3710 int UtcDaliActorColorModePropertyAsString(void)
3712 TestApplication application;
3714 Actor actor = Actor::New();
3716 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3717 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3719 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3720 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3722 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3723 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3725 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3726 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3728 // Invalid should not change anything
3729 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3730 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3735 int UtcDaliActorPositionInheritancePropertyAsString(void)
3737 TestApplication application;
3739 Actor actor = Actor::New();
3741 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3742 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3744 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3745 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3747 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3748 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3750 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3751 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3753 // Invalid should not change anything
3754 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3755 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3760 int UtcDaliActorDrawModePropertyAsString(void)
3762 TestApplication application;
3764 Actor actor = Actor::New();
3766 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3767 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3769 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3770 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3772 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3773 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3775 // Invalid should not change anything
3776 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3777 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3782 int UtcDaliActorColorModePropertyAsEnum(void)
3784 TestApplication application;
3786 Actor actor = Actor::New();
3788 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3789 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3791 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3792 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3794 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3795 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3797 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3798 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3803 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3805 TestApplication application;
3807 Actor actor = Actor::New();
3809 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3810 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3812 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3813 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3815 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3816 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3818 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3819 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3824 int UtcDaliActorDrawModePropertyAsEnum(void)
3826 TestApplication application;
3828 Actor actor = Actor::New();
3830 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3831 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3833 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3834 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3836 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3837 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3842 int UtcDaliActorAddRendererP(void)
3844 tet_infoline("Testing Actor::AddRenderer");
3845 TestApplication application;
3847 Actor actor = Actor::New();
3849 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3851 Geometry geometry = CreateQuadGeometry();
3852 Shader shader = CreateShader();
3853 Renderer renderer = Renderer::New(geometry, shader);
3855 actor.AddRenderer( renderer );
3856 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3857 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3862 int UtcDaliActorAddRendererN(void)
3864 tet_infoline("Testing Actor::AddRenderer");
3865 TestApplication application;
3867 Actor actor = Actor::New();
3873 actor.AddRenderer( renderer );
3874 tet_printf("Assertion test failed - no Exception\n" );
3875 tet_result(TET_FAIL);
3877 catch(Dali::DaliException& e)
3879 DALI_TEST_PRINT_ASSERT( e );
3880 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3881 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3885 tet_printf("Assertion test failed - wrong Exception\n" );
3886 tet_result(TET_FAIL);
3892 int UtcDaliActorAddRendererOnStage(void)
3894 tet_infoline("Testing Actor::AddRenderer");
3895 TestApplication application;
3897 Actor actor = Actor::New();
3898 Stage::GetCurrent().Add(actor);
3900 application.SendNotification();
3901 application.Render(0);
3903 Geometry geometry = CreateQuadGeometry();
3904 Shader shader = CreateShader();
3905 Renderer renderer = Renderer::New(geometry, shader);
3907 application.SendNotification();
3908 application.Render(0);
3912 actor.AddRenderer( renderer );
3913 tet_result(TET_PASS);
3917 tet_result(TET_FAIL);
3923 int UtcDaliActorRemoveRendererP1(void)
3925 tet_infoline("Testing Actor::RemoveRenderer");
3926 TestApplication application;
3928 Actor actor = Actor::New();
3930 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3933 Geometry geometry = CreateQuadGeometry();
3934 Shader shader = CreateShader();
3935 Renderer renderer = Renderer::New(geometry, shader);
3937 actor.AddRenderer( renderer );
3938 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3939 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3941 application.SendNotification();
3942 application.Render();
3946 Renderer renderer = actor.GetRendererAt(0);
3947 actor.RemoveRenderer(renderer);
3948 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3950 application.SendNotification();
3951 application.Render();
3954 // Call one final time to ensure that the renderer is actually removed after
3955 // the handle goes out of scope, and excercises the deletion code path in
3956 // scene graph and render.
3957 application.SendNotification();
3958 application.Render();
3963 int UtcDaliActorRemoveRendererP2(void)
3965 tet_infoline("Testing Actor::RemoveRenderer");
3966 TestApplication application;
3968 Actor actor = Actor::New();
3970 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3972 Geometry geometry = CreateQuadGeometry();
3973 Shader shader = CreateShader();
3974 Renderer renderer = Renderer::New(geometry, shader);
3976 actor.AddRenderer( renderer );
3977 application.SendNotification();
3978 application.Render();
3980 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3981 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3983 actor.RemoveRenderer(0);
3984 application.SendNotification();
3985 application.Render();
3987 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3989 // Shut down whilst holding onto the renderer handle.
3994 int UtcDaliActorRemoveRendererN(void)
3996 tet_infoline("Testing Actor::RemoveRenderer");
3997 TestApplication application;
3999 Actor actor = Actor::New();
4001 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
4003 Geometry geometry = CreateQuadGeometry();
4004 Shader shader = CreateShader();
4005 Renderer renderer = Renderer::New(geometry, shader);
4007 actor.AddRenderer( renderer );
4008 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4009 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4011 actor.RemoveRenderer(10);
4012 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
4013 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
4018 // Clipping test helper functions:
4019 Actor CreateActorWithContent( uint32_t width, uint32_t height)
4021 BufferImage image = BufferImage::New( width, height );
4022 Actor actor = CreateRenderableActor( image );
4024 // Setup dimensions and position so actor is not skipped by culling.
4025 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4026 actor.SetSize( width, height );
4027 actor.SetParentOrigin( ParentOrigin::CENTER );
4028 actor.SetAnchorPoint( AnchorPoint::CENTER );
4033 Actor CreateActorWithContent16x16()
4035 return CreateActorWithContent( 16, 16 );
4038 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
4040 enabledDisableTrace.Reset();
4041 stencilTrace.Reset();
4042 enabledDisableTrace.Enable( true );
4043 stencilTrace.Enable( true );
4045 application.SendNotification();
4046 application.Render();
4048 enabledDisableTrace.Enable( false );
4049 stencilTrace.Enable( false );
4052 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
4054 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4056 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
4057 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
4058 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
4059 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
4062 int UtcDaliActorPropertyClippingP(void)
4064 // This test checks the clippingMode property.
4065 tet_infoline( "Testing Actor::Property::ClippingMode: P" );
4066 TestApplication application;
4068 Actor actor = Actor::New();
4070 // Check default clippingEnabled value.
4071 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4074 bool getValueResult = getValue.Get( value );
4075 DALI_TEST_CHECK( getValueResult );
4077 if( getValueResult )
4079 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4082 // Check setting the property to the stencil mode.
4083 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4085 // Check the new value was set.
4086 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4087 getValueResult = getValue.Get( value );
4088 DALI_TEST_CHECK( getValueResult );
4090 if( getValueResult )
4092 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4095 // Check setting the property to the scissor mode.
4096 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4098 // Check the new value was set.
4099 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4100 getValueResult = getValue.Get( value );
4101 DALI_TEST_CHECK( getValueResult );
4103 if( getValueResult )
4105 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION );
4110 int UtcDaliActorPropertyClippingN(void)
4112 // Negative test case for Clipping.
4113 tet_infoline( "Testing Actor::Property::ClippingMode: N" );
4114 TestApplication application;
4116 Actor actor = Actor::New();
4118 // Check default clippingEnabled value.
4119 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4122 bool getValueResult = getValue.Get( value );
4123 DALI_TEST_CHECK( getValueResult );
4125 if( getValueResult )
4127 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4130 // Check setting an invalid property value won't change the current property value.
4131 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4133 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4134 getValueResult = getValue.Get( value );
4135 DALI_TEST_CHECK( getValueResult );
4137 if( getValueResult )
4139 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4145 int UtcDaliActorPropertyClippingActor(void)
4147 // This test checks that an actor is correctly setup for clipping.
4148 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor" );
4149 TestApplication application;
4151 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4152 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4153 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4154 size_t startIndex = 0u;
4156 // Create a clipping actor.
4157 Actor actorDepth1Clip = CreateActorWithContent16x16();
4158 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4159 Stage::GetCurrent().Add( actorDepth1Clip );
4161 // Gather the call trace.
4162 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4164 // Check we are writing to the color buffer.
4165 CheckColorMask( glAbstraction, true );
4167 // Check the stencil buffer was enabled.
4168 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4170 // Check the stencil buffer was cleared.
4171 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4173 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4174 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4175 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4176 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4181 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4183 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4184 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable" );
4185 TestApplication application;
4187 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4188 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4189 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4190 size_t startIndex = 0u;
4192 // Create a clipping actor.
4193 Actor actorDepth1Clip = CreateActorWithContent16x16();
4194 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4195 Stage::GetCurrent().Add( actorDepth1Clip );
4197 // Gather the call trace.
4198 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4200 // Check we are writing to the color buffer.
4201 CheckColorMask( glAbstraction, true );
4203 // Check the stencil buffer was enabled.
4204 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
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 ) );
4212 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4214 // Now disable the clipping
4215 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4217 // Gather the call trace.
4218 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4220 // Check the stencil buffer was disabled.
4221 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4223 // Ensure all values in stencil-mask are set to 1.
4225 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4230 int UtcDaliActorPropertyClippingNestedChildren(void)
4232 // This test checks that a hierarchy of actors are clipped correctly by
4233 // writing to and reading from the correct bit-planes of the stencil buffer.
4234 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children" );
4235 TestApplication application;
4236 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4237 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4238 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4240 // Create a clipping actor.
4241 Actor actorDepth1Clip = CreateActorWithContent16x16();
4242 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4243 Stage::GetCurrent().Add( actorDepth1Clip );
4245 // Create a child actor.
4246 Actor childDepth2 = CreateActorWithContent16x16();
4247 actorDepth1Clip.Add( childDepth2 );
4249 // Create another clipping actor.
4250 Actor childDepth2Clip = CreateActorWithContent16x16();
4251 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4252 childDepth2.Add( childDepth2Clip );
4254 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4255 // This tests the sort algorithm.
4256 Actor childDepth3 = CreateActorWithContent16x16();
4257 childDepth2Clip.Add( childDepth3 );
4258 Actor childDepth4 = CreateActorWithContent16x16();
4259 childDepth3.Add( childDepth4 );
4261 // Gather the call trace.
4262 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4264 // Check we are writing to the color buffer.
4265 CheckColorMask( glAbstraction, true );
4267 // Check the stencil buffer was enabled.
4268 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4270 // Perform the test twice, once for 2D layer, and once for 3D.
4271 for( unsigned int i = 0u ; i < 2u; ++i )
4273 size_t startIndex = 0u;
4275 // Check the stencil buffer was cleared.
4276 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4278 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4279 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4280 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4281 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4283 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4284 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4285 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4287 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4288 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4289 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4290 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4292 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4293 // (Both must be set to pass the check).
4294 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4295 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4297 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4300 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4301 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4308 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4310 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4311 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order" );
4312 TestApplication application;
4313 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4314 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4316 /* We create a small tree of actors as follows:
4320 Clipping enabled -> B D
4324 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4327 for( int i = 0; i < 5; ++i )
4329 BufferImage image = BufferImage::New( 16u, 16u );
4330 Actor actor = CreateRenderableActor( image );
4332 // Setup dimensions and position so actor is not skipped by culling.
4333 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
4334 actor.SetSize( 16.0f, 16.0f );
4338 actor.SetParentOrigin( ParentOrigin::CENTER );
4342 float b = i > 2 ? 1.0f : -1.0f;
4343 actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
4349 // Enable clipping on the actor at the top of the left branch.
4350 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4352 // Build the scene graph.
4353 Stage::GetCurrent().Add( actors[0] );
4356 actors[0].Add( actors[1] );
4357 actors[1].Add( actors[2] );
4360 actors[0].Add( actors[3] );
4361 actors[3].Add( actors[4] );
4363 // Gather the call trace.
4364 enabledDisableTrace.Reset();
4365 enabledDisableTrace.Enable( true );
4366 application.SendNotification();
4367 application.Render();
4368 enabledDisableTrace.Enable( false );
4370 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4372 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
4373 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4375 size_t startIndex = 0u;
4376 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
4377 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
4378 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4380 // Swap the clipping actor from top of left branch to top of right branch.
4381 actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4382 actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4384 // Gather the call trace.
4385 enabledDisableTrace.Reset();
4386 enabledDisableTrace.Enable( true );
4387 application.SendNotification();
4388 application.Render();
4389 enabledDisableTrace.Enable( false );
4391 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4392 // This proves the draw order has remained the same.
4394 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
4395 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
4400 int UtcDaliActorPropertyScissorClippingActor(void)
4402 // This test checks that an actor is correctly setup for clipping.
4403 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor" );
4404 TestApplication application;
4406 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4407 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4408 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4410 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4411 const Vector2 imageSize( 16.0f, 16.0f );
4413 // Create a clipping actor.
4414 Actor clippingActorA = CreateActorWithContent16x16();
4415 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4416 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4417 clippingActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
4418 clippingActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
4419 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4420 Stage::GetCurrent().Add( clippingActorA );
4422 // Gather the call trace.
4423 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4425 // Check we are writing to the color buffer.
4426 CheckColorMask( glAbstraction, true );
4428 // Check scissor test was enabled.
4429 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4431 // Check the scissor was set, and the coordinates are correct.
4432 std::stringstream compareParametersString;
4433 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4434 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 0, 0, 16, 16
4436 clippingActorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
4437 clippingActorA.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
4439 // Gather the call trace.
4440 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4442 // Check the scissor was set, and the coordinates are correct.
4443 compareParametersString.str( std::string() );
4444 compareParametersString.clear();
4445 compareParametersString << ( stageSize.x - imageSize.x ) << ", " << ( stageSize.y - imageSize.y ) << ", " << imageSize.x << ", " << imageSize.y;
4446 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with 464, 784, 16, 16
4451 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4453 // This test checks that an actor is correctly setup for clipping.
4454 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings" );
4455 TestApplication application;
4458 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4459 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4460 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4462 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4463 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4464 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4466 // Create a clipping actors.
4467 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4468 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4470 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4471 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4472 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4474 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4475 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4476 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4478 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4479 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4481 Stage::GetCurrent().Add( clippingActorA );
4482 Stage::GetCurrent().Add( clippingActorB );
4484 // Gather the call trace.
4485 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4487 // Check we are writing to the color buffer.
4488 CheckColorMask( glAbstraction, true );
4490 // Check scissor test was enabled.
4491 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4493 // Check the scissor was set, and the coordinates are correct.
4494 std::stringstream compareParametersString;
4496 std::string clipA( "0, 500, 480, 200" );
4497 std::string clipB( "0, 380, 480, 40" );
4499 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4500 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4505 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4507 // This test checks that an actor is correctly setup for clipping.
4508 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4509 TestApplication application;
4511 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4512 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4513 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4515 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4516 const Vector2 imageSize( 16.0f, 16.0f );
4518 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4520 A is drawn first - with scissor clipping on
4521 B is drawn second - also with scissor clipping on
4522 C is the generated clipping region, the intersection ( A ∩ B )
4526 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4527 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4528 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4532 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4535 // Create a clipping actor.
4536 Actor clippingActorA = CreateActorWithContent16x16();
4537 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4538 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4539 clippingActorA.SetParentOrigin( ParentOrigin::CENTER );
4540 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER );
4541 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4542 Stage::GetCurrent().Add( clippingActorA );
4544 // Create a child clipping actor.
4545 Actor clippingActorB = CreateActorWithContent16x16();
4546 clippingActorB.SetParentOrigin( ParentOrigin::CENTER );
4547 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER );
4548 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4549 clippingActorA.Add( clippingActorB );
4551 // positionModifiers is an array of positions to position B around.
4552 // expect is an array of expected scissor clip coordinate results.
4553 const Vector2 positionModifiers[4] = { Vector2( 1.0f, 1.0f ), Vector2( -1.0f, 1.0f ), Vector2( -1.0f, -1.0f ), Vector2( 1.0f, -1.0f ) };
4554 const Vector4 expect[4] = { Vector4( 240, 392, 8, 8 ), Vector4( 232, 392, 8, 8 ), Vector4( 232, 400, 8, 8 ), Vector4( 240, 400, 8, 8 ) };
4556 // Loop through each overlap combination.
4557 for( unsigned int test = 0u; test < 4u; ++test )
4559 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4560 const Vector2 position = ( imageSize / 2.0f ) * positionModifiers[test];
4561 clippingActorB.SetPosition( position.x, position.y );
4563 // Gather the call trace.
4564 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4566 // Check we are writing to the color buffer.
4567 CheckColorMask( glAbstraction, true );
4569 // Check scissor test was enabled.
4570 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4572 // Check the scissor was set, and the coordinates are correct.
4573 const Vector4& expectResults( expect[test] );
4574 std::stringstream compareParametersString;
4575 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4576 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", compareParametersString.str() ) ); // Compare with the expected result
4582 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4584 // This test checks that an actor is correctly setup for clipping.
4585 tet_infoline( "Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested" );
4586 TestApplication application;
4588 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4589 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4590 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4592 /* Create a nest of 2 scissors and siblings of the parent.
4602 const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT );
4603 const Vector2 sizeA{ stageSize.width, stageSize.height * 0.25f };
4604 const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f };
4605 const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f };
4606 const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f };
4607 const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f };
4609 // Create a clipping actors.
4610 Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height );
4611 Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height );
4612 Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height );
4613 Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height );
4614 Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height );
4616 clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4617 clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4618 clippingActorA.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4620 clippingActorB.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4621 clippingActorB.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4622 clippingActorB.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4624 clippingActorC.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4625 clippingActorC.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4626 clippingActorC.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4628 clippingActorD.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4629 clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4630 clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4632 clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT );
4633 clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
4635 clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f );
4636 clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f );
4637 clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f );
4638 clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f );
4639 clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f );
4641 Stage::GetCurrent().Add( clippingActorA );
4642 clippingActorA.Add( clippingActorB );
4643 Stage::GetCurrent().Add( clippingActorC );
4644 Stage::GetCurrent().Add( clippingActorD );
4645 clippingActorD.Add( clippingActorE );
4647 // Gather the call trace.
4648 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4650 // Check we are writing to the color buffer.
4651 CheckColorMask( glAbstraction, true );
4653 // Check scissor test was enabled.
4654 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4656 // Check the scissor was set, and the coordinates are correct.
4657 std::string clipA( "0, 500, 480, 200" );
4658 std::string clipB( "0, 580, 480, 40" );
4659 std::string clipC( "0, 200, 480, 200" );
4660 std::string clipD( "0, 300, 480, 200" );
4662 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipA ) );
4663 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipB ) );
4664 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipC ) );
4665 DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", clipD ) );
4666 DALI_TEST_CHECK( scissorTrace.CountMethod( "Scissor" ) == 4 ); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4671 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4673 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4674 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4675 TestApplication application;
4677 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4678 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4679 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4681 // Create a clipping actor.
4682 Actor actorDepth1Clip = CreateActorWithContent16x16();
4683 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4684 Stage::GetCurrent().Add( actorDepth1Clip );
4686 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4687 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4689 // Gather the call trace.
4690 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4692 // Check we are writing to the color buffer.
4693 CheckColorMask( glAbstraction, true );
4695 // Check the stencil buffer was not enabled.
4696 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4698 // Check stencil functions are not called.
4699 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4700 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4701 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4703 // Check that scissor clipping is overriden by the renderer properties.
4704 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4706 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
4708 // Gather the call trace.
4709 GenerateTrace( application, enabledDisableTrace, scissorTrace );
4711 // Check the stencil buffer was not enabled.
4712 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4714 DALI_TEST_CHECK( !scissorTrace.FindMethod( "StencilFunc" ) );
4719 int UtcDaliGetPropertyN(void)
4721 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4722 TestApplication app;
4724 Actor actor = Actor::New();
4726 unsigned int propertyCount = actor.GetPropertyCount();
4727 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4731 int UtcDaliActorRaiseLower(void)
4733 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4735 TestApplication application;
4737 Stage stage( Stage::GetCurrent() );
4739 Actor actorA = Actor::New();
4740 Actor actorB = Actor::New();
4741 Actor actorC = Actor::New();
4743 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4744 actorA.SetParentOrigin( ParentOrigin::CENTER );
4746 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4747 actorB.SetParentOrigin( ParentOrigin::CENTER );
4749 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4750 actorC.SetParentOrigin( ParentOrigin::CENTER );
4752 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4753 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4755 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4756 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4758 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4759 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4761 stage.Add( actorA );
4762 stage.Add( actorB );
4763 stage.Add( actorC );
4765 ResetTouchCallbacks();
4767 application.SendNotification();
4768 application.Render();
4770 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4771 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4772 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4774 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4775 // Only top actor will get touched.
4776 actorA.TouchSignal().Connect( TestTouchCallback );
4777 actorB.TouchSignal().Connect( TestTouchCallback2 );
4778 actorC.TouchSignal().Connect( TestTouchCallback3 );
4780 Dali::Integration::Point point;
4781 point.SetDeviceId( 1 );
4782 point.SetState( PointState::DOWN );
4783 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4784 Dali::Integration::TouchEvent touchEvent;
4785 touchEvent.AddPoint( point );
4787 application.ProcessEvent( touchEvent );
4789 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4790 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4791 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4793 ResetTouchCallbacks();
4795 tet_printf( "Testing Raising of Actor\n" );
4797 int preActorOrder( 0 );
4798 int postActorOrder( 0 );
4800 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4801 value.Get( preActorOrder );
4804 // Ensure sort order is calculated before next touch event
4805 application.SendNotification();
4807 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4808 value.Get( postActorOrder );
4810 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4812 application.ProcessEvent( touchEvent );
4814 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4815 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4816 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4818 ResetTouchCallbacks();
4820 tet_printf( "Testing Lowering of Actor\n" );
4822 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4823 value.Get( preActorOrder );
4826 application.SendNotification(); // ensure sort order calculated before next touch event
4828 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4829 value.Get( postActorOrder );
4831 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4833 application.ProcessEvent( touchEvent );
4835 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4836 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4837 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4839 ResetTouchCallbacks();
4844 int UtcDaliActorRaiseToTopLowerToBottom(void)
4846 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4848 TestApplication application;
4850 Stage stage( Stage::GetCurrent() );
4852 Actor actorA = Actor::New();
4853 Actor actorB = Actor::New();
4854 Actor actorC = Actor::New();
4856 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4857 // enables checking of which actor the uniform is assigned too
4858 Shader shaderA = CreateShader();
4859 shaderA.RegisterProperty( "uRendererColor",1.f);
4861 Shader shaderB = CreateShader();
4862 shaderB.RegisterProperty( "uRendererColor", 2.f );
4864 Shader shaderC = CreateShader();
4865 shaderC.RegisterProperty( "uRendererColor", 3.f );
4867 Geometry geometry = CreateQuadGeometry();
4869 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4870 Renderer rendererA = Renderer::New(geometry, shaderA);
4871 actorA.AddRenderer(rendererA);
4873 Renderer rendererB = Renderer::New(geometry, shaderB);
4874 actorB.AddRenderer(rendererB);
4876 Renderer rendererC = Renderer::New(geometry, shaderC);
4877 actorC.AddRenderer(rendererC);
4879 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4880 actorA.SetParentOrigin( ParentOrigin::CENTER );
4882 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4883 actorB.SetParentOrigin( ParentOrigin::CENTER );
4885 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4886 actorC.SetParentOrigin( ParentOrigin::CENTER );
4888 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4889 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4891 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4892 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4894 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4895 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4897 stage.Add( actorA );
4898 stage.Add( actorB );
4899 stage.Add( actorC );
4901 ResetTouchCallbacks();
4903 // Set up gl abstraction trace so can query the set uniform order
4904 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4905 glAbstraction.EnableSetUniformCallTrace(true);
4906 glAbstraction.ResetSetUniformCallStack();
4908 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4910 application.SendNotification();
4911 application.Render();
4913 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4916 // Test order of uniforms in stack
4917 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4918 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4919 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4921 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4923 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4925 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4926 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4927 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4929 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4930 // Only top actor will get touched.
4931 actorA.TouchSignal().Connect( TestTouchCallback );
4932 actorB.TouchSignal().Connect( TestTouchCallback2 );
4933 actorC.TouchSignal().Connect( TestTouchCallback3 );
4935 Dali::Integration::Point point;
4936 point.SetDeviceId( 1 );
4937 point.SetState( PointState::DOWN );
4938 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4939 Dali::Integration::TouchEvent touchEvent;
4940 touchEvent.AddPoint( point );
4942 application.ProcessEvent( touchEvent );
4944 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4945 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4946 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4948 ResetTouchCallbacks();
4950 tet_printf( "RaiseToTop ActorA\n" );
4952 actorA.RaiseToTop();
4953 application.SendNotification(); // ensure sorting order is calculated before next touch event
4955 application.ProcessEvent( touchEvent );
4957 glAbstraction.ResetSetUniformCallStack();
4958 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4960 application.SendNotification();
4961 application.Render();
4963 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4965 // Test order of uniforms in stack
4966 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4967 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4968 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4970 tet_infoline( "Testing A above C and B at bottom\n" );
4971 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4973 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4975 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4976 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4977 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4979 ResetTouchCallbacks();
4981 tet_printf( "RaiseToTop ActorB\n" );
4983 actorB.RaiseToTop();
4984 application.SendNotification(); // Ensure sort order is calculated before next touch event
4986 application.ProcessEvent( touchEvent );
4988 glAbstraction.ResetSetUniformCallStack();
4989 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4991 application.SendNotification();
4992 application.Render();
4994 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4996 // Test order of uniforms in stack
4997 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4998 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4999 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5001 tet_infoline( "Testing B above A and C at bottom\n" );
5002 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
5004 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
5006 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5007 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5008 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5010 ResetTouchCallbacks();
5012 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
5014 actorA.LowerToBottom();
5015 application.SendNotification();
5016 application.Render();
5018 actorB.LowerToBottom();
5019 application.SendNotification();
5020 application.Render();
5022 application.ProcessEvent( touchEvent );
5024 glAbstraction.ResetSetUniformCallStack();
5025 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5027 application.SendNotification();
5028 application.Render();
5030 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5032 // Test order of uniforms in stack
5033 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5034 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5035 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5037 tet_infoline( "Testing C above A and B at bottom\n" );
5038 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
5040 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
5042 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5043 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5044 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5046 ResetTouchCallbacks();
5051 int UtcDaliActorRaiseAbove(void)
5053 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
5055 TestApplication application;
5057 Stage stage( Stage::GetCurrent() );
5059 Actor actorA = Actor::New();
5060 Actor actorB = Actor::New();
5061 Actor actorC = Actor::New();
5063 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5064 actorA.SetParentOrigin( ParentOrigin::CENTER );
5066 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5067 actorB.SetParentOrigin( ParentOrigin::CENTER );
5069 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5070 actorC.SetParentOrigin( ParentOrigin::CENTER );
5072 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5073 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5075 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5076 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5078 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5079 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5081 stage.Add( actorA );
5082 stage.Add( actorB );
5083 stage.Add( actorC );
5085 ResetTouchCallbacks();
5087 application.SendNotification();
5088 application.Render();
5090 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5091 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5092 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5094 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5095 // Only top actor will get touched.
5096 actorA.TouchSignal().Connect( TestTouchCallback );
5097 actorB.TouchSignal().Connect( TestTouchCallback2 );
5098 actorC.TouchSignal().Connect( TestTouchCallback3 );
5100 Dali::Integration::Point point;
5101 point.SetDeviceId( 1 );
5102 point.SetState( PointState::DOWN );
5103 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5104 Dali::Integration::TouchEvent touchEvent;
5105 touchEvent.AddPoint( point );
5107 application.ProcessEvent( touchEvent );
5109 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5110 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5111 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5113 ResetTouchCallbacks();
5115 tet_printf( "Raise actor B Above Actor C\n" );
5117 actorB.RaiseAbove( actorC );
5118 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5119 application.SendNotification();
5121 application.ProcessEvent( touchEvent );
5123 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5124 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5125 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5127 ResetTouchCallbacks();
5129 tet_printf( "Raise actor A Above Actor B\n" );
5131 actorA.RaiseAbove( actorB );
5133 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5134 application.SendNotification();
5136 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
5138 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5139 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5140 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5142 ResetTouchCallbacks();
5147 int UtcDaliActorLowerBelow(void)
5149 tet_infoline( "UtcDaliActor LowerBelow test \n" );
5151 TestApplication application;
5153 Stage stage( Stage::GetCurrent() );
5155 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5156 // enables checking of which actor the uniform is assigned too
5157 Shader shaderA = CreateShader();
5158 shaderA.RegisterProperty( "uRendererColor",1.f);
5160 Shader shaderB = CreateShader();
5161 shaderB.RegisterProperty( "uRendererColor", 2.f );
5163 Shader shaderC = CreateShader();
5164 shaderC.RegisterProperty( "uRendererColor", 3.f );
5166 Actor actorA = Actor::New();
5167 Actor actorB = Actor::New();
5168 Actor actorC = Actor::New();
5170 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5171 Geometry geometry = CreateQuadGeometry();
5173 Renderer rendererA = Renderer::New(geometry, shaderA);
5174 actorA.AddRenderer(rendererA);
5176 Renderer rendererB = Renderer::New(geometry, shaderB);
5177 actorB.AddRenderer(rendererB);
5179 Renderer rendererC = Renderer::New(geometry, shaderC);
5180 actorC.AddRenderer(rendererC);
5182 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5183 actorA.SetParentOrigin( ParentOrigin::CENTER );
5185 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5186 actorB.SetParentOrigin( ParentOrigin::CENTER );
5188 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5189 actorC.SetParentOrigin( ParentOrigin::CENTER );
5191 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5192 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5194 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5195 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5197 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5198 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5200 Actor container = Actor::New();
5201 container.SetParentOrigin( ParentOrigin::CENTER );
5202 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
5203 stage.Add( container );
5205 container.Add( actorA );
5206 container.Add( actorB );
5207 container.Add( actorC );
5209 ResetTouchCallbacks();
5211 // Set up gl abstraction trace so can query the set uniform order
5212 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5213 glAbstraction.EnableSetUniformCallTrace(true);
5214 glAbstraction.ResetSetUniformCallStack();
5215 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5217 glAbstraction.ResetSetUniformCallStack();
5219 application.SendNotification();
5220 application.Render();
5222 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5224 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5226 // Test order of uniforms in stack
5227 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5228 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5229 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5231 tet_infoline( "Testing C above B and A at bottom\n" );
5232 bool CBA = ( indexC > indexB) && ( indexB > indexA );
5234 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
5236 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5237 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5238 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5240 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5241 // Only top actor will get touched.
5242 actorA.TouchSignal().Connect( TestTouchCallback );
5243 actorB.TouchSignal().Connect( TestTouchCallback2 );
5244 actorC.TouchSignal().Connect( TestTouchCallback3 );
5246 Dali::Integration::Point point;
5247 point.SetDeviceId( 1 );
5248 point.SetState( PointState::DOWN );
5249 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5250 Dali::Integration::TouchEvent touchEvent;
5251 touchEvent.AddPoint( point );
5253 tet_infoline( "UtcDaliActor Test Set up completed \n" );
5255 application.ProcessEvent( touchEvent );
5257 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5258 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5259 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5261 ResetTouchCallbacks();
5263 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" );
5265 actorC.LowerBelow( actorB );
5266 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5267 application.SendNotification();
5268 application.Render();
5270 application.ProcessEvent( touchEvent ); // touch event
5272 glAbstraction.ResetSetUniformCallStack();
5273 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5275 application.SendNotification();
5276 application.Render();
5278 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5280 // Test order of uniforms in stack
5281 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5282 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5283 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5285 tet_infoline( "Testing render order is A, C, B" );
5286 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
5287 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
5289 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5290 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5291 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5293 ResetTouchCallbacks();
5295 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
5297 actorC.LowerBelow( actorA );
5298 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5299 application.SendNotification();
5300 application.Render();
5302 application.ProcessEvent( touchEvent );
5304 glAbstraction.ResetSetUniformCallStack();
5305 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5307 application.Render();
5308 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5310 // Test order of uniforms in stack
5311 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5312 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5313 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5315 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5316 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
5318 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5319 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5320 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5322 ResetTouchCallbacks();
5324 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
5326 actorB.LowerBelow( actorC );
5327 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5328 application.SendNotification();
5329 application.Render();
5331 application.ProcessEvent( touchEvent );
5333 glAbstraction.ResetSetUniformCallStack();
5334 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5336 application.Render();
5337 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
5339 // Test order of uniforms in stack
5340 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
5341 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
5342 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
5344 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
5345 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
5351 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5353 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
5355 TestApplication application;
5357 Stage stage( Stage::GetCurrent() );
5359 Actor parentA = Actor::New();
5360 Actor parentB = Actor::New();
5361 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5362 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5363 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5364 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5366 parentA.SetAnchorPoint( AnchorPoint::CENTER );
5367 parentA.SetParentOrigin( ParentOrigin::CENTER );
5369 parentB.SetAnchorPoint( AnchorPoint::CENTER );
5370 parentB.SetParentOrigin( ParentOrigin::CENTER );
5372 stage.Add( parentA );
5373 stage.Add( parentB );
5375 Actor actorA = Actor::New();
5376 Actor actorB = Actor::New();
5377 Actor actorC = Actor::New();
5379 parentA.Add( actorA );
5380 parentA.Add( actorB );
5382 tet_printf( "Actor C added to different parent from A and B \n" );
5383 parentB.Add( actorC );
5385 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5386 actorA.SetParentOrigin( ParentOrigin::CENTER );
5388 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5389 actorB.SetParentOrigin( ParentOrigin::CENTER );
5391 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5392 actorC.SetParentOrigin( ParentOrigin::CENTER );
5394 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5395 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5397 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5398 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5400 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5401 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5403 ResetTouchCallbacks();
5405 application.SendNotification();
5406 application.Render();
5408 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5409 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5410 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5412 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5413 // Only top actor will get touched.
5414 actorA.TouchSignal().Connect( TestTouchCallback );
5415 actorB.TouchSignal().Connect( TestTouchCallback2 );
5416 actorC.TouchSignal().Connect( TestTouchCallback3 );
5418 Dali::Integration::Point point;
5419 point.SetDeviceId( 1 );
5420 point.SetState( PointState::DOWN );
5421 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5422 Dali::Integration::TouchEvent touchEvent;
5423 touchEvent.AddPoint( point );
5425 application.ProcessEvent( touchEvent );
5427 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5428 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5429 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5431 ResetTouchCallbacks();
5433 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
5435 actorA.RaiseAbove( actorC );
5436 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5437 application.SendNotification();
5439 application.ProcessEvent( touchEvent ); // touch event
5441 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5442 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5443 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5445 ResetTouchCallbacks();
5450 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5452 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
5454 TestApplication application;
5456 Stage stage( Stage::GetCurrent() );
5458 Actor actorA = Actor::New();
5459 Actor actorB = Actor::New();
5460 Actor actorC = Actor::New();
5462 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5463 actorA.SetParentOrigin( ParentOrigin::CENTER );
5465 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5466 actorB.SetParentOrigin( ParentOrigin::CENTER );
5468 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5469 actorC.SetParentOrigin( ParentOrigin::CENTER );
5471 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5472 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5474 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5475 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5477 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5478 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5480 ResetTouchCallbacks();
5482 application.SendNotification();
5483 application.Render();
5485 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5486 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5487 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5489 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5490 // Only top actor will get touched.
5491 actorA.TouchSignal().Connect( TestTouchCallback );
5492 actorB.TouchSignal().Connect( TestTouchCallback2 );
5493 actorC.TouchSignal().Connect( TestTouchCallback3 );
5495 Dali::Integration::Point point;
5496 point.SetDeviceId( 1 );
5497 point.SetState( PointState::DOWN );
5498 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5499 Dali::Integration::TouchEvent touchEvent;
5500 touchEvent.AddPoint( point );
5502 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5504 actorA.RaiseAbove( actorC );
5505 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5506 application.SendNotification();
5508 application.ProcessEvent( touchEvent );
5510 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5512 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5513 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5514 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5516 ResetTouchCallbacks();
5518 stage.Add ( actorB );
5519 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5520 actorA.LowerBelow( actorC );
5522 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5523 application.SendNotification();
5524 application.Render();
5526 application.ProcessEvent( touchEvent );
5528 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5529 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5530 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5531 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5533 ResetTouchCallbacks();
5535 tet_printf( "Adding Actor A to stage, will be on top\n" );
5537 stage.Add ( actorA );
5538 application.SendNotification();
5539 application.Render();
5541 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5542 actorB.RaiseAbove( actorC );
5543 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5544 application.SendNotification();
5546 application.ProcessEvent( touchEvent );
5548 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5549 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5550 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5551 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5553 ResetTouchCallbacks();
5555 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5556 actorA.LowerBelow( actorC );
5557 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5558 application.SendNotification();
5560 application.ProcessEvent( touchEvent );
5562 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5563 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5564 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5565 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5567 ResetTouchCallbacks();
5569 stage.Add ( actorC );
5570 actorA.RaiseAbove( actorC );
5571 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5572 application.SendNotification();
5573 application.Render();
5575 application.ProcessEvent( touchEvent );
5577 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5578 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5579 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5580 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5585 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5587 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5589 TestApplication application;
5591 Stage stage( Stage::GetCurrent() );
5593 Actor actorA = Actor::New();
5594 Actor actorB = Actor::New();
5595 Actor actorC = Actor::New();
5597 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5598 actorA.SetParentOrigin( ParentOrigin::CENTER );
5600 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5601 actorB.SetParentOrigin( ParentOrigin::CENTER );
5603 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5604 actorC.SetParentOrigin( ParentOrigin::CENTER );
5606 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5607 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5609 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5610 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5612 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5613 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5615 ResetTouchCallbacks();
5617 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5618 // Only top actor will get touched.
5619 actorA.TouchSignal().Connect( TestTouchCallback );
5620 actorB.TouchSignal().Connect( TestTouchCallback2 );
5621 actorC.TouchSignal().Connect( TestTouchCallback3 );
5623 Dali::Integration::Point point;
5624 point.SetDeviceId( 1 );
5625 point.SetState( PointState::DOWN );
5626 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5627 Dali::Integration::TouchEvent touchEvent;
5628 touchEvent.AddPoint( point );
5630 stage.Add ( actorA );
5631 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5634 application.SendNotification();
5635 application.Render();
5637 application.ProcessEvent( touchEvent );
5639 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5641 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5642 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5643 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5645 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5646 ResetTouchCallbacks();
5649 // Sort actor tree before next touch event
5650 application.SendNotification();
5651 application.Render();
5653 application.ProcessEvent( touchEvent );
5655 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5657 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5658 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5659 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5660 ResetTouchCallbacks();
5662 tet_printf( "Lower actor C below B but C not parented\n" );
5665 // Sort actor tree before next touch event
5666 application.SendNotification();
5667 application.Render();
5669 application.ProcessEvent( touchEvent );
5671 tet_printf( "Not parented so Lower should show no effect\n" );
5673 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5674 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5675 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5676 ResetTouchCallbacks();
5678 tet_printf( "Raise actor B to top\n" );
5680 actorB.RaiseToTop();
5681 // Sort actor tree before next touch event
5682 application.SendNotification();
5683 application.Render();
5685 application.ProcessEvent( touchEvent );
5687 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5689 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5690 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5691 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5692 ResetTouchCallbacks();
5694 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5696 stage.Add ( actorB );
5698 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5700 actorC.LowerToBottom();
5701 application.SendNotification();
5702 application.Render();
5704 application.ProcessEvent( touchEvent );
5706 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5708 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5709 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5710 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5711 ResetTouchCallbacks();
5717 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5719 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5721 TestApplication application;
5723 Stage stage( Stage::GetCurrent() );
5725 Actor actorA = Actor::New();
5726 Actor actorB = Actor::New();
5727 Actor actorC = Actor::New();
5729 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5730 actorA.SetParentOrigin( ParentOrigin::CENTER );
5732 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5733 actorB.SetParentOrigin( ParentOrigin::CENTER );
5735 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5736 actorC.SetParentOrigin( ParentOrigin::CENTER );
5738 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5739 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5741 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5742 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5744 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5745 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5747 stage.Add( actorA );
5748 stage.Add( actorB );
5749 stage.Add( actorC );
5751 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5752 // Only top actor will get touched.
5753 actorA.TouchSignal().Connect( TestTouchCallback );
5754 actorB.TouchSignal().Connect( TestTouchCallback2 );
5755 actorC.TouchSignal().Connect( TestTouchCallback3 );
5757 ResetTouchCallbacks();
5759 application.SendNotification();
5760 application.Render();
5762 Dali::Integration::Point point;
5763 point.SetDeviceId( 1 );
5764 point.SetState( PointState::DOWN );
5765 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5766 Dali::Integration::TouchEvent touchEvent;
5767 touchEvent.AddPoint( point );
5769 application.ProcessEvent( touchEvent );
5771 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5772 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5773 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5775 ResetTouchCallbacks();
5777 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5779 actorA.RaiseAbove( actorA );
5780 application.SendNotification();
5781 application.Render();
5783 application.ProcessEvent( touchEvent );
5785 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5787 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5788 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5789 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5791 ResetTouchCallbacks();
5793 actorA.RaiseAbove( actorC );
5794 application.SendNotification();
5795 application.Render();
5797 application.ProcessEvent( touchEvent );
5799 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5800 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5801 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5802 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5807 int UtcDaliActorGetScreenPosition(void)
5809 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5811 TestApplication application;
5813 Stage stage( Stage::GetCurrent() );
5815 Actor actorA = Actor::New();
5816 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5818 Vector2 size2( 10.0f, 20.0f );
5819 actorA.SetSize( size2 );
5821 actorA.SetPosition( 0.f, 0.f );
5823 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5825 stage.Add( actorA );
5827 application.SendNotification();
5828 application.Render();
5830 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5831 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5833 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5834 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5836 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5837 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5839 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5841 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5843 application.SendNotification();
5844 application.Render();
5846 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5847 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5849 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5850 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5852 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5853 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5855 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5857 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5859 application.SendNotification();
5860 application.Render();
5862 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5863 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5865 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5866 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5868 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5869 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5871 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5873 actorA.SetPosition( 30.0, 0.0 );
5875 application.SendNotification();
5876 application.Render();
5878 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5879 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5881 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5882 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5884 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5885 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5887 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5889 actorA.SetPosition( 30.0, 420.0 );
5891 application.SendNotification();
5892 application.Render();
5894 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5895 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5897 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5898 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5900 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5901 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5903 tet_infoline( "UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n" );
5905 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5906 actorA.SetPosition( 30.0, 30.0 );
5908 Actor actorB = Actor::New();
5909 actorB.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5910 actorB.SetSize( size2 );
5911 actorB.SetPosition( 10.f, 10.f );
5912 actorA.Add( actorB );
5914 actorA.SetScale( 2.0f );
5916 application.SendNotification();
5917 application.Render();
5919 actorScreenPosition = actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5921 DALI_TEST_EQUALS( actorScreenPosition.x, 50lu , TEST_LOCATION );
5922 DALI_TEST_EQUALS( actorScreenPosition.y, 50lu , TEST_LOCATION );
5927 int UtcDaliActorGetScreenPositionAfterScaling(void)
5929 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5931 TestApplication application;
5933 Stage stage( Stage::GetCurrent() );
5935 Actor actorA = Actor::New();
5936 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5938 Vector2 size2( 10.0f, 20.0f );
5939 actorA.SetSize( size2 );
5940 actorA.SetScale( 1.5f );
5941 actorA.SetPosition( 0.f, 0.f );
5943 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5945 stage.Add( actorA );
5947 application.SendNotification();
5948 application.Render();
5950 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5951 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5953 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5954 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5956 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5957 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5959 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5961 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5963 application.SendNotification();
5964 application.Render();
5966 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5967 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5969 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5970 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5972 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5973 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5978 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5980 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5982 TestApplication application;
5984 Stage stage( Stage::GetCurrent() );
5986 Actor actorA = Actor::New();
5987 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5988 actorA.SetParentOrigin( ParentOrigin::CENTER );
5989 Vector2 size2( 10.0f, 20.0f );
5990 actorA.SetSize( size2 );
5991 actorA.SetPosition( 0.f, 0.f );
5993 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5995 stage.Add( actorA );
5997 application.SendNotification();
5998 application.Render();
6000 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6001 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6003 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6004 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6006 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
6007 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
6009 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
6011 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
6012 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6014 application.SendNotification();
6015 application.Render();
6017 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6018 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6020 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
6021 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6023 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
6024 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
6030 int UtcDaliActorGetScreenPositionWithChildActors(void)
6032 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
6034 TestApplication application;
6036 Stage stage( Stage::GetCurrent() );
6038 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6040 Actor actorA = Actor::New();
6041 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6042 actorA.SetParentOrigin( ParentOrigin::CENTER );
6043 Vector2 size1( 10.0f, 20.0f );
6044 actorA.SetSize( size1 );
6045 actorA.SetPosition( 0.f, 0.f );
6047 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6049 Actor parentActorA = Actor::New();
6050 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6051 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6052 Vector2 size2( 30.0f, 60.0f );
6053 parentActorA.SetSize( size2 );
6054 parentActorA.SetPosition( 0.f, 0.f );
6056 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6058 stage.Add( parentActorA );
6059 parentActorA.Add ( actorA );
6061 application.SendNotification();
6062 application.Render();
6064 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6065 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6067 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6068 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6070 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
6071 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
6073 tet_infoline( "Test 2\n");
6075 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
6077 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6078 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
6080 application.SendNotification();
6081 application.Render();
6083 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6084 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6086 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
6087 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6089 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
6090 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
6095 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6097 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
6099 TestApplication application;
6101 Stage stage( Stage::GetCurrent() );
6103 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6105 Actor actorA = Actor::New();
6106 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6107 actorA.SetParentOrigin( ParentOrigin::CENTER );
6108 Vector2 size1( 10.0f, 20.0f );
6109 actorA.SetSize( size1 );
6110 actorA.SetPosition( 0.f, 0.f );
6112 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
6114 Actor parentActorA = Actor::New();
6115 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6116 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
6117 Vector2 size2( 30.0f, 60.0f );
6118 parentActorA.SetSize( size2 );
6119 parentActorA.SetPosition( 0.f, 0.f );
6121 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
6123 Actor grandParentActorA = Actor::New();
6124 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
6125 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
6126 Vector2 size3( 60.0f, 120.0f );
6127 grandParentActorA.SetSize( size3 );
6128 grandParentActorA.SetPosition( 0.f, 0.f );
6130 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
6132 stage.Add( grandParentActorA );
6133 grandParentActorA.Add ( parentActorA );
6135 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
6137 parentActorA.Add ( actorA );
6139 application.SendNotification();
6140 application.Render();
6142 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
6143 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
6145 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
6146 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
6148 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
6149 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
6154 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6156 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
6158 TestApplication application;
6160 Stage stage( Stage::GetCurrent() );
6162 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6164 Actor actorA = Actor::New();
6165 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6166 actorA.SetParentOrigin( ParentOrigin::CENTER );
6167 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6168 actorA.SetSize( 10.0f, 20.0f );
6169 stage.Add( actorA );
6171 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6173 Actor actorB = Actor::New();
6174 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6175 actorB.SetParentOrigin( ParentOrigin::CENTER );
6176 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6177 Vector2 actorBSize( 30.0f, 60.0f );
6178 actorB.SetSize( actorBSize );
6179 stage.Add( actorB );
6181 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
6183 Actor actorC = Actor::New();
6184 actorC.SetAnchorPoint( AnchorPoint::CENTER );
6185 actorC.SetParentOrigin( ParentOrigin::CENTER );
6186 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6187 Vector2 actorCSize( 60.0f, 120.0f );
6188 actorC.SetSize( actorCSize );
6189 stage.Add( actorC );
6191 application.SendNotification();
6192 application.Render();
6194 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
6196 Vector2 center( stage.GetSize() * 0.5f );
6198 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6199 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6200 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
6202 tet_infoline( "Add scale to all actors" );
6204 actorA.SetScale( 2.0f );
6205 actorB.SetScale( 2.0f );
6206 actorC.SetScale( 2.0f );
6208 application.SendNotification();
6209 application.Render();
6211 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
6212 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
6213 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
6218 int utcDaliActorPositionUsesAnchorPoint(void)
6220 TestApplication application;
6221 tet_infoline( "Check default behaviour\n" );
6223 Actor actor = Actor::New();
6224 actor.SetParentOrigin( ParentOrigin::CENTER );
6225 actor.SetAnchorPoint( AnchorPoint::CENTER );
6226 actor.SetSize( 100.0f, 100.0f );
6227 Stage::GetCurrent().Add( actor );
6229 application.SendNotification();
6230 application.Render();
6232 tet_infoline( "Check that the world position is in the center\n" );
6233 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6235 tet_infoline( "Set the position uses anchor point property to false\n" );
6236 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6238 application.SendNotification();
6239 application.Render();
6241 tet_infoline( "Check that the world position has changed appropriately\n" );
6242 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6247 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6249 TestApplication application;
6250 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6252 Actor actor = Actor::New();
6253 actor.SetParentOrigin( ParentOrigin::CENTER );
6254 actor.SetAnchorPoint( AnchorPoint::CENTER );
6255 actor.SetSize( 100.0f, 100.0f );
6256 actor.SetScale( 2.0f );
6257 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6258 Stage::GetCurrent().Add( actor );
6260 application.SendNotification();
6261 application.Render();
6263 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
6264 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6266 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6267 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6268 application.SendNotification();
6269 application.Render();
6270 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6272 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6273 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6274 application.SendNotification();
6275 application.Render();
6276 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
6281 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6283 TestApplication application;
6284 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6286 Actor actor = Actor::New();
6287 actor.SetParentOrigin( ParentOrigin::CENTER );
6288 actor.SetAnchorPoint( AnchorPoint::CENTER );
6289 actor.SetSize( 100.0f, 100.0f );
6290 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6291 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6292 Stage::GetCurrent().Add( actor );
6294 application.SendNotification();
6295 application.Render();
6297 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
6298 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6300 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6301 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6302 application.SendNotification();
6303 application.Render();
6304 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6306 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6307 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6308 application.SendNotification();
6309 application.Render();
6310 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
6315 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6317 TestApplication application;
6318 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6320 Actor actor = Actor::New();
6321 actor.SetParentOrigin( ParentOrigin::CENTER );
6322 actor.SetAnchorPoint( AnchorPoint::CENTER );
6323 actor.SetSize( 100.0f, 100.0f );
6324 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
6325 actor.SetScale( 2.0f );
6326 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6327 Stage::GetCurrent().Add( actor );
6329 application.SendNotification();
6330 application.Render();
6332 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
6333 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
6335 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
6336 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6337 application.SendNotification();
6338 application.Render();
6339 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
6341 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
6342 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6343 application.SendNotification();
6344 application.Render();
6345 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
6350 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6352 TestApplication application;
6353 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
6355 Actor parent = Actor::New();
6357 Stage::GetCurrent().Add( parent );
6358 Vector2 stageSize( Stage::GetCurrent().GetSize() );
6360 Actor actor = Actor::New();
6361 actor.SetParentOrigin( ParentOrigin::CENTER );
6362 actor.SetAnchorPoint( AnchorPoint::CENTER );
6363 actor.SetSize( 100.0f, 100.0f );
6364 actor.SetInheritScale( false );
6365 actor.SetInheritOrientation( false );
6366 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
6367 parent.Add( actor );
6369 application.SendNotification();
6370 application.Render();
6372 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
6374 tet_infoline( "Check the world position is in the right place\n" );
6375 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6377 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
6378 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
6379 application.SendNotification();
6380 application.Render();
6381 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6383 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
6384 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
6385 application.SendNotification();
6386 application.Render();
6387 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
6392 int utcDaliActorVisibilityChangeSignalSelf(void)
6394 TestApplication application;
6395 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
6397 Actor actor = Actor::New();
6399 VisibilityChangedFunctorData data;
6400 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6402 actor.SetVisible( false );
6404 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6406 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
6409 actor.SetVisible( false );
6410 data.Check( false /* not called */, TEST_LOCATION );
6412 tet_infoline( "Change the visibility using properties, ensure called" );
6415 actor.SetProperty( Actor::Property::VISIBLE, true );
6416 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6418 tet_infoline( "Set the visibility to current using properties, ensure not called" );
6421 actor.SetProperty( Actor::Property::VISIBLE, true );
6422 data.Check( false /* not called */, TEST_LOCATION );
6427 int utcDaliActorVisibilityChangeSignalChildren(void)
6429 TestApplication application;
6430 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
6432 Actor parent = Actor::New();
6433 Actor child = Actor::New();
6434 parent.Add( child );
6436 Actor grandChild = Actor::New();
6437 child.Add( grandChild );
6439 VisibilityChangedFunctorData parentData;
6440 VisibilityChangedFunctorData childData;
6441 VisibilityChangedFunctorData grandChildData;
6443 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
6444 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
6445 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
6447 parent.SetVisible( false );
6448 parentData.Check( false /* not called */, TEST_LOCATION );
6449 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6450 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6452 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
6455 grandChildData.Reset();
6457 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
6459 parent.SetVisible( true );
6460 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6461 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6462 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
6464 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
6467 grandChildData.Reset();
6469 parent.SetVisible( true );
6470 parentData.Check( false /* not called */, TEST_LOCATION );
6471 childData.Check( false /* not called */, TEST_LOCATION );
6472 grandChildData.Check( false /* not called */, TEST_LOCATION );
6477 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6479 TestApplication application;
6480 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
6482 Actor actor = Actor::New();
6483 Stage::GetCurrent().Add( actor );
6485 application.SendNotification();
6486 application.Render();
6488 VisibilityChangedFunctorData data;
6489 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6491 Animation animation = Animation::New( 1.0f );
6492 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6494 data.Check( false, TEST_LOCATION );
6495 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6496 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6498 tet_infoline( "Play the animation and check the property value" );
6501 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6502 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6504 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6505 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6507 application.SendNotification();
6508 application.Render( 1100 ); // After the animation
6510 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6516 static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
6518 gLayoutDirectionType = type;
6521 int UtcDaliActorLayoutDirectionProperty(void)
6523 TestApplication application;
6524 tet_infoline( "Check layout direction property" );
6526 Actor actor0 = Actor::New();
6527 DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6528 Stage::GetCurrent().Add( actor0 );
6530 application.SendNotification();
6531 application.Render();
6533 Actor actor1 = Actor::New();
6534 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6535 Actor actor2 = Actor::New();
6536 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6537 Actor actor3 = Actor::New();
6538 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6539 Actor actor4 = Actor::New();
6540 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6541 Actor actor5 = Actor::New();
6542 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6543 Actor actor6 = Actor::New();
6544 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6545 Actor actor7 = Actor::New();
6546 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6547 Actor actor8 = Actor::New();
6548 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6549 Actor actor9 = Actor::New();
6550 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6552 actor1.Add( actor2 );
6553 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6554 actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
6556 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6557 actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
6558 DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6560 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6561 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6562 DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
6564 actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6565 actor0.Add( actor1 );
6566 DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6567 DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6569 Stage::GetCurrent().Add( actor3 );
6570 actor3.Add( actor4 );
6571 actor4.Add( actor5 );
6572 actor5.Add( actor6 );
6573 actor5.Add( actor7 );
6574 actor7.Add( actor8 );
6575 actor8.Add( actor9 );
6576 actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6577 actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6579 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
6580 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
6581 DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
6583 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6585 DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6586 DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6587 DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6588 DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6589 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6590 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6591 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6593 actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
6594 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6595 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6597 actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
6598 DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6599 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6600 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
6602 actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
6603 DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
6604 DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );