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;
56 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
58 gTestConstraintCalled = true;
63 * TestConstraint reference.
64 * When constraint is called, the resultRef is updated
65 * with the value supplied.
68 struct TestConstraintRef
70 TestConstraintRef(unsigned int& resultRef, unsigned int value)
71 : mResultRef(resultRef),
76 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
81 unsigned int& mResultRef;
85 static bool TestCallback(Actor actor, const TouchEvent& event)
87 gTouchCallBackCalled = true;
92 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
94 gTouchCallBackCalled = true;
99 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
101 gTouchCallBackCalled2 = true;
106 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
108 gTouchCallBackCalled3 = true;
113 static void ResetTouchCallbacks()
115 gTouchCallBackCalled = false;
116 gTouchCallBackCalled2 = false;
117 gTouchCallBackCalled3 = false;
120 static bool TestCallback3(Actor actor, const HoverEvent& event)
122 gHoverCallBackCalled = true;
127 // validation stuff for onstage & offstage signals
128 static std::vector< std::string > gActorNamesOnOffStage;
129 static int gOnStageCallBackCalled;
130 void OnStageCallback( Actor actor )
132 ++gOnStageCallBackCalled;
133 gActorNamesOnOffStage.push_back( actor.GetName() );
134 DALI_TEST_CHECK( actor.OnStage() == true );
136 static int gOffStageCallBackCalled;
137 void OffStageCallback( Actor actor )
139 ++gOffStageCallBackCalled;
140 gActorNamesOnOffStage.push_back( actor.GetName() );
141 DALI_TEST_CHECK( actor.OnStage() == false );
144 struct PositionComponentConstraint
146 PositionComponentConstraint(){}
148 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
150 const Matrix& m = inputs[0]->GetMatrix();
153 m.GetTransformComponents(pos, rot, scale);
157 struct OrientationComponentConstraint
159 OrientationComponentConstraint(){}
161 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
163 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
166 orientation = parentOrientation;
171 static bool gOnRelayoutCallBackCalled = false;
172 static std::vector< std::string > gActorNamesRelayout;
174 void OnRelayoutCallback( Actor actor )
176 gOnRelayoutCallBackCalled = true;
177 gActorNamesRelayout.push_back( actor.GetName() );
180 struct VisibilityChangedFunctorData
182 VisibilityChangedFunctorData()
185 type( DevelActor::VisibilityChange::SELF ),
194 type = DevelActor::VisibilityChange::SELF;
198 void Check( bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char * location )
200 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
201 DALI_TEST_EQUALS( actor, compareActor, TEST_INNER_LOCATION( location ) );
202 DALI_TEST_EQUALS( visible, compareVisible, TEST_INNER_LOCATION( location ) );
203 DALI_TEST_EQUALS( (int)type, (int)compareType, TEST_INNER_LOCATION( location ) );
206 void Check( bool compareCalled, const std::string& location )
208 DALI_TEST_EQUALS( called, compareCalled, TEST_INNER_LOCATION( location ) );
213 DevelActor::VisibilityChange::Type type;
217 struct VisibilityChangedFunctor
219 VisibilityChangedFunctor( VisibilityChangedFunctorData& dataVar ) : data( dataVar ) { }
221 void operator()( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
224 data.visible = visible;
229 VisibilityChangedFunctorData& data;
232 } // anonymous namespace
235 //& purpose: Testing New API
236 int UtcDaliActorNew(void)
238 TestApplication application;
240 Actor actor = Actor::New();
242 DALI_TEST_CHECK(actor);
246 //& purpose: Testing Dali::Actor::DownCast()
247 int UtcDaliActorDownCastP(void)
249 TestApplication application;
250 tet_infoline("Testing Dali::Actor::DownCast()");
252 Actor actor = Actor::New();
253 BaseHandle object(actor);
254 Actor actor2 = Actor::DownCast(object);
255 DALI_TEST_CHECK(actor2);
259 //& purpose: Testing Dali::Actor::DownCast()
260 int UtcDaliActorDownCastN(void)
262 TestApplication application;
263 tet_infoline("Testing Dali::Actor::DownCast()");
265 BaseHandle unInitializedObject;
266 Actor actor = Actor::DownCast(unInitializedObject);
267 DALI_TEST_CHECK(!actor);
271 //& purpose: Testing Dali::Actor::GetName()
272 int UtcDaliActorGetName(void)
274 TestApplication application;
276 Actor actor = Actor::New();
278 DALI_TEST_CHECK(actor.GetName().empty());
282 //& purpose: Testing Dali::Actor::SetName()
283 int UtcDaliActorSetName(void)
285 TestApplication application;
287 string str("ActorName");
288 Actor actor = Actor::New();
291 DALI_TEST_CHECK(actor.GetName() == str);
295 int UtcDaliActorGetId(void)
297 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
298 TestApplication application;
300 Actor first = Actor::New();
301 Actor second = Actor::New();
302 Actor third = Actor::New();
304 DALI_TEST_CHECK(first.GetId() != second.GetId());
305 DALI_TEST_CHECK(second.GetId() != third.GetId());
309 int UtcDaliActorIsRoot(void)
311 TestApplication application;
313 Actor actor = Actor::New();
314 DALI_TEST_CHECK(!actor.IsRoot());
316 // get the root layer
317 actor = Stage::GetCurrent().GetLayer( 0 );
318 DALI_TEST_CHECK( actor.IsRoot() );
322 int UtcDaliActorOnStage(void)
324 TestApplication application;
326 Actor actor = Actor::New();
327 DALI_TEST_CHECK( !actor.OnStage() );
329 // get the root layer
330 actor = Stage::GetCurrent().GetLayer( 0 );
331 DALI_TEST_CHECK( actor.OnStage() );
335 int UtcDaliActorIsLayer(void)
337 TestApplication application;
339 Actor actor = Actor::New();
340 DALI_TEST_CHECK( !actor.IsLayer() );
342 // get the root layer
343 actor = Stage::GetCurrent().GetLayer( 0 );
344 DALI_TEST_CHECK( actor.IsLayer() );
348 int UtcDaliActorGetLayer(void)
350 TestApplication application;
352 Actor actor = Actor::New();
353 Stage::GetCurrent().Add(actor);
354 Layer layer = actor.GetLayer();
356 DALI_TEST_CHECK(layer);
358 // get the root layers layer
359 actor = Stage::GetCurrent().GetLayer( 0 );
360 DALI_TEST_CHECK( actor.GetLayer() );
364 int UtcDaliActorAddP(void)
366 tet_infoline("Testing Actor::Add");
367 TestApplication application;
369 Actor parent = Actor::New();
370 Actor child = Actor::New();
372 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
376 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
378 Actor parent2 = Actor::New();
379 parent2.Add( child );
381 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
382 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
384 // try Adding to same parent again, works
385 parent2.Add( child );
386 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
388 // try reparenting an orphaned child
390 Actor temporaryParent = Actor::New();
391 temporaryParent.Add( child );
392 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
394 // temporaryParent has now died, reparent the orphaned child
395 parent2.Add( child );
396 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
401 int UtcDaliActorAddN(void)
403 tet_infoline("Testing Actor::Add");
404 TestApplication application;
406 Actor child = Actor::New();
408 Actor parent2 = Actor::New();
409 parent2.Add( child );
414 parent2.Add( parent2 );
415 tet_printf("Assertion test failed - no Exception\n" );
416 tet_result(TET_FAIL);
418 catch(Dali::DaliException& e)
420 DALI_TEST_PRINT_ASSERT( e );
421 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
422 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
426 tet_printf("Assertion test failed - wrong Exception\n" );
427 tet_result(TET_FAIL);
430 // try reparenting root
433 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
434 tet_printf("Assertion test failed - no Exception\n" );
435 tet_result(TET_FAIL);
437 catch(Dali::DaliException& e)
439 DALI_TEST_PRINT_ASSERT( e );
440 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
441 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
445 tet_printf("Assertion test failed - wrong Exception\n" );
446 tet_result(TET_FAIL);
453 parent2.Add( empty );
454 tet_printf("Assertion test failed - no Exception\n" );
455 tet_result(TET_FAIL);
457 catch(Dali::DaliException& e)
459 DALI_TEST_PRINT_ASSERT( e );
460 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
461 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
465 tet_printf("Assertion test failed - wrong Exception\n" );
466 tet_result(TET_FAIL);
472 int UtcDaliActorRemoveN(void)
474 tet_infoline("Testing Actor::Remove");
475 TestApplication application;
477 Actor parent = Actor::New();
478 Actor child = Actor::New();
479 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
482 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
484 parent.Remove(child);
485 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
487 // remove again, no problem
488 parent.Remove(child);
489 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
493 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
494 // try Remove self, its a no-op
495 parent.Remove( parent );
496 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
502 parent.Remove( empty );
503 tet_printf("Assertion test failed - no Exception\n" );
504 tet_result(TET_FAIL);
506 catch(Dali::DaliException& e)
508 DALI_TEST_PRINT_ASSERT( e );
509 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
510 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
514 tet_printf("Assertion test failed - wrong Exception\n" );
515 tet_result(TET_FAIL);
520 int UtcDaliActorRemoveP(void)
522 TestApplication application;
524 Actor parent = Actor::New();
525 Actor child = Actor::New();
526 Actor random = Actor::New();
528 Stage::GetCurrent().Add( parent );
530 DALI_TEST_CHECK(parent.GetChildCount() == 0);
534 DALI_TEST_CHECK(parent.GetChildCount() == 1);
536 parent.Remove(random);
538 DALI_TEST_CHECK(parent.GetChildCount() == 1);
540 Stage::GetCurrent().Remove( parent );
542 DALI_TEST_CHECK(parent.GetChildCount() == 1);
546 int UtcDaliActorGetChildCount(void)
548 TestApplication application;
550 Actor parent = Actor::New();
551 Actor child = Actor::New();
553 DALI_TEST_CHECK(parent.GetChildCount() == 0);
557 DALI_TEST_CHECK(parent.GetChildCount() == 1);
561 int UtcDaliActorGetChildren01(void)
563 TestApplication application;
565 Actor parent = Actor::New();
566 Actor first = Actor::New();
567 Actor second = Actor::New();
568 Actor third = Actor::New();
574 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
575 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
576 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
580 int UtcDaliActorGetChildren02(void)
582 TestApplication application;
584 Actor parent = Actor::New();
585 Actor first = Actor::New();
586 Actor second = Actor::New();
587 Actor third = Actor::New();
593 const Actor& constParent = parent;
595 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
596 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
597 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
601 int UtcDaliActorGetParent01(void)
603 TestApplication application;
605 Actor parent = Actor::New();
606 Actor child = Actor::New();
610 DALI_TEST_CHECK(child.GetParent() == parent);
614 int UtcDaliActorGetParent02(void)
616 TestApplication application;
618 Actor actor = Actor::New();
620 DALI_TEST_CHECK(!actor.GetParent());
624 int UtcDaliActorSetParentOrigin(void)
626 TestApplication application;
628 Actor actor = Actor::New();
630 Vector3 vector(0.7f, 0.8f, 0.9f);
631 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
633 actor.SetParentOrigin(vector);
635 // flush the queue and render once
636 application.SendNotification();
637 application.Render();
639 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
641 Stage::GetCurrent().Add( actor );
643 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
645 // flush the queue and render once
646 application.SendNotification();
647 application.Render();
649 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
651 Stage::GetCurrent().Remove( actor );
655 int UtcDaliActorSetParentOriginIndividual(void)
657 TestApplication application;
659 Actor actor = Actor::New();
661 Vector3 vector(0.7f, 0.8f, 0.9f);
662 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
664 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
666 // flush the queue and render once
667 application.SendNotification();
668 application.Render();
670 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
672 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
674 // flush the queue and render once
675 application.SendNotification();
676 application.Render();
678 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
680 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
682 // flush the queue and render once
683 application.SendNotification();
684 application.Render();
686 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
691 int UtcDaliActorGetCurrentParentOrigin(void)
693 TestApplication application;
695 Actor actor = Actor::New();
697 Vector3 vector(0.7f, 0.8f, 0.9f);
698 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
700 actor.SetParentOrigin(vector);
702 // flush the queue and render once
703 application.SendNotification();
704 application.Render();
706 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
710 int UtcDaliActorSetAnchorPoint(void)
712 TestApplication application;
714 Actor actor = Actor::New();
716 Vector3 vector(0.7f, 0.8f, 0.9f);
717 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
719 actor.SetAnchorPoint(vector);
721 // flush the queue and render once
722 application.SendNotification();
723 application.Render();
725 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
727 Stage::GetCurrent().Add( actor );
729 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
730 // flush the queue and render once
731 application.SendNotification();
732 application.Render();
734 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
736 Stage::GetCurrent().Remove( actor );
740 int UtcDaliActorSetAnchorPointIndividual(void)
742 TestApplication application;
744 Actor actor = Actor::New();
746 Vector3 vector(0.7f, 0.8f, 0.9f);
747 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
749 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
751 // flush the queue and render once
752 application.SendNotification();
753 application.Render();
755 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
757 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
759 // flush the queue and render once
760 application.SendNotification();
761 application.Render();
763 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
765 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
767 // flush the queue and render once
768 application.SendNotification();
769 application.Render();
771 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
776 int UtcDaliActorGetCurrentAnchorPoint(void)
778 TestApplication application;
780 Actor actor = Actor::New();
782 Vector3 vector(0.7f, 0.8f, 0.9f);
783 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
785 actor.SetAnchorPoint(vector);
787 // flush the queue and render once
788 application.SendNotification();
789 application.Render();
791 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
795 // SetSize(float width, float height)
796 int UtcDaliActorSetSize01(void)
798 TestApplication application;
800 Actor actor = Actor::New();
801 Vector3 vector(100.0f, 100.0f, 0.0f);
803 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
805 actor.SetSize(vector.x, vector.y);
807 // Immediately retrieve the size after setting
808 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
809 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
811 // Flush the queue and render once
812 application.SendNotification();
813 application.Render();
815 // Check the size in the new frame
816 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
818 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
819 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
821 // Change the resize policy and check whether the size stays the same
822 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
824 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
825 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
827 // Set a new size after resize policy is changed and check the new size
828 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
830 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
831 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
833 // Change the resize policy again and check whether the new size stays the same
834 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
836 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
837 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
839 // Set another new size after resize policy is changed and check the new size
840 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
842 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
843 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
848 // SetSize(float width, float height, float depth)
849 int UtcDaliActorSetSize02(void)
851 TestApplication application;
853 Actor actor = Actor::New();
854 Vector3 vector(100.0f, 100.0f, 100.0f);
856 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
858 actor.SetSize(vector.x, vector.y, vector.z);
860 // Immediately check the size after setting
861 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
862 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
864 // flush the queue and render once
865 application.SendNotification();
866 application.Render();
868 // Check the size in the new frame
869 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
871 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
872 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
877 // SetSize(Vector2 size)
878 int UtcDaliActorSetSize03(void)
880 TestApplication application;
882 Actor actor = Actor::New();
883 Vector3 vector(100.0f, 100.0f, 0.0f);
885 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
887 actor.SetSize(Vector2(vector.x, vector.y));
889 // Immediately check the size after setting
890 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
891 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
893 // flush the queue and render once
894 application.SendNotification();
895 application.Render();
897 // Check the size in the new frame
898 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
900 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
901 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
906 // SetSize(Vector3 size)
907 int UtcDaliActorSetSize04(void)
909 TestApplication application;
911 Actor actor = Actor::New();
912 Vector3 vector(100.0f, 100.0f, 100.0f);
914 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
916 actor.SetSize(vector);
918 // Immediately check the size after setting
919 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
920 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
922 // flush the queue and render once
923 application.SendNotification();
924 application.Render();
926 // Check the size in the new frame
927 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
929 Stage::GetCurrent().Add( actor );
930 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
932 // Immediately check the size after setting
933 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
934 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
936 // flush the queue and render once
937 application.SendNotification();
938 application.Render();
940 // Check the size in the new frame
941 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
943 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
944 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
946 Stage::GetCurrent().Remove( actor );
950 int UtcDaliActorSetSizeIndividual(void)
952 TestApplication application;
954 Actor actor = Actor::New();
956 Vector3 vector(0.7f, 0.8f, 0.9f);
957 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
959 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
961 // Immediately check the width after setting
962 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
963 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
965 // flush the queue and render once
966 application.SendNotification();
967 application.Render();
969 // Check the width in the new frame
970 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
972 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
973 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
975 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
977 // Immediately check the height after setting
978 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
979 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
981 // flush the queue and render once
982 application.SendNotification();
983 application.Render();
985 // Check the height in the new frame
986 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
988 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
989 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
991 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
993 // Immediately check the depth after setting
994 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
995 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
997 // flush the queue and render once
998 application.SendNotification();
999 application.Render();
1001 // Check the depth in the new frame
1002 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1004 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1005 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1007 // Change the resize policy and check whether the size stays the same
1008 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1010 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1011 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1013 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1014 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1016 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1017 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1019 // Change the resize policy again and check whether the size stays the same
1020 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1022 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1023 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1025 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1026 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1028 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1029 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1034 int UtcDaliActorSetSizeIndividual02(void)
1036 TestApplication application;
1038 Actor actor = Actor::New();
1039 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1040 Stage::GetCurrent().Add( actor );
1042 Vector3 vector( 100.0f, 200.0f, 400.0f );
1043 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1045 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1046 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1048 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1049 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1051 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1052 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1054 // flush the queue and render once
1055 application.SendNotification();
1056 application.Render();
1058 // Check the width in the new frame
1059 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1060 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1066 int UtcDaliActorGetCurrentSize(void)
1068 TestApplication application;
1070 Actor actor = Actor::New();
1071 Vector3 vector(100.0f, 100.0f, 20.0f);
1073 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1075 actor.SetSize(vector);
1077 // flush the queue and render once
1078 application.SendNotification();
1079 application.Render();
1081 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1085 int UtcDaliActorGetNaturalSize(void)
1087 TestApplication application;
1089 Actor actor = Actor::New();
1090 Vector3 vector( 0.0f, 0.0f, 0.0f );
1092 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1097 int UtcDaliActorGetCurrentSizeImmediate(void)
1099 TestApplication application;
1101 Actor actor = Actor::New();
1102 Vector3 vector(100.0f, 100.0f, 20.0f);
1104 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1105 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1107 actor.SetSize(vector);
1109 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1110 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1112 // flush the queue and render once
1113 application.SendNotification();
1114 application.Render();
1116 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1117 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1120 // Build the animation
1121 const float durationSeconds = 2.0f;
1122 Animation animation = Animation::New( durationSeconds );
1123 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1124 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1126 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1128 // Start the animation
1131 application.SendNotification();
1132 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1134 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1139 // SetPosition(float x, float y)
1140 int UtcDaliActorSetPosition01(void)
1142 TestApplication application;
1144 Actor actor = Actor::New();
1146 // Set to random to start off with
1147 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1149 Vector3 vector(100.0f, 100.0f, 0.0f);
1151 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1153 actor.SetPosition(vector.x, vector.y);
1154 // flush the queue and render once
1155 application.SendNotification();
1156 application.Render();
1157 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1159 Stage::GetCurrent().Add( actor );
1160 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1161 // flush the queue and render once
1162 application.SendNotification();
1163 application.Render();
1164 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1169 // flush the queue and render once
1170 application.SendNotification();
1171 application.Render();
1172 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1174 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1175 // flush the queue and render once
1176 application.SendNotification();
1177 application.Render();
1178 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1180 Stage::GetCurrent().Remove( actor );
1184 // SetPosition(float x, float y, float z)
1185 int UtcDaliActorSetPosition02(void)
1187 TestApplication application;
1189 Actor actor = Actor::New();
1191 // Set to random to start off with
1192 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1194 Vector3 vector(100.0f, 100.0f, 100.0f);
1196 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1198 actor.SetPosition(vector.x, vector.y, vector.z);
1200 // flush the queue and render once
1201 application.SendNotification();
1202 application.Render();
1204 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1208 // SetPosition(Vector3 position)
1209 int UtcDaliActorSetPosition03(void)
1211 TestApplication application;
1213 Actor actor = Actor::New();
1215 // Set to random to start off with
1216 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1218 Vector3 vector(100.0f, 100.0f, 100.0f);
1220 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1222 actor.SetPosition(vector);
1224 // flush the queue and render once
1225 application.SendNotification();
1226 application.Render();
1228 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1232 int UtcDaliActorSetX(void)
1234 TestApplication application;
1236 Actor actor = Actor::New();
1238 Vector3 vector(100.0f, 0.0f, 0.0f);
1240 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1244 // flush the queue and render once
1245 application.SendNotification();
1246 application.Render();
1248 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1252 int UtcDaliActorSetY(void)
1254 TestApplication application;
1256 Actor actor = Actor::New();
1258 Vector3 vector(0.0f, 100.0f, 0.0f);
1260 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1264 // flush the queue and render once
1265 application.SendNotification();
1266 application.Render();
1268 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1272 int UtcDaliActorSetZ(void)
1274 TestApplication application;
1276 Actor actor = Actor::New();
1278 Vector3 vector(0.0f, 0.0f, 100.0f);
1280 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1284 // flush the queue and render once
1285 application.SendNotification();
1286 application.Render();
1288 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1292 int UtcDaliActorSetPositionProperties(void)
1294 TestApplication application;
1296 Actor actor = Actor::New();
1298 Vector3 vector(0.7f, 0.8f, 0.9f);
1299 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1301 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1303 // flush the queue and render once
1304 application.SendNotification();
1305 application.Render();
1307 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1309 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1311 // flush the queue and render once
1312 application.SendNotification();
1313 application.Render();
1315 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1317 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1319 // flush the queue and render once
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1328 int UtcDaliActorTranslateBy(void)
1330 TestApplication application;
1332 Actor actor = Actor::New();
1333 Vector3 vector(100.0f, 100.0f, 100.0f);
1335 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1337 actor.SetPosition(vector);
1339 // flush the queue and render once
1340 application.SendNotification();
1341 application.Render();
1343 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1345 actor.TranslateBy(vector);
1347 // flush the queue and render once
1348 application.SendNotification();
1349 application.Render();
1351 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1355 int UtcDaliActorGetCurrentPosition(void)
1357 TestApplication application;
1359 Actor actor = Actor::New();
1360 Vector3 setVector(100.0f, 100.0f, 0.0f);
1361 actor.SetPosition(setVector);
1363 // flush the queue and render once
1364 application.SendNotification();
1365 application.Render();
1367 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1371 int UtcDaliActorGetCurrentWorldPosition(void)
1373 TestApplication application;
1375 Actor parent = Actor::New();
1376 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1377 parent.SetPosition( parentPosition );
1378 parent.SetParentOrigin( ParentOrigin::CENTER );
1379 parent.SetAnchorPoint( AnchorPoint::CENTER );
1380 Stage::GetCurrent().Add( parent );
1382 Actor child = Actor::New();
1383 child.SetParentOrigin( ParentOrigin::CENTER );
1384 child.SetAnchorPoint( AnchorPoint::CENTER );
1385 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1386 child.SetPosition( childPosition );
1387 parent.Add( child );
1389 // The actors should not have a world position yet
1390 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1391 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1393 application.SendNotification();
1394 application.Render(0);
1396 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1397 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1399 // The actors should have a world position now
1400 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1401 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1405 int UtcDaliActorInheritPosition(void)
1407 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1408 TestApplication application;
1410 Actor parent = Actor::New();
1411 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1412 parent.SetPosition( parentPosition );
1413 parent.SetParentOrigin( ParentOrigin::CENTER );
1414 parent.SetAnchorPoint( AnchorPoint::CENTER );
1415 Stage::GetCurrent().Add( parent );
1417 Actor child = Actor::New();
1418 child.SetParentOrigin( ParentOrigin::CENTER );
1419 child.SetAnchorPoint( AnchorPoint::CENTER );
1420 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1421 child.SetPosition( childPosition );
1422 parent.Add( child );
1424 // The actors should not have a world position yet
1425 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1426 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1428 // first test default, which is to inherit position
1429 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1430 application.SendNotification();
1431 application.Render(0); // should only really call Update as Render is not required to update scene
1432 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1433 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1434 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1435 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1438 //Change child position
1439 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1440 child.SetPosition( childOffset );
1442 // Change inheritance mode to not inherit
1443 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1444 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1445 application.SendNotification();
1446 application.Render(0); // should only really call Update as Render is not required to update scene
1447 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1448 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1449 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1450 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1454 int UtcDaliActorSetInheritPosition(void)
1456 tet_infoline("Testing Actor::SetInheritPosition");
1457 TestApplication application;
1459 Actor parent = Actor::New();
1460 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1461 parent.SetPosition( parentPosition );
1462 parent.SetParentOrigin( ParentOrigin::CENTER );
1463 parent.SetAnchorPoint( AnchorPoint::CENTER );
1464 Stage::GetCurrent().Add( parent );
1466 Actor child = Actor::New();
1467 child.SetParentOrigin( ParentOrigin::CENTER );
1468 child.SetAnchorPoint( AnchorPoint::CENTER );
1469 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1470 child.SetPosition( childPosition );
1471 parent.Add( child );
1473 // The actors should not have a world position yet
1474 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1475 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1477 // first test default, which is to inherit position
1478 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1479 application.SendNotification();
1480 application.Render(0); // should only really call Update as Render is not required to update scene
1481 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1482 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1483 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1484 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1486 //Change child position
1487 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1488 child.SetPosition( childOffset );
1490 // Use local position as world postion
1491 child.SetInheritPosition( false );
1492 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1493 application.SendNotification();
1494 application.Render(0); // should only really call Update as Render is not required to update scene
1495 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1496 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1497 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1498 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1500 //Change back to inherit position from parent
1501 child.SetInheritPosition( true );
1502 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1503 application.SendNotification();
1504 application.Render(0); // should only really call Update as Render is not required to update scene
1505 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1506 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1507 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1508 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1512 // SetOrientation(float angleRadians, Vector3 axis)
1513 int UtcDaliActorSetOrientation01(void)
1515 TestApplication application;
1517 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1518 Actor actor = Actor::New();
1520 actor.SetOrientation(rotation);
1522 // flush the queue and render once
1523 application.SendNotification();
1524 application.Render();
1526 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1530 int UtcDaliActorSetOrientation02(void)
1532 TestApplication application;
1534 Actor actor = Actor::New();
1536 Radian angle( 0.785f );
1537 Vector3 axis(1.0f, 1.0f, 0.0f);
1539 actor.SetOrientation( angle, axis);
1540 Quaternion rotation( angle, axis );
1541 // flush the queue and render once
1542 application.SendNotification();
1543 application.Render();
1544 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1546 Stage::GetCurrent().Add( actor );
1547 actor.RotateBy( Degree( 360 ), axis);
1548 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1550 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1551 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1552 // flush the queue and render once
1553 application.SendNotification();
1554 application.Render();
1555 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1557 actor.SetOrientation( angle, axis);
1558 // flush the queue and render once
1559 application.SendNotification();
1560 application.Render();
1561 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1563 Stage::GetCurrent().Remove( actor );
1567 // SetOrientation(float angleRadians, Vector3 axis)
1568 int UtcDaliActorSetOrientationProperty(void)
1570 TestApplication application;
1572 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1573 Actor actor = Actor::New();
1575 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1577 // flush the queue and render once
1578 application.SendNotification();
1579 application.Render();
1581 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1585 // RotateBy(float angleRadians, Vector3 axis)
1586 int UtcDaliActorRotateBy01(void)
1588 TestApplication application;
1590 Actor actor = Actor::New();
1592 Radian angle( M_PI * 0.25f );
1593 actor.RotateBy(( angle ), Vector3::ZAXIS);
1594 // flush the queue and render once
1595 application.SendNotification();
1596 application.Render();
1597 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1599 Stage::GetCurrent().Add( actor );
1601 actor.RotateBy( angle, Vector3::ZAXIS);
1602 // flush the queue and render once
1603 application.SendNotification();
1604 application.Render();
1605 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1607 Stage::GetCurrent().Remove( actor );
1611 // RotateBy(Quaternion relativeRotation)
1612 int UtcDaliActorRotateBy02(void)
1614 TestApplication application;
1616 Actor actor = Actor::New();
1618 Radian angle( M_PI * 0.25f );
1619 Quaternion rotation(angle, Vector3::ZAXIS);
1620 actor.RotateBy(rotation);
1621 // flush the queue and render once
1622 application.SendNotification();
1623 application.Render();
1624 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1626 actor.RotateBy(rotation);
1627 // flush the queue and render once
1628 application.SendNotification();
1629 application.Render();
1630 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1634 int UtcDaliActorGetCurrentOrientation(void)
1636 TestApplication application;
1637 Actor actor = Actor::New();
1639 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1640 actor.SetOrientation(rotation);
1641 // flush the queue and render once
1642 application.SendNotification();
1643 application.Render();
1644 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1648 int UtcDaliActorGetCurrentWorldOrientation(void)
1650 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1651 TestApplication application;
1653 Actor parent = Actor::New();
1654 Radian rotationAngle( Degree(90.0f) );
1655 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1656 parent.SetOrientation( rotation );
1657 Stage::GetCurrent().Add( parent );
1659 Actor child = Actor::New();
1660 child.SetOrientation( rotation );
1661 parent.Add( child );
1663 // The actors should not have a world rotation yet
1664 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1665 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1667 application.SendNotification();
1668 application.Render(0);
1670 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1671 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1673 // The actors should have a world rotation now
1674 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1675 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1677 // turn off child rotation inheritance
1678 child.SetInheritOrientation( false );
1679 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1680 application.SendNotification();
1681 application.Render(0);
1683 // The actors should have a world rotation now
1684 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1685 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1689 // SetScale(float scale)
1690 int UtcDaliActorSetScale01(void)
1692 TestApplication application;
1694 Actor actor = Actor::New();
1696 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1697 actor.SetScale(0.25f);
1699 Vector3 scale(10.0f, 10.0f, 10.0f);
1700 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1702 actor.SetScale(scale.x);
1704 // flush the queue and render once
1705 application.SendNotification();
1706 application.Render();
1708 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1712 // SetScale(float scaleX, float scaleY, float scaleZ)
1713 int UtcDaliActorSetScale02(void)
1715 TestApplication application;
1716 Vector3 scale(10.0f, 10.0f, 10.0f);
1718 Actor actor = Actor::New();
1720 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1721 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1723 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1725 actor.SetScale(scale.x, scale.y, scale.z);
1726 // flush the queue and render once
1727 application.SendNotification();
1728 application.Render();
1729 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1731 // add to stage and test
1732 Stage::GetCurrent().Add( actor );
1733 actor.SetScale( 2.0f, 2.0f, 2.0f );
1734 // flush the queue and render once
1735 application.SendNotification();
1736 application.Render();
1737 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1739 Stage::GetCurrent().Remove( actor );
1744 // SetScale(Vector3 scale)
1745 int UtcDaliActorSetScale03(void)
1747 TestApplication application;
1748 Vector3 scale(10.0f, 10.0f, 10.0f);
1750 Actor actor = Actor::New();
1752 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1753 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1755 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1757 actor.SetScale(scale);
1759 // flush the queue and render once
1760 application.SendNotification();
1761 application.Render();
1763 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1767 int UtcDaliActorSetScaleIndividual(void)
1769 TestApplication application;
1771 Actor actor = Actor::New();
1773 Vector3 vector(0.7f, 0.8f, 0.9f);
1774 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1776 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1778 // flush the queue and render once
1779 application.SendNotification();
1780 application.Render();
1782 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1784 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1786 // flush the queue and render once
1787 application.SendNotification();
1788 application.Render();
1790 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1792 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1794 // flush the queue and render once
1795 application.SendNotification();
1796 application.Render();
1798 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1803 int UtcDaliActorScaleBy(void)
1805 TestApplication application;
1806 Actor actor = Actor::New();
1807 Vector3 vector(100.0f, 100.0f, 100.0f);
1809 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1811 actor.SetScale(vector);
1813 // flush the queue and render once
1814 application.SendNotification();
1815 application.Render();
1817 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1819 actor.ScaleBy(vector);
1821 // flush the queue and render once
1822 application.SendNotification();
1823 application.Render();
1825 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1829 int UtcDaliActorGetCurrentScale(void)
1831 TestApplication application;
1832 Vector3 scale(12.0f, 1.0f, 2.0f);
1834 Actor actor = Actor::New();
1836 actor.SetScale(scale);
1838 // flush the queue and render once
1839 application.SendNotification();
1840 application.Render();
1842 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1846 int UtcDaliActorGetCurrentWorldScale(void)
1848 TestApplication application;
1850 Actor parent = Actor::New();
1851 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1852 parent.SetScale( parentScale );
1853 Stage::GetCurrent().Add( parent );
1855 Actor child = Actor::New();
1856 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1857 child.SetScale( childScale );
1858 parent.Add( child );
1860 // The actors should not have a scale yet
1861 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1862 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1864 // The actors should not have a world scale yet
1865 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1866 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1868 application.SendNotification();
1869 application.Render(0);
1871 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1872 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1874 // The actors should have a world scale now
1875 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1876 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1880 int UtcDaliActorInheritScale(void)
1882 tet_infoline("Testing Actor::SetInheritScale");
1883 TestApplication application;
1885 Actor parent = Actor::New();
1886 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1887 parent.SetScale( parentScale );
1888 Stage::GetCurrent().Add( parent );
1890 Actor child = Actor::New();
1891 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1892 child.SetScale( childScale );
1893 parent.Add( child );
1895 application.SendNotification();
1896 application.Render(0);
1898 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1899 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1901 child.SetInheritScale( false );
1902 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1904 application.SendNotification();
1905 application.Render(0);
1907 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1911 int UtcDaliActorSetVisible(void)
1913 TestApplication application;
1915 Actor actor = Actor::New();
1916 actor.SetVisible(false);
1917 // flush the queue and render once
1918 application.SendNotification();
1919 application.Render();
1920 DALI_TEST_CHECK(actor.IsVisible() == false);
1922 actor.SetVisible(true);
1923 // flush the queue and render once
1924 application.SendNotification();
1925 application.Render();
1926 DALI_TEST_CHECK(actor.IsVisible() == true);
1928 // put actor on stage
1929 Stage::GetCurrent().Add( actor );
1930 actor.SetVisible(false);
1931 // flush the queue and render once
1932 application.SendNotification();
1933 application.Render();
1934 DALI_TEST_CHECK(actor.IsVisible() == false);
1938 int UtcDaliActorIsVisible(void)
1940 TestApplication application;
1942 Actor actor = Actor::New();
1944 DALI_TEST_CHECK(actor.IsVisible() == true);
1948 int UtcDaliActorSetOpacity(void)
1950 TestApplication application;
1952 Actor actor = Actor::New();
1953 // initial opacity is 1
1954 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1956 actor.SetOpacity( 0.4f);
1957 // flush the queue and render once
1958 application.SendNotification();
1959 application.Render();
1960 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1962 // change opacity, actor is on stage to change is not immediate
1963 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1964 // flush the queue and render once
1965 application.SendNotification();
1966 application.Render();
1967 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1969 // put actor on stage
1970 Stage::GetCurrent().Add( actor );
1972 // change opacity, actor is on stage to change is not immediate
1973 actor.SetOpacity( 0.9f );
1974 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1975 // flush the queue and render once
1976 application.SendNotification();
1977 application.Render();
1978 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1980 // change opacity, actor is on stage to change is not immediate
1981 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1982 // flush the queue and render once
1983 application.SendNotification();
1984 application.Render();
1985 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1989 int UtcDaliActorGetCurrentOpacity(void)
1991 TestApplication application;
1993 Actor actor = Actor::New();
1994 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1996 actor.SetOpacity(0.5f);
1997 // flush the queue and render once
1998 application.SendNotification();
1999 application.Render();
2000 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2004 int UtcDaliActorSetSensitive(void)
2006 TestApplication application;
2007 Actor actor = Actor::New();
2009 bool sensitive = !actor.IsSensitive();
2011 actor.SetSensitive(sensitive);
2013 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2017 int UtcDaliActorIsSensitive(void)
2019 TestApplication application;
2020 Actor actor = Actor::New();
2021 actor.SetSensitive(false);
2023 DALI_TEST_CHECK(false == actor.IsSensitive());
2027 int UtcDaliActorSetColor(void)
2029 TestApplication application;
2030 Actor actor = Actor::New();
2031 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2033 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2035 actor.SetColor(color);
2036 // flush the queue and render once
2037 application.SendNotification();
2038 application.Render();
2039 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2041 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2042 // flush the queue and render once
2043 application.SendNotification();
2044 application.Render();
2045 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2047 Stage::GetCurrent().Add( actor );
2048 actor.SetColor( color );
2049 // flush the queue and render once
2050 application.SendNotification();
2051 application.Render();
2052 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2054 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2055 // flush the queue and render once
2056 application.SendNotification();
2057 application.Render();
2058 // Actor color is not clamped
2059 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2060 // world color is clamped
2061 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2063 Stage::GetCurrent().Remove( actor );
2067 int UtcDaliActorSetColorIndividual(void)
2069 TestApplication application;
2071 Actor actor = Actor::New();
2073 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2074 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2076 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2078 // flush the queue and render once
2079 application.SendNotification();
2080 application.Render();
2082 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2084 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2086 // flush the queue and render once
2087 application.SendNotification();
2088 application.Render();
2090 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2092 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2094 // flush the queue and render once
2095 application.SendNotification();
2096 application.Render();
2098 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2100 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2102 // flush the queue and render once
2103 application.SendNotification();
2104 application.Render();
2106 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2108 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2110 // flush the queue and render once
2111 application.SendNotification();
2112 application.Render();
2114 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2120 int UtcDaliActorGetCurrentColor(void)
2122 TestApplication application;
2123 Actor actor = Actor::New();
2124 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2126 actor.SetColor(color);
2127 // flush the queue and render once
2128 application.SendNotification();
2129 application.Render();
2130 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2134 int UtcDaliActorGetCurrentWorldColor(void)
2136 tet_infoline("Actor::GetCurrentWorldColor");
2137 TestApplication application;
2139 Actor parent = Actor::New();
2140 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2141 parent.SetColor( parentColor );
2142 Stage::GetCurrent().Add( parent );
2144 Actor child = Actor::New();
2145 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2146 child.SetColor( childColor );
2147 parent.Add( child );
2149 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2150 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2152 // verify the default color mode
2153 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2155 // The actors should not have a world color yet
2156 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2157 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2159 application.SendNotification();
2160 application.Render(0);
2162 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2163 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2165 // The actors should have a world color now
2166 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2167 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2170 child.SetColorMode( USE_OWN_COLOR );
2171 application.SendNotification();
2172 application.Render(0);
2173 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2176 child.SetColorMode( USE_PARENT_COLOR );
2177 application.SendNotification();
2178 application.Render(0);
2179 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2180 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2183 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2184 application.SendNotification();
2185 application.Render(0);
2186 Vector4 expectedColor( childColor );
2187 expectedColor.a *= parentColor.a;
2188 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2189 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2193 int UtcDaliActorSetColorMode(void)
2195 tet_infoline("Actor::SetColorMode");
2196 TestApplication application;
2197 Actor actor = Actor::New();
2198 Actor child = Actor::New();
2201 actor.SetColorMode( USE_OWN_COLOR );
2202 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2204 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2205 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2207 actor.SetColorMode( USE_PARENT_COLOR );
2208 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2210 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2211 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2215 int UtcDaliActorScreenToLocal(void)
2217 TestApplication application;
2218 Actor actor = Actor::New();
2219 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2220 actor.SetSize(100.0f, 100.0f);
2221 actor.SetPosition(10.0f, 10.0f);
2222 Stage::GetCurrent().Add(actor);
2224 // flush the queue and render once
2225 application.SendNotification();
2226 application.Render();
2231 application.SendNotification();
2232 application.Render();
2234 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2236 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2237 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2241 int UtcDaliActorSetLeaveRequired(void)
2243 TestApplication application;
2245 Actor actor = Actor::New();
2247 actor.SetLeaveRequired(false);
2248 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2250 actor.SetLeaveRequired(true);
2251 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2255 int UtcDaliActorGetLeaveRequired(void)
2257 TestApplication application;
2259 Actor actor = Actor::New();
2261 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2265 int UtcDaliActorSetKeyboardFocusable(void)
2267 TestApplication application;
2269 Actor actor = Actor::New();
2271 actor.SetKeyboardFocusable(true);
2272 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2274 actor.SetKeyboardFocusable(false);
2275 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2279 int UtcDaliActorIsKeyboardFocusable(void)
2281 TestApplication application;
2283 Actor actor = Actor::New();
2285 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2289 int UtcDaliActorRemoveConstraints(void)
2291 tet_infoline(" UtcDaliActorRemoveConstraints");
2292 TestApplication application;
2294 gTestConstraintCalled = false;
2296 Actor actor = Actor::New();
2298 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2300 actor.RemoveConstraints();
2302 DALI_TEST_CHECK( gTestConstraintCalled == false );
2304 Stage::GetCurrent().Add( actor );
2307 // flush the queue and render once
2308 application.SendNotification();
2309 application.Render();
2311 actor.RemoveConstraints();
2313 DALI_TEST_CHECK( gTestConstraintCalled == true );
2317 int UtcDaliActorRemoveConstraintTag(void)
2319 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2320 TestApplication application;
2322 Actor actor = Actor::New();
2324 // 1. Apply Constraint1 and Constraint2, and test...
2325 unsigned int result1 = 0u;
2326 unsigned int result2 = 0u;
2328 unsigned constraint1Tag = 1u;
2329 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2330 constraint1.SetTag( constraint1Tag );
2331 constraint1.Apply();
2333 unsigned constraint2Tag = 2u;
2334 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2335 constraint2.SetTag( constraint2Tag );
2336 constraint2.Apply();
2338 Stage::GetCurrent().Add( actor );
2339 // flush the queue and render once
2340 application.SendNotification();
2341 application.Render();
2343 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2344 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2346 // 2. Remove Constraint1 and test...
2349 actor.RemoveConstraints(constraint1Tag);
2350 // make color property dirty, which will trigger constraints to be reapplied.
2351 actor.SetColor( Color::WHITE );
2352 // flush the queue and render once
2353 application.SendNotification();
2354 application.Render();
2356 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2357 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2359 // 3. Re-Apply Constraint1 and test...
2362 constraint1.Apply();
2363 // make color property dirty, which will trigger constraints to be reapplied.
2364 actor.SetColor( Color::WHITE );
2365 // flush the queue and render once
2366 application.SendNotification();
2367 application.Render();
2369 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2370 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2372 // 2. Remove Constraint2 and test...
2375 actor.RemoveConstraints(constraint2Tag);
2376 // make color property dirty, which will trigger constraints to be reapplied.
2377 actor.SetColor( Color::WHITE );
2378 // flush the queue and render once
2379 application.SendNotification();
2380 application.Render();
2382 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2383 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2385 // 2. Remove Constraint1 as well and test...
2388 actor.RemoveConstraints(constraint1Tag);
2389 // make color property dirty, which will trigger constraints to be reapplied.
2390 actor.SetColor( Color::WHITE );
2391 // flush the queue and render once
2392 application.SendNotification();
2393 application.Render();
2395 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2396 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2400 int UtcDaliActorTouchedSignal(void)
2402 TestApplication application;
2404 ResetTouchCallbacks();
2406 // get the root layer
2407 Actor actor = Stage::GetCurrent().GetRootLayer();
2408 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2410 application.SendNotification();
2411 application.Render();
2413 // connect to its touch signal
2414 actor.TouchedSignal().Connect( TestCallback );
2416 // simulate a touch event in the middle of the screen
2417 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2418 Dali::Integration::Point point;
2419 point.SetDeviceId( 1 );
2420 point.SetState( PointState::DOWN );
2421 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2422 Dali::Integration::TouchEvent event;
2423 event.AddPoint( point );
2424 application.ProcessEvent( event );
2426 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2430 int UtcDaliActorHoveredSignal(void)
2432 TestApplication application;
2434 gHoverCallBackCalled = false;
2436 // get the root layer
2437 Actor actor = Stage::GetCurrent().GetRootLayer();
2438 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2440 application.SendNotification();
2441 application.Render();
2443 // connect to its hover signal
2444 actor.HoveredSignal().Connect( TestCallback3 );
2446 // simulate a hover event in the middle of the screen
2447 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2448 Dali::Integration::Point point;
2449 point.SetDeviceId( 1 );
2450 point.SetState( PointState::MOTION );
2451 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2452 Dali::Integration::HoverEvent event;
2453 event.AddPoint( point );
2454 application.ProcessEvent( event );
2456 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2460 int UtcDaliActorOnOffStageSignal(void)
2462 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2464 TestApplication application;
2467 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2468 gActorNamesOnOffStage.clear();
2470 Actor parent = Actor::New();
2471 parent.SetName( "parent" );
2472 parent.OnStageSignal().Connect( OnStageCallback );
2473 parent.OffStageSignal().Connect( OffStageCallback );
2475 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2476 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2478 // add parent to stage
2479 Stage::GetCurrent().Add( parent );
2480 // onstage emitted, offstage not
2481 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2482 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2483 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2485 // test adding a child, should get onstage emitted
2487 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2488 gActorNamesOnOffStage.clear();
2490 Actor child = Actor::New();
2491 child.SetName( "child" );
2492 child.OnStageSignal().Connect( OnStageCallback );
2493 child.OffStageSignal().Connect( OffStageCallback );
2494 parent.Add( child ); // add child
2495 // onstage emitted, offstage not
2496 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2497 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2498 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2500 // test removing parent from stage
2502 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2503 gActorNamesOnOffStage.clear();
2505 Stage::GetCurrent().Remove( parent );
2506 // onstage not emitted, offstage is
2507 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2508 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2509 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2510 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2512 // test adding parent back to stage
2514 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2515 gActorNamesOnOffStage.clear();
2517 Stage::GetCurrent().Add( parent );
2518 // onstage emitted, offstage not
2519 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2520 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2521 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2522 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2524 // test removing child
2526 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2527 gActorNamesOnOffStage.clear();
2529 parent.Remove( child );
2530 // onstage not emitted, offstage is
2531 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2532 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2533 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2535 // test removing parent
2537 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2538 gActorNamesOnOffStage.clear();
2540 Stage::GetCurrent().Remove( parent );
2541 // onstage not emitted, offstage is
2542 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2543 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2544 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2548 int UtcDaliActorFindChildByName(void)
2550 tet_infoline("Testing Dali::Actor::FindChildByName()");
2551 TestApplication application;
2553 Actor parent = Actor::New();
2554 parent.SetName( "parent" );
2555 Actor first = Actor::New();
2556 first .SetName( "first" );
2557 Actor second = Actor::New();
2558 second.SetName( "second" );
2563 Actor found = parent.FindChildByName( "foo" );
2564 DALI_TEST_CHECK( !found );
2566 found = parent.FindChildByName( "parent" );
2567 DALI_TEST_CHECK( found == parent );
2569 found = parent.FindChildByName( "first" );
2570 DALI_TEST_CHECK( found == first );
2572 found = parent.FindChildByName( "second" );
2573 DALI_TEST_CHECK( found == second );
2577 int UtcDaliActorFindChildById(void)
2579 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2580 TestApplication application;
2582 Actor parent = Actor::New();
2583 Actor first = Actor::New();
2584 Actor second = Actor::New();
2589 Actor found = parent.FindChildById( 100000 );
2590 DALI_TEST_CHECK( !found );
2592 found = parent.FindChildById( parent.GetId() );
2593 DALI_TEST_CHECK( found == parent );
2595 found = parent.FindChildById( first.GetId() );
2596 DALI_TEST_CHECK( found == first );
2598 found = parent.FindChildById( second.GetId() );
2599 DALI_TEST_CHECK( found == second );
2603 int UtcDaliActorHitTest(void)
2608 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2610 mTouchPoint( touchPoint ),
2615 Vector2 mTouchPoint;
2619 TestApplication application;
2620 tet_infoline(" UtcDaliActorHitTest");
2622 // Fill a vector with different hit tests.
2623 struct HitTestData* hitTestData[] = {
2624 // scale touch point result
2625 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2626 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2627 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.
2628 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2629 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.
2633 // get the root layer
2634 Actor actor = Actor::New();
2635 actor.SetAnchorPoint( AnchorPoint::CENTER );
2636 actor.SetParentOrigin( ParentOrigin::CENTER );
2638 Stage::GetCurrent().Add( actor );
2640 ResetTouchCallbacks();
2642 unsigned int index = 0;
2643 while( NULL != hitTestData[index] )
2645 actor.SetSize( 1.f, 1.f );
2646 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2648 // flush the queue and render once
2649 application.SendNotification();
2650 application.Render();
2652 DALI_TEST_CHECK( !gTouchCallBackCalled );
2654 // connect to its touch signal
2655 actor.TouchedSignal().Connect(TestCallback);
2657 Dali::Integration::Point point;
2658 point.SetState( PointState::DOWN );
2659 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2660 Dali::Integration::TouchEvent event;
2661 event.AddPoint( point );
2663 // flush the queue and render once
2664 application.SendNotification();
2665 application.Render();
2666 application.ProcessEvent( event );
2668 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2670 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2671 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2672 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2673 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2674 hitTestData[index]->mResult );
2676 ResetTouchCallbacks();
2682 int UtcDaliActorSetDrawMode(void)
2684 TestApplication app;
2685 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2687 Actor a = Actor::New();
2689 Stage::GetCurrent().Add(a);
2690 app.SendNotification();
2692 app.SendNotification();
2695 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2697 a.SetDrawMode( DrawMode::OVERLAY_2D );
2698 app.SendNotification();
2701 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2703 a.SetDrawMode( DrawMode::NORMAL );
2704 app.SendNotification();
2707 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2711 int UtcDaliActorSetDrawModeOverlayRender(void)
2713 TestApplication app;
2714 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2716 app.SendNotification();
2719 std::vector<GLuint> ids;
2720 ids.push_back( 8 ); // first rendered actor
2721 ids.push_back( 9 ); // second rendered actor
2722 ids.push_back( 10 ); // third rendered actor
2723 app.GetGlAbstraction().SetNextTextureIds( ids );
2725 BufferImage imageA = BufferImage::New(16, 16);
2726 BufferImage imageB = BufferImage::New(16, 16);
2727 BufferImage imageC = BufferImage::New(16, 16);
2728 Actor a = CreateRenderableActor( imageA );
2729 Actor b = CreateRenderableActor( imageB );
2730 Actor c = CreateRenderableActor( imageC );
2732 app.SendNotification();
2735 //Textures are bound when first created. Clear bound textures vector
2736 app.GetGlAbstraction().ClearBoundTextures();
2738 // Render a,b,c as regular non-overlays. so order will be:
2742 Stage::GetCurrent().Add(a);
2743 Stage::GetCurrent().Add(b);
2744 Stage::GetCurrent().Add(c);
2746 app.SendNotification();
2749 // Should be 3 textures changes.
2750 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2751 typedef std::vector<GLuint>::size_type TextureSize;
2752 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2753 if( boundTextures.size() == 3 )
2755 DALI_TEST_CHECK( boundTextures[0] == 8u );
2756 DALI_TEST_CHECK( boundTextures[1] == 9u );
2757 DALI_TEST_CHECK( boundTextures[2] == 10u );
2760 // Now texture ids have been set, we can monitor their render order.
2761 // render a as an overlay (last), so order will be:
2765 a.SetDrawMode( DrawMode::OVERLAY_2D );
2766 app.GetGlAbstraction().ClearBoundTextures();
2768 app.SendNotification();
2771 // Should be 3 texture changes.
2772 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2773 if( boundTextures.size() == 3 )
2775 DALI_TEST_CHECK( boundTextures[0] == 9u );
2776 DALI_TEST_CHECK( boundTextures[1] == 10u );
2777 DALI_TEST_CHECK( boundTextures[2] == 8u );
2782 int UtcDaliActorGetCurrentWorldMatrix(void)
2784 TestApplication app;
2785 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2787 Actor parent = Actor::New();
2788 parent.SetParentOrigin(ParentOrigin::CENTER);
2789 parent.SetAnchorPoint(AnchorPoint::CENTER);
2790 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2791 Radian rotationAngle(Degree(85.0f));
2792 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2793 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2794 parent.SetPosition( parentPosition );
2795 parent.SetOrientation( parentRotation );
2796 parent.SetScale( parentScale );
2797 Stage::GetCurrent().Add( parent );
2799 Actor child = Actor::New();
2800 child.SetParentOrigin(ParentOrigin::CENTER);
2801 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2802 Radian childRotationAngle(Degree(23.0f));
2803 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2804 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2805 child.SetPosition( childPosition );
2806 child.SetOrientation( childRotation );
2807 child.SetScale( childScale );
2808 parent.Add( child );
2810 app.SendNotification();
2813 app.SendNotification();
2815 Matrix parentMatrix(false);
2816 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2818 Matrix childMatrix(false);
2819 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2821 //Child matrix should be the composition of child and parent
2822 Matrix childWorldMatrix(false);
2823 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2825 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2826 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2832 int UtcDaliActorConstrainedToWorldMatrix(void)
2834 TestApplication app;
2835 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2837 Actor parent = Actor::New();
2838 parent.SetParentOrigin(ParentOrigin::CENTER);
2839 parent.SetAnchorPoint(AnchorPoint::CENTER);
2840 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2841 Radian rotationAngle(Degree(85.0f));
2842 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2843 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2844 parent.SetPosition( parentPosition );
2845 parent.SetOrientation( parentRotation );
2846 parent.SetScale( parentScale );
2847 Stage::GetCurrent().Add( parent );
2849 Actor child = Actor::New();
2850 child.SetParentOrigin(ParentOrigin::CENTER);
2851 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2852 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2853 posConstraint.Apply();
2855 Stage::GetCurrent().Add( child );
2857 app.SendNotification();
2860 app.SendNotification();
2862 Matrix parentMatrix(false);
2863 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2865 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2866 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2870 int UtcDaliActorConstrainedToOrientation(void)
2872 TestApplication app;
2873 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2875 Actor parent = Actor::New();
2876 parent.SetParentOrigin(ParentOrigin::CENTER);
2877 parent.SetAnchorPoint(AnchorPoint::CENTER);
2878 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2879 Radian rotationAngle(Degree(85.0f));
2880 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2881 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2882 parent.SetPosition( parentPosition );
2883 parent.SetOrientation( parentRotation );
2884 parent.SetScale( parentScale );
2885 Stage::GetCurrent().Add( parent );
2887 Actor child = Actor::New();
2888 child.SetParentOrigin(ParentOrigin::CENTER);
2889 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2890 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2891 posConstraint.Apply();
2893 Stage::GetCurrent().Add( child );
2895 app.SendNotification();
2898 app.SendNotification();
2900 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2904 int UtcDaliActorConstrainedToOpacity(void)
2906 TestApplication app;
2907 tet_infoline(" UtcDaliActorConstrainedToOpacity");
2909 Actor parent = Actor::New();
2910 parent.SetOpacity( 0.7f );
2911 Stage::GetCurrent().Add( parent );
2913 Actor child = Actor::New();
2914 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2915 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2916 opacityConstraint.Apply();
2918 Stage::GetCurrent().Add( child );
2920 app.SendNotification();
2923 app.SendNotification();
2925 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2927 parent.SetOpacity( 0.3f );
2929 app.SendNotification();
2932 app.SendNotification();
2934 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2939 int UtcDaliActorUnparent(void)
2941 TestApplication app;
2942 tet_infoline(" UtcDaliActorUnparent");
2944 Actor parent = Actor::New();
2945 Stage::GetCurrent().Add( parent );
2947 Actor child = Actor::New();
2949 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2950 DALI_TEST_CHECK( !child.GetParent() );
2952 // Test that calling Unparent with no parent is a NOOP
2955 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2956 DALI_TEST_CHECK( !child.GetParent() );
2958 // Test that Unparent works
2959 parent.Add( child );
2961 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2962 DALI_TEST_CHECK( parent == child.GetParent() );
2966 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2967 DALI_TEST_CHECK( !child.GetParent() );
2969 // Test that UnparentAndReset works
2970 parent.Add( child );
2972 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2973 DALI_TEST_CHECK( parent == child.GetParent() );
2975 UnparentAndReset( child );
2977 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2978 DALI_TEST_CHECK( !child );
2980 // Test that UnparentAndReset is a NOOP with empty handle
2981 UnparentAndReset( child );
2983 DALI_TEST_CHECK( !child );
2987 int UtcDaliActorGetChildAt(void)
2989 TestApplication app;
2990 tet_infoline(" UtcDaliActorGetChildAt");
2992 Actor parent = Actor::New();
2993 Stage::GetCurrent().Add( parent );
2995 Actor child0 = Actor::New();
2996 parent.Add( child0 );
2998 Actor child1 = Actor::New();
2999 parent.Add( child1 );
3001 Actor child2 = Actor::New();
3002 parent.Add( child2 );
3004 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3005 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3006 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3010 int UtcDaliActorSetGetOverlay(void)
3012 TestApplication app;
3013 tet_infoline(" UtcDaliActorSetGetOverlay");
3015 Actor parent = Actor::New();
3016 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3017 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3022 int UtcDaliActorCreateDestroy(void)
3024 Actor* actor = new Actor;
3025 DALI_TEST_CHECK( actor );
3032 struct PropertyStringIndex
3034 const char * const name;
3035 const Property::Index index;
3036 const Property::Type type;
3039 const PropertyStringIndex PROPERTY_TABLE[] =
3041 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3042 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3043 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3044 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3045 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3046 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3047 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3048 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3049 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3050 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3051 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3052 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3053 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3054 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3055 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3056 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3057 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3058 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3059 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3060 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3061 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3062 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3063 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3064 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3065 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3066 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3067 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3068 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3069 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3070 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3071 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3072 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3073 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3074 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3075 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3076 { "name", Actor::Property::NAME, Property::STRING },
3077 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3078 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3079 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3080 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3081 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3082 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3083 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3084 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3085 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3086 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3087 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3088 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3089 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3090 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3091 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3092 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3093 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3094 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3095 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3097 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3098 } // unnamed namespace
3100 int UtcDaliActorProperties(void)
3102 TestApplication app;
3104 Actor actor = Actor::New();
3106 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3108 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3109 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3110 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3111 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3116 int UtcDaliRelayoutProperties_ResizePolicies(void)
3118 TestApplication app;
3120 Actor actor = Actor::New();
3123 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3124 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3126 // Set resize policy for all dimensions
3127 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3128 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3130 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3133 // Set individual dimensions
3134 const char* const widthPolicy = "FILL_TO_PARENT";
3135 const char* const heightPolicy = "FIXED";
3137 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3138 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3140 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3141 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3143 // Set individual dimensions using enums
3144 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3145 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3147 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3148 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3150 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3151 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3156 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3158 TestApplication app;
3160 Actor actor = Actor::New();
3163 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3164 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3166 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3167 actor.SetSizeScalePolicy( policy );
3168 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3171 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3172 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3174 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3175 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3177 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3178 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3183 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3185 TestApplication app;
3187 Actor actor = Actor::New();
3190 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3191 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3193 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3194 actor.SetSizeModeFactor( sizeMode );
3195 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3198 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3200 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3201 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3206 int UtcDaliRelayoutProperties_DimensionDependency(void)
3208 TestApplication app;
3210 Actor actor = Actor::New();
3213 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3214 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3217 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3218 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3220 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3221 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3223 // Test setting another resize policy
3224 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3225 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3230 int UtcDaliRelayoutProperties_Padding(void)
3232 TestApplication app;
3234 Actor actor = Actor::New();
3237 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3240 actor.SetProperty( Actor::Property::PADDING, padding );
3241 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3243 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3248 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3250 TestApplication app;
3252 Actor actor = Actor::New();
3255 Vector2 minSize( 1.0f, 2.0f );
3257 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3258 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3260 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3262 Vector2 maxSize( 3.0f, 4.0f );
3264 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3265 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3267 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3272 int UtcDaliActorGetHeightForWidth(void)
3274 TestApplication app;
3276 Actor actor = Actor::New();
3278 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3283 int UtcDaliActorGetWidthForHeight(void)
3285 TestApplication app;
3287 Actor actor = Actor::New();
3289 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3294 int UtcDaliActorGetRelayoutSize(void)
3296 TestApplication app;
3298 Actor actor = Actor::New();
3300 // Add actor to stage
3301 Stage::GetCurrent().Add( actor );
3303 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3305 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3306 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3308 // Flush the queue and render once
3309 app.SendNotification();
3312 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3317 int UtcDaliActorSetPadding(void)
3319 TestApplication app;
3321 Actor actor = Actor::New();
3324 actor.GetPadding( padding );
3326 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3327 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3328 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3329 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3331 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3332 actor.SetPadding( padding2 );
3334 actor.GetPadding( padding );
3336 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3337 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3338 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3339 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3344 int UtcDaliActorSetMinimumSize(void)
3346 TestApplication app;
3348 Actor actor = Actor::New();
3350 Vector2 size = actor.GetMinimumSize();
3352 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3353 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3355 Vector2 size2( 1.0f, 2.0f );
3356 actor.SetMinimumSize( size2 );
3358 size = actor.GetMinimumSize();
3360 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3361 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3366 int UtcDaliActorSetMaximumSize(void)
3368 TestApplication app;
3370 Actor actor = Actor::New();
3372 Vector2 size = actor.GetMaximumSize();
3374 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3375 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3377 Vector2 size2( 1.0f, 2.0f );
3378 actor.SetMaximumSize( size2 );
3380 size = actor.GetMaximumSize();
3382 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3383 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3388 int UtcDaliActorOnRelayoutSignal(void)
3390 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3392 TestApplication application;
3395 gOnRelayoutCallBackCalled = false;
3396 gActorNamesRelayout.clear();
3398 Actor actor = Actor::New();
3399 actor.SetName( "actor" );
3400 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3403 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3405 // Add actor to stage
3406 Stage::GetCurrent().Add( actor );
3408 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3409 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3411 // Flush the queue and render once
3412 application.SendNotification();
3413 application.Render();
3415 // OnRelayout emitted
3416 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3417 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3422 int UtcDaliActorGetHierachyDepth(void)
3424 TestApplication application;
3425 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3428 /* Build tree of actors:
3438 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3440 Stage stage( Stage::GetCurrent() );
3442 Actor actorA = Actor::New();
3443 Actor actorB = Actor::New();
3444 Actor actorC = Actor::New();
3445 Actor actorD = Actor::New();
3446 Actor actorE = Actor::New();
3447 Actor actorF = Actor::New();
3449 //Test that root actor has depth equal 0
3450 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3452 //Test actors return depth -1 when not connected to the tree
3453 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3454 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3455 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3456 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3457 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3458 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3460 //Create the hierarchy
3461 stage.Add( actorA );
3462 actorA.Add( actorB );
3463 actorA.Add( actorC );
3464 actorB.Add( actorD );
3465 actorB.Add( actorE );
3466 actorC.Add( actorF );
3468 //Test actors return correct depth
3469 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3470 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3471 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3472 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3473 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3474 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3476 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3477 actorA.Remove( actorB );
3479 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3480 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3481 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3483 //Removing actorA from the stage. All actors should have depth equal -1
3484 stage.Remove( actorA );
3486 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3487 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3488 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3489 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3490 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3491 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3496 int UtcDaliActorAnchorPointPropertyAsString(void)
3498 TestApplication application;
3500 Actor actor = Actor::New();
3502 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3503 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3505 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3506 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3508 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3509 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3511 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3512 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3514 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3515 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3517 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3518 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3520 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3521 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3523 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3524 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3526 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3527 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3529 // Invalid should not change anything
3530 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3531 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3536 int UtcDaliActorParentOriginPropertyAsString(void)
3538 TestApplication application;
3540 Actor actor = Actor::New();
3542 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3543 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3545 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3546 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3548 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3549 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3551 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3552 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3554 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3555 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3557 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3558 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3560 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3561 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3563 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3564 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3566 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3567 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3569 // Invalid should not change anything
3570 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3571 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3576 int UtcDaliActorColorModePropertyAsString(void)
3578 TestApplication application;
3580 Actor actor = Actor::New();
3582 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3583 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3585 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3586 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3588 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3589 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3591 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3592 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3594 // Invalid should not change anything
3595 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3596 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3601 int UtcDaliActorPositionInheritancePropertyAsString(void)
3603 TestApplication application;
3605 Actor actor = Actor::New();
3607 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3608 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3610 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3611 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3613 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3614 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3616 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3617 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3619 // Invalid should not change anything
3620 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3621 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3626 int UtcDaliActorDrawModePropertyAsString(void)
3628 TestApplication application;
3630 Actor actor = Actor::New();
3632 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3633 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3635 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3636 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3638 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3639 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3641 // Invalid should not change anything
3642 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3643 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3648 int UtcDaliActorColorModePropertyAsEnum(void)
3650 TestApplication application;
3652 Actor actor = Actor::New();
3654 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3655 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3657 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3658 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3660 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3661 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3663 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3664 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3669 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3671 TestApplication application;
3673 Actor actor = Actor::New();
3675 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3676 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3678 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3679 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3681 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3682 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3684 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3685 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3690 int UtcDaliActorDrawModePropertyAsEnum(void)
3692 TestApplication application;
3694 Actor actor = Actor::New();
3696 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3697 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3699 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3700 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3702 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3703 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3708 int UtcDaliActorAddRendererP(void)
3710 tet_infoline("Testing Actor::AddRenderer");
3711 TestApplication application;
3713 Actor actor = Actor::New();
3715 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3717 Geometry geometry = CreateQuadGeometry();
3718 Shader shader = CreateShader();
3719 Renderer renderer = Renderer::New(geometry, shader);
3721 actor.AddRenderer( renderer );
3722 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3723 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3728 int UtcDaliActorAddRendererN(void)
3730 tet_infoline("Testing Actor::AddRenderer");
3731 TestApplication application;
3733 Actor actor = Actor::New();
3739 actor.AddRenderer( renderer );
3740 tet_printf("Assertion test failed - no Exception\n" );
3741 tet_result(TET_FAIL);
3743 catch(Dali::DaliException& e)
3745 DALI_TEST_PRINT_ASSERT( e );
3746 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3747 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3751 tet_printf("Assertion test failed - wrong Exception\n" );
3752 tet_result(TET_FAIL);
3758 int UtcDaliActorAddRendererOnStage(void)
3760 tet_infoline("Testing Actor::AddRenderer");
3761 TestApplication application;
3763 Actor actor = Actor::New();
3764 Stage::GetCurrent().Add(actor);
3766 application.SendNotification();
3767 application.Render(0);
3769 Geometry geometry = CreateQuadGeometry();
3770 Shader shader = CreateShader();
3771 Renderer renderer = Renderer::New(geometry, shader);
3773 application.SendNotification();
3774 application.Render(0);
3778 actor.AddRenderer( renderer );
3779 tet_result(TET_PASS);
3783 tet_result(TET_FAIL);
3789 int UtcDaliActorRemoveRendererP1(void)
3791 tet_infoline("Testing Actor::RemoveRenderer");
3792 TestApplication application;
3794 Actor actor = Actor::New();
3796 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3798 Geometry geometry = CreateQuadGeometry();
3799 Shader shader = CreateShader();
3800 Renderer renderer = Renderer::New(geometry, shader);
3802 actor.AddRenderer( renderer );
3803 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3804 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3806 actor.RemoveRenderer(renderer);
3807 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3813 int UtcDaliActorRemoveRendererP2(void)
3815 tet_infoline("Testing Actor::RemoveRenderer");
3816 TestApplication application;
3818 Actor actor = Actor::New();
3820 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3822 Geometry geometry = CreateQuadGeometry();
3823 Shader shader = CreateShader();
3824 Renderer renderer = Renderer::New(geometry, shader);
3826 actor.AddRenderer( renderer );
3827 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3828 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3830 actor.RemoveRenderer(0);
3831 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3838 int UtcDaliActorRemoveRendererN(void)
3840 tet_infoline("Testing Actor::RemoveRenderer");
3841 TestApplication application;
3843 Actor actor = Actor::New();
3845 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3847 Geometry geometry = CreateQuadGeometry();
3848 Shader shader = CreateShader();
3849 Renderer renderer = Renderer::New(geometry, shader);
3851 actor.AddRenderer( renderer );
3852 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3853 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3855 actor.RemoveRenderer(10);
3856 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3857 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3862 // Clipping test helper functions:
3863 Actor CreateActorWithContent()
3865 BufferImage image = BufferImage::New( 16u, 16u );
3866 Actor actor = CreateRenderableActor( image );
3868 // Setup dimensions and position so actor is not skipped by culling.
3869 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3870 actor.SetSize( 16.0f, 16.0f );
3871 actor.SetParentOrigin( ParentOrigin::CENTER );
3872 actor.SetAnchorPoint( AnchorPoint::CENTER );
3877 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3879 enabledDisableTrace.Reset();
3880 stencilTrace.Reset();
3881 enabledDisableTrace.Enable( true );
3882 stencilTrace.Enable( true );
3884 application.SendNotification();
3885 application.Render();
3887 enabledDisableTrace.Enable( false );
3888 stencilTrace.Enable( false );
3891 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3893 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3895 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3896 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3897 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3898 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3901 int UtcDaliActorPropertyClippingP(void)
3903 // This test checks the clippingMode property.
3904 tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3905 TestApplication application;
3907 Actor actor = Actor::New();
3909 // Check default clippingEnabled value.
3910 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3913 bool getValueResult = getValue.Get( value );
3914 DALI_TEST_CHECK( getValueResult );
3916 if( getValueResult )
3918 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3921 // Check setting the property.
3922 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3924 // Check the new value was set.
3925 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3926 getValueResult = getValue.Get( value );
3927 DALI_TEST_CHECK( getValueResult );
3929 if( getValueResult )
3931 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3937 int UtcDaliActorPropertyClippingN(void)
3939 // Negative test case for Clipping.
3940 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3941 TestApplication application;
3943 Actor actor = Actor::New();
3945 // Check default clippingEnabled value.
3946 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3949 bool getValueResult = getValue.Get( value );
3950 DALI_TEST_CHECK( getValueResult );
3952 if( getValueResult )
3954 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3957 // Check setting an invalid property value won't change the current property value.
3958 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3960 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3961 getValueResult = getValue.Get( value );
3962 DALI_TEST_CHECK( getValueResult );
3964 if( getValueResult )
3966 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3972 int UtcDaliActorPropertyClippingActor(void)
3974 // This test checks that an actor is correctly setup for clipping.
3975 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3976 TestApplication application;
3978 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3979 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3980 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3981 size_t startIndex = 0u;
3983 // Create a clipping actor.
3984 Actor actorDepth1Clip = CreateActorWithContent();
3985 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3986 Stage::GetCurrent().Add( actorDepth1Clip );
3988 // Gather the call trace.
3989 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3991 // Check we are writing to the color buffer.
3992 CheckColorMask( glAbstraction, true );
3994 // Check the stencil buffer was enabled.
3995 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3997 // Check the stencil buffer was cleared.
3998 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4000 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4001 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4002 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4003 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4008 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4010 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4011 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
4012 TestApplication application;
4014 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4015 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4016 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4017 size_t startIndex = 0u;
4019 // Create a clipping actor.
4020 Actor actorDepth1Clip = CreateActorWithContent();
4021 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4022 Stage::GetCurrent().Add( actorDepth1Clip );
4024 // Gather the call trace.
4025 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4027 // Check we are writing to the color buffer.
4028 CheckColorMask( glAbstraction, true );
4030 // Check the stencil buffer was enabled.
4031 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4033 // Check the stencil buffer was cleared.
4034 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4036 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4037 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4038 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4039 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4041 // Now disable the clipping
4042 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4044 // Gather the call trace.
4045 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4047 // Check the stencil buffer was disabled.
4048 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4050 // Ensure all values in stencil-mask are set to 1.
4052 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4058 int UtcDaliActorPropertyClippingNestedChildren(void)
4060 // This test checks that a hierarchy of actors are clipped correctly by
4061 // writing to and reading from the correct bit-planes of the stencil buffer.
4062 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
4063 TestApplication application;
4064 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4065 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4066 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4068 // Create a clipping actor.
4069 Actor actorDepth1Clip = CreateActorWithContent();
4070 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4071 Stage::GetCurrent().Add( actorDepth1Clip );
4073 // Create a child actor.
4074 Actor childDepth2 = CreateActorWithContent();
4075 actorDepth1Clip.Add( childDepth2 );
4077 // Create another clipping actor.
4078 Actor childDepth2Clip = CreateActorWithContent();
4079 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4080 childDepth2.Add( childDepth2Clip );
4082 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4083 // This tests the sort algorithm.
4084 Actor childDepth3 = CreateActorWithContent();
4085 childDepth2Clip.Add( childDepth3 );
4086 Actor childDepth4 = CreateActorWithContent();
4087 childDepth3.Add( childDepth4 );
4089 // Gather the call trace.
4090 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4092 // Check we are writing to the color buffer.
4093 CheckColorMask( glAbstraction, true );
4095 // Check the stencil buffer was enabled.
4096 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4098 // Perform the test twice, once for 2D layer, and once for 3D.
4099 for( unsigned int i = 0u ; i < 2u; ++i )
4101 size_t startIndex = 0u;
4103 // Check the stencil buffer was cleared.
4104 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4106 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4107 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4108 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4109 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4111 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4112 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4113 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4115 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4116 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4117 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4118 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4120 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4121 // (Both must be set to pass the check).
4122 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4123 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4125 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4128 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4129 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4136 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4138 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4139 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4140 TestApplication application;
4142 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4143 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4144 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4146 // Create a clipping actor.
4147 Actor actorDepth1Clip = CreateActorWithContent();
4148 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4149 Stage::GetCurrent().Add( actorDepth1Clip );
4151 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4152 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4154 // Gather the call trace.
4155 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4157 // Check we are writing to the color buffer.
4158 CheckColorMask( glAbstraction, true );
4160 // Check the stencil buffer was not enabled.
4161 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4163 // Check stencil functions are not called.
4164 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4165 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4166 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4171 int UtcDaliGetPropertyN(void)
4173 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4174 TestApplication app;
4176 Actor actor = Actor::New();
4178 unsigned int propertyCount = actor.GetPropertyCount();
4179 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4183 int UtcDaliActorRaiseLower(void)
4185 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4187 TestApplication application;
4189 Stage stage( Stage::GetCurrent() );
4191 Actor actorA = Actor::New();
4192 Actor actorB = Actor::New();
4193 Actor actorC = Actor::New();
4195 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4196 actorA.SetParentOrigin( ParentOrigin::CENTER );
4198 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4199 actorB.SetParentOrigin( ParentOrigin::CENTER );
4201 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4202 actorC.SetParentOrigin( ParentOrigin::CENTER );
4204 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4205 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4207 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4208 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4210 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4211 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4213 stage.Add( actorA );
4214 stage.Add( actorB );
4215 stage.Add( actorC );
4217 ResetTouchCallbacks();
4219 application.SendNotification();
4220 application.Render();
4222 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4223 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4224 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4226 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4227 // Only top actor will get touched.
4228 actorA.TouchSignal().Connect( TestTouchCallback );
4229 actorB.TouchSignal().Connect( TestTouchCallback2 );
4230 actorC.TouchSignal().Connect( TestTouchCallback3 );
4232 Dali::Integration::Point point;
4233 point.SetDeviceId( 1 );
4234 point.SetState( PointState::DOWN );
4235 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4236 Dali::Integration::TouchEvent event;
4237 event.AddPoint( point );
4239 application.ProcessEvent( event );
4241 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4242 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4243 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4245 ResetTouchCallbacks();
4247 tet_printf( "Testing Raising of Actor\n" );
4249 int preActorOrder( 0 );
4250 int postActorOrder( 0 );
4252 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4253 value.Get( preActorOrder );
4255 DevelActor::Raise( actorB );
4257 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4258 value.Get( postActorOrder );
4260 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4262 application.ProcessEvent( event );
4264 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4265 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4266 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4268 ResetTouchCallbacks();
4270 tet_printf( "Testing Lowering of Actor\n" );
4272 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4273 value.Get( preActorOrder );
4275 DevelActor::Lower( actorB );
4277 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4278 value.Get( postActorOrder );
4280 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4282 application.ProcessEvent( event );
4284 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4285 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4286 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4288 ResetTouchCallbacks();
4293 int UtcDaliActorRaiseToTopLowerToBottom(void)
4295 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4297 TestApplication application;
4299 Stage stage( Stage::GetCurrent() );
4301 Actor actorA = Actor::New();
4302 Actor actorB = Actor::New();
4303 Actor actorC = Actor::New();
4305 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4306 // enables checking of which actor the uniform is assigned too
4307 Shader shaderA = CreateShader();
4308 shaderA.RegisterProperty( "uRendererColor",1.f);
4310 Shader shaderB = CreateShader();
4311 shaderB.RegisterProperty( "uRendererColor", 2.f );
4313 Shader shaderC = CreateShader();
4314 shaderC.RegisterProperty( "uRendererColor", 3.f );
4316 Geometry geometry = CreateQuadGeometry();
4318 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4319 Renderer rendererA = Renderer::New(geometry, shaderA);
4320 actorA.AddRenderer(rendererA);
4322 Renderer rendererB = Renderer::New(geometry, shaderB);
4323 actorB.AddRenderer(rendererB);
4325 Renderer rendererC = Renderer::New(geometry, shaderC);
4326 actorC.AddRenderer(rendererC);
4328 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4329 actorA.SetParentOrigin( ParentOrigin::CENTER );
4331 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4332 actorB.SetParentOrigin( ParentOrigin::CENTER );
4334 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4335 actorC.SetParentOrigin( ParentOrigin::CENTER );
4337 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4338 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4340 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4341 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4343 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4344 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4346 stage.Add( actorA );
4347 stage.Add( actorB );
4348 stage.Add( actorC );
4350 ResetTouchCallbacks();
4352 // Set up gl abstraction trace so can query the set uniform order
4353 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4354 glAbstraction.EnableSetUniformCallTrace(true);
4355 glAbstraction.ResetSetUniformCallStack();
4357 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4359 application.SendNotification();
4360 application.Render();
4362 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4365 // Test order of uniforms in stack
4366 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4367 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4368 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4370 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4372 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4374 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4375 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4376 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4378 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4379 // Only top actor will get touched.
4380 actorA.TouchSignal().Connect( TestTouchCallback );
4381 actorB.TouchSignal().Connect( TestTouchCallback2 );
4382 actorC.TouchSignal().Connect( TestTouchCallback3 );
4384 Dali::Integration::Point point;
4385 point.SetDeviceId( 1 );
4386 point.SetState( PointState::DOWN );
4387 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4388 Dali::Integration::TouchEvent event;
4389 event.AddPoint( point );
4391 application.ProcessEvent( event );
4393 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4394 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4395 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4397 ResetTouchCallbacks();
4399 tet_printf( "RaiseToTop ActorA\n" );
4401 DevelActor::RaiseToTop( actorA );
4403 application.ProcessEvent( event );
4405 glAbstraction.ResetSetUniformCallStack();
4406 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4408 application.SendNotification();
4409 application.Render();
4411 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4413 // Test order of uniforms in stack
4414 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4415 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4416 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4418 tet_infoline( "Testing A above C and B at bottom\n" );
4419 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4421 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4423 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4424 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4425 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4427 ResetTouchCallbacks();
4429 tet_printf( "RaiseToTop ActorB\n" );
4431 DevelActor::RaiseToTop( actorB );
4433 application.ProcessEvent( event );
4435 glAbstraction.ResetSetUniformCallStack();
4436 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4438 application.SendNotification();
4439 application.Render();
4441 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4443 // Test order of uniforms in stack
4444 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4445 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4446 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4448 tet_infoline( "Testing B above A and C at bottom\n" );
4449 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4451 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4453 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4454 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4455 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4457 ResetTouchCallbacks();
4459 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4461 DevelActor::LowerToBottom( actorA );
4462 application.SendNotification();
4463 application.Render();
4465 DevelActor::LowerToBottom( actorB );
4466 application.SendNotification();
4467 application.Render();
4469 application.ProcessEvent( event );
4471 glAbstraction.ResetSetUniformCallStack();
4472 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4474 application.SendNotification();
4475 application.Render();
4477 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4479 // Test order of uniforms in stack
4480 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4481 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4482 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4484 tet_infoline( "Testing C above A and B at bottom\n" );
4485 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4487 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4489 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4490 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4491 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4493 ResetTouchCallbacks();
4498 int UtcDaliActorRaiseAbove(void)
4500 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4502 TestApplication application;
4504 Stage stage( Stage::GetCurrent() );
4506 Actor actorA = Actor::New();
4507 Actor actorB = Actor::New();
4508 Actor actorC = Actor::New();
4510 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4511 actorA.SetParentOrigin( ParentOrigin::CENTER );
4513 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4514 actorB.SetParentOrigin( ParentOrigin::CENTER );
4516 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4517 actorC.SetParentOrigin( ParentOrigin::CENTER );
4519 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4520 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4522 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4523 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4525 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4526 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4528 stage.Add( actorA );
4529 stage.Add( actorB );
4530 stage.Add( actorC );
4532 ResetTouchCallbacks();
4534 application.SendNotification();
4535 application.Render();
4537 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4538 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4539 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4541 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4542 // Only top actor will get touched.
4543 actorA.TouchSignal().Connect( TestTouchCallback );
4544 actorB.TouchSignal().Connect( TestTouchCallback2 );
4545 actorC.TouchSignal().Connect( TestTouchCallback3 );
4547 Dali::Integration::Point point;
4548 point.SetDeviceId( 1 );
4549 point.SetState( PointState::DOWN );
4550 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4551 Dali::Integration::TouchEvent event;
4552 event.AddPoint( point );
4554 application.ProcessEvent( event );
4556 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4557 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4558 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4560 ResetTouchCallbacks();
4562 tet_printf( "Raise actor B Above Actor C\n" );
4564 DevelActor::RaiseAbove( actorB, actorC );
4566 application.ProcessEvent( event );
4568 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4569 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4570 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4572 ResetTouchCallbacks();
4574 tet_printf( "Raise actor A Above Actor B\n" );
4576 DevelActor::RaiseAbove( actorA, actorB );
4578 application.ProcessEvent( event );
4580 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4581 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4582 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4584 ResetTouchCallbacks();
4589 int UtcDaliActorLowerBelow(void)
4591 tet_infoline( "UtcDaliActor LowerBelow test \n" );
4593 TestApplication application;
4595 Stage stage( Stage::GetCurrent() );
4597 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4598 // enables checking of which actor the uniform is assigned too
4599 Shader shaderA = CreateShader();
4600 shaderA.RegisterProperty( "uRendererColor",1.f);
4602 Shader shaderB = CreateShader();
4603 shaderB.RegisterProperty( "uRendererColor", 2.f );
4605 Shader shaderC = CreateShader();
4606 shaderC.RegisterProperty( "uRendererColor", 3.f );
4608 Actor actorA = Actor::New();
4609 Actor actorB = Actor::New();
4610 Actor actorC = Actor::New();
4612 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4613 Geometry geometry = CreateQuadGeometry();
4615 Renderer rendererA = Renderer::New(geometry, shaderA);
4616 actorA.AddRenderer(rendererA);
4618 Renderer rendererB = Renderer::New(geometry, shaderB);
4619 actorB.AddRenderer(rendererB);
4621 Renderer rendererC = Renderer::New(geometry, shaderC);
4622 actorC.AddRenderer(rendererC);
4624 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4625 actorA.SetParentOrigin( ParentOrigin::CENTER );
4627 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4628 actorB.SetParentOrigin( ParentOrigin::CENTER );
4630 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4631 actorC.SetParentOrigin( ParentOrigin::CENTER );
4633 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4634 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4636 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4637 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4639 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4640 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4642 stage.Add( actorA );
4643 stage.Add( actorB );
4644 stage.Add( actorC );
4646 ResetTouchCallbacks();
4648 // Set up gl abstraction trace so can query the set uniform order
4649 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4650 glAbstraction.EnableSetUniformCallTrace(true);
4651 glAbstraction.ResetSetUniformCallStack();
4652 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4654 glAbstraction.ResetSetUniformCallStack();
4656 application.SendNotification();
4657 application.Render();
4659 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4661 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4663 // Test order of uniforms in stack
4664 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4665 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4666 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4668 tet_infoline( "Testing C above B and A at bottom\n" );
4669 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4671 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4673 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4674 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4675 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4677 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4678 // Only top actor will get touched.
4679 actorA.TouchSignal().Connect( TestTouchCallback );
4680 actorB.TouchSignal().Connect( TestTouchCallback2 );
4681 actorC.TouchSignal().Connect( TestTouchCallback3 );
4683 Dali::Integration::Point point;
4684 point.SetDeviceId( 1 );
4685 point.SetState( PointState::DOWN );
4686 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4687 Dali::Integration::TouchEvent event;
4688 event.AddPoint( point );
4690 tet_infoline( "UtcDaliActor Test Set up completed \n" );
4692 application.ProcessEvent( event );
4694 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4695 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4696 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4698 ResetTouchCallbacks();
4700 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" );
4702 DevelActor::LowerBelow( actorC, actorB );
4704 application.SendNotification();
4705 application.Render();
4707 application.ProcessEvent( event );
4709 glAbstraction.ResetSetUniformCallStack();
4710 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4712 application.SendNotification();
4713 application.Render();
4715 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4717 // Test order of uniforms in stack
4718 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4719 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4720 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4722 tet_infoline( "Testing B above A and C at bottom\n" );
4723 bool BAC = ( indexB > indexA) && ( indexA > indexC ); // B at TOP, then A then C at bottom
4725 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4727 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4728 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4729 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4731 ResetTouchCallbacks();
4733 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4735 DevelActor::LowerBelow( actorB, actorC );
4737 application.SendNotification();
4738 application.Render();
4740 application.ProcessEvent( event );
4742 glAbstraction.ResetSetUniformCallStack();
4743 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4745 application.Render();
4746 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4748 // Test order of uniforms in stack
4749 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4750 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4751 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4753 bool ACB = ( indexA > indexC) && ( indexC > indexB ); // A on TOP, then C then B at bottom
4755 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4757 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4758 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4759 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4761 ResetTouchCallbacks();
4763 tet_printf( "Lower actor A below Actor C leaving C on top\n" );
4765 DevelActor::LowerBelow( actorA, actorC );
4767 application.SendNotification();
4768 application.Render();
4770 application.ProcessEvent( event );
4772 glAbstraction.ResetSetUniformCallStack();
4773 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4775 application.Render();
4776 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4778 // Test order of uniforms in stack
4779 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4780 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4781 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4783 bool CAB = ( indexC > indexA) && ( indexA > indexB );
4785 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4790 int UtcDaliActorMaxSiblingOrder(void)
4792 tet_infoline( "UtcDaliActor De-fragment of sibling order once max index reached\n" );
4794 TestApplication application;
4796 int testOrders[] = { 0,1,3,5,17,998, 999 };
4797 int resultingOrders[] = { 0,1,2,3,4,6,5 };
4799 const int TEST_ORDERS_COUNT = sizeof( testOrders ) / sizeof( testOrders[0] );
4801 Stage stage( Stage::GetCurrent() );
4803 Actor parent = Actor::New();
4805 for ( int index = 0; index < TEST_ORDERS_COUNT; index++ )
4807 Actor newActor = Actor::New();
4808 newActor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, testOrders[index] );
4809 parent.Add( newActor );
4811 stage.Add( parent );
4813 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4814 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4816 Actor sibling = parent.GetChildAt( index );
4817 int siblingOrder = 0;
4818 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4819 value.Get( siblingOrder );
4820 tet_printf( "%d, ", siblingOrder );
4824 Actor sibling = parent.GetChildAt( 5 );
4825 DevelActor::RaiseToTop( sibling );
4827 application.SendNotification();
4828 application.Render();
4830 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4831 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4833 Actor sibling = parent.GetChildAt( index );
4834 int siblingOrder = 0;
4835 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4836 value.Get( siblingOrder );
4837 tet_printf( "%d, ", siblingOrder );
4838 DALI_TEST_EQUALS( siblingOrder, resultingOrders[ index] , TEST_LOCATION );
4846 int UtcDaliActorRaiseAboveLowerBelowDifferentParentsN(void)
4848 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4850 TestApplication application;
4852 Stage stage( Stage::GetCurrent() );
4854 Actor parentA = Actor::New();
4855 Actor parentB = Actor::New();
4856 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4857 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4858 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4859 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4861 parentA.SetAnchorPoint( AnchorPoint::CENTER );
4862 parentA.SetParentOrigin( ParentOrigin::CENTER );
4864 parentB.SetAnchorPoint( AnchorPoint::CENTER );
4865 parentB.SetParentOrigin( ParentOrigin::CENTER );
4867 stage.Add( parentA );
4868 stage.Add( parentB );
4870 Actor actorA = Actor::New();
4871 Actor actorB = Actor::New();
4872 Actor actorC = Actor::New();
4874 parentA.Add( actorA );
4875 parentA.Add( actorB );
4877 tet_printf( "Actor C added to different parent from A and B \n" );
4878 parentB.Add( actorC );
4880 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4881 actorA.SetParentOrigin( ParentOrigin::CENTER );
4883 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4884 actorB.SetParentOrigin( ParentOrigin::CENTER );
4886 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4887 actorC.SetParentOrigin( ParentOrigin::CENTER );
4889 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4890 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4892 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4893 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4895 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4896 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4898 ResetTouchCallbacks();
4900 application.SendNotification();
4901 application.Render();
4903 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4904 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4905 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4907 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4908 // Only top actor will get touched.
4909 actorA.TouchSignal().Connect( TestTouchCallback );
4910 actorB.TouchSignal().Connect( TestTouchCallback2 );
4911 actorC.TouchSignal().Connect( TestTouchCallback3 );
4913 Dali::Integration::Point point;
4914 point.SetDeviceId( 1 );
4915 point.SetState( PointState::DOWN );
4916 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4917 Dali::Integration::TouchEvent event;
4918 event.AddPoint( point );
4920 application.ProcessEvent( event );
4922 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4923 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4924 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4926 ResetTouchCallbacks();
4928 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
4930 DevelActor::RaiseAbove( actorA, actorC );
4932 application.ProcessEvent( event );
4934 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4935 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4936 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4938 ResetTouchCallbacks();
4943 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
4945 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
4947 TestApplication application;
4949 Stage stage( Stage::GetCurrent() );
4951 Actor actorA = Actor::New();
4952 Actor actorB = Actor::New();
4953 Actor actorC = Actor::New();
4955 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4956 actorA.SetParentOrigin( ParentOrigin::CENTER );
4958 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4959 actorB.SetParentOrigin( ParentOrigin::CENTER );
4961 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4962 actorC.SetParentOrigin( ParentOrigin::CENTER );
4964 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4965 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4967 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4968 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4970 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4971 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4973 ResetTouchCallbacks();
4975 application.SendNotification();
4976 application.Render();
4978 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4979 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4980 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4982 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4983 // Only top actor will get touched.
4984 actorA.TouchSignal().Connect( TestTouchCallback );
4985 actorB.TouchSignal().Connect( TestTouchCallback2 );
4986 actorC.TouchSignal().Connect( TestTouchCallback3 );
4988 Dali::Integration::Point point;
4989 point.SetDeviceId( 1 );
4990 point.SetState( PointState::DOWN );
4991 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4992 Dali::Integration::TouchEvent event;
4993 event.AddPoint( point );
4995 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
4997 DevelActor::RaiseAbove( actorA, actorC );
4999 application.ProcessEvent( event );
5001 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5003 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5004 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5005 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5007 ResetTouchCallbacks();
5009 stage.Add ( actorB );
5011 application.SendNotification();
5012 application.Render();
5014 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5015 DevelActor::LowerBelow( actorA, actorC );
5016 application.ProcessEvent( event );
5018 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5019 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5020 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5021 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5023 ResetTouchCallbacks();
5025 tet_printf( "Adding Actor A to stage, will be on top\n" );
5027 stage.Add ( actorA );
5028 application.SendNotification();
5029 application.Render();
5031 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5032 DevelActor::RaiseAbove( actorB, actorC );
5033 application.ProcessEvent( event );
5035 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5036 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5037 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5038 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5040 ResetTouchCallbacks();
5042 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5043 DevelActor::LowerBelow( actorA, actorC );
5044 application.ProcessEvent( event );
5046 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5047 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5048 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5049 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5051 ResetTouchCallbacks();
5053 stage.Add ( actorC );
5055 application.SendNotification();
5056 application.Render();
5058 DevelActor::RaiseAbove( actorA, actorC );
5059 application.ProcessEvent( event );
5061 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5062 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5063 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5064 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5069 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5071 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5073 TestApplication application;
5075 Stage stage( Stage::GetCurrent() );
5077 Actor actorA = Actor::New();
5078 Actor actorB = Actor::New();
5079 Actor actorC = Actor::New();
5081 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5082 actorA.SetParentOrigin( ParentOrigin::CENTER );
5084 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5085 actorB.SetParentOrigin( ParentOrigin::CENTER );
5087 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5088 actorC.SetParentOrigin( ParentOrigin::CENTER );
5090 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5091 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5093 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5094 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5096 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5097 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5099 ResetTouchCallbacks();
5101 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5102 // Only top actor will get touched.
5103 actorA.TouchSignal().Connect( TestTouchCallback );
5104 actorB.TouchSignal().Connect( TestTouchCallback2 );
5105 actorC.TouchSignal().Connect( TestTouchCallback3 );
5107 Dali::Integration::Point point;
5108 point.SetDeviceId( 1 );
5109 point.SetState( PointState::DOWN );
5110 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5111 Dali::Integration::TouchEvent event;
5112 event.AddPoint( point );
5114 stage.Add ( actorA );
5116 application.SendNotification();
5117 application.Render();
5119 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5121 DevelActor::Raise( actorB );
5123 application.ProcessEvent( event );
5125 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5127 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5128 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5129 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5131 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5132 ResetTouchCallbacks();
5134 DevelActor::Lower( actorC );
5136 application.ProcessEvent( event );
5138 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5140 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5141 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5142 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5143 ResetTouchCallbacks();
5145 tet_printf( "Lower actor C below B but C not parented\n" );
5147 DevelActor::Lower( actorB );
5149 application.ProcessEvent( event );
5151 tet_printf( "Not parented so Lower should show no effect\n" );
5153 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5154 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5155 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5156 ResetTouchCallbacks();
5158 tet_printf( "Raise actor B to top\n" );
5160 DevelActor::RaiseToTop( actorB );
5162 application.ProcessEvent( event );
5164 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5166 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5167 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5168 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5169 ResetTouchCallbacks();
5171 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5173 stage.Add ( actorB );
5175 application.SendNotification();
5176 application.Render();
5178 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5180 DevelActor::LowerToBottom( actorC );
5182 application.ProcessEvent( event );
5184 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5186 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5187 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5188 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5189 ResetTouchCallbacks();
5195 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5197 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5199 TestApplication application;
5201 Stage stage( Stage::GetCurrent() );
5203 Actor actorA = Actor::New();
5204 Actor actorB = Actor::New();
5205 Actor actorC = Actor::New();
5207 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5208 actorA.SetParentOrigin( ParentOrigin::CENTER );
5210 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5211 actorB.SetParentOrigin( ParentOrigin::CENTER );
5213 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5214 actorC.SetParentOrigin( ParentOrigin::CENTER );
5216 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5217 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5219 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5220 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5222 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5223 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5225 stage.Add( actorA );
5226 stage.Add( actorB );
5227 stage.Add( actorC );
5229 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5230 // Only top actor will get touched.
5231 actorA.TouchSignal().Connect( TestTouchCallback );
5232 actorB.TouchSignal().Connect( TestTouchCallback2 );
5233 actorC.TouchSignal().Connect( TestTouchCallback3 );
5235 ResetTouchCallbacks();
5237 application.SendNotification();
5238 application.Render();
5240 Dali::Integration::Point point;
5241 point.SetDeviceId( 1 );
5242 point.SetState( PointState::DOWN );
5243 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5244 Dali::Integration::TouchEvent event;
5245 event.AddPoint( point );
5247 application.ProcessEvent( event );
5249 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5250 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5251 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5253 ResetTouchCallbacks();
5255 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5257 DevelActor::RaiseAbove( actorA, actorA );
5259 application.ProcessEvent( event );
5261 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5263 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5264 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5265 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5267 ResetTouchCallbacks();
5269 DevelActor::RaiseAbove( actorA, actorC );
5270 application.ProcessEvent( event );
5272 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5273 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5274 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5275 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5280 int UtcDaliActorGetScreenPosition(void)
5282 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5284 TestApplication application;
5286 Stage stage( Stage::GetCurrent() );
5288 Actor actorA = Actor::New();
5289 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5291 Vector2 size2( 10.0f, 20.0f );
5292 actorA.SetSize( size2 );
5294 actorA.SetPosition( 0.f, 0.f );
5296 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5298 stage.Add( actorA );
5300 application.SendNotification();
5301 application.Render();
5303 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5304 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5306 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5307 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5309 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5310 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5312 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5314 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5316 application.SendNotification();
5317 application.Render();
5319 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5320 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5322 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5323 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5325 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5326 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5328 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5330 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5332 application.SendNotification();
5333 application.Render();
5335 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5336 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5338 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5339 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5341 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5342 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5344 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5346 actorA.SetPosition( 30.0, 0.0 );
5348 application.SendNotification();
5349 application.Render();
5351 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5352 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5354 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5355 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5357 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5358 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5360 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5362 actorA.SetPosition( 30.0, 420.0 );
5364 application.SendNotification();
5365 application.Render();
5367 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5368 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5370 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5371 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5373 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5374 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5380 int UtcDaliActorGetScreenPositionAfterScaling(void)
5382 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5384 TestApplication application;
5386 Stage stage( Stage::GetCurrent() );
5388 Actor actorA = Actor::New();
5389 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5391 Vector2 size2( 10.0f, 20.0f );
5392 actorA.SetSize( size2 );
5393 actorA.SetScale( 1.5f );
5394 actorA.SetPosition( 0.f, 0.f );
5396 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5398 stage.Add( actorA );
5400 application.SendNotification();
5401 application.Render();
5403 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5404 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5406 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5407 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5409 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5410 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5412 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5414 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5416 application.SendNotification();
5417 application.Render();
5419 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5420 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5422 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5423 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5425 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5426 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5431 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5433 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5435 TestApplication application;
5437 Stage stage( Stage::GetCurrent() );
5439 Actor actorA = Actor::New();
5440 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5441 actorA.SetParentOrigin( ParentOrigin::CENTER );
5442 Vector2 size2( 10.0f, 20.0f );
5443 actorA.SetSize( size2 );
5444 actorA.SetPosition( 0.f, 0.f );
5446 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5448 stage.Add( actorA );
5450 application.SendNotification();
5451 application.Render();
5453 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5454 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5456 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5457 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5459 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
5460 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
5462 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5464 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5465 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5467 application.SendNotification();
5468 application.Render();
5470 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5471 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5473 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5474 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5476 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5477 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5483 int UtcDaliActorGetScreenPositionWithChildActors(void)
5485 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5487 TestApplication application;
5489 Stage stage( Stage::GetCurrent() );
5491 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5493 Actor actorA = Actor::New();
5494 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5495 actorA.SetParentOrigin( ParentOrigin::CENTER );
5496 Vector2 size1( 10.0f, 20.0f );
5497 actorA.SetSize( size1 );
5498 actorA.SetPosition( 0.f, 0.f );
5500 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5502 Actor parentActorA = Actor::New();
5503 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5504 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5505 Vector2 size2( 30.0f, 60.0f );
5506 parentActorA.SetSize( size2 );
5507 parentActorA.SetPosition( 0.f, 0.f );
5509 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5511 stage.Add( parentActorA );
5512 parentActorA.Add ( actorA );
5514 application.SendNotification();
5515 application.Render();
5517 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5518 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5520 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5521 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5523 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
5524 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
5526 tet_infoline( "Test 2\n");
5528 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5530 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5531 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5533 application.SendNotification();
5534 application.Render();
5536 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5537 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5539 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5540 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5542 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
5543 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
5548 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5550 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5552 TestApplication application;
5554 Stage stage( Stage::GetCurrent() );
5556 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5558 Actor actorA = Actor::New();
5559 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5560 actorA.SetParentOrigin( ParentOrigin::CENTER );
5561 Vector2 size1( 10.0f, 20.0f );
5562 actorA.SetSize( size1 );
5563 actorA.SetPosition( 0.f, 0.f );
5565 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5567 Actor parentActorA = Actor::New();
5568 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5569 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5570 Vector2 size2( 30.0f, 60.0f );
5571 parentActorA.SetSize( size2 );
5572 parentActorA.SetPosition( 0.f, 0.f );
5574 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5576 Actor grandParentActorA = Actor::New();
5577 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5578 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5579 Vector2 size3( 60.0f, 120.0f );
5580 grandParentActorA.SetSize( size3 );
5581 grandParentActorA.SetPosition( 0.f, 0.f );
5583 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5585 stage.Add( grandParentActorA );
5586 grandParentActorA.Add ( parentActorA );
5588 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5590 parentActorA.Add ( actorA );
5592 application.SendNotification();
5593 application.Render();
5595 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5596 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5598 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5599 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5601 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
5602 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
5607 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5609 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
5611 TestApplication application;
5613 Stage stage( Stage::GetCurrent() );
5615 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5617 Actor actorA = Actor::New();
5618 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5619 actorA.SetParentOrigin( ParentOrigin::CENTER );
5620 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5621 actorA.SetSize( 10.0f, 20.0f );
5622 stage.Add( actorA );
5624 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5626 Actor actorB = Actor::New();
5627 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5628 actorB.SetParentOrigin( ParentOrigin::CENTER );
5629 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5630 Vector2 actorBSize( 30.0f, 60.0f );
5631 actorB.SetSize( actorBSize );
5632 stage.Add( actorB );
5634 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5636 Actor actorC = Actor::New();
5637 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5638 actorC.SetParentOrigin( ParentOrigin::CENTER );
5639 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5640 Vector2 actorCSize( 60.0f, 120.0f );
5641 actorC.SetSize( actorCSize );
5642 stage.Add( actorC );
5644 application.SendNotification();
5645 application.Render();
5647 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
5649 Vector2 center( stage.GetSize() * 0.5f );
5651 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5652 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5653 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5655 tet_infoline( "Add scale to all actors" );
5657 actorA.SetScale( 2.0f );
5658 actorB.SetScale( 2.0f );
5659 actorC.SetScale( 2.0f );
5661 application.SendNotification();
5662 application.Render();
5664 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
5665 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
5666 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
5671 int utcDaliActorPositionUsesAnchorPoint(void)
5673 TestApplication application;
5674 tet_infoline( "Check default behaviour\n" );
5676 Actor actor = Actor::New();
5677 actor.SetParentOrigin( ParentOrigin::CENTER );
5678 actor.SetAnchorPoint( AnchorPoint::CENTER );
5679 actor.SetSize( 100.0f, 100.0f );
5680 Stage::GetCurrent().Add( actor );
5682 application.SendNotification();
5683 application.Render();
5685 tet_infoline( "Check that the world position is in the center\n" );
5686 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5688 tet_infoline( "Set the position uses anchor point property to false\n" );
5689 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5691 application.SendNotification();
5692 application.Render();
5694 tet_infoline( "Check that the world position has changed appropriately\n" );
5695 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5700 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
5702 TestApplication application;
5703 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5705 Actor actor = Actor::New();
5706 actor.SetParentOrigin( ParentOrigin::CENTER );
5707 actor.SetAnchorPoint( AnchorPoint::CENTER );
5708 actor.SetSize( 100.0f, 100.0f );
5709 actor.SetScale( 2.0f );
5710 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5711 Stage::GetCurrent().Add( actor );
5713 application.SendNotification();
5714 application.Render();
5716 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
5717 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5719 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5720 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5721 application.SendNotification();
5722 application.Render();
5723 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5725 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5726 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5727 application.SendNotification();
5728 application.Render();
5729 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5734 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
5736 TestApplication application;
5737 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5739 Actor actor = Actor::New();
5740 actor.SetParentOrigin( ParentOrigin::CENTER );
5741 actor.SetAnchorPoint( AnchorPoint::CENTER );
5742 actor.SetSize( 100.0f, 100.0f );
5743 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5744 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5745 Stage::GetCurrent().Add( actor );
5747 application.SendNotification();
5748 application.Render();
5750 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
5751 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5753 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5754 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5755 application.SendNotification();
5756 application.Render();
5757 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5759 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5760 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5761 application.SendNotification();
5762 application.Render();
5763 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
5768 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
5770 TestApplication application;
5771 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5773 Actor actor = Actor::New();
5774 actor.SetParentOrigin( ParentOrigin::CENTER );
5775 actor.SetAnchorPoint( AnchorPoint::CENTER );
5776 actor.SetSize( 100.0f, 100.0f );
5777 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5778 actor.SetScale( 2.0f );
5779 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5780 Stage::GetCurrent().Add( actor );
5782 application.SendNotification();
5783 application.Render();
5785 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
5786 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5788 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5789 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5790 application.SendNotification();
5791 application.Render();
5792 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5794 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5795 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5796 application.SendNotification();
5797 application.Render();
5798 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
5803 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
5805 TestApplication application;
5806 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5808 Actor parent = Actor::New();
5810 Stage::GetCurrent().Add( parent );
5811 Vector2 stageSize( Stage::GetCurrent().GetSize() );
5813 Actor actor = Actor::New();
5814 actor.SetParentOrigin( ParentOrigin::CENTER );
5815 actor.SetAnchorPoint( AnchorPoint::CENTER );
5816 actor.SetSize( 100.0f, 100.0f );
5817 actor.SetInheritScale( false );
5818 actor.SetInheritOrientation( false );
5819 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5820 parent.Add( actor );
5822 application.SendNotification();
5823 application.Render();
5825 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
5827 tet_infoline( "Check the world position is in the right place\n" );
5828 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5830 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
5831 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5832 application.SendNotification();
5833 application.Render();
5834 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5836 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
5837 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5838 application.SendNotification();
5839 application.Render();
5840 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5845 int utcDaliActorVisibilityChangeSignalSelf(void)
5847 TestApplication application;
5848 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
5850 Actor actor = Actor::New();
5852 VisibilityChangedFunctorData data;
5853 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
5855 actor.SetVisible( false );
5857 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5859 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
5862 actor.SetVisible( false );
5863 data.Check( false /* not called */, TEST_LOCATION );
5865 tet_infoline( "Change the visibility using properties, ensure called" );
5868 actor.SetProperty( Actor::Property::VISIBLE, true );
5869 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5871 tet_infoline( "Set the visibility to current using properties, ensure not called" );
5874 actor.SetProperty( Actor::Property::VISIBLE, true );
5875 data.Check( false /* not called */, TEST_LOCATION );
5880 int utcDaliActorVisibilityChangeSignalChildren(void)
5882 TestApplication application;
5883 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
5885 Actor parent = Actor::New();
5886 Actor child = Actor::New();
5887 parent.Add( child );
5889 Actor grandChild = Actor::New();
5890 child.Add( grandChild );
5892 VisibilityChangedFunctorData parentData;
5893 VisibilityChangedFunctorData childData;
5894 VisibilityChangedFunctorData grandChildData;
5896 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
5897 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
5898 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
5900 parent.SetVisible( false );
5901 parentData.Check( false /* not called */, TEST_LOCATION );
5902 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
5903 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
5905 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
5908 grandChildData.Reset();
5910 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
5912 parent.SetVisible( true );
5913 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5914 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
5915 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
5917 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
5920 grandChildData.Reset();
5922 parent.SetVisible( true );
5923 parentData.Check( false /* not called */, TEST_LOCATION );
5924 childData.Check( false /* not called */, TEST_LOCATION );
5925 grandChildData.Check( false /* not called */, TEST_LOCATION );