2 * Copyright (c) 2014 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/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/hover-event-integ.h>
24 #include <dali-test-suite-utils.h>
32 void utc_dali_actor_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_actor_cleanup(void)
39 test_return_value = TET_PASS;
44 bool gTouchCallBackCalled=false;
45 bool gHoverCallBackCalled=false;
48 * Simulates a Down Touch at 25.0, 25.0.
49 * @param[in] app Test Application instance.
51 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
53 app.SendNotification();
55 app.SendNotification();
58 gTouchCallBackCalled = false;
60 // simulate a touch event
61 Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f );
62 Dali::Integration::TouchEvent event;
63 event.AddPoint( point );
64 app.ProcessEvent( event );
66 app.SendNotification();
68 app.SendNotification();
74 static bool gTestConstraintCalled;
78 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
80 gTestConstraintCalled = true;
85 * TestConstraint reference.
86 * When constraint is called, the resultRef is updated
87 * with the value supplied.
90 struct TestConstraintRef
92 TestConstraintRef(unsigned int& resultRef, unsigned int value)
93 : mResultRef(resultRef),
98 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
103 unsigned int& mResultRef;
107 static bool TestCallback(Actor actor, const TouchEvent& event)
109 gTouchCallBackCalled = true;
114 static bool TestCallback3(Actor actor, const HoverEvent& event)
116 gHoverCallBackCalled = true;
121 static Vector3 gSetSize;
122 static bool gSetSizeCallBackCalled;
123 void SetSizeCallback( Actor actor, const Vector3& size )
125 gSetSizeCallBackCalled = true;
128 // validation stuff for onstage & offstage signals
129 static std::vector< std::string > gActorNamesOnOffStage;
130 static int gOnStageCallBackCalled;
131 void OnStageCallback( Actor actor )
133 ++gOnStageCallBackCalled;
134 gActorNamesOnOffStage.push_back( actor.GetName() );
135 DALI_TEST_CHECK( actor.OnStage() == true );
137 static int gOffStageCallBackCalled;
138 void OffStageCallback( Actor actor )
140 ++gOffStageCallBackCalled;
141 gActorNamesOnOffStage.push_back( actor.GetName() );
142 DALI_TEST_CHECK( actor.OnStage() == false );
145 struct PositionComponentConstraint
147 PositionComponentConstraint(){}
149 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
151 const Matrix& m = inputs[0]->GetMatrix();
154 m.GetTransformComponents(pos, rot, scale);
160 static bool gOnRelayoutCallBackCalled = 0;
161 static std::vector< std::string > gActorNamesRelayout;
163 void OnRelayoutCallback( Actor actor )
165 ++gOnRelayoutCallBackCalled;
166 gActorNamesRelayout.push_back( actor.GetName() );
169 } // anonymous namespace
172 //& purpose: Testing New API
173 int UtcDaliActorNew(void)
175 TestApplication application;
177 Actor actor = Actor::New();
179 DALI_TEST_CHECK(actor);
183 //& purpose: Testing Dali::Actor::DownCast()
184 int UtcDaliActorDownCastP(void)
186 TestApplication application;
187 tet_infoline("Testing Dali::Actor::DownCast()");
189 Actor actor = Actor::New();
190 BaseHandle object(actor);
191 Actor actor2 = Actor::DownCast(object);
192 DALI_TEST_CHECK(actor2);
196 //& purpose: Testing Dali::Actor::DownCast()
197 int UtcDaliActorDownCastN(void)
199 TestApplication application;
200 tet_infoline("Testing Dali::Actor::DownCast()");
202 BaseHandle unInitializedObject;
203 Actor actor = Actor::DownCast(unInitializedObject);
204 DALI_TEST_CHECK(!actor);
208 //& purpose: Testing Dali::Actor::GetName()
209 int UtcDaliActorGetName(void)
211 TestApplication application;
213 Actor actor = Actor::New();
215 DALI_TEST_CHECK(actor.GetName().empty());
219 //& purpose: Testing Dali::Actor::SetName()
220 int UtcDaliActorSetName(void)
222 TestApplication application;
224 string str("ActorName");
225 Actor actor = Actor::New();
228 DALI_TEST_CHECK(actor.GetName() == str);
232 int UtcDaliActorGetId(void)
234 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
235 TestApplication application;
237 Actor first = Actor::New();
238 Actor second = Actor::New();
239 Actor third = Actor::New();
241 DALI_TEST_CHECK(first.GetId() != second.GetId());
242 DALI_TEST_CHECK(second.GetId() != third.GetId());
246 int UtcDaliActorIsRoot(void)
248 TestApplication application;
250 Actor actor = Actor::New();
251 DALI_TEST_CHECK(!actor.IsRoot());
253 // get the root layer
254 actor = Stage::GetCurrent().GetLayer( 0 );
255 DALI_TEST_CHECK( actor.IsRoot() );
259 int UtcDaliActorOnStage(void)
261 TestApplication application;
263 Actor actor = Actor::New();
264 DALI_TEST_CHECK( !actor.OnStage() );
266 // get the root layer
267 actor = Stage::GetCurrent().GetLayer( 0 );
268 DALI_TEST_CHECK( actor.OnStage() );
272 int UtcDaliActorIsLayer(void)
274 TestApplication application;
276 Actor actor = Actor::New();
277 DALI_TEST_CHECK( !actor.IsLayer() );
279 // get the root layer
280 actor = Stage::GetCurrent().GetLayer( 0 );
281 DALI_TEST_CHECK( actor.IsLayer() );
285 int UtcDaliActorGetLayer(void)
287 TestApplication application;
289 Actor actor = Actor::New();
290 Stage::GetCurrent().Add(actor);
291 Layer layer = actor.GetLayer();
293 DALI_TEST_CHECK(layer);
295 // get the root layers layer
296 actor = Stage::GetCurrent().GetLayer( 0 );
297 DALI_TEST_CHECK( actor.GetLayer() );
301 int UtcDaliActorAddP(void)
303 tet_infoline("Testing Actor::Add");
304 TestApplication application;
306 Actor parent = Actor::New();
307 Actor child = Actor::New();
309 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
313 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
315 Actor parent2 = Actor::New();
316 parent2.Add( child );
318 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
319 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
321 // try Adding to same parent again, works
322 parent2.Add( child );
323 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
325 // try reparenting an orphaned child
327 Actor temporaryParent = Actor::New();
328 temporaryParent.Add( child );
329 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
331 // temporaryParent has now died, reparent the orphaned child
332 parent2.Add( child );
333 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
338 int UtcDaliActorAddN(void)
340 tet_infoline("Testing Actor::Add");
341 TestApplication application;
343 Actor child = Actor::New();
345 Actor parent2 = Actor::New();
346 parent2.Add( child );
351 parent2.Add( parent2 );
352 tet_printf("Assertion test failed - no Exception\n" );
353 tet_result(TET_FAIL);
355 catch(Dali::DaliException& e)
357 DALI_TEST_PRINT_ASSERT( e );
358 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
359 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
363 tet_printf("Assertion test failed - wrong Exception\n" );
364 tet_result(TET_FAIL);
367 // try reparenting root
370 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
371 tet_printf("Assertion test failed - no Exception\n" );
372 tet_result(TET_FAIL);
374 catch(Dali::DaliException& e)
376 DALI_TEST_PRINT_ASSERT( e );
377 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
378 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
382 tet_printf("Assertion test failed - wrong Exception\n" );
383 tet_result(TET_FAIL);
390 parent2.Add( empty );
391 tet_printf("Assertion test failed - no Exception\n" );
392 tet_result(TET_FAIL);
394 catch(Dali::DaliException& e)
396 DALI_TEST_PRINT_ASSERT( e );
397 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
398 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
402 tet_printf("Assertion test failed - wrong Exception\n" );
403 tet_result(TET_FAIL);
409 int UtcDaliActorInsert(void)
411 tet_infoline("Testing Actor::Insert");
412 TestApplication application;
414 Actor parent = Actor::New();
415 Stage::GetCurrent().Add( parent );
416 Actor first = Actor::New();
417 Actor second = Actor::New();
418 Actor third = Actor::New();
420 parent.Insert(1, first); // test insert beyond range
421 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
422 parent.Insert(0, second);
423 DALI_TEST_EQUALS( parent.GetChildCount(), 2u, TEST_LOCATION );
424 parent.Insert(1, third);
426 DALI_TEST_EQUALS( parent.GetChildCount(), 3u, TEST_LOCATION );
428 DALI_TEST_CHECK(parent.GetChildAt(0) == second);
429 DALI_TEST_CHECK(parent.GetChildAt(1) == third);
430 DALI_TEST_CHECK(parent.GetChildAt(2) == first);
436 int UtcDaliActorRemoveN(void)
438 tet_infoline("Testing Actor::Remove");
439 TestApplication application;
441 Actor parent = Actor::New();
442 Actor child = Actor::New();
443 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
446 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
448 parent.Remove(child);
449 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
451 // remove again, no problem
452 parent.Remove(child);
453 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
457 // try illegal Remove
460 parent.Remove( parent );
461 tet_printf("Assertion test failed - no Exception\n" );
462 tet_result(TET_FAIL);
464 catch(Dali::DaliException& e)
466 DALI_TEST_PRINT_ASSERT( e );
467 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
468 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
472 tet_printf("Assertion test failed - wrong Exception\n" );
473 tet_result(TET_FAIL);
480 parent.Remove( empty );
481 tet_printf("Assertion test failed - no Exception\n" );
482 tet_result(TET_FAIL);
484 catch(Dali::DaliException& e)
486 DALI_TEST_PRINT_ASSERT( e );
487 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
488 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
492 tet_printf("Assertion test failed - wrong Exception\n" );
493 tet_result(TET_FAIL);
498 int UtcDaliActorRemoveP(void)
500 TestApplication application;
502 Actor parent = Actor::New();
503 Actor child = Actor::New();
504 Actor random = Actor::New();
506 Stage::GetCurrent().Add( parent );
508 DALI_TEST_CHECK(parent.GetChildCount() == 0);
512 DALI_TEST_CHECK(parent.GetChildCount() == 1);
514 parent.Remove(random);
516 DALI_TEST_CHECK(parent.GetChildCount() == 1);
518 Stage::GetCurrent().Remove( parent );
520 DALI_TEST_CHECK(parent.GetChildCount() == 1);
524 int UtcDaliActorGetChildCount(void)
526 TestApplication application;
528 Actor parent = Actor::New();
529 Actor child = Actor::New();
531 DALI_TEST_CHECK(parent.GetChildCount() == 0);
535 DALI_TEST_CHECK(parent.GetChildCount() == 1);
539 int UtcDaliActorGetChildren01(void)
541 TestApplication application;
543 Actor parent = Actor::New();
544 Actor first = Actor::New();
545 Actor second = Actor::New();
546 Actor third = Actor::New();
552 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
553 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
554 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
558 int UtcDaliActorGetChildren02(void)
560 TestApplication application;
562 Actor parent = Actor::New();
563 Actor first = Actor::New();
564 Actor second = Actor::New();
565 Actor third = Actor::New();
571 const Actor& constParent = parent;
573 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
574 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
575 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
579 int UtcDaliActorGetParent01(void)
581 TestApplication application;
583 Actor parent = Actor::New();
584 Actor child = Actor::New();
588 DALI_TEST_CHECK(child.GetParent() == parent);
592 int UtcDaliActorGetParent02(void)
594 TestApplication application;
596 Actor actor = Actor::New();
598 DALI_TEST_CHECK(!actor.GetParent());
602 int UtcDaliActorSetParentOrigin(void)
604 TestApplication application;
606 Actor actor = Actor::New();
608 Vector3 vector(0.7f, 0.8f, 0.9f);
609 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
611 actor.SetParentOrigin(vector);
613 // flush the queue and render once
614 application.SendNotification();
615 application.Render();
617 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
619 Stage::GetCurrent().Add( actor );
621 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
623 // flush the queue and render once
624 application.SendNotification();
625 application.Render();
627 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
629 Stage::GetCurrent().Remove( actor );
633 int UtcDaliActorGetCurrentParentOrigin(void)
635 TestApplication application;
637 Actor actor = Actor::New();
639 Vector3 vector(0.7f, 0.8f, 0.9f);
640 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
642 actor.SetParentOrigin(vector);
644 // flush the queue and render once
645 application.SendNotification();
646 application.Render();
648 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
652 int UtcDaliActorSetAnchorPoint(void)
654 TestApplication application;
656 Actor actor = Actor::New();
658 Vector3 vector(0.7f, 0.8f, 0.9f);
659 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
661 actor.SetAnchorPoint(vector);
663 // flush the queue and render once
664 application.SendNotification();
665 application.Render();
667 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
669 Stage::GetCurrent().Add( actor );
671 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
672 // flush the queue and render once
673 application.SendNotification();
674 application.Render();
676 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
678 Stage::GetCurrent().Remove( actor );
682 int UtcDaliActorGetCurrentAnchorPoint(void)
684 TestApplication application;
686 Actor actor = Actor::New();
688 Vector3 vector(0.7f, 0.8f, 0.9f);
689 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
691 actor.SetAnchorPoint(vector);
693 // flush the queue and render once
694 application.SendNotification();
695 application.Render();
697 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
701 // SetSize(float width, float height)
702 int UtcDaliActorSetSize01(void)
704 TestApplication application;
706 Actor actor = Actor::New();
707 Vector3 vector(100.0f, 100.0f, 100.0f);
709 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
711 actor.SetSize(vector.x, vector.y);
713 // flush the queue and render once
714 application.SendNotification();
715 application.Render();
717 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
721 // SetSize(float width, float height, float depth)
722 int UtcDaliActorSetSize02(void)
724 TestApplication application;
726 Actor actor = Actor::New();
727 Vector3 vector(100.0f, 100.0f, 100.0f);
729 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
731 actor.SetSize(vector.x, vector.y, vector.z);
733 // flush the queue and render once
734 application.SendNotification();
735 application.Render();
737 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
741 // SetSize(Vector2 size)
742 int UtcDaliActorSetSize03(void)
744 TestApplication application;
746 Actor actor = Actor::New();
747 Vector3 vector(100.0f, 100.0f, 100.0f);
749 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
751 actor.SetSize(Vector2(vector.x, vector.y));
753 // flush the queue and render once
754 application.SendNotification();
755 application.Render();
757 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
761 // SetSize(Vector3 size)
762 int UtcDaliActorSetSize04(void)
764 TestApplication application;
766 Actor actor = Actor::New();
767 Vector3 vector(100.0f, 100.0f, 100.0f);
769 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
771 actor.SetSize(vector);
773 // flush the queue and render once
774 application.SendNotification();
775 application.Render();
777 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
779 Stage::GetCurrent().Add( actor );
780 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
782 // flush the queue and render once
783 application.SendNotification();
784 application.Render();
786 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
787 Stage::GetCurrent().Remove( actor );
791 int UtcDaliActorGetCurrentSize(void)
793 TestApplication application;
795 Actor actor = Actor::New();
796 Vector3 vector(100.0f, 100.0f, 20.0f);
798 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
800 actor.SetSize(vector);
802 // flush the queue and render once
803 application.SendNotification();
804 application.Render();
806 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
810 int UtcDaliActorGetNaturalSize(void)
812 TestApplication application;
814 Actor actor = Actor::New();
815 Vector3 vector( 0.0f, 0.0f, 0.0f );
817 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
822 int UtcDaliActorGetCurrentSizeImmediate(void)
824 TestApplication application;
826 Actor actor = Actor::New();
827 Vector3 vector(100.0f, 100.0f, 20.0f);
829 DALI_TEST_CHECK(vector != actor.GetTargetSize());
830 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
832 actor.SetSize(vector);
834 DALI_TEST_CHECK(vector == actor.GetTargetSize());
835 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
837 // flush the queue and render once
838 application.SendNotification();
839 application.Render();
841 DALI_TEST_CHECK(vector == actor.GetTargetSize());
842 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
845 // Build the animation
846 const float durationSeconds = 2.0f;
847 Animation animation = Animation::New( durationSeconds );
848 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
849 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
851 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
853 // Start the animation
856 application.SendNotification();
857 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
859 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
864 // SetPosition(float x, float y)
865 int UtcDaliActorSetPosition01(void)
867 TestApplication application;
869 Actor actor = Actor::New();
871 // Set to random to start off with
872 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
874 Vector3 vector(100.0f, 100.0f, 0.0f);
876 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
878 actor.SetPosition(vector.x, vector.y);
879 // flush the queue and render once
880 application.SendNotification();
881 application.Render();
882 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
884 Stage::GetCurrent().Add( actor );
885 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
886 // flush the queue and render once
887 application.SendNotification();
888 application.Render();
889 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
894 // flush the queue and render once
895 application.SendNotification();
896 application.Render();
897 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
899 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
900 // flush the queue and render once
901 application.SendNotification();
902 application.Render();
903 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
905 Stage::GetCurrent().Remove( actor );
909 // SetPosition(float x, float y, float z)
910 int UtcDaliActorSetPosition02(void)
912 TestApplication application;
914 Actor actor = Actor::New();
916 // Set to random to start off with
917 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
919 Vector3 vector(100.0f, 100.0f, 100.0f);
921 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
923 actor.SetPosition(vector.x, vector.y, vector.z);
925 // flush the queue and render once
926 application.SendNotification();
927 application.Render();
929 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
933 // SetPosition(Vector3 position)
934 int UtcDaliActorSetPosition03(void)
936 TestApplication application;
938 Actor actor = Actor::New();
940 // Set to random to start off with
941 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
943 Vector3 vector(100.0f, 100.0f, 100.0f);
945 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
947 actor.SetPosition(vector);
949 // flush the queue and render once
950 application.SendNotification();
951 application.Render();
953 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
957 int UtcDaliActorSetX(void)
959 TestApplication application;
961 Actor actor = Actor::New();
963 Vector3 vector(100.0f, 0.0f, 0.0f);
965 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
969 // flush the queue and render once
970 application.SendNotification();
971 application.Render();
973 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
977 int UtcDaliActorSetY(void)
979 TestApplication application;
981 Actor actor = Actor::New();
983 Vector3 vector(0.0f, 100.0f, 0.0f);
985 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
989 // flush the queue and render once
990 application.SendNotification();
991 application.Render();
993 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
997 int UtcDaliActorSetZ(void)
999 TestApplication application;
1001 Actor actor = Actor::New();
1003 Vector3 vector(0.0f, 0.0f, 100.0f);
1005 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1009 // flush the queue and render once
1010 application.SendNotification();
1011 application.Render();
1013 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1017 int UtcDaliActorTranslateBy(void)
1019 TestApplication application;
1021 Actor actor = Actor::New();
1022 Vector3 vector(100.0f, 100.0f, 100.0f);
1024 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1026 actor.SetPosition(vector);
1028 // flush the queue and render once
1029 application.SendNotification();
1030 application.Render();
1032 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1034 actor.TranslateBy(vector);
1036 // flush the queue and render once
1037 application.SendNotification();
1038 application.Render();
1040 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1044 int UtcDaliActorGetCurrentPosition(void)
1046 TestApplication application;
1048 Actor actor = Actor::New();
1049 Vector3 setVector(100.0f, 100.0f, 0.0f);
1050 actor.SetPosition(setVector);
1052 // flush the queue and render once
1053 application.SendNotification();
1054 application.Render();
1056 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1060 int UtcDaliActorGetCurrentWorldPosition(void)
1062 TestApplication application;
1064 Actor parent = Actor::New();
1065 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1066 parent.SetPosition( parentPosition );
1067 parent.SetParentOrigin( ParentOrigin::CENTER );
1068 parent.SetAnchorPoint( AnchorPoint::CENTER );
1069 Stage::GetCurrent().Add( parent );
1071 Actor child = Actor::New();
1072 child.SetParentOrigin( ParentOrigin::CENTER );
1073 child.SetAnchorPoint( AnchorPoint::CENTER );
1074 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1075 child.SetPosition( childPosition );
1076 parent.Add( child );
1078 // The actors should not have a world position yet
1079 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1080 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1082 application.SendNotification();
1083 application.Render(0);
1085 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1086 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1088 // The actors should have a world position now
1089 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1090 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1094 int UtcDaliActorInheritPosition(void)
1096 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1097 TestApplication application;
1099 Actor parent = Actor::New();
1100 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1101 parent.SetPosition( parentPosition );
1102 parent.SetParentOrigin( ParentOrigin::CENTER );
1103 parent.SetAnchorPoint( AnchorPoint::CENTER );
1104 Stage::GetCurrent().Add( parent );
1106 Actor child = Actor::New();
1107 child.SetParentOrigin( ParentOrigin::CENTER );
1108 child.SetAnchorPoint( AnchorPoint::CENTER );
1109 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1110 child.SetPosition( childPosition );
1111 parent.Add( child );
1113 // The actors should not have a world position yet
1114 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1115 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1117 // first test default, which is INHERIT_PARENT_POSITION
1118 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1119 application.SendNotification();
1120 application.Render(0); // should only really call Update as Render is not required to update scene
1121 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1122 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1123 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1124 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1126 // Change inheritance mode to use parent
1127 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1128 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1129 application.SendNotification();
1130 application.Render(0); // should only really call Update as Render is not required to update scene
1131 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1132 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1133 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1134 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1136 // Change inheritance mode to use parent + offset
1137 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1138 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1139 child.SetPosition( childOffset );
1140 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1141 application.SendNotification();
1142 application.Render(0); // should only really call Update as Render is not required to update scene
1143 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1144 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1145 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1146 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1148 // Change inheritance mode to not inherit
1149 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1150 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1151 application.SendNotification();
1152 application.Render(0); // should only really call Update as Render is not required to update scene
1153 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1154 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1155 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1156 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1160 // SetOrientation(float angleRadians, Vector3 axis)
1161 int UtcDaliActorSetOrientation01(void)
1163 TestApplication application;
1165 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1166 Actor actor = Actor::New();
1168 actor.SetOrientation(rotation);
1170 // flush the queue and render once
1171 application.SendNotification();
1172 application.Render();
1174 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1178 int UtcDaliActorSetOrientation02(void)
1180 TestApplication application;
1182 Actor actor = Actor::New();
1184 Radian angle( 0.785f );
1185 Vector3 axis(1.0f, 1.0f, 0.0f);
1187 actor.SetOrientation( angle, axis);
1188 Quaternion rotation( angle, axis );
1189 // flush the queue and render once
1190 application.SendNotification();
1191 application.Render();
1192 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1194 Stage::GetCurrent().Add( actor );
1195 actor.RotateBy( Degree( 360 ), axis);
1196 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1198 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1199 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1200 // flush the queue and render once
1201 application.SendNotification();
1202 application.Render();
1203 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1205 actor.SetOrientation( angle, axis);
1206 // flush the queue and render once
1207 application.SendNotification();
1208 application.Render();
1209 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1211 Stage::GetCurrent().Remove( actor );
1215 // RotateBy(float angleRadians, Vector3 axis)
1216 int UtcDaliActorRotateBy01(void)
1218 TestApplication application;
1220 Actor actor = Actor::New();
1222 Radian angle( M_PI * 0.25f );
1223 actor.RotateBy(( angle ), Vector3::ZAXIS);
1224 // flush the queue and render once
1225 application.SendNotification();
1226 application.Render();
1227 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1229 Stage::GetCurrent().Add( actor );
1231 actor.RotateBy( angle, Vector3::ZAXIS);
1232 // flush the queue and render once
1233 application.SendNotification();
1234 application.Render();
1235 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1237 Stage::GetCurrent().Remove( actor );
1241 // RotateBy(Quaternion relativeRotation)
1242 int UtcDaliActorRotateBy02(void)
1244 TestApplication application;
1246 Actor actor = Actor::New();
1248 Radian angle( M_PI * 0.25f );
1249 Quaternion rotation(angle, Vector3::ZAXIS);
1250 actor.RotateBy(rotation);
1251 // flush the queue and render once
1252 application.SendNotification();
1253 application.Render();
1254 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1256 actor.RotateBy(rotation);
1257 // flush the queue and render once
1258 application.SendNotification();
1259 application.Render();
1260 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1264 int UtcDaliActorGetCurrentOrientation(void)
1266 TestApplication application;
1267 Actor actor = Actor::New();
1269 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1270 actor.SetOrientation(rotation);
1271 // flush the queue and render once
1272 application.SendNotification();
1273 application.Render();
1274 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1278 int UtcDaliActorGetCurrentWorldOrientation(void)
1280 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1281 TestApplication application;
1283 Actor parent = Actor::New();
1284 Radian rotationAngle( Degree(90.0f) );
1285 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1286 parent.SetOrientation( rotation );
1287 Stage::GetCurrent().Add( parent );
1289 Actor child = Actor::New();
1290 child.SetOrientation( rotation );
1291 parent.Add( child );
1293 // The actors should not have a world rotation yet
1294 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1295 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1297 application.SendNotification();
1298 application.Render(0);
1300 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1301 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1303 // The actors should have a world rotation now
1304 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1305 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1307 // turn off child rotation inheritance
1308 child.SetInheritOrientation( false );
1309 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1310 application.SendNotification();
1311 application.Render(0);
1313 // The actors should have a world rotation now
1314 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1315 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1319 // SetScale(float scale)
1320 int UtcDaliActorSetScale01(void)
1322 TestApplication application;
1324 Actor actor = Actor::New();
1326 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1327 actor.SetScale(0.25f);
1329 Vector3 scale(10.0f, 10.0f, 10.0f);
1330 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1332 actor.SetScale(scale.x);
1334 // flush the queue and render once
1335 application.SendNotification();
1336 application.Render();
1338 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1342 // SetScale(float scaleX, float scaleY, float scaleZ)
1343 int UtcDaliActorSetScale02(void)
1345 TestApplication application;
1346 Vector3 scale(10.0f, 10.0f, 10.0f);
1348 Actor actor = Actor::New();
1350 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1351 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1353 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1355 actor.SetScale(scale.x, scale.y, scale.z);
1356 // flush the queue and render once
1357 application.SendNotification();
1358 application.Render();
1359 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1361 // add to stage and test
1362 Stage::GetCurrent().Add( actor );
1363 actor.SetScale( 2.0f, 2.0f, 2.0f );
1364 // flush the queue and render once
1365 application.SendNotification();
1366 application.Render();
1367 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1369 Stage::GetCurrent().Remove( actor );
1374 // SetScale(Vector3 scale)
1375 int UtcDaliActorSetScale03(void)
1377 TestApplication application;
1378 Vector3 scale(10.0f, 10.0f, 10.0f);
1380 Actor actor = Actor::New();
1382 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1383 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1385 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1387 actor.SetScale(scale);
1389 // flush the queue and render once
1390 application.SendNotification();
1391 application.Render();
1393 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1397 int UtcDaliActorScaleBy(void)
1399 TestApplication application;
1400 Actor actor = Actor::New();
1401 Vector3 vector(100.0f, 100.0f, 100.0f);
1403 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1405 actor.SetScale(vector);
1407 // flush the queue and render once
1408 application.SendNotification();
1409 application.Render();
1411 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1413 actor.ScaleBy(vector);
1415 // flush the queue and render once
1416 application.SendNotification();
1417 application.Render();
1419 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1423 int UtcDaliActorGetCurrentScale(void)
1425 TestApplication application;
1426 Vector3 scale(12.0f, 1.0f, 2.0f);
1428 Actor actor = Actor::New();
1430 actor.SetScale(scale);
1432 // flush the queue and render once
1433 application.SendNotification();
1434 application.Render();
1436 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1440 int UtcDaliActorGetCurrentWorldScale(void)
1442 TestApplication application;
1444 Actor parent = Actor::New();
1445 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1446 parent.SetScale( parentScale );
1447 Stage::GetCurrent().Add( parent );
1449 Actor child = Actor::New();
1450 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1451 child.SetScale( childScale );
1452 parent.Add( child );
1454 // The actors should not have a scale yet
1455 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1456 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1458 // The actors should not have a world scale yet
1459 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1460 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1462 application.SendNotification();
1463 application.Render(0);
1465 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1466 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1468 // The actors should have a world scale now
1469 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1470 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1474 int UtcDaliActorInheritScale(void)
1476 tet_infoline("Testing Actor::SetInheritScale");
1477 TestApplication application;
1479 Actor parent = Actor::New();
1480 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1481 parent.SetScale( parentScale );
1482 Stage::GetCurrent().Add( parent );
1484 Actor child = Actor::New();
1485 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1486 child.SetScale( childScale );
1487 parent.Add( child );
1489 application.SendNotification();
1490 application.Render(0);
1492 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1493 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1495 child.SetInheritScale( false );
1496 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1498 application.SendNotification();
1499 application.Render(0);
1501 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1505 int UtcDaliActorSetVisible(void)
1507 TestApplication application;
1509 Actor actor = Actor::New();
1510 actor.SetVisible(false);
1511 // flush the queue and render once
1512 application.SendNotification();
1513 application.Render();
1514 DALI_TEST_CHECK(actor.IsVisible() == false);
1516 actor.SetVisible(true);
1517 // flush the queue and render once
1518 application.SendNotification();
1519 application.Render();
1520 DALI_TEST_CHECK(actor.IsVisible() == true);
1522 // put actor on stage
1523 Stage::GetCurrent().Add( actor );
1524 actor.SetVisible(false);
1525 // flush the queue and render once
1526 application.SendNotification();
1527 application.Render();
1528 DALI_TEST_CHECK(actor.IsVisible() == false);
1532 int UtcDaliActorIsVisible(void)
1534 TestApplication application;
1536 Actor actor = Actor::New();
1538 DALI_TEST_CHECK(actor.IsVisible() == true);
1542 int UtcDaliActorSetOpacity(void)
1544 TestApplication application;
1546 Actor actor = Actor::New();
1547 // initial opacity is 1
1548 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1550 actor.SetOpacity( 0.4f);
1551 // flush the queue and render once
1552 application.SendNotification();
1553 application.Render();
1554 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1556 // change opacity, actor is on stage to change is not immediate
1557 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1558 // flush the queue and render once
1559 application.SendNotification();
1560 application.Render();
1561 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1563 // put actor on stage
1564 Stage::GetCurrent().Add( actor );
1566 // change opacity, actor is on stage to change is not immediate
1567 actor.SetOpacity( 0.9f );
1568 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1569 // flush the queue and render once
1570 application.SendNotification();
1571 application.Render();
1572 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1574 // change opacity, actor is on stage to change is not immediate
1575 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1576 // flush the queue and render once
1577 application.SendNotification();
1578 application.Render();
1579 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1583 int UtcDaliActorGetCurrentOpacity(void)
1585 TestApplication application;
1587 Actor actor = Actor::New();
1588 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1590 actor.SetOpacity(0.5f);
1591 // flush the queue and render once
1592 application.SendNotification();
1593 application.Render();
1594 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1598 int UtcDaliActorSetSensitive(void)
1600 TestApplication application;
1601 Actor actor = Actor::New();
1603 bool sensitive = !actor.IsSensitive();
1605 actor.SetSensitive(sensitive);
1607 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1611 int UtcDaliActorIsSensitive(void)
1613 TestApplication application;
1614 Actor actor = Actor::New();
1615 actor.SetSensitive(false);
1617 DALI_TEST_CHECK(false == actor.IsSensitive());
1621 int UtcDaliActorSetColor(void)
1623 TestApplication application;
1624 Actor actor = Actor::New();
1625 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1627 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1629 actor.SetColor(color);
1630 // flush the queue and render once
1631 application.SendNotification();
1632 application.Render();
1633 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1635 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1636 // flush the queue and render once
1637 application.SendNotification();
1638 application.Render();
1639 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1641 Stage::GetCurrent().Add( actor );
1642 actor.SetColor( color );
1643 // flush the queue and render once
1644 application.SendNotification();
1645 application.Render();
1646 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1648 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1649 // flush the queue and render once
1650 application.SendNotification();
1651 application.Render();
1652 // Actor color is not clamped
1653 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1654 // world color is clamped
1655 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1657 Stage::GetCurrent().Remove( actor );
1661 int UtcDaliActorGetCurrentColor(void)
1663 TestApplication application;
1664 Actor actor = Actor::New();
1665 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1667 actor.SetColor(color);
1668 // flush the queue and render once
1669 application.SendNotification();
1670 application.Render();
1671 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1675 int UtcDaliActorGetCurrentWorldColor(void)
1677 tet_infoline("Actor::GetCurrentWorldColor");
1678 TestApplication application;
1680 Actor parent = Actor::New();
1681 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1682 parent.SetColor( parentColor );
1683 Stage::GetCurrent().Add( parent );
1685 Actor child = Actor::New();
1686 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1687 child.SetColor( childColor );
1688 parent.Add( child );
1690 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1691 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1693 // verify the default color mode
1694 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1696 // The actors should not have a world color yet
1697 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1698 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1700 application.SendNotification();
1701 application.Render(0);
1703 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1704 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1706 // The actors should have a world color now
1707 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1708 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1711 child.SetColorMode( USE_OWN_COLOR );
1712 application.SendNotification();
1713 application.Render(0);
1714 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1717 child.SetColorMode( USE_PARENT_COLOR );
1718 application.SendNotification();
1719 application.Render(0);
1720 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1721 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1724 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1725 application.SendNotification();
1726 application.Render(0);
1727 Vector4 expectedColor( childColor );
1728 expectedColor.a *= parentColor.a;
1729 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1730 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1734 int UtcDaliActorSetColorMode(void)
1736 tet_infoline("Actor::SetColorMode");
1737 TestApplication application;
1738 Actor actor = Actor::New();
1739 Actor child = Actor::New();
1742 actor.SetColorMode( USE_OWN_COLOR );
1743 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1745 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1746 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1748 actor.SetColorMode( USE_PARENT_COLOR );
1749 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1751 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1752 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1756 int UtcDaliActorScreenToLocal(void)
1758 TestApplication application;
1759 Actor actor = Actor::New();
1760 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1761 actor.SetSize(100.0f, 100.0f);
1762 actor.SetPosition(10.0f, 10.0f);
1763 Stage::GetCurrent().Add(actor);
1765 // flush the queue and render once
1766 application.SendNotification();
1767 application.Render();
1772 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1774 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1775 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1779 int UtcDaliActorSetLeaveRequired(void)
1781 TestApplication application;
1783 Actor actor = Actor::New();
1785 actor.SetLeaveRequired(false);
1786 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1788 actor.SetLeaveRequired(true);
1789 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1793 int UtcDaliActorGetLeaveRequired(void)
1795 TestApplication application;
1797 Actor actor = Actor::New();
1799 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1803 int UtcDaliActorSetKeyboardFocusable(void)
1805 TestApplication application;
1807 Actor actor = Actor::New();
1809 actor.SetKeyboardFocusable(true);
1810 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1812 actor.SetKeyboardFocusable(false);
1813 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1817 int UtcDaliActorIsKeyboardFocusable(void)
1819 TestApplication application;
1821 Actor actor = Actor::New();
1823 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1827 int UtcDaliActorRemoveConstraints(void)
1829 tet_infoline(" UtcDaliActorRemoveConstraints");
1830 TestApplication application;
1832 gTestConstraintCalled = false;
1834 Actor actor = Actor::New();
1836 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
1838 actor.RemoveConstraints();
1840 DALI_TEST_CHECK( gTestConstraintCalled == false );
1842 Stage::GetCurrent().Add( actor );
1845 // flush the queue and render once
1846 application.SendNotification();
1847 application.Render();
1849 actor.RemoveConstraints();
1851 DALI_TEST_CHECK( gTestConstraintCalled == true );
1855 int UtcDaliActorRemoveConstraintTag(void)
1857 tet_infoline(" UtcDaliActorRemoveConstraintTag");
1858 TestApplication application;
1860 Actor actor = Actor::New();
1862 // 1. Apply Constraint1 and Constraint2, and test...
1863 unsigned int result1 = 0u;
1864 unsigned int result2 = 0u;
1866 unsigned constraint1Tag = 1u;
1867 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
1868 constraint1.SetTag( constraint1Tag );
1869 constraint1.Apply();
1871 unsigned constraint2Tag = 2u;
1872 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
1873 constraint2.SetTag( constraint2Tag );
1874 constraint2.Apply();
1876 Stage::GetCurrent().Add( actor );
1877 // flush the queue and render once
1878 application.SendNotification();
1879 application.Render();
1881 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1882 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1884 // 2. Remove Constraint1 and test...
1887 actor.RemoveConstraints(constraint1Tag);
1888 // make color property dirty, which will trigger constraints to be reapplied.
1889 actor.SetColor( Color::WHITE );
1890 // flush the queue and render once
1891 application.SendNotification();
1892 application.Render();
1894 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1895 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1897 // 3. Re-Apply Constraint1 and test...
1900 constraint1.Apply();
1901 // make color property dirty, which will trigger constraints to be reapplied.
1902 actor.SetColor( Color::WHITE );
1903 // flush the queue and render once
1904 application.SendNotification();
1905 application.Render();
1907 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1908 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1910 // 2. Remove Constraint2 and test...
1913 actor.RemoveConstraints(constraint2Tag);
1914 // make color property dirty, which will trigger constraints to be reapplied.
1915 actor.SetColor( Color::WHITE );
1916 // flush the queue and render once
1917 application.SendNotification();
1918 application.Render();
1920 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1921 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1923 // 2. Remove Constraint1 as well and test...
1926 actor.RemoveConstraints(constraint1Tag);
1927 // make color property dirty, which will trigger constraints to be reapplied.
1928 actor.SetColor( Color::WHITE );
1929 // flush the queue and render once
1930 application.SendNotification();
1931 application.Render();
1933 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1934 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1938 int UtcDaliActorTouchedSignal(void)
1940 TestApplication application;
1942 gTouchCallBackCalled = false;
1944 // get the root layer
1945 Actor actor = Stage::GetCurrent().GetRootLayer();
1946 DALI_TEST_CHECK( gTouchCallBackCalled == false );
1948 application.SendNotification();
1949 application.Render();
1951 // connect to its touch signal
1952 actor.TouchedSignal().Connect( TestCallback );
1954 // simulate a touch event in the middle of the screen
1955 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1956 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
1957 Dali::Integration::TouchEvent event;
1958 event.AddPoint( point );
1959 application.ProcessEvent( event );
1961 DALI_TEST_CHECK( gTouchCallBackCalled == true );
1965 int UtcDaliActorHoveredSignal(void)
1967 TestApplication application;
1969 gHoverCallBackCalled = false;
1971 // get the root layer
1972 Actor actor = Stage::GetCurrent().GetRootLayer();
1973 DALI_TEST_CHECK( gHoverCallBackCalled == false );
1975 application.SendNotification();
1976 application.Render();
1978 // connect to its hover signal
1979 actor.HoveredSignal().Connect( TestCallback3 );
1981 // simulate a hover event in the middle of the screen
1982 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1983 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
1984 Dali::Integration::HoverEvent event;
1985 event.AddPoint( point );
1986 application.ProcessEvent( event );
1988 DALI_TEST_CHECK( gHoverCallBackCalled == true );
1992 int UtcDaliActorOnOffStageSignal(void)
1994 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
1996 TestApplication application;
1999 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2000 gActorNamesOnOffStage.clear();
2002 Actor parent = Actor::New();
2003 parent.SetName( "parent" );
2004 parent.OnStageSignal().Connect( OnStageCallback );
2005 parent.OffStageSignal().Connect( OffStageCallback );
2007 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2008 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2010 // add parent to stage
2011 Stage::GetCurrent().Add( parent );
2012 // onstage emitted, offstage not
2013 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2014 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2015 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2017 // test adding a child, should get onstage emitted
2019 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2020 gActorNamesOnOffStage.clear();
2022 Actor child = Actor::New();
2023 child.SetName( "child" );
2024 child.OnStageSignal().Connect( OnStageCallback );
2025 child.OffStageSignal().Connect( OffStageCallback );
2026 parent.Add( child ); // add child
2027 // onstage emitted, offstage not
2028 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2029 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2030 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2032 // test removing parent from stage
2034 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2035 gActorNamesOnOffStage.clear();
2037 Stage::GetCurrent().Remove( parent );
2038 // onstage not emitted, offstage is
2039 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2040 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2041 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2042 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2044 // test adding parent back to stage
2046 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2047 gActorNamesOnOffStage.clear();
2049 Stage::GetCurrent().Add( parent );
2050 // onstage emitted, offstage not
2051 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2052 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2053 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2054 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2056 // test removing child
2058 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2059 gActorNamesOnOffStage.clear();
2061 parent.Remove( child );
2062 // onstage not emitted, offstage is
2063 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2064 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2065 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2067 // test removing parent
2069 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2070 gActorNamesOnOffStage.clear();
2072 Stage::GetCurrent().Remove( parent );
2073 // onstage not emitted, offstage is
2074 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2075 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2076 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2080 int UtcDaliActorFindChildByName(void)
2082 tet_infoline("Testing Dali::Actor::FindChildByName()");
2083 TestApplication application;
2085 Actor parent = Actor::New();
2086 parent.SetName( "parent" );
2087 Actor first = Actor::New();
2088 first .SetName( "first" );
2089 Actor second = Actor::New();
2090 second.SetName( "second" );
2095 Actor found = parent.FindChildByName( "foo" );
2096 DALI_TEST_CHECK( !found );
2098 found = parent.FindChildByName( "parent" );
2099 DALI_TEST_CHECK( found == parent );
2101 found = parent.FindChildByName( "first" );
2102 DALI_TEST_CHECK( found == first );
2104 found = parent.FindChildByName( "second" );
2105 DALI_TEST_CHECK( found == second );
2109 int UtcDaliActorFindChildById(void)
2111 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2112 TestApplication application;
2114 Actor parent = Actor::New();
2115 Actor first = Actor::New();
2116 Actor second = Actor::New();
2121 Actor found = parent.FindChildById( 100000 );
2122 DALI_TEST_CHECK( !found );
2124 found = parent.FindChildById( parent.GetId() );
2125 DALI_TEST_CHECK( found == parent );
2127 found = parent.FindChildById( first.GetId() );
2128 DALI_TEST_CHECK( found == first );
2130 found = parent.FindChildById( second.GetId() );
2131 DALI_TEST_CHECK( found == second );
2135 int UtcDaliActorHitTest(void)
2140 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2142 mTouchPoint( touchPoint ),
2147 Vector2 mTouchPoint;
2151 TestApplication application;
2152 tet_infoline(" UtcDaliActorHitTest");
2154 // Fill a vector with different hit tests.
2155 struct HitTestData* hitTestData[] = {
2156 // scale touch point result
2157 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2158 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2159 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.
2160 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2161 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.
2165 // get the root layer
2166 Actor actor = Actor::New();
2167 actor.SetAnchorPoint( AnchorPoint::CENTER );
2168 actor.SetParentOrigin( ParentOrigin::CENTER );
2170 Stage::GetCurrent().Add( actor );
2172 gTouchCallBackCalled = false;
2174 unsigned int index = 0;
2175 while( NULL != hitTestData[index] )
2177 actor.SetSize( 1.f, 1.f );
2178 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2180 // flush the queue and render once
2181 application.SendNotification();
2182 application.Render();
2184 DALI_TEST_CHECK( !gTouchCallBackCalled );
2186 // connect to its touch signal
2187 actor.TouchedSignal().Connect(TestCallback);
2189 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2190 Dali::Integration::TouchEvent event;
2191 event.AddPoint( point );
2193 // flush the queue and render once
2194 application.SendNotification();
2195 application.Render();
2196 application.ProcessEvent( event );
2198 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2200 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2201 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2202 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2203 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2204 hitTestData[index]->mResult );
2206 gTouchCallBackCalled = false;
2212 int UtcDaliActorSetDrawMode(void)
2214 TestApplication app;
2215 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2217 Actor a = Actor::New();
2219 Stage::GetCurrent().Add(a);
2220 app.SendNotification();
2222 app.SendNotification();
2225 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2227 a.SetDrawMode( DrawMode::OVERLAY );
2228 app.SendNotification();
2231 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2233 a.SetDrawMode( DrawMode::STENCIL );
2234 app.SendNotification();
2237 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2239 a.SetDrawMode( DrawMode::NORMAL );
2240 app.SendNotification();
2243 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2247 int UtcDaliActorSetDrawModeOverlayRender(void)
2249 TestApplication app;
2250 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2252 app.SendNotification();
2255 std::vector<GLuint> ids;
2256 ids.push_back( 8 ); // first rendered actor
2257 ids.push_back( 9 ); // second rendered actor
2258 ids.push_back( 10 ); // third rendered actor
2259 app.GetGlAbstraction().SetNextTextureIds( ids );
2261 BufferImage imageA = BufferImage::New(16, 16);
2262 BufferImage imageB = BufferImage::New(16, 16);
2263 BufferImage imageC = BufferImage::New(16, 16);
2264 ImageActor a = ImageActor::New( imageA );
2265 ImageActor b = ImageActor::New( imageB );
2266 ImageActor c = ImageActor::New( imageC );
2268 // Render a,b,c as regular non-overlays. so order will be:
2272 Stage::GetCurrent().Add(a);
2273 Stage::GetCurrent().Add(b);
2274 Stage::GetCurrent().Add(c);
2276 app.SendNotification();
2279 // Should be 3 textures changes.
2280 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2281 typedef std::vector<GLuint>::size_type TextureSize;
2282 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2283 if( boundTextures.size() == 3 )
2285 DALI_TEST_CHECK( boundTextures[0] == 8u );
2286 DALI_TEST_CHECK( boundTextures[1] == 9u );
2287 DALI_TEST_CHECK( boundTextures[2] == 10u );
2290 // Now texture ids have been set, we can monitor their render order.
2291 // render a as an overlay (last), so order will be:
2295 a.SetDrawMode( DrawMode::OVERLAY );
2296 app.GetGlAbstraction().ClearBoundTextures();
2298 app.SendNotification();
2301 // Should be 3 texture changes.
2302 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2303 if( boundTextures.size() == 3 )
2305 DALI_TEST_CHECK( boundTextures[0] == 9u );
2306 DALI_TEST_CHECK( boundTextures[1] == 10u );
2307 DALI_TEST_CHECK( boundTextures[2] == 8u );
2312 int UtcDaliActorGetCurrentWorldMatrix(void)
2314 TestApplication app;
2315 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2317 Actor parent = Actor::New();
2318 parent.SetParentOrigin(ParentOrigin::CENTER);
2319 parent.SetAnchorPoint(AnchorPoint::CENTER);
2320 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2321 Radian rotationAngle(Degree(85.0f));
2322 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2323 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2324 parent.SetPosition( parentPosition );
2325 parent.SetOrientation( parentRotation );
2326 parent.SetScale( parentScale );
2327 Stage::GetCurrent().Add( parent );
2329 Actor child = Actor::New();
2330 child.SetParentOrigin(ParentOrigin::CENTER);
2331 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2332 Radian childRotationAngle(Degree(23.0f));
2333 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2334 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2335 child.SetPosition( childPosition );
2336 child.SetOrientation( childRotation );
2337 child.SetScale( childScale );
2338 parent.Add( child );
2340 // The actors should not have a world matrix yet
2341 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2342 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2344 app.SendNotification();
2347 app.SendNotification();
2349 Matrix parentMatrix(false);
2350 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2352 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2353 Quaternion childWorldRotation = parentRotation * childRotation;
2354 Vector3 childWorldScale = parentScale * childScale;
2356 Matrix childWorldMatrix(false);
2357 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2359 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2360 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2366 int UtcDaliActorConstrainedToWorldMatrix(void)
2368 TestApplication app;
2369 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2371 Actor parent = Actor::New();
2372 parent.SetParentOrigin(ParentOrigin::CENTER);
2373 parent.SetAnchorPoint(AnchorPoint::CENTER);
2374 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2375 Radian rotationAngle(Degree(85.0f));
2376 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2377 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2378 parent.SetPosition( parentPosition );
2379 parent.SetOrientation( parentRotation );
2380 parent.SetScale( parentScale );
2381 Stage::GetCurrent().Add( parent );
2383 Actor child = Actor::New();
2384 child.SetParentOrigin(ParentOrigin::CENTER);
2385 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2386 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2387 posConstraint.Apply();
2389 Stage::GetCurrent().Add( child );
2391 // The actors should not have a world matrix yet
2392 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2393 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2395 app.SendNotification();
2398 app.SendNotification();
2400 Matrix parentMatrix(false);
2401 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2403 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2404 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2408 int UtcDaliActorUnparent(void)
2410 TestApplication app;
2411 tet_infoline(" UtcDaliActorUnparent");
2413 Actor parent = Actor::New();
2414 Stage::GetCurrent().Add( parent );
2416 Actor child = Actor::New();
2418 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2419 DALI_TEST_CHECK( !child.GetParent() );
2421 // Test that calling Unparent with no parent is a NOOP
2424 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2425 DALI_TEST_CHECK( !child.GetParent() );
2427 // Test that Unparent works
2428 parent.Add( child );
2430 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2431 DALI_TEST_CHECK( parent == child.GetParent() );
2435 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2436 DALI_TEST_CHECK( !child.GetParent() );
2438 // Test that UnparentAndReset works
2439 parent.Add( child );
2441 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2442 DALI_TEST_CHECK( parent == child.GetParent() );
2444 UnparentAndReset( child );
2446 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2447 DALI_TEST_CHECK( !child );
2449 // Test that UnparentAndReset is a NOOP with empty handle
2450 UnparentAndReset( child );
2452 DALI_TEST_CHECK( !child );
2456 int UtcDaliActorGetChildAt(void)
2458 TestApplication app;
2459 tet_infoline(" UtcDaliActorGetChildAt");
2461 Actor parent = Actor::New();
2462 Stage::GetCurrent().Add( parent );
2464 Actor child0 = Actor::New();
2465 parent.Add( child0 );
2467 Actor child1 = Actor::New();
2468 parent.Add( child1 );
2470 Actor child2 = Actor::New();
2471 parent.Add( child2 );
2473 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2474 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2475 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2479 int UtcDaliActorSetGetOverlay(void)
2481 TestApplication app;
2482 tet_infoline(" UtcDaliActorSetGetOverlay");
2484 Actor parent = Actor::New();
2485 parent.SetDrawMode(DrawMode::OVERLAY );
2486 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2491 // Current Dynamics functions are crashing, so testing these sections are futile
2493 int UtcDaliActorDynamics(void)
2495 DALI_TEST_CHECK( true );
2499 int UtcDaliActorCreateDestroy(void)
2501 Actor* actor = new Actor;
2502 DALI_TEST_CHECK( actor );
2509 struct PropertyStringIndex
2511 const char * const name;
2512 const Property::Index index;
2513 const Property::Type type;
2516 const PropertyStringIndex PROPERTY_TABLE[] =
2518 { "parent-origin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2519 { "parent-origin-x", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2520 { "parent-origin-y", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2521 { "parent-origin-z", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2522 { "anchor-point", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2523 { "anchor-point-x", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2524 { "anchor-point-y", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2525 { "anchor-point-z", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2526 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2527 { "size-width", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2528 { "size-height", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2529 { "size-depth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2530 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2531 { "position-x", Actor::Property::POSITION_X, Property::FLOAT },
2532 { "position-y", Actor::Property::POSITION_Y, Property::FLOAT },
2533 { "position-z", Actor::Property::POSITION_Z, Property::FLOAT },
2534 { "world-position", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2535 { "world-position-x", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2536 { "world-position-y", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2537 { "world-position-z", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2538 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2539 { "world-orientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2540 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2541 { "scale-x", Actor::Property::SCALE_X, Property::FLOAT },
2542 { "scale-y", Actor::Property::SCALE_Y, Property::FLOAT },
2543 { "scale-z", Actor::Property::SCALE_Z, Property::FLOAT },
2544 { "world-scale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2545 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2546 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2547 { "color-red", Actor::Property::COLOR_RED, Property::FLOAT },
2548 { "color-green", Actor::Property::COLOR_GREEN, Property::FLOAT },
2549 { "color-blue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2550 { "color-alpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2551 { "world-color", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2552 { "world-matrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2553 { "name", Actor::Property::NAME, Property::STRING },
2554 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2555 { "leave-required", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2556 { "inherit-orientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2557 { "inherit-scale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2558 { "color-mode", Actor::Property::COLOR_MODE, Property::STRING },
2559 { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2560 { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING },
2561 { "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2562 { "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2563 { "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2564 { "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2565 { "width-for-height", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2566 { "height-for-width", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2567 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2568 { "minimum-size", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2569 { "maximum-size", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2571 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2572 } // unnamed namespace
2574 int UtcDaliActorProperties(void)
2576 TestApplication app;
2578 Actor actor = Actor::New();
2580 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2582 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2583 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2584 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2585 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2590 int UtcDaliRelayoutProperties_ResizePolicies(void)
2592 TestApplication app;
2594 Actor actor = Actor::New();
2597 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2598 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2600 // Set resize policy for all dimensions
2601 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2602 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2604 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2607 // Set individual dimensions
2608 const char* const widthPolicy = "FILL_TO_PARENT";
2609 const char* const heightPolicy = "FIXED";
2611 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2612 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2614 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2615 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2620 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2622 TestApplication app;
2624 Actor actor = Actor::New();
2627 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2628 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2630 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2631 actor.SetSizeScalePolicy( policy );
2632 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2635 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2636 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2638 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2639 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2641 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2642 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2647 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2649 TestApplication app;
2651 Actor actor = Actor::New();
2654 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2655 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2657 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2658 actor.SetSizeModeFactor( sizeMode );
2659 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2662 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2664 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2665 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2670 int UtcDaliRelayoutProperties_DimensionDependency(void)
2672 TestApplication app;
2674 Actor actor = Actor::New();
2677 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2678 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2681 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2682 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2684 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2685 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2687 // Test setting another resize policy
2688 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2689 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2694 int UtcDaliRelayoutProperties_Padding(void)
2696 TestApplication app;
2698 Actor actor = Actor::New();
2701 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2704 actor.SetProperty( Actor::Property::PADDING, padding );
2705 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2707 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2712 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2714 TestApplication app;
2716 Actor actor = Actor::New();
2719 Vector2 minSize( 1.0f, 2.0f );
2721 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2722 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2724 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2726 Vector2 maxSize( 3.0f, 4.0f );
2728 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2729 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2731 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2736 int UtcDaliActorGetHeightForWidth(void)
2738 TestApplication app;
2740 Actor actor = Actor::New();
2742 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
2747 int UtcDaliActorGetWidthForHeight(void)
2749 TestApplication app;
2751 Actor actor = Actor::New();
2753 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
2758 int UtcDaliActorGetRelayoutSize(void)
2760 TestApplication app;
2762 Actor actor = Actor::New();
2764 // Add actor to stage
2765 Stage::GetCurrent().Add( actor );
2767 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
2769 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
2770 actor.SetSize( Vector2( 1.0f, 0.0f ) );
2772 // Flush the queue and render once
2773 app.SendNotification();
2776 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
2781 int UtcDaliActorSetPadding(void)
2783 TestApplication app;
2785 Actor actor = Actor::New();
2788 actor.GetPadding( padding );
2790 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
2791 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
2792 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
2793 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
2795 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
2796 actor.SetPadding( padding2 );
2798 actor.GetPadding( padding );
2800 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
2801 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
2802 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
2803 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
2808 int UtcDaliActorSetMinimumSize(void)
2810 TestApplication app;
2812 Actor actor = Actor::New();
2814 Vector2 size = actor.GetMinimumSize();
2816 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
2817 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
2819 Vector2 size2( 1.0f, 2.0f );
2820 actor.SetMinimumSize( size2 );
2822 size = actor.GetMinimumSize();
2824 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2825 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2830 int UtcDaliActorSetMaximumSize(void)
2832 TestApplication app;
2834 Actor actor = Actor::New();
2836 Vector2 size = actor.GetMaximumSize();
2838 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
2839 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
2841 Vector2 size2( 1.0f, 2.0f );
2842 actor.SetMaximumSize( size2 );
2844 size = actor.GetMaximumSize();
2846 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2847 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2852 int UtcDaliActorOnRelayoutSignal(void)
2854 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
2856 TestApplication application;
2859 gOnRelayoutCallBackCalled = 0;
2860 gActorNamesRelayout.clear();
2862 Actor actor = Actor::New();
2863 actor.SetName( "actor" );
2864 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
2867 DALI_TEST_CHECK( gOnRelayoutCallBackCalled == 0 );
2869 // Add actor to stage
2870 Stage::GetCurrent().Add( actor );
2872 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2873 actor.SetSize( Vector2( 1.0f, 2.0 ) );
2875 // Flush the queue and render once
2876 application.SendNotification();
2877 application.Render();
2879 // OnRelayout emitted
2880 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, 1, TEST_LOCATION );
2881 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );