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 );
810 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
811 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
812 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
814 // Flush the queue and render once
815 application.SendNotification();
816 application.Render();
818 // Check the size in the new frame
819 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
821 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
822 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
823 DALI_TEST_EQUALS( vector.width, actor.GetProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
824 DALI_TEST_EQUALS( vector.height, actor.GetProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
825 DALI_TEST_EQUALS( vector.depth, actor.GetProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
827 // Check async behaviour
828 currentSize = actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >();
829 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
830 DALI_TEST_EQUALS( vector.width, actor.GetCurrentProperty< float >( Actor::Property::SIZE_WIDTH ), TEST_LOCATION );
831 DALI_TEST_EQUALS( vector.height, actor.GetCurrentProperty< float >( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
832 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentProperty< float >( Actor::Property::SIZE_DEPTH ), TEST_LOCATION );
834 // Change the resize policy and check whether the size stays the same
835 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
837 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
838 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
840 // Set a new size after resize policy is changed and check the new size
841 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
843 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
844 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
846 // Change the resize policy again and check whether the new size stays the same
847 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
849 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
850 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
852 // Set another new size after resize policy is changed and check the new size
853 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
855 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
856 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
861 // SetSize(float width, float height, float depth)
862 int UtcDaliActorSetSize02(void)
864 TestApplication application;
866 Actor actor = Actor::New();
867 Vector3 vector(100.0f, 100.0f, 100.0f);
869 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
871 actor.SetSize(vector.x, vector.y, vector.z);
873 // Immediately check the size after setting
874 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
875 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
877 // flush the queue and render once
878 application.SendNotification();
879 application.Render();
881 // Check the size in the new frame
882 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
884 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
885 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
890 // SetSize(Vector2 size)
891 int UtcDaliActorSetSize03(void)
893 TestApplication application;
895 Actor actor = Actor::New();
896 Vector3 vector(100.0f, 100.0f, 0.0f);
898 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
900 actor.SetSize(Vector2(vector.x, vector.y));
902 // Immediately check the size after setting
903 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
904 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
906 // flush the queue and render once
907 application.SendNotification();
908 application.Render();
910 // Check the size in the new frame
911 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
913 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
914 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
919 // SetSize(Vector3 size)
920 int UtcDaliActorSetSize04(void)
922 TestApplication application;
924 Actor actor = Actor::New();
925 Vector3 vector(100.0f, 100.0f, 100.0f);
927 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
929 actor.SetSize(vector);
931 // Immediately check the size after setting
932 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
933 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
935 // flush the queue and render once
936 application.SendNotification();
937 application.Render();
939 // Check the size in the new frame
940 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
942 Stage::GetCurrent().Add( actor );
943 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
945 // Immediately check the size after setting
946 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
947 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
949 // flush the queue and render once
950 application.SendNotification();
951 application.Render();
953 // Check the size in the new frame
954 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
956 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
957 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
959 Stage::GetCurrent().Remove( actor );
963 int UtcDaliActorSetSizeIndividual(void)
965 TestApplication application;
967 Actor actor = Actor::New();
969 Vector3 vector(0.7f, 0.8f, 0.9f);
970 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
972 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
974 // Immediately check the width after setting
975 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
976 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
978 // flush the queue and render once
979 application.SendNotification();
980 application.Render();
982 // Check the width in the new frame
983 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
985 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
986 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
988 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
990 // Immediately check the height after setting
991 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
992 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
994 // flush the queue and render once
995 application.SendNotification();
996 application.Render();
998 // Check the height in the new frame
999 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1001 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1002 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1004 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1006 // Immediately check the depth after setting
1007 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1008 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1010 // flush the queue and render once
1011 application.SendNotification();
1012 application.Render();
1014 // Check the depth in the new frame
1015 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
1017 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1018 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1020 // Change the resize policy and check whether the size stays the same
1021 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1023 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1024 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1026 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1027 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1029 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1030 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1032 // Change the resize policy again and check whether the size stays the same
1033 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1035 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
1036 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1038 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
1039 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1041 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
1042 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1047 int UtcDaliActorSetSizeIndividual02(void)
1049 TestApplication application;
1051 Actor actor = Actor::New();
1052 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
1053 Stage::GetCurrent().Add( actor );
1055 Vector3 vector( 100.0f, 200.0f, 400.0f );
1056 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
1058 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
1059 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1061 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
1062 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1064 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1065 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1067 // flush the queue and render once
1068 application.SendNotification();
1069 application.Render();
1071 // Check the width in the new frame
1072 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1073 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1079 int UtcDaliActorGetCurrentSize(void)
1081 TestApplication application;
1083 Actor actor = Actor::New();
1084 Vector3 vector(100.0f, 100.0f, 20.0f);
1086 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1088 actor.SetSize(vector);
1090 // flush the queue and render once
1091 application.SendNotification();
1092 application.Render();
1094 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1098 int UtcDaliActorGetNaturalSize(void)
1100 TestApplication application;
1102 Actor actor = Actor::New();
1103 Vector3 vector( 0.0f, 0.0f, 0.0f );
1105 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1110 int UtcDaliActorGetCurrentSizeImmediate(void)
1112 TestApplication application;
1114 Actor actor = Actor::New();
1115 Vector3 vector(100.0f, 100.0f, 20.0f);
1117 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1118 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1120 actor.SetSize(vector);
1122 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1123 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1125 // flush the queue and render once
1126 application.SendNotification();
1127 application.Render();
1129 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1130 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1133 // Build the animation
1134 const float durationSeconds = 2.0f;
1135 Animation animation = Animation::New( durationSeconds );
1136 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1137 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1139 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1141 // Start the animation
1144 application.SendNotification();
1145 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1147 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1152 // SetPosition(float x, float y)
1153 int UtcDaliActorSetPosition01(void)
1155 TestApplication application;
1157 Actor actor = Actor::New();
1159 // Set to random to start off with
1160 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1162 Vector3 vector(100.0f, 100.0f, 0.0f);
1164 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1166 actor.SetPosition(vector.x, vector.y);
1167 // flush the queue and render once
1168 application.SendNotification();
1169 application.Render();
1170 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1172 Stage::GetCurrent().Add( actor );
1173 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1174 // flush the queue and render once
1175 application.SendNotification();
1176 application.Render();
1177 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1182 // flush the queue and render once
1183 application.SendNotification();
1184 application.Render();
1185 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1187 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1188 // flush the queue and render once
1189 application.SendNotification();
1190 application.Render();
1191 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1193 Stage::GetCurrent().Remove( actor );
1197 // SetPosition(float x, float y, float z)
1198 int UtcDaliActorSetPosition02(void)
1200 TestApplication application;
1202 Actor actor = Actor::New();
1204 // Set to random to start off with
1205 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1207 Vector3 vector(100.0f, 100.0f, 100.0f);
1209 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1211 actor.SetPosition(vector.x, vector.y, vector.z);
1213 // flush the queue and render once
1214 application.SendNotification();
1215 application.Render();
1217 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1221 // SetPosition(Vector3 position)
1222 int UtcDaliActorSetPosition03(void)
1224 TestApplication application;
1226 Actor actor = Actor::New();
1228 // Set to random to start off with
1229 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1231 Vector3 vector(100.0f, 100.0f, 100.0f);
1233 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1235 actor.SetPosition(vector);
1237 // flush the queue and render once
1238 application.SendNotification();
1239 application.Render();
1241 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1245 int UtcDaliActorSetX(void)
1247 TestApplication application;
1249 Actor actor = Actor::New();
1251 Vector3 vector(100.0f, 0.0f, 0.0f);
1253 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1257 // flush the queue and render once
1258 application.SendNotification();
1259 application.Render();
1261 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1265 int UtcDaliActorSetY(void)
1267 TestApplication application;
1269 Actor actor = Actor::New();
1271 Vector3 vector(0.0f, 100.0f, 0.0f);
1273 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1277 // flush the queue and render once
1278 application.SendNotification();
1279 application.Render();
1281 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1285 int UtcDaliActorSetZ(void)
1287 TestApplication application;
1289 Actor actor = Actor::New();
1291 Vector3 vector(0.0f, 0.0f, 100.0f);
1293 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1297 // flush the queue and render once
1298 application.SendNotification();
1299 application.Render();
1301 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1305 int UtcDaliActorSetPositionProperties(void)
1307 TestApplication application;
1309 Actor actor = Actor::New();
1311 Vector3 vector(0.7f, 0.8f, 0.9f);
1312 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1314 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1315 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1316 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1318 // flush the queue and render once
1319 application.SendNotification();
1320 application.Render();
1322 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1323 DALI_TEST_EQUALS( vector.x, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1324 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1325 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, TEST_LOCATION );
1326 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::POSITION_X ), TEST_LOCATION );
1328 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1329 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1330 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1332 // flush the queue and render once
1333 application.SendNotification();
1334 application.Render();
1336 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1337 DALI_TEST_EQUALS( vector.y, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1338 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1339 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, TEST_LOCATION );
1340 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Y ), TEST_LOCATION );
1342 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1343 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1344 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1346 // flush the queue and render once
1347 application.SendNotification();
1348 application.Render();
1350 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1351 DALI_TEST_EQUALS( vector.z, actor.GetProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1352 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1353 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).z, TEST_LOCATION );
1354 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::POSITION_Z ), TEST_LOCATION );
1359 int UtcDaliActorTranslateBy(void)
1361 TestApplication application;
1363 Actor actor = Actor::New();
1364 Vector3 vector(100.0f, 100.0f, 100.0f);
1366 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1368 actor.SetPosition(vector);
1370 // flush the queue and render once
1371 application.SendNotification();
1372 application.Render();
1374 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1376 actor.TranslateBy(vector);
1378 // flush the queue and render once
1379 application.SendNotification();
1380 application.Render();
1382 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1386 int UtcDaliActorGetCurrentPosition(void)
1388 TestApplication application;
1390 Actor actor = Actor::New();
1391 Vector3 setVector(100.0f, 100.0f, 0.0f);
1392 actor.SetPosition(setVector);
1394 // flush the queue and render once
1395 application.SendNotification();
1396 application.Render();
1398 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1402 int UtcDaliActorGetCurrentWorldPosition(void)
1404 TestApplication application;
1406 Actor parent = Actor::New();
1407 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1408 parent.SetPosition( parentPosition );
1409 parent.SetParentOrigin( ParentOrigin::CENTER );
1410 parent.SetAnchorPoint( AnchorPoint::CENTER );
1411 Stage::GetCurrent().Add( parent );
1413 Actor child = Actor::New();
1414 child.SetParentOrigin( ParentOrigin::CENTER );
1415 child.SetAnchorPoint( AnchorPoint::CENTER );
1416 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1417 child.SetPosition( childPosition );
1418 parent.Add( child );
1420 // The actors should not have a world position yet
1421 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1422 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1424 application.SendNotification();
1425 application.Render(0);
1427 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1428 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1430 // The actors should have a world position now
1431 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1432 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1436 int UtcDaliActorInheritPosition(void)
1438 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1439 TestApplication application;
1441 Actor parent = Actor::New();
1442 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1443 parent.SetPosition( parentPosition );
1444 parent.SetParentOrigin( ParentOrigin::CENTER );
1445 parent.SetAnchorPoint( AnchorPoint::CENTER );
1446 Stage::GetCurrent().Add( parent );
1448 Actor child = Actor::New();
1449 child.SetParentOrigin( ParentOrigin::CENTER );
1450 child.SetAnchorPoint( AnchorPoint::CENTER );
1451 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1452 child.SetPosition( childPosition );
1453 parent.Add( child );
1455 // The actors should not have a world position yet
1456 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1457 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1459 // first test default, which is to inherit position
1460 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1461 application.SendNotification();
1462 application.Render(0); // should only really call Update as Render is not required to update scene
1463 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1464 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1465 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1466 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1469 //Change child position
1470 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1471 child.SetPosition( childOffset );
1473 // Change inheritance mode to not inherit
1474 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1475 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1476 application.SendNotification();
1477 application.Render(0); // should only really call Update as Render is not required to update scene
1478 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1479 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1480 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1481 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1485 int UtcDaliActorSetInheritPosition(void)
1487 tet_infoline("Testing Actor::SetInheritPosition");
1488 TestApplication application;
1490 Actor parent = Actor::New();
1491 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1492 parent.SetPosition( parentPosition );
1493 parent.SetParentOrigin( ParentOrigin::CENTER );
1494 parent.SetAnchorPoint( AnchorPoint::CENTER );
1495 Stage::GetCurrent().Add( parent );
1497 Actor child = Actor::New();
1498 child.SetParentOrigin( ParentOrigin::CENTER );
1499 child.SetAnchorPoint( AnchorPoint::CENTER );
1500 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1501 child.SetPosition( childPosition );
1502 parent.Add( child );
1504 // The actors should not have a world position yet
1505 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1506 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1508 // first test default, which is to inherit position
1509 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1510 application.SendNotification();
1511 application.Render(0); // should only really call Update as Render is not required to update scene
1512 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1513 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1514 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1515 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1517 //Change child position
1518 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1519 child.SetPosition( childOffset );
1521 // Use local position as world postion
1522 child.SetInheritPosition( false );
1523 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1524 application.SendNotification();
1525 application.Render(0); // should only really call Update as Render is not required to update scene
1526 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1527 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1528 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1529 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1531 //Change back to inherit position from parent
1532 child.SetInheritPosition( true );
1533 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1534 application.SendNotification();
1535 application.Render(0); // should only really call Update as Render is not required to update scene
1536 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1537 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1538 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1539 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1543 // SetOrientation(float angleRadians, Vector3 axis)
1544 int UtcDaliActorSetOrientation01(void)
1546 TestApplication application;
1548 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1549 Actor actor = Actor::New();
1551 actor.SetOrientation(rotation);
1553 // flush the queue and render once
1554 application.SendNotification();
1555 application.Render();
1557 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1561 int UtcDaliActorSetOrientation02(void)
1563 TestApplication application;
1565 Actor actor = Actor::New();
1567 Radian angle( 0.785f );
1568 Vector3 axis(1.0f, 1.0f, 0.0f);
1570 actor.SetOrientation( angle, axis);
1571 Quaternion rotation( angle, axis );
1572 // flush the queue and render once
1573 application.SendNotification();
1574 application.Render();
1575 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1577 Stage::GetCurrent().Add( actor );
1578 actor.RotateBy( Degree( 360 ), axis);
1579 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1581 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1582 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1583 // flush the queue and render once
1584 application.SendNotification();
1585 application.Render();
1586 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1588 actor.SetOrientation( angle, axis);
1589 // flush the queue and render once
1590 application.SendNotification();
1591 application.Render();
1592 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1594 Stage::GetCurrent().Remove( actor );
1598 // SetOrientation(float angleRadians, Vector3 axis)
1599 int UtcDaliActorSetOrientationProperty(void)
1601 TestApplication application;
1603 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1604 Actor actor = Actor::New();
1606 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1607 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1609 // flush the queue and render once
1610 application.SendNotification();
1611 application.Render();
1613 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1614 DALI_TEST_EQUALS(rotation, actor.GetProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1615 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), 0.001, TEST_LOCATION);
1619 // RotateBy(float angleRadians, Vector3 axis)
1620 int UtcDaliActorRotateBy01(void)
1622 TestApplication application;
1624 Actor actor = Actor::New();
1626 Radian angle( M_PI * 0.25f );
1627 actor.RotateBy(( angle ), Vector3::ZAXIS);
1628 // flush the queue and render once
1629 application.SendNotification();
1630 application.Render();
1631 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1633 Stage::GetCurrent().Add( actor );
1635 actor.RotateBy( angle, Vector3::ZAXIS);
1636 // flush the queue and render once
1637 application.SendNotification();
1638 application.Render();
1639 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1641 Stage::GetCurrent().Remove( actor );
1645 // RotateBy(Quaternion relativeRotation)
1646 int UtcDaliActorRotateBy02(void)
1648 TestApplication application;
1650 Actor actor = Actor::New();
1652 Radian angle( M_PI * 0.25f );
1653 Quaternion rotation(angle, Vector3::ZAXIS);
1654 actor.RotateBy(rotation);
1655 // flush the queue and render once
1656 application.SendNotification();
1657 application.Render();
1658 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1660 actor.RotateBy(rotation);
1661 // flush the queue and render once
1662 application.SendNotification();
1663 application.Render();
1664 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1668 int UtcDaliActorGetCurrentOrientation(void)
1670 TestApplication application;
1671 Actor actor = Actor::New();
1673 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1674 actor.SetOrientation(rotation);
1675 // flush the queue and render once
1676 application.SendNotification();
1677 application.Render();
1678 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1682 int UtcDaliActorGetCurrentWorldOrientation(void)
1684 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1685 TestApplication application;
1687 Actor parent = Actor::New();
1688 Radian rotationAngle( Degree(90.0f) );
1689 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1690 parent.SetOrientation( rotation );
1691 Stage::GetCurrent().Add( parent );
1693 Actor child = Actor::New();
1694 child.SetOrientation( rotation );
1695 parent.Add( child );
1697 // The actors should not have a world rotation yet
1698 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1699 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1701 application.SendNotification();
1702 application.Render(0);
1704 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1705 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1707 // The actors should have a world rotation now
1708 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1709 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1711 // turn off child rotation inheritance
1712 child.SetInheritOrientation( false );
1713 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1714 application.SendNotification();
1715 application.Render(0);
1717 // The actors should have a world rotation now
1718 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1719 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1723 // SetScale(float scale)
1724 int UtcDaliActorSetScale01(void)
1726 TestApplication application;
1728 Actor actor = Actor::New();
1730 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1731 actor.SetScale(0.25f);
1733 Vector3 scale(10.0f, 10.0f, 10.0f);
1734 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1736 actor.SetScale(scale.x);
1738 // flush the queue and render once
1739 application.SendNotification();
1740 application.Render();
1742 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1746 // SetScale(float scaleX, float scaleY, float scaleZ)
1747 int UtcDaliActorSetScale02(void)
1749 TestApplication application;
1750 Vector3 scale(10.0f, 10.0f, 10.0f);
1752 Actor actor = Actor::New();
1754 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1755 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1757 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1759 actor.SetScale(scale.x, scale.y, scale.z);
1760 // flush the queue and render once
1761 application.SendNotification();
1762 application.Render();
1763 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1765 // add to stage and test
1766 Stage::GetCurrent().Add( actor );
1767 actor.SetScale( 2.0f, 2.0f, 2.0f );
1768 // flush the queue and render once
1769 application.SendNotification();
1770 application.Render();
1771 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1773 Stage::GetCurrent().Remove( actor );
1778 // SetScale(Vector3 scale)
1779 int UtcDaliActorSetScale03(void)
1781 TestApplication application;
1782 Vector3 scale(10.0f, 10.0f, 10.0f);
1784 Actor actor = Actor::New();
1786 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1787 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1789 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1791 actor.SetScale(scale);
1793 // flush the queue and render once
1794 application.SendNotification();
1795 application.Render();
1797 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1801 int UtcDaliActorSetScaleIndividual(void)
1803 TestApplication application;
1805 Actor actor = Actor::New();
1807 Vector3 vector(0.7f, 0.8f, 0.9f);
1808 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1810 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1811 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1813 // flush the queue and render once
1814 application.SendNotification();
1815 application.Render();
1817 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1818 DALI_TEST_EQUALS( vector.x, actor.GetProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1819 DALI_TEST_EQUALS( vector.x, actor.GetCurrentProperty< float >( Actor::Property::SCALE_X ), TEST_LOCATION );
1821 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1822 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1824 // flush the queue and render once
1825 application.SendNotification();
1826 application.Render();
1828 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1829 DALI_TEST_EQUALS( vector.y, actor.GetProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1830 DALI_TEST_EQUALS( vector.y, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Y ), TEST_LOCATION );
1832 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1833 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1835 // flush the queue and render once
1836 application.SendNotification();
1837 application.Render();
1839 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1840 DALI_TEST_EQUALS( vector.z, actor.GetProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1841 DALI_TEST_EQUALS( vector.z, actor.GetCurrentProperty< float >( Actor::Property::SCALE_Z ), TEST_LOCATION );
1843 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1844 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), TEST_LOCATION );
1849 int UtcDaliActorScaleBy(void)
1851 TestApplication application;
1852 Actor actor = Actor::New();
1853 Vector3 vector(100.0f, 100.0f, 100.0f);
1855 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1857 actor.SetScale(vector);
1859 // flush the queue and render once
1860 application.SendNotification();
1861 application.Render();
1863 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1865 actor.ScaleBy(vector);
1867 // flush the queue and render once
1868 application.SendNotification();
1869 application.Render();
1871 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1875 int UtcDaliActorGetCurrentScale(void)
1877 TestApplication application;
1878 Vector3 scale(12.0f, 1.0f, 2.0f);
1880 Actor actor = Actor::New();
1882 actor.SetScale(scale);
1884 // flush the queue and render once
1885 application.SendNotification();
1886 application.Render();
1888 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1892 int UtcDaliActorGetCurrentWorldScale(void)
1894 TestApplication application;
1896 Actor parent = Actor::New();
1897 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1898 parent.SetScale( parentScale );
1899 Stage::GetCurrent().Add( parent );
1901 Actor child = Actor::New();
1902 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1903 child.SetScale( childScale );
1904 parent.Add( child );
1906 // The actors should not have a scale yet
1907 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1908 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1910 // The actors should not have a world scale yet
1911 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1912 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1914 application.SendNotification();
1915 application.Render(0);
1917 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1918 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1920 // The actors should have a world scale now
1921 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1922 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1926 int UtcDaliActorInheritScale(void)
1928 tet_infoline("Testing Actor::SetInheritScale");
1929 TestApplication application;
1931 Actor parent = Actor::New();
1932 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1933 parent.SetScale( parentScale );
1934 Stage::GetCurrent().Add( parent );
1936 Actor child = Actor::New();
1937 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1938 child.SetScale( childScale );
1939 parent.Add( child );
1941 application.SendNotification();
1942 application.Render(0);
1944 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1945 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1947 child.SetInheritScale( false );
1948 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1950 application.SendNotification();
1951 application.Render(0);
1953 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1957 int UtcDaliActorSetVisible(void)
1959 TestApplication application;
1961 Actor actor = Actor::New();
1962 actor.SetVisible(false);
1963 // flush the queue and render once
1964 application.SendNotification();
1965 application.Render();
1966 DALI_TEST_CHECK(actor.IsVisible() == false);
1968 actor.SetVisible(true);
1969 // flush the queue and render once
1970 application.SendNotification();
1971 application.Render();
1972 DALI_TEST_CHECK(actor.IsVisible() == true);
1974 // put actor on stage
1975 Stage::GetCurrent().Add( actor );
1976 actor.SetVisible(false);
1977 // flush the queue and render once
1978 application.SendNotification();
1979 application.Render();
1980 DALI_TEST_CHECK(actor.IsVisible() == false);
1984 int UtcDaliActorIsVisible(void)
1986 TestApplication application;
1988 Actor actor = Actor::New();
1990 DALI_TEST_CHECK(actor.IsVisible() == true);
1994 int UtcDaliActorSetOpacity(void)
1996 TestApplication application;
1998 Actor actor = Actor::New();
1999 // initial opacity is 1
2000 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
2002 actor.SetOpacity( 0.4f);
2003 // flush the queue and render once
2004 application.SendNotification();
2005 application.Render();
2006 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
2008 // change opacity, actor is on stage to change is not immediate
2009 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
2010 // flush the queue and render once
2011 application.SendNotification();
2012 application.Render();
2013 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2015 // put actor on stage
2016 Stage::GetCurrent().Add( actor );
2018 // change opacity, actor is on stage to change is not immediate
2019 actor.SetOpacity( 0.9f );
2020 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
2021 // flush the queue and render once
2022 application.SendNotification();
2023 application.Render();
2024 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
2026 // change opacity, actor is on stage to change is not immediate
2027 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
2028 // flush the queue and render once
2029 application.SendNotification();
2030 application.Render();
2031 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
2035 int UtcDaliActorGetCurrentOpacity(void)
2037 TestApplication application;
2039 Actor actor = Actor::New();
2040 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
2042 actor.SetOpacity(0.5f);
2043 // flush the queue and render once
2044 application.SendNotification();
2045 application.Render();
2046 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
2050 int UtcDaliActorSetSensitive(void)
2052 TestApplication application;
2053 Actor actor = Actor::New();
2055 bool sensitive = !actor.IsSensitive();
2057 actor.SetSensitive(sensitive);
2059 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
2063 int UtcDaliActorIsSensitive(void)
2065 TestApplication application;
2066 Actor actor = Actor::New();
2067 actor.SetSensitive(false);
2069 DALI_TEST_CHECK(false == actor.IsSensitive());
2073 int UtcDaliActorSetColor(void)
2075 TestApplication application;
2076 Actor actor = Actor::New();
2077 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2079 DALI_TEST_CHECK(color != actor.GetCurrentColor());
2081 actor.SetColor(color);
2082 // flush the queue and render once
2083 application.SendNotification();
2084 application.Render();
2085 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2087 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
2088 // flush the queue and render once
2089 application.SendNotification();
2090 application.Render();
2091 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
2093 Stage::GetCurrent().Add( actor );
2094 actor.SetColor( color );
2095 // flush the queue and render once
2096 application.SendNotification();
2097 application.Render();
2098 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2100 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2101 // flush the queue and render once
2102 application.SendNotification();
2103 application.Render();
2104 // Actor color is not clamped
2105 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2106 // world color is clamped
2107 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2109 Stage::GetCurrent().Remove( actor );
2113 int UtcDaliActorSetColorIndividual(void)
2115 TestApplication application;
2117 Actor actor = Actor::New();
2119 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2120 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2122 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2123 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2125 // flush the queue and render once
2126 application.SendNotification();
2127 application.Render();
2129 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2130 DALI_TEST_EQUALS( vector.r, actor.GetProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2131 DALI_TEST_EQUALS( vector.r, actor.GetCurrentProperty< float >( Actor::Property::COLOR_RED ), TEST_LOCATION );
2133 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2134 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2136 // flush the queue and render once
2137 application.SendNotification();
2138 application.Render();
2140 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2141 DALI_TEST_EQUALS( vector.g, actor.GetProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2142 DALI_TEST_EQUALS( vector.g, actor.GetCurrentProperty< float >( Actor::Property::COLOR_GREEN ), TEST_LOCATION );
2144 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2145 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2147 // flush the queue and render once
2148 application.SendNotification();
2149 application.Render();
2151 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2152 DALI_TEST_EQUALS( vector.b, actor.GetProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2153 DALI_TEST_EQUALS( vector.b, actor.GetCurrentProperty< float >( Actor::Property::COLOR_BLUE ), TEST_LOCATION );
2156 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2157 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2159 // flush the queue and render once
2160 application.SendNotification();
2161 application.Render();
2163 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2164 DALI_TEST_EQUALS( vector.a, actor.GetProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2165 DALI_TEST_EQUALS( vector.a, actor.GetCurrentProperty< float >( Actor::Property::COLOR_ALPHA ), TEST_LOCATION );
2167 DALI_TEST_EQUALS( vector, actor.GetProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2168 DALI_TEST_EQUALS( vector, actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), TEST_LOCATION );
2170 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2173 // flush the queue and render once
2174 application.SendNotification();
2175 application.Render();
2177 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2183 int UtcDaliActorGetCurrentColor(void)
2185 TestApplication application;
2186 Actor actor = Actor::New();
2187 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2189 actor.SetColor(color);
2190 // flush the queue and render once
2191 application.SendNotification();
2192 application.Render();
2193 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2197 int UtcDaliActorGetCurrentWorldColor(void)
2199 tet_infoline("Actor::GetCurrentWorldColor");
2200 TestApplication application;
2202 Actor parent = Actor::New();
2203 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2204 parent.SetColor( parentColor );
2205 Stage::GetCurrent().Add( parent );
2207 Actor child = Actor::New();
2208 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2209 child.SetColor( childColor );
2210 parent.Add( child );
2212 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2213 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2215 // verify the default color mode
2216 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2218 // The actors should not have a world color yet
2219 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2220 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2222 application.SendNotification();
2223 application.Render(0);
2225 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2226 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2228 // The actors should have a world color now
2229 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2230 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2233 child.SetColorMode( USE_OWN_COLOR );
2234 application.SendNotification();
2235 application.Render(0);
2236 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2239 child.SetColorMode( USE_PARENT_COLOR );
2240 application.SendNotification();
2241 application.Render(0);
2242 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2243 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2246 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2247 application.SendNotification();
2248 application.Render(0);
2249 Vector4 expectedColor( childColor );
2250 expectedColor.a *= parentColor.a;
2251 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2252 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2256 int UtcDaliActorSetColorMode(void)
2258 tet_infoline("Actor::SetColorMode");
2259 TestApplication application;
2260 Actor actor = Actor::New();
2261 Actor child = Actor::New();
2264 actor.SetColorMode( USE_OWN_COLOR );
2265 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2267 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2268 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2270 actor.SetColorMode( USE_PARENT_COLOR );
2271 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2273 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2274 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2278 int UtcDaliActorScreenToLocal(void)
2280 TestApplication application;
2281 Actor actor = Actor::New();
2282 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2283 actor.SetSize(100.0f, 100.0f);
2284 actor.SetPosition(10.0f, 10.0f);
2285 Stage::GetCurrent().Add(actor);
2287 // flush the queue and render once
2288 application.SendNotification();
2289 application.Render();
2294 application.SendNotification();
2295 application.Render();
2297 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2299 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2300 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2304 int UtcDaliActorSetLeaveRequired(void)
2306 TestApplication application;
2308 Actor actor = Actor::New();
2310 actor.SetLeaveRequired(false);
2311 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2313 actor.SetLeaveRequired(true);
2314 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2318 int UtcDaliActorGetLeaveRequired(void)
2320 TestApplication application;
2322 Actor actor = Actor::New();
2324 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2328 int UtcDaliActorSetKeyboardFocusable(void)
2330 TestApplication application;
2332 Actor actor = Actor::New();
2334 actor.SetKeyboardFocusable(true);
2335 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2337 actor.SetKeyboardFocusable(false);
2338 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2342 int UtcDaliActorIsKeyboardFocusable(void)
2344 TestApplication application;
2346 Actor actor = Actor::New();
2348 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2352 int UtcDaliActorRemoveConstraints(void)
2354 tet_infoline(" UtcDaliActorRemoveConstraints");
2355 TestApplication application;
2357 gTestConstraintCalled = false;
2359 Actor actor = Actor::New();
2361 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2363 actor.RemoveConstraints();
2365 DALI_TEST_CHECK( gTestConstraintCalled == false );
2367 Stage::GetCurrent().Add( actor );
2370 // flush the queue and render once
2371 application.SendNotification();
2372 application.Render();
2374 actor.RemoveConstraints();
2376 DALI_TEST_CHECK( gTestConstraintCalled == true );
2380 int UtcDaliActorRemoveConstraintTag(void)
2382 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2383 TestApplication application;
2385 Actor actor = Actor::New();
2387 // 1. Apply Constraint1 and Constraint2, and test...
2388 unsigned int result1 = 0u;
2389 unsigned int result2 = 0u;
2391 unsigned constraint1Tag = 1u;
2392 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2393 constraint1.SetTag( constraint1Tag );
2394 constraint1.Apply();
2396 unsigned constraint2Tag = 2u;
2397 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2398 constraint2.SetTag( constraint2Tag );
2399 constraint2.Apply();
2401 Stage::GetCurrent().Add( actor );
2402 // flush the queue and render once
2403 application.SendNotification();
2404 application.Render();
2406 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2407 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2409 // 2. Remove Constraint1 and test...
2412 actor.RemoveConstraints(constraint1Tag);
2413 // make color property dirty, which will trigger constraints to be reapplied.
2414 actor.SetColor( Color::WHITE );
2415 // flush the queue and render once
2416 application.SendNotification();
2417 application.Render();
2419 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2420 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2422 // 3. Re-Apply Constraint1 and test...
2425 constraint1.Apply();
2426 // make color property dirty, which will trigger constraints to be reapplied.
2427 actor.SetColor( Color::WHITE );
2428 // flush the queue and render once
2429 application.SendNotification();
2430 application.Render();
2432 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2433 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2435 // 2. Remove Constraint2 and test...
2438 actor.RemoveConstraints(constraint2Tag);
2439 // make color property dirty, which will trigger constraints to be reapplied.
2440 actor.SetColor( Color::WHITE );
2441 // flush the queue and render once
2442 application.SendNotification();
2443 application.Render();
2445 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2446 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2448 // 2. Remove Constraint1 as well and test...
2451 actor.RemoveConstraints(constraint1Tag);
2452 // make color property dirty, which will trigger constraints to be reapplied.
2453 actor.SetColor( Color::WHITE );
2454 // flush the queue and render once
2455 application.SendNotification();
2456 application.Render();
2458 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2459 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2463 int UtcDaliActorTouchedSignal(void)
2465 TestApplication application;
2467 ResetTouchCallbacks();
2469 // get the root layer
2470 Actor actor = Stage::GetCurrent().GetRootLayer();
2471 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2473 application.SendNotification();
2474 application.Render();
2476 // connect to its touch signal
2477 actor.TouchedSignal().Connect( TestCallback );
2479 // simulate a touch event in the middle of the screen
2480 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2481 Dali::Integration::Point point;
2482 point.SetDeviceId( 1 );
2483 point.SetState( PointState::DOWN );
2484 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2485 Dali::Integration::TouchEvent touchEvent;
2486 touchEvent.AddPoint( point );
2487 application.ProcessEvent( touchEvent );
2489 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2493 int UtcDaliActorHoveredSignal(void)
2495 TestApplication application;
2497 gHoverCallBackCalled = false;
2499 // get the root layer
2500 Actor actor = Stage::GetCurrent().GetRootLayer();
2501 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2503 application.SendNotification();
2504 application.Render();
2506 // connect to its hover signal
2507 actor.HoveredSignal().Connect( TestCallback3 );
2509 // simulate a hover event in the middle of the screen
2510 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2511 Dali::Integration::Point point;
2512 point.SetDeviceId( 1 );
2513 point.SetState( PointState::MOTION );
2514 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2515 Dali::Integration::HoverEvent hoverEvent;
2516 hoverEvent.AddPoint( point );
2517 application.ProcessEvent( hoverEvent );
2519 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2523 int UtcDaliActorOnOffStageSignal(void)
2525 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2527 TestApplication application;
2530 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2531 gActorNamesOnOffStage.clear();
2533 Actor parent = Actor::New();
2534 parent.SetName( "parent" );
2535 parent.OnStageSignal().Connect( OnStageCallback );
2536 parent.OffStageSignal().Connect( OffStageCallback );
2538 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2539 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2541 // add parent to stage
2542 Stage::GetCurrent().Add( parent );
2543 // onstage emitted, offstage not
2544 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2545 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2546 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2548 // test adding a child, should get onstage emitted
2550 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2551 gActorNamesOnOffStage.clear();
2553 Actor child = Actor::New();
2554 child.SetName( "child" );
2555 child.OnStageSignal().Connect( OnStageCallback );
2556 child.OffStageSignal().Connect( OffStageCallback );
2557 parent.Add( child ); // add child
2558 // onstage emitted, offstage not
2559 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2560 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2561 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2563 // test removing parent from stage
2565 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2566 gActorNamesOnOffStage.clear();
2568 Stage::GetCurrent().Remove( parent );
2569 // onstage not emitted, offstage is
2570 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2571 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2572 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2573 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2575 // test adding parent back to stage
2577 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2578 gActorNamesOnOffStage.clear();
2580 Stage::GetCurrent().Add( parent );
2581 // onstage emitted, offstage not
2582 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2583 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2584 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2585 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2587 // test removing child
2589 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2590 gActorNamesOnOffStage.clear();
2592 parent.Remove( child );
2593 // onstage not emitted, offstage is
2594 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2595 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2596 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2598 // test removing parent
2600 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2601 gActorNamesOnOffStage.clear();
2603 Stage::GetCurrent().Remove( parent );
2604 // onstage not emitted, offstage is
2605 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2606 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2607 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2611 int UtcDaliActorFindChildByName(void)
2613 tet_infoline("Testing Dali::Actor::FindChildByName()");
2614 TestApplication application;
2616 Actor parent = Actor::New();
2617 parent.SetName( "parent" );
2618 Actor first = Actor::New();
2619 first .SetName( "first" );
2620 Actor second = Actor::New();
2621 second.SetName( "second" );
2626 Actor found = parent.FindChildByName( "foo" );
2627 DALI_TEST_CHECK( !found );
2629 found = parent.FindChildByName( "parent" );
2630 DALI_TEST_CHECK( found == parent );
2632 found = parent.FindChildByName( "first" );
2633 DALI_TEST_CHECK( found == first );
2635 found = parent.FindChildByName( "second" );
2636 DALI_TEST_CHECK( found == second );
2640 int UtcDaliActorFindChildById(void)
2642 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2643 TestApplication application;
2645 Actor parent = Actor::New();
2646 Actor first = Actor::New();
2647 Actor second = Actor::New();
2652 Actor found = parent.FindChildById( 100000 );
2653 DALI_TEST_CHECK( !found );
2655 found = parent.FindChildById( parent.GetId() );
2656 DALI_TEST_CHECK( found == parent );
2658 found = parent.FindChildById( first.GetId() );
2659 DALI_TEST_CHECK( found == first );
2661 found = parent.FindChildById( second.GetId() );
2662 DALI_TEST_CHECK( found == second );
2666 int UtcDaliActorHitTest(void)
2671 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2673 mTouchPoint( touchPoint ),
2678 Vector2 mTouchPoint;
2682 TestApplication application;
2683 tet_infoline(" UtcDaliActorHitTest");
2685 // Fill a vector with different hit tests.
2686 struct HitTestData* hitTestData[] = {
2687 // scale touch point result
2688 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2689 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2690 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.
2691 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2692 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.
2696 // get the root layer
2697 Actor actor = Actor::New();
2698 actor.SetAnchorPoint( AnchorPoint::CENTER );
2699 actor.SetParentOrigin( ParentOrigin::CENTER );
2701 Stage::GetCurrent().Add( actor );
2703 ResetTouchCallbacks();
2705 unsigned int index = 0;
2706 while( NULL != hitTestData[index] )
2708 actor.SetSize( 1.f, 1.f );
2709 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2711 // flush the queue and render once
2712 application.SendNotification();
2713 application.Render();
2715 DALI_TEST_CHECK( !gTouchCallBackCalled );
2717 // connect to its touch signal
2718 actor.TouchedSignal().Connect(TestCallback);
2720 Dali::Integration::Point point;
2721 point.SetState( PointState::DOWN );
2722 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2723 Dali::Integration::TouchEvent event;
2724 event.AddPoint( point );
2726 // flush the queue and render once
2727 application.SendNotification();
2728 application.Render();
2729 application.ProcessEvent( event );
2731 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2733 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2734 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2735 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2736 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2737 hitTestData[index]->mResult );
2739 ResetTouchCallbacks();
2745 int UtcDaliActorSetDrawMode(void)
2747 TestApplication app;
2748 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2750 Actor a = Actor::New();
2752 Stage::GetCurrent().Add(a);
2753 app.SendNotification();
2755 app.SendNotification();
2758 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2760 a.SetDrawMode( DrawMode::OVERLAY_2D );
2761 app.SendNotification();
2764 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2766 a.SetDrawMode( DrawMode::NORMAL );
2767 app.SendNotification();
2770 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2774 int UtcDaliActorSetDrawModeOverlayRender(void)
2776 TestApplication app;
2777 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2779 app.SendNotification();
2782 std::vector<GLuint> ids;
2783 ids.push_back( 8 ); // first rendered actor
2784 ids.push_back( 9 ); // second rendered actor
2785 ids.push_back( 10 ); // third rendered actor
2786 app.GetGlAbstraction().SetNextTextureIds( ids );
2788 BufferImage imageA = BufferImage::New(16, 16);
2789 BufferImage imageB = BufferImage::New(16, 16);
2790 BufferImage imageC = BufferImage::New(16, 16);
2791 Actor a = CreateRenderableActor( imageA );
2792 Actor b = CreateRenderableActor( imageB );
2793 Actor c = CreateRenderableActor( imageC );
2795 app.SendNotification();
2798 //Textures are bound when first created. Clear bound textures vector
2799 app.GetGlAbstraction().ClearBoundTextures();
2801 // Render a,b,c as regular non-overlays. so order will be:
2805 Stage::GetCurrent().Add(a);
2806 Stage::GetCurrent().Add(b);
2807 Stage::GetCurrent().Add(c);
2809 app.SendNotification();
2812 // Should be 3 textures changes.
2813 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2814 typedef std::vector<GLuint>::size_type TextureSize;
2815 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2816 if( boundTextures.size() == 3 )
2818 DALI_TEST_CHECK( boundTextures[0] == 8u );
2819 DALI_TEST_CHECK( boundTextures[1] == 9u );
2820 DALI_TEST_CHECK( boundTextures[2] == 10u );
2823 // Now texture ids have been set, we can monitor their render order.
2824 // render a as an overlay (last), so order will be:
2828 a.SetDrawMode( DrawMode::OVERLAY_2D );
2829 app.GetGlAbstraction().ClearBoundTextures();
2831 app.SendNotification();
2834 // Should be 3 texture changes.
2835 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2836 if( boundTextures.size() == 3 )
2838 DALI_TEST_CHECK( boundTextures[0] == 9u );
2839 DALI_TEST_CHECK( boundTextures[1] == 10u );
2840 DALI_TEST_CHECK( boundTextures[2] == 8u );
2845 int UtcDaliActorGetCurrentWorldMatrix(void)
2847 TestApplication app;
2848 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2850 Actor parent = Actor::New();
2851 parent.SetParentOrigin(ParentOrigin::CENTER);
2852 parent.SetAnchorPoint(AnchorPoint::CENTER);
2853 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2854 Radian rotationAngle(Degree(85.0f));
2855 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2856 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2857 parent.SetPosition( parentPosition );
2858 parent.SetOrientation( parentRotation );
2859 parent.SetScale( parentScale );
2860 Stage::GetCurrent().Add( parent );
2862 Actor child = Actor::New();
2863 child.SetParentOrigin(ParentOrigin::CENTER);
2864 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2865 Radian childRotationAngle(Degree(23.0f));
2866 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2867 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2868 child.SetPosition( childPosition );
2869 child.SetOrientation( childRotation );
2870 child.SetScale( childScale );
2871 parent.Add( child );
2873 app.SendNotification();
2876 app.SendNotification();
2878 Matrix parentMatrix(false);
2879 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2881 Matrix childMatrix(false);
2882 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2884 //Child matrix should be the composition of child and parent
2885 Matrix childWorldMatrix(false);
2886 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2888 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2889 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2895 int UtcDaliActorConstrainedToWorldMatrix(void)
2897 TestApplication app;
2898 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2900 Actor parent = Actor::New();
2901 parent.SetParentOrigin(ParentOrigin::CENTER);
2902 parent.SetAnchorPoint(AnchorPoint::CENTER);
2903 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2904 Radian rotationAngle(Degree(85.0f));
2905 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2906 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2907 parent.SetPosition( parentPosition );
2908 parent.SetOrientation( parentRotation );
2909 parent.SetScale( parentScale );
2910 Stage::GetCurrent().Add( parent );
2912 Actor child = Actor::New();
2913 child.SetParentOrigin(ParentOrigin::CENTER);
2914 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2915 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2916 posConstraint.Apply();
2918 Stage::GetCurrent().Add( child );
2920 app.SendNotification();
2923 app.SendNotification();
2925 Matrix parentMatrix(false);
2926 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2928 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2929 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2933 int UtcDaliActorConstrainedToOrientation(void)
2935 TestApplication app;
2936 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2938 Actor parent = Actor::New();
2939 parent.SetParentOrigin(ParentOrigin::CENTER);
2940 parent.SetAnchorPoint(AnchorPoint::CENTER);
2941 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2942 Radian rotationAngle(Degree(85.0f));
2943 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2944 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2945 parent.SetPosition( parentPosition );
2946 parent.SetOrientation( parentRotation );
2947 parent.SetScale( parentScale );
2948 Stage::GetCurrent().Add( parent );
2950 Actor child = Actor::New();
2951 child.SetParentOrigin(ParentOrigin::CENTER);
2952 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2953 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2954 posConstraint.Apply();
2956 Stage::GetCurrent().Add( child );
2958 app.SendNotification();
2961 app.SendNotification();
2963 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2967 int UtcDaliActorConstrainedToOpacity(void)
2969 TestApplication app;
2970 tet_infoline(" UtcDaliActorConstrainedToOpacity");
2972 Actor parent = Actor::New();
2973 parent.SetOpacity( 0.7f );
2974 Stage::GetCurrent().Add( parent );
2976 Actor child = Actor::New();
2977 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2978 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2979 opacityConstraint.Apply();
2981 Stage::GetCurrent().Add( child );
2983 app.SendNotification();
2986 app.SendNotification();
2988 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2990 parent.SetOpacity( 0.3f );
2992 app.SendNotification();
2995 app.SendNotification();
2997 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
3002 int UtcDaliActorUnparent(void)
3004 TestApplication app;
3005 tet_infoline(" UtcDaliActorUnparent");
3007 Actor parent = Actor::New();
3008 Stage::GetCurrent().Add( parent );
3010 Actor child = Actor::New();
3012 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3013 DALI_TEST_CHECK( !child.GetParent() );
3015 // Test that calling Unparent with no parent is a NOOP
3018 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3019 DALI_TEST_CHECK( !child.GetParent() );
3021 // Test that Unparent works
3022 parent.Add( child );
3024 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3025 DALI_TEST_CHECK( parent == child.GetParent() );
3029 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3030 DALI_TEST_CHECK( !child.GetParent() );
3032 // Test that UnparentAndReset works
3033 parent.Add( child );
3035 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
3036 DALI_TEST_CHECK( parent == child.GetParent() );
3038 UnparentAndReset( child );
3040 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
3041 DALI_TEST_CHECK( !child );
3043 // Test that UnparentAndReset is a NOOP with empty handle
3044 UnparentAndReset( child );
3046 DALI_TEST_CHECK( !child );
3050 int UtcDaliActorGetChildAt(void)
3052 TestApplication app;
3053 tet_infoline(" UtcDaliActorGetChildAt");
3055 Actor parent = Actor::New();
3056 Stage::GetCurrent().Add( parent );
3058 Actor child0 = Actor::New();
3059 parent.Add( child0 );
3061 Actor child1 = Actor::New();
3062 parent.Add( child1 );
3064 Actor child2 = Actor::New();
3065 parent.Add( child2 );
3067 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
3068 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
3069 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
3073 int UtcDaliActorSetGetOverlay(void)
3075 TestApplication app;
3076 tet_infoline(" UtcDaliActorSetGetOverlay");
3078 Actor parent = Actor::New();
3079 parent.SetDrawMode(DrawMode::OVERLAY_2D );
3080 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
3085 int UtcDaliActorCreateDestroy(void)
3087 Actor* actor = new Actor;
3088 DALI_TEST_CHECK( actor );
3095 struct PropertyStringIndex
3097 const char * const name;
3098 const Property::Index index;
3099 const Property::Type type;
3102 const PropertyStringIndex PROPERTY_TABLE[] =
3104 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
3105 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
3106 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
3107 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
3108 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
3109 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
3110 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
3111 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
3112 { "size", Actor::Property::SIZE, Property::VECTOR3 },
3113 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
3114 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3115 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3116 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3117 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3118 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3119 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3120 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3121 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3122 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3123 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3124 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3125 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3126 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3127 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3128 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3129 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3130 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3131 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3132 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3133 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3134 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3135 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3136 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3137 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3138 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3139 { "name", Actor::Property::NAME, Property::STRING },
3140 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3141 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3142 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3143 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3144 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3145 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3146 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3147 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3148 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3149 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3150 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3151 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3152 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3153 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3154 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3155 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3156 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3157 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3158 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3160 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3161 } // unnamed namespace
3163 int UtcDaliActorProperties(void)
3165 TestApplication app;
3167 Actor actor = Actor::New();
3169 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3171 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3172 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3173 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3174 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3179 int UtcDaliRelayoutProperties_ResizePolicies(void)
3181 TestApplication app;
3183 Actor actor = Actor::New();
3186 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3187 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3189 // Set resize policy for all dimensions
3190 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3191 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3193 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3196 // Set individual dimensions
3197 const char* const widthPolicy = "FILL_TO_PARENT";
3198 const char* const heightPolicy = "FIXED";
3200 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3201 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3203 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3204 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3206 // Set individual dimensions using enums
3207 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3208 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3210 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3211 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3213 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3214 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3219 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3221 TestApplication app;
3223 Actor actor = Actor::New();
3226 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3227 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3229 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3230 actor.SetSizeScalePolicy( policy );
3231 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3234 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3235 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3237 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3238 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3240 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3241 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3246 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3248 TestApplication app;
3250 Actor actor = Actor::New();
3253 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3254 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3256 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3257 actor.SetSizeModeFactor( sizeMode );
3258 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3261 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3263 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3264 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3269 int UtcDaliRelayoutProperties_DimensionDependency(void)
3271 TestApplication app;
3273 Actor actor = Actor::New();
3276 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3277 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3280 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3281 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3283 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3284 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3286 // Test setting another resize policy
3287 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3288 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3293 int UtcDaliRelayoutProperties_Padding(void)
3295 TestApplication app;
3297 Actor actor = Actor::New();
3300 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3303 actor.SetProperty( Actor::Property::PADDING, padding );
3304 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3306 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3311 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3313 TestApplication app;
3315 Actor actor = Actor::New();
3318 Vector2 minSize( 1.0f, 2.0f );
3320 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3321 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3323 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3325 Vector2 maxSize( 3.0f, 4.0f );
3327 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3328 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3330 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3335 int UtcDaliActorGetHeightForWidth(void)
3337 TestApplication app;
3339 Actor actor = Actor::New();
3341 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3346 int UtcDaliActorGetWidthForHeight(void)
3348 TestApplication app;
3350 Actor actor = Actor::New();
3352 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3357 int UtcDaliActorGetRelayoutSize(void)
3359 TestApplication app;
3361 Actor actor = Actor::New();
3363 // Add actor to stage
3364 Stage::GetCurrent().Add( actor );
3366 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3368 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3369 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3371 // Flush the queue and render once
3372 app.SendNotification();
3375 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3380 int UtcDaliActorSetPadding(void)
3382 TestApplication app;
3384 Actor actor = Actor::New();
3387 actor.GetPadding( padding );
3389 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3390 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3391 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3392 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3394 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3395 actor.SetPadding( padding2 );
3397 actor.GetPadding( padding );
3399 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3400 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3401 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3402 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3407 int UtcDaliActorSetMinimumSize(void)
3409 TestApplication app;
3411 Actor actor = Actor::New();
3413 Vector2 size = actor.GetMinimumSize();
3415 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3416 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3418 Vector2 size2( 1.0f, 2.0f );
3419 actor.SetMinimumSize( size2 );
3421 size = actor.GetMinimumSize();
3423 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3424 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3429 int UtcDaliActorSetMaximumSize(void)
3431 TestApplication app;
3433 Actor actor = Actor::New();
3435 Vector2 size = actor.GetMaximumSize();
3437 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3438 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3440 Vector2 size2( 1.0f, 2.0f );
3441 actor.SetMaximumSize( size2 );
3443 size = actor.GetMaximumSize();
3445 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3446 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3451 int UtcDaliActorOnRelayoutSignal(void)
3453 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3455 TestApplication application;
3458 gOnRelayoutCallBackCalled = false;
3459 gActorNamesRelayout.clear();
3461 Actor actor = Actor::New();
3462 actor.SetName( "actor" );
3463 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3466 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3468 // Add actor to stage
3469 Stage::GetCurrent().Add( actor );
3471 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3472 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3474 // Flush the queue and render once
3475 application.SendNotification();
3476 application.Render();
3478 // OnRelayout emitted
3479 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3480 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3485 int UtcDaliActorGetHierachyDepth(void)
3487 TestApplication application;
3488 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3491 /* Build tree of actors:
3501 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3503 Stage stage( Stage::GetCurrent() );
3505 Actor actorA = Actor::New();
3506 Actor actorB = Actor::New();
3507 Actor actorC = Actor::New();
3508 Actor actorD = Actor::New();
3509 Actor actorE = Actor::New();
3510 Actor actorF = Actor::New();
3512 //Test that root actor has depth equal 0
3513 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3515 //Test actors return depth -1 when not connected to the tree
3516 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3517 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3518 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3519 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3520 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3521 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3523 //Create the hierarchy
3524 stage.Add( actorA );
3525 actorA.Add( actorB );
3526 actorA.Add( actorC );
3527 actorB.Add( actorD );
3528 actorB.Add( actorE );
3529 actorC.Add( actorF );
3531 //Test actors return correct depth
3532 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3533 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3534 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3535 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3536 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3537 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3539 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3540 actorA.Remove( actorB );
3542 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3543 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3544 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3546 //Removing actorA from the stage. All actors should have depth equal -1
3547 stage.Remove( actorA );
3549 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3550 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3551 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3552 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3553 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3554 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3559 int UtcDaliActorAnchorPointPropertyAsString(void)
3561 TestApplication application;
3563 Actor actor = Actor::New();
3565 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3566 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3568 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3569 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3571 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3572 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3574 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3575 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3577 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3578 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3580 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3581 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3583 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3584 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3586 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3587 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3589 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3590 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3592 // Invalid should not change anything
3593 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3594 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3599 int UtcDaliActorParentOriginPropertyAsString(void)
3601 TestApplication application;
3603 Actor actor = Actor::New();
3605 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3606 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3608 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3609 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3611 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3612 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3614 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3615 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3617 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3618 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3620 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3621 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3623 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3624 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3626 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3627 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3629 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3630 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3632 // Invalid should not change anything
3633 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3634 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3639 int UtcDaliActorColorModePropertyAsString(void)
3641 TestApplication application;
3643 Actor actor = Actor::New();
3645 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3646 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3648 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3649 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3651 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3652 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3654 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3655 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3657 // Invalid should not change anything
3658 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3659 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3664 int UtcDaliActorPositionInheritancePropertyAsString(void)
3666 TestApplication application;
3668 Actor actor = Actor::New();
3670 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3671 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3673 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3674 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3676 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3677 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3679 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3680 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3682 // Invalid should not change anything
3683 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3684 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3689 int UtcDaliActorDrawModePropertyAsString(void)
3691 TestApplication application;
3693 Actor actor = Actor::New();
3695 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3696 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3698 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3699 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3701 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3702 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3704 // Invalid should not change anything
3705 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3706 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3711 int UtcDaliActorColorModePropertyAsEnum(void)
3713 TestApplication application;
3715 Actor actor = Actor::New();
3717 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3718 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3720 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3721 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3723 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3724 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3726 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3727 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3732 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3734 TestApplication application;
3736 Actor actor = Actor::New();
3738 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3739 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3741 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3742 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3744 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3745 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3747 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3748 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3753 int UtcDaliActorDrawModePropertyAsEnum(void)
3755 TestApplication application;
3757 Actor actor = Actor::New();
3759 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3760 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3762 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3763 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3765 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3766 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3771 int UtcDaliActorAddRendererP(void)
3773 tet_infoline("Testing Actor::AddRenderer");
3774 TestApplication application;
3776 Actor actor = Actor::New();
3778 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3780 Geometry geometry = CreateQuadGeometry();
3781 Shader shader = CreateShader();
3782 Renderer renderer = Renderer::New(geometry, shader);
3784 actor.AddRenderer( renderer );
3785 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3786 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3791 int UtcDaliActorAddRendererN(void)
3793 tet_infoline("Testing Actor::AddRenderer");
3794 TestApplication application;
3796 Actor actor = Actor::New();
3802 actor.AddRenderer( renderer );
3803 tet_printf("Assertion test failed - no Exception\n" );
3804 tet_result(TET_FAIL);
3806 catch(Dali::DaliException& e)
3808 DALI_TEST_PRINT_ASSERT( e );
3809 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3810 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3814 tet_printf("Assertion test failed - wrong Exception\n" );
3815 tet_result(TET_FAIL);
3821 int UtcDaliActorAddRendererOnStage(void)
3823 tet_infoline("Testing Actor::AddRenderer");
3824 TestApplication application;
3826 Actor actor = Actor::New();
3827 Stage::GetCurrent().Add(actor);
3829 application.SendNotification();
3830 application.Render(0);
3832 Geometry geometry = CreateQuadGeometry();
3833 Shader shader = CreateShader();
3834 Renderer renderer = Renderer::New(geometry, shader);
3836 application.SendNotification();
3837 application.Render(0);
3841 actor.AddRenderer( renderer );
3842 tet_result(TET_PASS);
3846 tet_result(TET_FAIL);
3852 int UtcDaliActorRemoveRendererP1(void)
3854 tet_infoline("Testing Actor::RemoveRenderer");
3855 TestApplication application;
3857 Actor actor = Actor::New();
3859 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3862 Geometry geometry = CreateQuadGeometry();
3863 Shader shader = CreateShader();
3864 Renderer renderer = Renderer::New(geometry, shader);
3866 actor.AddRenderer( renderer );
3867 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3868 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3870 application.SendNotification();
3871 application.Render();
3875 Renderer renderer = actor.GetRendererAt(0);
3876 actor.RemoveRenderer(renderer);
3877 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3879 application.SendNotification();
3880 application.Render();
3883 // Call one final time to ensure that the renderer is actually removed after
3884 // the handle goes out of scope, and excercises the deletion code path in
3885 // scene graph and render.
3886 application.SendNotification();
3887 application.Render();
3892 int UtcDaliActorRemoveRendererP2(void)
3894 tet_infoline("Testing Actor::RemoveRenderer");
3895 TestApplication application;
3897 Actor actor = Actor::New();
3899 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3901 Geometry geometry = CreateQuadGeometry();
3902 Shader shader = CreateShader();
3903 Renderer renderer = Renderer::New(geometry, shader);
3905 actor.AddRenderer( renderer );
3906 application.SendNotification();
3907 application.Render();
3909 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3910 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3912 actor.RemoveRenderer(0);
3913 application.SendNotification();
3914 application.Render();
3916 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3918 // Shut down whilst holding onto the renderer handle.
3923 int UtcDaliActorRemoveRendererN(void)
3925 tet_infoline("Testing Actor::RemoveRenderer");
3926 TestApplication application;
3928 Actor actor = Actor::New();
3930 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3932 Geometry geometry = CreateQuadGeometry();
3933 Shader shader = CreateShader();
3934 Renderer renderer = Renderer::New(geometry, shader);
3936 actor.AddRenderer( renderer );
3937 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3938 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3940 actor.RemoveRenderer(10);
3941 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3942 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3947 // Clipping test helper functions:
3948 Actor CreateActorWithContent()
3950 BufferImage image = BufferImage::New( 16u, 16u );
3951 Actor actor = CreateRenderableActor( image );
3953 // Setup dimensions and position so actor is not skipped by culling.
3954 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3955 actor.SetSize( 16.0f, 16.0f );
3956 actor.SetParentOrigin( ParentOrigin::CENTER );
3957 actor.SetAnchorPoint( AnchorPoint::CENTER );
3962 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3964 enabledDisableTrace.Reset();
3965 stencilTrace.Reset();
3966 enabledDisableTrace.Enable( true );
3967 stencilTrace.Enable( true );
3969 application.SendNotification();
3970 application.Render();
3972 enabledDisableTrace.Enable( false );
3973 stencilTrace.Enable( false );
3976 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3978 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3980 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3981 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3982 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3983 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3986 int UtcDaliActorPropertyClippingP(void)
3988 // This test checks the clippingMode property.
3989 tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3990 TestApplication application;
3992 Actor actor = Actor::New();
3994 // Check default clippingEnabled value.
3995 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3998 bool getValueResult = getValue.Get( value );
3999 DALI_TEST_CHECK( getValueResult );
4001 if( getValueResult )
4003 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4006 // Check setting the property.
4007 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4009 // Check the new value was set.
4010 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4011 getValueResult = getValue.Get( value );
4012 DALI_TEST_CHECK( getValueResult );
4014 if( getValueResult )
4016 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
4022 int UtcDaliActorPropertyClippingN(void)
4024 // Negative test case for Clipping.
4025 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
4026 TestApplication application;
4028 Actor actor = Actor::New();
4030 // Check default clippingEnabled value.
4031 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
4034 bool getValueResult = getValue.Get( value );
4035 DALI_TEST_CHECK( getValueResult );
4037 if( getValueResult )
4039 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4042 // Check setting an invalid property value won't change the current property value.
4043 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
4045 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
4046 getValueResult = getValue.Get( value );
4047 DALI_TEST_CHECK( getValueResult );
4049 if( getValueResult )
4051 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
4057 int UtcDaliActorPropertyClippingActor(void)
4059 // This test checks that an actor is correctly setup for clipping.
4060 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
4061 TestApplication application;
4063 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4064 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4065 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4066 size_t startIndex = 0u;
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 // Gather the call trace.
4074 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4076 // Check we are writing to the color buffer.
4077 CheckColorMask( glAbstraction, true );
4079 // Check the stencil buffer was enabled.
4080 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4082 // Check the stencil buffer was cleared.
4083 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4085 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4086 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4087 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4088 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4093 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4095 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4096 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
4097 TestApplication application;
4099 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4100 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4101 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4102 size_t startIndex = 0u;
4104 // Create a clipping actor.
4105 Actor actorDepth1Clip = CreateActorWithContent();
4106 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4107 Stage::GetCurrent().Add( actorDepth1Clip );
4109 // Gather the call trace.
4110 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4112 // Check we are writing to the color buffer.
4113 CheckColorMask( glAbstraction, true );
4115 // Check the stencil buffer was enabled.
4116 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4118 // Check the stencil buffer was cleared.
4119 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4121 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4122 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4123 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
4124 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4126 // Now disable the clipping
4127 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
4129 // Gather the call trace.
4130 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4132 // Check the stencil buffer was disabled.
4133 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4135 // Ensure all values in stencil-mask are set to 1.
4137 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4143 int UtcDaliActorPropertyClippingNestedChildren(void)
4145 // This test checks that a hierarchy of actors are clipped correctly by
4146 // writing to and reading from the correct bit-planes of the stencil buffer.
4147 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
4148 TestApplication application;
4149 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4150 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4151 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4153 // Create a clipping actor.
4154 Actor actorDepth1Clip = CreateActorWithContent();
4155 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4156 Stage::GetCurrent().Add( actorDepth1Clip );
4158 // Create a child actor.
4159 Actor childDepth2 = CreateActorWithContent();
4160 actorDepth1Clip.Add( childDepth2 );
4162 // Create another clipping actor.
4163 Actor childDepth2Clip = CreateActorWithContent();
4164 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4165 childDepth2.Add( childDepth2Clip );
4167 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4168 // This tests the sort algorithm.
4169 Actor childDepth3 = CreateActorWithContent();
4170 childDepth2Clip.Add( childDepth3 );
4171 Actor childDepth4 = CreateActorWithContent();
4172 childDepth3.Add( childDepth4 );
4174 // Gather the call trace.
4175 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4177 // Check we are writing to the color buffer.
4178 CheckColorMask( glAbstraction, true );
4180 // Check the stencil buffer was enabled.
4181 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4183 // Perform the test twice, once for 2D layer, and once for 3D.
4184 for( unsigned int i = 0u ; i < 2u; ++i )
4186 size_t startIndex = 0u;
4188 // Check the stencil buffer was cleared.
4189 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4191 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4192 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4193 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4194 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4196 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4197 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4198 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4200 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4201 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4202 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4203 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4205 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4206 // (Both must be set to pass the check).
4207 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4208 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4210 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4213 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4214 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4221 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4223 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4224 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4225 TestApplication application;
4227 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4228 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4229 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4231 // Create a clipping actor.
4232 Actor actorDepth1Clip = CreateActorWithContent();
4233 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4234 Stage::GetCurrent().Add( actorDepth1Clip );
4236 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4237 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4239 // Gather the call trace.
4240 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4242 // Check we are writing to the color buffer.
4243 CheckColorMask( glAbstraction, true );
4245 // Check the stencil buffer was not enabled.
4246 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4248 // Check stencil functions are not called.
4249 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4250 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4251 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4256 int UtcDaliGetPropertyN(void)
4258 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4259 TestApplication app;
4261 Actor actor = Actor::New();
4263 unsigned int propertyCount = actor.GetPropertyCount();
4264 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4268 int UtcDaliActorRaiseLower(void)
4270 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4272 TestApplication application;
4274 Stage stage( Stage::GetCurrent() );
4276 Actor actorA = Actor::New();
4277 Actor actorB = Actor::New();
4278 Actor actorC = Actor::New();
4280 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4281 actorA.SetParentOrigin( ParentOrigin::CENTER );
4283 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4284 actorB.SetParentOrigin( ParentOrigin::CENTER );
4286 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4287 actorC.SetParentOrigin( ParentOrigin::CENTER );
4289 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4290 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4292 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4293 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4295 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4296 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4298 stage.Add( actorA );
4299 stage.Add( actorB );
4300 stage.Add( actorC );
4302 ResetTouchCallbacks();
4304 application.SendNotification();
4305 application.Render();
4307 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4308 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4309 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4311 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4312 // Only top actor will get touched.
4313 actorA.TouchSignal().Connect( TestTouchCallback );
4314 actorB.TouchSignal().Connect( TestTouchCallback2 );
4315 actorC.TouchSignal().Connect( TestTouchCallback3 );
4317 Dali::Integration::Point point;
4318 point.SetDeviceId( 1 );
4319 point.SetState( PointState::DOWN );
4320 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4321 Dali::Integration::TouchEvent touchEvent;
4322 touchEvent.AddPoint( point );
4324 application.ProcessEvent( touchEvent );
4326 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4327 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4328 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4330 ResetTouchCallbacks();
4332 tet_printf( "Testing Raising of Actor\n" );
4334 int preActorOrder( 0 );
4335 int postActorOrder( 0 );
4337 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4338 value.Get( preActorOrder );
4340 DevelActor::Raise( actorB );
4341 // Ensure sort order is calculated before next touch event
4342 application.SendNotification();
4344 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4345 value.Get( postActorOrder );
4347 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4349 application.ProcessEvent( touchEvent );
4351 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4352 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4353 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4355 ResetTouchCallbacks();
4357 tet_printf( "Testing Lowering of Actor\n" );
4359 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4360 value.Get( preActorOrder );
4362 DevelActor::Lower( actorB );
4363 application.SendNotification(); // ensure sort order calculated before next touch event
4365 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4366 value.Get( postActorOrder );
4368 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4370 application.ProcessEvent( touchEvent );
4372 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4373 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4374 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4376 ResetTouchCallbacks();
4381 int UtcDaliActorRaiseToTopLowerToBottom(void)
4383 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4385 TestApplication application;
4387 Stage stage( Stage::GetCurrent() );
4389 Actor actorA = Actor::New();
4390 Actor actorB = Actor::New();
4391 Actor actorC = Actor::New();
4393 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4394 // enables checking of which actor the uniform is assigned too
4395 Shader shaderA = CreateShader();
4396 shaderA.RegisterProperty( "uRendererColor",1.f);
4398 Shader shaderB = CreateShader();
4399 shaderB.RegisterProperty( "uRendererColor", 2.f );
4401 Shader shaderC = CreateShader();
4402 shaderC.RegisterProperty( "uRendererColor", 3.f );
4404 Geometry geometry = CreateQuadGeometry();
4406 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4407 Renderer rendererA = Renderer::New(geometry, shaderA);
4408 actorA.AddRenderer(rendererA);
4410 Renderer rendererB = Renderer::New(geometry, shaderB);
4411 actorB.AddRenderer(rendererB);
4413 Renderer rendererC = Renderer::New(geometry, shaderC);
4414 actorC.AddRenderer(rendererC);
4416 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4417 actorA.SetParentOrigin( ParentOrigin::CENTER );
4419 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4420 actorB.SetParentOrigin( ParentOrigin::CENTER );
4422 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4423 actorC.SetParentOrigin( ParentOrigin::CENTER );
4425 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4426 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4428 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4429 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4431 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4432 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4434 stage.Add( actorA );
4435 stage.Add( actorB );
4436 stage.Add( actorC );
4438 ResetTouchCallbacks();
4440 // Set up gl abstraction trace so can query the set uniform order
4441 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4442 glAbstraction.EnableSetUniformCallTrace(true);
4443 glAbstraction.ResetSetUniformCallStack();
4445 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4447 application.SendNotification();
4448 application.Render();
4450 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4453 // Test order of uniforms in stack
4454 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4455 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4456 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4458 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4460 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4462 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4463 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4464 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4466 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4467 // Only top actor will get touched.
4468 actorA.TouchSignal().Connect( TestTouchCallback );
4469 actorB.TouchSignal().Connect( TestTouchCallback2 );
4470 actorC.TouchSignal().Connect( TestTouchCallback3 );
4472 Dali::Integration::Point point;
4473 point.SetDeviceId( 1 );
4474 point.SetState( PointState::DOWN );
4475 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4476 Dali::Integration::TouchEvent touchEvent;
4477 touchEvent.AddPoint( point );
4479 application.ProcessEvent( touchEvent );
4481 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4482 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4483 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4485 ResetTouchCallbacks();
4487 tet_printf( "RaiseToTop ActorA\n" );
4489 DevelActor::RaiseToTop( actorA );
4490 application.SendNotification(); // ensure sorting order is calculated before next touch event
4492 application.ProcessEvent( touchEvent );
4494 glAbstraction.ResetSetUniformCallStack();
4495 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4497 application.SendNotification();
4498 application.Render();
4500 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4502 // Test order of uniforms in stack
4503 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4504 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4505 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4507 tet_infoline( "Testing A above C and B at bottom\n" );
4508 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4510 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4512 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4513 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4514 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4516 ResetTouchCallbacks();
4518 tet_printf( "RaiseToTop ActorB\n" );
4520 DevelActor::RaiseToTop( actorB );
4521 application.SendNotification(); // Ensure sort order is calculated before next touch event
4523 application.ProcessEvent( touchEvent );
4525 glAbstraction.ResetSetUniformCallStack();
4526 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4528 application.SendNotification();
4529 application.Render();
4531 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4533 // Test order of uniforms in stack
4534 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4535 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4536 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4538 tet_infoline( "Testing B above A and C at bottom\n" );
4539 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4541 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4543 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4544 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4545 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4547 ResetTouchCallbacks();
4549 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4551 DevelActor::LowerToBottom( actorA );
4552 application.SendNotification();
4553 application.Render();
4555 DevelActor::LowerToBottom( actorB );
4556 application.SendNotification();
4557 application.Render();
4559 application.ProcessEvent( touchEvent );
4561 glAbstraction.ResetSetUniformCallStack();
4562 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4564 application.SendNotification();
4565 application.Render();
4567 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4569 // Test order of uniforms in stack
4570 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4571 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4572 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4574 tet_infoline( "Testing C above A and B at bottom\n" );
4575 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4577 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4579 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4580 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4581 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4583 ResetTouchCallbacks();
4588 int UtcDaliActorRaiseAbove(void)
4590 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4592 TestApplication application;
4594 Stage stage( Stage::GetCurrent() );
4596 Actor actorA = Actor::New();
4597 Actor actorB = Actor::New();
4598 Actor actorC = Actor::New();
4600 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4601 actorA.SetParentOrigin( ParentOrigin::CENTER );
4603 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4604 actorB.SetParentOrigin( ParentOrigin::CENTER );
4606 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4607 actorC.SetParentOrigin( ParentOrigin::CENTER );
4609 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4610 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4612 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4613 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4615 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4616 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4618 stage.Add( actorA );
4619 stage.Add( actorB );
4620 stage.Add( actorC );
4622 ResetTouchCallbacks();
4624 application.SendNotification();
4625 application.Render();
4627 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4628 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4629 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4631 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4632 // Only top actor will get touched.
4633 actorA.TouchSignal().Connect( TestTouchCallback );
4634 actorB.TouchSignal().Connect( TestTouchCallback2 );
4635 actorC.TouchSignal().Connect( TestTouchCallback3 );
4637 Dali::Integration::Point point;
4638 point.SetDeviceId( 1 );
4639 point.SetState( PointState::DOWN );
4640 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4641 Dali::Integration::TouchEvent touchEvent;
4642 touchEvent.AddPoint( point );
4644 application.ProcessEvent( touchEvent );
4646 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4647 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4648 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4650 ResetTouchCallbacks();
4652 tet_printf( "Raise actor B Above Actor C\n" );
4654 DevelActor::RaiseAbove( actorB, actorC );
4655 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4656 application.SendNotification();
4658 application.ProcessEvent( touchEvent );
4660 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4661 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4662 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4664 ResetTouchCallbacks();
4666 tet_printf( "Raise actor A Above Actor B\n" );
4668 DevelActor::RaiseAbove( actorA, actorB );
4670 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4671 application.SendNotification();
4673 application.ProcessEvent( touchEvent ); // process a touch event on ordered actors.
4675 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4676 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4677 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4679 ResetTouchCallbacks();
4684 int UtcDaliActorLowerBelow(void)
4686 tet_infoline( "UtcDaliActor LowerBelow test \n" );
4688 TestApplication application;
4690 Stage stage( Stage::GetCurrent() );
4692 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4693 // enables checking of which actor the uniform is assigned too
4694 Shader shaderA = CreateShader();
4695 shaderA.RegisterProperty( "uRendererColor",1.f);
4697 Shader shaderB = CreateShader();
4698 shaderB.RegisterProperty( "uRendererColor", 2.f );
4700 Shader shaderC = CreateShader();
4701 shaderC.RegisterProperty( "uRendererColor", 3.f );
4703 Actor actorA = Actor::New();
4704 Actor actorB = Actor::New();
4705 Actor actorC = Actor::New();
4707 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4708 Geometry geometry = CreateQuadGeometry();
4710 Renderer rendererA = Renderer::New(geometry, shaderA);
4711 actorA.AddRenderer(rendererA);
4713 Renderer rendererB = Renderer::New(geometry, shaderB);
4714 actorB.AddRenderer(rendererB);
4716 Renderer rendererC = Renderer::New(geometry, shaderC);
4717 actorC.AddRenderer(rendererC);
4719 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4720 actorA.SetParentOrigin( ParentOrigin::CENTER );
4722 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4723 actorB.SetParentOrigin( ParentOrigin::CENTER );
4725 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4726 actorC.SetParentOrigin( ParentOrigin::CENTER );
4728 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4729 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4731 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4732 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4734 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4735 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4737 Actor container = Actor::New();
4738 container.SetParentOrigin( ParentOrigin::CENTER );
4739 container.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
4740 stage.Add( container );
4742 container.Add( actorA );
4743 container.Add( actorB );
4744 container.Add( actorC );
4746 ResetTouchCallbacks();
4748 // Set up gl abstraction trace so can query the set uniform order
4749 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4750 glAbstraction.EnableSetUniformCallTrace(true);
4751 glAbstraction.ResetSetUniformCallStack();
4752 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4754 glAbstraction.ResetSetUniformCallStack();
4756 application.SendNotification();
4757 application.Render();
4759 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4761 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4763 // Test order of uniforms in stack
4764 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4765 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4766 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4768 tet_infoline( "Testing C above B and A at bottom\n" );
4769 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4771 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4773 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4774 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4775 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4777 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4778 // Only top actor will get touched.
4779 actorA.TouchSignal().Connect( TestTouchCallback );
4780 actorB.TouchSignal().Connect( TestTouchCallback2 );
4781 actorC.TouchSignal().Connect( TestTouchCallback3 );
4783 Dali::Integration::Point point;
4784 point.SetDeviceId( 1 );
4785 point.SetState( PointState::DOWN );
4786 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4787 Dali::Integration::TouchEvent touchEvent;
4788 touchEvent.AddPoint( point );
4790 tet_infoline( "UtcDaliActor Test Set up completed \n" );
4792 application.ProcessEvent( touchEvent );
4794 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4795 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4796 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4798 ResetTouchCallbacks();
4800 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" );
4802 DevelActor::LowerBelow( actorC, actorB );
4803 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4804 application.SendNotification();
4805 application.Render();
4807 application.ProcessEvent( touchEvent ); // touch event
4809 glAbstraction.ResetSetUniformCallStack();
4810 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4812 application.SendNotification();
4813 application.Render();
4815 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4817 // Test order of uniforms in stack
4818 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4819 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4820 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4822 tet_infoline( "Testing render order is A, C, B" );
4823 DALI_TEST_EQUALS( indexC > indexA, true, TEST_LOCATION );
4824 DALI_TEST_EQUALS( indexB > indexC, true, TEST_LOCATION );
4826 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4827 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4828 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4830 ResetTouchCallbacks();
4832 tet_printf( "Lower actor C below Actor A leaving B on top\n" );
4834 DevelActor::LowerBelow( actorC, actorA );
4835 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4836 application.SendNotification();
4837 application.Render();
4839 application.ProcessEvent( touchEvent );
4841 glAbstraction.ResetSetUniformCallStack();
4842 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4844 application.Render();
4845 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4847 // Test order of uniforms in stack
4848 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4849 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4850 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4852 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
4853 DALI_TEST_EQUALS( indexB > indexA, true, TEST_LOCATION );
4855 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4856 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4857 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4859 ResetTouchCallbacks();
4861 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4863 DevelActor::LowerBelow( actorB, actorC );
4864 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4865 application.SendNotification();
4866 application.Render();
4868 application.ProcessEvent( touchEvent );
4870 glAbstraction.ResetSetUniformCallStack();
4871 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4873 application.Render();
4874 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4876 // Test order of uniforms in stack
4877 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4878 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4879 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4881 DALI_TEST_EQUALS( indexC > indexB, true, TEST_LOCATION );
4882 DALI_TEST_EQUALS( indexA > indexC, true, TEST_LOCATION );
4888 int UtcDaliActorRaiseAboveDifferentParentsN(void)
4890 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4892 TestApplication application;
4894 Stage stage( Stage::GetCurrent() );
4896 Actor parentA = Actor::New();
4897 Actor parentB = Actor::New();
4898 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4899 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4900 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4901 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4903 parentA.SetAnchorPoint( AnchorPoint::CENTER );
4904 parentA.SetParentOrigin( ParentOrigin::CENTER );
4906 parentB.SetAnchorPoint( AnchorPoint::CENTER );
4907 parentB.SetParentOrigin( ParentOrigin::CENTER );
4909 stage.Add( parentA );
4910 stage.Add( parentB );
4912 Actor actorA = Actor::New();
4913 Actor actorB = Actor::New();
4914 Actor actorC = Actor::New();
4916 parentA.Add( actorA );
4917 parentA.Add( actorB );
4919 tet_printf( "Actor C added to different parent from A and B \n" );
4920 parentB.Add( actorC );
4922 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4923 actorA.SetParentOrigin( ParentOrigin::CENTER );
4925 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4926 actorB.SetParentOrigin( ParentOrigin::CENTER );
4928 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4929 actorC.SetParentOrigin( ParentOrigin::CENTER );
4931 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4932 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4934 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4935 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4937 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4938 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4940 ResetTouchCallbacks();
4942 application.SendNotification();
4943 application.Render();
4945 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4946 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4947 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4949 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4950 // Only top actor will get touched.
4951 actorA.TouchSignal().Connect( TestTouchCallback );
4952 actorB.TouchSignal().Connect( TestTouchCallback2 );
4953 actorC.TouchSignal().Connect( TestTouchCallback3 );
4955 Dali::Integration::Point point;
4956 point.SetDeviceId( 1 );
4957 point.SetState( PointState::DOWN );
4958 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4959 Dali::Integration::TouchEvent touchEvent;
4960 touchEvent.AddPoint( point );
4962 application.ProcessEvent( touchEvent );
4964 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4965 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4966 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4968 ResetTouchCallbacks();
4970 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
4972 DevelActor::RaiseAbove( actorA, actorC );
4973 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
4974 application.SendNotification();
4976 application.ProcessEvent( touchEvent ); // touch event
4978 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4979 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4980 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4982 ResetTouchCallbacks();
4987 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
4989 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
4991 TestApplication application;
4993 Stage stage( Stage::GetCurrent() );
4995 Actor actorA = Actor::New();
4996 Actor actorB = Actor::New();
4997 Actor actorC = Actor::New();
4999 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5000 actorA.SetParentOrigin( ParentOrigin::CENTER );
5002 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5003 actorB.SetParentOrigin( ParentOrigin::CENTER );
5005 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5006 actorC.SetParentOrigin( ParentOrigin::CENTER );
5008 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5009 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5011 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5012 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5014 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5015 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5017 ResetTouchCallbacks();
5019 application.SendNotification();
5020 application.Render();
5022 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5023 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5024 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
5026 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5027 // Only top actor will get touched.
5028 actorA.TouchSignal().Connect( TestTouchCallback );
5029 actorB.TouchSignal().Connect( TestTouchCallback2 );
5030 actorC.TouchSignal().Connect( TestTouchCallback3 );
5032 Dali::Integration::Point point;
5033 point.SetDeviceId( 1 );
5034 point.SetState( PointState::DOWN );
5035 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5036 Dali::Integration::TouchEvent touchEvent;
5037 touchEvent.AddPoint( point );
5039 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
5041 DevelActor::RaiseAbove( actorA, actorC );
5042 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5043 application.SendNotification();
5045 application.ProcessEvent( touchEvent );
5047 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5049 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5050 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5051 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5053 ResetTouchCallbacks();
5055 stage.Add ( actorB );
5056 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
5057 DevelActor::LowerBelow( actorA, actorC );
5059 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5060 application.SendNotification();
5061 application.Render();
5063 application.ProcessEvent( touchEvent );
5065 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
5066 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5067 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5068 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5070 ResetTouchCallbacks();
5072 tet_printf( "Adding Actor A to stage, will be on top\n" );
5074 stage.Add ( actorA );
5075 application.SendNotification();
5076 application.Render();
5078 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
5079 DevelActor::RaiseAbove( actorB, actorC );
5080 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5081 application.SendNotification();
5083 application.ProcessEvent( touchEvent );
5085 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
5086 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5087 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5088 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5090 ResetTouchCallbacks();
5092 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
5093 DevelActor::LowerBelow( actorA, actorC );
5094 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5095 application.SendNotification();
5097 application.ProcessEvent( touchEvent );
5099 tet_printf( "C not parented so LowerBelow should show no effect\n" );
5100 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5101 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5102 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5104 ResetTouchCallbacks();
5106 stage.Add ( actorC );
5107 DevelActor::RaiseAbove( actorA, actorC );
5108 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5109 application.SendNotification();
5110 application.Render();
5112 application.ProcessEvent( touchEvent );
5114 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5115 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5116 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5117 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5122 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5124 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5126 TestApplication application;
5128 Stage stage( Stage::GetCurrent() );
5130 Actor actorA = Actor::New();
5131 Actor actorB = Actor::New();
5132 Actor actorC = Actor::New();
5134 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5135 actorA.SetParentOrigin( ParentOrigin::CENTER );
5137 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5138 actorB.SetParentOrigin( ParentOrigin::CENTER );
5140 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5141 actorC.SetParentOrigin( ParentOrigin::CENTER );
5143 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5144 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5146 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5147 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5149 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5150 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5152 ResetTouchCallbacks();
5154 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5155 // Only top actor will get touched.
5156 actorA.TouchSignal().Connect( TestTouchCallback );
5157 actorB.TouchSignal().Connect( TestTouchCallback2 );
5158 actorC.TouchSignal().Connect( TestTouchCallback3 );
5160 Dali::Integration::Point point;
5161 point.SetDeviceId( 1 );
5162 point.SetState( PointState::DOWN );
5163 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5164 Dali::Integration::TouchEvent touchEvent;
5165 touchEvent.AddPoint( point );
5167 stage.Add ( actorA );
5168 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5169 DevelActor::Raise( actorB );
5171 application.SendNotification();
5172 application.Render();
5174 application.ProcessEvent( touchEvent );
5176 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5178 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5179 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5180 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5182 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5183 ResetTouchCallbacks();
5185 DevelActor::Lower( actorC );
5186 // Sort actor tree before next touch event
5187 application.SendNotification();
5188 application.Render();
5190 application.ProcessEvent( touchEvent );
5192 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5194 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5195 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5196 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5197 ResetTouchCallbacks();
5199 tet_printf( "Lower actor C below B but C not parented\n" );
5201 DevelActor::Lower( actorB );
5202 // Sort actor tree before next touch event
5203 application.SendNotification();
5204 application.Render();
5206 application.ProcessEvent( touchEvent );
5208 tet_printf( "Not parented so Lower should show no effect\n" );
5210 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5211 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5212 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5213 ResetTouchCallbacks();
5215 tet_printf( "Raise actor B to top\n" );
5217 DevelActor::RaiseToTop( actorB );
5218 // Sort actor tree before next touch event
5219 application.SendNotification();
5220 application.Render();
5222 application.ProcessEvent( touchEvent );
5224 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5226 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5227 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5228 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5229 ResetTouchCallbacks();
5231 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5233 stage.Add ( actorB );
5235 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5237 DevelActor::LowerToBottom( actorC );
5238 application.SendNotification();
5239 application.Render();
5241 application.ProcessEvent( touchEvent );
5243 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5245 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5246 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5247 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5248 ResetTouchCallbacks();
5254 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5256 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5258 TestApplication application;
5260 Stage stage( Stage::GetCurrent() );
5262 Actor actorA = Actor::New();
5263 Actor actorB = Actor::New();
5264 Actor actorC = Actor::New();
5266 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5267 actorA.SetParentOrigin( ParentOrigin::CENTER );
5269 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5270 actorB.SetParentOrigin( ParentOrigin::CENTER );
5272 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5273 actorC.SetParentOrigin( ParentOrigin::CENTER );
5275 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5276 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5278 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5279 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5281 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5282 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5284 stage.Add( actorA );
5285 stage.Add( actorB );
5286 stage.Add( actorC );
5288 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5289 // Only top actor will get touched.
5290 actorA.TouchSignal().Connect( TestTouchCallback );
5291 actorB.TouchSignal().Connect( TestTouchCallback2 );
5292 actorC.TouchSignal().Connect( TestTouchCallback3 );
5294 ResetTouchCallbacks();
5296 application.SendNotification();
5297 application.Render();
5299 Dali::Integration::Point point;
5300 point.SetDeviceId( 1 );
5301 point.SetState( PointState::DOWN );
5302 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5303 Dali::Integration::TouchEvent touchEvent;
5304 touchEvent.AddPoint( point );
5306 application.ProcessEvent( touchEvent );
5308 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5309 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5310 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5312 ResetTouchCallbacks();
5314 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5316 DevelActor::RaiseAbove( actorA, actorA );
5317 application.SendNotification();
5318 application.Render();
5320 application.ProcessEvent( touchEvent );
5322 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5324 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5325 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5326 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5328 ResetTouchCallbacks();
5330 DevelActor::RaiseAbove( actorA, actorC );
5331 application.SendNotification();
5332 application.Render();
5334 application.ProcessEvent( touchEvent );
5336 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5337 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5338 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5339 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5344 int UtcDaliActorGetScreenPosition(void)
5346 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5348 TestApplication application;
5350 Stage stage( Stage::GetCurrent() );
5352 Actor actorA = Actor::New();
5353 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5355 Vector2 size2( 10.0f, 20.0f );
5356 actorA.SetSize( size2 );
5358 actorA.SetPosition( 0.f, 0.f );
5360 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5362 stage.Add( actorA );
5364 application.SendNotification();
5365 application.Render();
5367 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5368 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5370 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5371 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5373 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5374 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5376 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5378 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5380 application.SendNotification();
5381 application.Render();
5383 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5384 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5386 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5387 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5389 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5390 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5392 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5394 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5396 application.SendNotification();
5397 application.Render();
5399 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5400 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5402 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5403 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5405 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5406 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5408 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5410 actorA.SetPosition( 30.0, 0.0 );
5412 application.SendNotification();
5413 application.Render();
5415 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5416 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5418 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5419 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5421 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5422 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5424 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5426 actorA.SetPosition( 30.0, 420.0 );
5428 application.SendNotification();
5429 application.Render();
5431 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5432 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5434 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5435 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5437 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5438 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5444 int UtcDaliActorGetScreenPositionAfterScaling(void)
5446 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5448 TestApplication application;
5450 Stage stage( Stage::GetCurrent() );
5452 Actor actorA = Actor::New();
5453 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5455 Vector2 size2( 10.0f, 20.0f );
5456 actorA.SetSize( size2 );
5457 actorA.SetScale( 1.5f );
5458 actorA.SetPosition( 0.f, 0.f );
5460 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5462 stage.Add( actorA );
5464 application.SendNotification();
5465 application.Render();
5467 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5468 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5470 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5471 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5473 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5474 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5476 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5478 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5480 application.SendNotification();
5481 application.Render();
5483 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5484 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5486 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5487 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5489 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5490 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5495 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5497 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5499 TestApplication application;
5501 Stage stage( Stage::GetCurrent() );
5503 Actor actorA = Actor::New();
5504 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5505 actorA.SetParentOrigin( ParentOrigin::CENTER );
5506 Vector2 size2( 10.0f, 20.0f );
5507 actorA.SetSize( size2 );
5508 actorA.SetPosition( 0.f, 0.f );
5510 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5512 stage.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, 240.0f , TEST_LOCATION );
5524 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
5526 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5528 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5529 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5531 application.SendNotification();
5532 application.Render();
5534 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5535 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5537 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5538 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5540 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5541 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5547 int UtcDaliActorGetScreenPositionWithChildActors(void)
5549 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5551 TestApplication application;
5553 Stage stage( Stage::GetCurrent() );
5555 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5557 Actor actorA = Actor::New();
5558 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5559 actorA.SetParentOrigin( ParentOrigin::CENTER );
5560 Vector2 size1( 10.0f, 20.0f );
5561 actorA.SetSize( size1 );
5562 actorA.SetPosition( 0.f, 0.f );
5564 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5566 Actor parentActorA = Actor::New();
5567 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5568 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5569 Vector2 size2( 30.0f, 60.0f );
5570 parentActorA.SetSize( size2 );
5571 parentActorA.SetPosition( 0.f, 0.f );
5573 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5575 stage.Add( parentActorA );
5576 parentActorA.Add ( actorA );
5578 application.SendNotification();
5579 application.Render();
5581 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5582 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5584 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5585 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5587 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
5588 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
5590 tet_infoline( "Test 2\n");
5592 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5594 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5595 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5597 application.SendNotification();
5598 application.Render();
5600 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5601 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5603 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5604 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5606 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
5607 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
5612 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5614 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5616 TestApplication application;
5618 Stage stage( Stage::GetCurrent() );
5620 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5622 Actor actorA = Actor::New();
5623 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5624 actorA.SetParentOrigin( ParentOrigin::CENTER );
5625 Vector2 size1( 10.0f, 20.0f );
5626 actorA.SetSize( size1 );
5627 actorA.SetPosition( 0.f, 0.f );
5629 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5631 Actor parentActorA = Actor::New();
5632 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5633 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5634 Vector2 size2( 30.0f, 60.0f );
5635 parentActorA.SetSize( size2 );
5636 parentActorA.SetPosition( 0.f, 0.f );
5638 tet_infoline( "Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n" );
5640 Actor grandParentActorA = Actor::New();
5641 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5642 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5643 Vector2 size3( 60.0f, 120.0f );
5644 grandParentActorA.SetSize( size3 );
5645 grandParentActorA.SetPosition( 0.f, 0.f );
5647 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5649 stage.Add( grandParentActorA );
5650 grandParentActorA.Add ( parentActorA );
5652 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5654 parentActorA.Add ( actorA );
5656 application.SendNotification();
5657 application.Render();
5659 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5660 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5662 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5663 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5665 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
5666 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
5671 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
5673 tet_infoline( "UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point" );
5675 TestApplication application;
5677 Stage stage( Stage::GetCurrent() );
5679 tet_infoline( "Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5681 Actor actorA = Actor::New();
5682 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5683 actorA.SetParentOrigin( ParentOrigin::CENTER );
5684 actorA.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5685 actorA.SetSize( 10.0f, 20.0f );
5686 stage.Add( actorA );
5688 tet_infoline( "Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5690 Actor actorB = Actor::New();
5691 actorB.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5692 actorB.SetParentOrigin( ParentOrigin::CENTER );
5693 actorB.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5694 Vector2 actorBSize( 30.0f, 60.0f );
5695 actorB.SetSize( actorBSize );
5696 stage.Add( actorB );
5698 tet_infoline( "Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false" );
5700 Actor actorC = Actor::New();
5701 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5702 actorC.SetParentOrigin( ParentOrigin::CENTER );
5703 actorC.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5704 Vector2 actorCSize( 60.0f, 120.0f );
5705 actorC.SetSize( actorCSize );
5706 stage.Add( actorC );
5708 application.SendNotification();
5709 application.Render();
5711 tet_infoline( "Despite differing sizes and anchor-points, the screen position for all actors is the same");
5713 Vector2 center( stage.GetSize() * 0.5f );
5715 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5716 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5717 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center, TEST_LOCATION );
5719 tet_infoline( "Add scale to all actors" );
5721 actorA.SetScale( 2.0f );
5722 actorB.SetScale( 2.0f );
5723 actorC.SetScale( 2.0f );
5725 application.SendNotification();
5726 application.Render();
5728 DALI_TEST_EQUALS( actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center /* TOP_LEFT Anchor */, TEST_LOCATION );
5729 DALI_TEST_EQUALS( actorB.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION );
5730 DALI_TEST_EQUALS( actorC.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION );
5735 int utcDaliActorPositionUsesAnchorPoint(void)
5737 TestApplication application;
5738 tet_infoline( "Check default behaviour\n" );
5740 Actor actor = Actor::New();
5741 actor.SetParentOrigin( ParentOrigin::CENTER );
5742 actor.SetAnchorPoint( AnchorPoint::CENTER );
5743 actor.SetSize( 100.0f, 100.0f );
5744 Stage::GetCurrent().Add( actor );
5746 application.SendNotification();
5747 application.Render();
5749 tet_infoline( "Check that the world position is in the center\n" );
5750 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5752 tet_infoline( "Set the position uses anchor point property to false\n" );
5753 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5755 application.SendNotification();
5756 application.Render();
5758 tet_infoline( "Check that the world position has changed appropriately\n" );
5759 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5764 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
5766 TestApplication application;
5767 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5769 Actor actor = Actor::New();
5770 actor.SetParentOrigin( ParentOrigin::CENTER );
5771 actor.SetAnchorPoint( AnchorPoint::CENTER );
5772 actor.SetSize( 100.0f, 100.0f );
5773 actor.SetScale( 2.0f );
5774 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5775 Stage::GetCurrent().Add( actor );
5777 application.SendNotification();
5778 application.Render();
5780 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
5781 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5783 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5784 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5785 application.SendNotification();
5786 application.Render();
5787 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5789 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5790 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5791 application.SendNotification();
5792 application.Render();
5793 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5798 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
5800 TestApplication application;
5801 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5803 Actor actor = Actor::New();
5804 actor.SetParentOrigin( ParentOrigin::CENTER );
5805 actor.SetAnchorPoint( AnchorPoint::CENTER );
5806 actor.SetSize( 100.0f, 100.0f );
5807 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5808 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5809 Stage::GetCurrent().Add( actor );
5811 application.SendNotification();
5812 application.Render();
5814 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
5815 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5817 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5818 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5819 application.SendNotification();
5820 application.Render();
5821 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5823 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5824 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5825 application.SendNotification();
5826 application.Render();
5827 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
5832 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
5834 TestApplication application;
5835 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5837 Actor actor = Actor::New();
5838 actor.SetParentOrigin( ParentOrigin::CENTER );
5839 actor.SetAnchorPoint( AnchorPoint::CENTER );
5840 actor.SetSize( 100.0f, 100.0f );
5841 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5842 actor.SetScale( 2.0f );
5843 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5844 Stage::GetCurrent().Add( actor );
5846 application.SendNotification();
5847 application.Render();
5849 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
5850 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5852 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5853 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5854 application.SendNotification();
5855 application.Render();
5856 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5858 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5859 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5860 application.SendNotification();
5861 application.Render();
5862 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
5867 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
5869 TestApplication application;
5870 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5872 Actor parent = Actor::New();
5874 Stage::GetCurrent().Add( parent );
5875 Vector2 stageSize( Stage::GetCurrent().GetSize() );
5877 Actor actor = Actor::New();
5878 actor.SetParentOrigin( ParentOrigin::CENTER );
5879 actor.SetAnchorPoint( AnchorPoint::CENTER );
5880 actor.SetSize( 100.0f, 100.0f );
5881 actor.SetInheritScale( false );
5882 actor.SetInheritOrientation( false );
5883 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5884 parent.Add( actor );
5886 application.SendNotification();
5887 application.Render();
5889 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
5891 tet_infoline( "Check the world position is in the right place\n" );
5892 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5894 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
5895 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5896 application.SendNotification();
5897 application.Render();
5898 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5900 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
5901 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5902 application.SendNotification();
5903 application.Render();
5904 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5909 int utcDaliActorVisibilityChangeSignalSelf(void)
5911 TestApplication application;
5912 tet_infoline( "Check that the visibility change signal is called when the visibility changes for the actor itself" );
5914 Actor actor = Actor::New();
5916 VisibilityChangedFunctorData data;
5917 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
5919 actor.SetVisible( false );
5921 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5923 tet_infoline( "Ensure functor is not called if we attempt to change the visibility to what it already is at" );
5926 actor.SetVisible( false );
5927 data.Check( false /* not called */, TEST_LOCATION );
5929 tet_infoline( "Change the visibility using properties, ensure called" );
5932 actor.SetProperty( Actor::Property::VISIBLE, true );
5933 data.Check( true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5935 tet_infoline( "Set the visibility to current using properties, ensure not called" );
5938 actor.SetProperty( Actor::Property::VISIBLE, true );
5939 data.Check( false /* not called */, TEST_LOCATION );
5944 int utcDaliActorVisibilityChangeSignalChildren(void)
5946 TestApplication application;
5947 tet_infoline( "Check that the visibility change signal is called for the children when the visibility changes for the parent" );
5949 Actor parent = Actor::New();
5950 Actor child = Actor::New();
5951 parent.Add( child );
5953 Actor grandChild = Actor::New();
5954 child.Add( grandChild );
5956 VisibilityChangedFunctorData parentData;
5957 VisibilityChangedFunctorData childData;
5958 VisibilityChangedFunctorData grandChildData;
5960 tet_infoline( "Only connect the child and grandchild, ensure they are called and not the parent" );
5961 DevelActor::VisibilityChangedSignal( child ).Connect( &application, VisibilityChangedFunctor( childData ) );
5962 DevelActor::VisibilityChangedSignal( grandChild ).Connect( &application, VisibilityChangedFunctor( grandChildData ) );
5964 parent.SetVisible( false );
5965 parentData.Check( false /* not called */, TEST_LOCATION );
5966 childData.Check( true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
5967 grandChildData.Check( true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
5969 tet_infoline( "Connect to the parent's signal as well and ensure all three are called" );
5972 grandChildData.Reset();
5974 DevelActor::VisibilityChangedSignal( parent ).Connect( &application, VisibilityChangedFunctor( parentData ) );
5976 parent.SetVisible( true );
5977 parentData.Check( true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
5978 childData.Check( true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
5979 grandChildData.Check( true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION );
5981 tet_infoline( "Ensure none of the functors are called if we attempt to change the visibility to what it already is at" );
5984 grandChildData.Reset();
5986 parent.SetVisible( true );
5987 parentData.Check( false /* not called */, TEST_LOCATION );
5988 childData.Check( false /* not called */, TEST_LOCATION );
5989 grandChildData.Check( false /* not called */, TEST_LOCATION );
5994 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
5996 TestApplication application;
5997 tet_infoline( "Check that the visibility change signal is emitted when the visibility changes when an animation starts" );
5999 Actor actor = Actor::New();
6000 Stage::GetCurrent().Add( actor );
6002 application.SendNotification();
6003 application.Render();
6005 VisibilityChangedFunctorData data;
6006 DevelActor::VisibilityChangedSignal( actor ).Connect( &application, VisibilityChangedFunctor( data ) );
6008 Animation animation = Animation::New( 1.0f );
6009 animation.AnimateTo( Property( actor, Actor::Property::VISIBLE ), false );
6011 data.Check( false, TEST_LOCATION );
6012 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6013 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6015 tet_infoline( "Play the animation and check the property value" );
6018 data.Check( true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION );
6019 DALI_TEST_EQUALS( actor.GetProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
6021 tet_infoline( "Animation not currently finished, so the current visibility should still be true" );
6022 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), true, TEST_LOCATION );
6024 application.SendNotification();
6025 application.Render( 1100 ); // After the animation
6027 DALI_TEST_EQUALS( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );