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 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
458 // try Remove self, its a no-op
459 parent.Remove( parent );
460 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
466 parent.Remove( empty );
467 tet_printf("Assertion test failed - no Exception\n" );
468 tet_result(TET_FAIL);
470 catch(Dali::DaliException& e)
472 DALI_TEST_PRINT_ASSERT( e );
473 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
474 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
478 tet_printf("Assertion test failed - wrong Exception\n" );
479 tet_result(TET_FAIL);
484 int UtcDaliActorRemoveP(void)
486 TestApplication application;
488 Actor parent = Actor::New();
489 Actor child = Actor::New();
490 Actor random = Actor::New();
492 Stage::GetCurrent().Add( parent );
494 DALI_TEST_CHECK(parent.GetChildCount() == 0);
498 DALI_TEST_CHECK(parent.GetChildCount() == 1);
500 parent.Remove(random);
502 DALI_TEST_CHECK(parent.GetChildCount() == 1);
504 Stage::GetCurrent().Remove( parent );
506 DALI_TEST_CHECK(parent.GetChildCount() == 1);
510 int UtcDaliActorGetChildCount(void)
512 TestApplication application;
514 Actor parent = Actor::New();
515 Actor child = Actor::New();
517 DALI_TEST_CHECK(parent.GetChildCount() == 0);
521 DALI_TEST_CHECK(parent.GetChildCount() == 1);
525 int UtcDaliActorGetChildren01(void)
527 TestApplication application;
529 Actor parent = Actor::New();
530 Actor first = Actor::New();
531 Actor second = Actor::New();
532 Actor third = Actor::New();
538 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
539 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
540 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
544 int UtcDaliActorGetChildren02(void)
546 TestApplication application;
548 Actor parent = Actor::New();
549 Actor first = Actor::New();
550 Actor second = Actor::New();
551 Actor third = Actor::New();
557 const Actor& constParent = parent;
559 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
560 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
561 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
565 int UtcDaliActorGetParent01(void)
567 TestApplication application;
569 Actor parent = Actor::New();
570 Actor child = Actor::New();
574 DALI_TEST_CHECK(child.GetParent() == parent);
578 int UtcDaliActorGetParent02(void)
580 TestApplication application;
582 Actor actor = Actor::New();
584 DALI_TEST_CHECK(!actor.GetParent());
588 int UtcDaliActorSetParentOrigin(void)
590 TestApplication application;
592 Actor actor = Actor::New();
594 Vector3 vector(0.7f, 0.8f, 0.9f);
595 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
597 actor.SetParentOrigin(vector);
599 // flush the queue and render once
600 application.SendNotification();
601 application.Render();
603 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
605 Stage::GetCurrent().Add( actor );
607 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
609 // flush the queue and render once
610 application.SendNotification();
611 application.Render();
613 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
615 Stage::GetCurrent().Remove( actor );
619 int UtcDaliActorGetCurrentParentOrigin(void)
621 TestApplication application;
623 Actor actor = Actor::New();
625 Vector3 vector(0.7f, 0.8f, 0.9f);
626 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
628 actor.SetParentOrigin(vector);
630 // flush the queue and render once
631 application.SendNotification();
632 application.Render();
634 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
638 int UtcDaliActorSetAnchorPoint(void)
640 TestApplication application;
642 Actor actor = Actor::New();
644 Vector3 vector(0.7f, 0.8f, 0.9f);
645 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
647 actor.SetAnchorPoint(vector);
649 // flush the queue and render once
650 application.SendNotification();
651 application.Render();
653 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
655 Stage::GetCurrent().Add( actor );
657 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
658 // flush the queue and render once
659 application.SendNotification();
660 application.Render();
662 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
664 Stage::GetCurrent().Remove( actor );
668 int UtcDaliActorGetCurrentAnchorPoint(void)
670 TestApplication application;
672 Actor actor = Actor::New();
674 Vector3 vector(0.7f, 0.8f, 0.9f);
675 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
677 actor.SetAnchorPoint(vector);
679 // flush the queue and render once
680 application.SendNotification();
681 application.Render();
683 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
687 // SetSize(float width, float height)
688 int UtcDaliActorSetSize01(void)
690 TestApplication application;
692 Actor actor = Actor::New();
693 Vector3 vector(100.0f, 100.0f, 100.0f);
695 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
697 actor.SetSize(vector.x, vector.y);
699 // flush the queue and render once
700 application.SendNotification();
701 application.Render();
703 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
707 // SetSize(float width, float height, float depth)
708 int UtcDaliActorSetSize02(void)
710 TestApplication application;
712 Actor actor = Actor::New();
713 Vector3 vector(100.0f, 100.0f, 100.0f);
715 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
717 actor.SetSize(vector.x, vector.y, vector.z);
719 // flush the queue and render once
720 application.SendNotification();
721 application.Render();
723 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
727 // SetSize(Vector2 size)
728 int UtcDaliActorSetSize03(void)
730 TestApplication application;
732 Actor actor = Actor::New();
733 Vector3 vector(100.0f, 100.0f, 100.0f);
735 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
737 actor.SetSize(Vector2(vector.x, vector.y));
739 // flush the queue and render once
740 application.SendNotification();
741 application.Render();
743 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
747 // SetSize(Vector3 size)
748 int UtcDaliActorSetSize04(void)
750 TestApplication application;
752 Actor actor = Actor::New();
753 Vector3 vector(100.0f, 100.0f, 100.0f);
755 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
757 actor.SetSize(vector);
759 // flush the queue and render once
760 application.SendNotification();
761 application.Render();
763 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
765 Stage::GetCurrent().Add( actor );
766 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
768 // flush the queue and render once
769 application.SendNotification();
770 application.Render();
772 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
773 Stage::GetCurrent().Remove( actor );
777 int UtcDaliActorGetCurrentSize(void)
779 TestApplication application;
781 Actor actor = Actor::New();
782 Vector3 vector(100.0f, 100.0f, 20.0f);
784 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
786 actor.SetSize(vector);
788 // flush the queue and render once
789 application.SendNotification();
790 application.Render();
792 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
796 int UtcDaliActorGetNaturalSize(void)
798 TestApplication application;
800 Actor actor = Actor::New();
801 Vector3 vector( 0.0f, 0.0f, 0.0f );
803 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
808 int UtcDaliActorGetCurrentSizeImmediate(void)
810 TestApplication application;
812 Actor actor = Actor::New();
813 Vector3 vector(100.0f, 100.0f, 20.0f);
815 DALI_TEST_CHECK(vector != actor.GetTargetSize());
816 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
818 actor.SetSize(vector);
820 DALI_TEST_CHECK(vector == actor.GetTargetSize());
821 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
823 // flush the queue and render once
824 application.SendNotification();
825 application.Render();
827 DALI_TEST_CHECK(vector == actor.GetTargetSize());
828 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
831 // Build the animation
832 const float durationSeconds = 2.0f;
833 Animation animation = Animation::New( durationSeconds );
834 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
835 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
837 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
839 // Start the animation
842 application.SendNotification();
843 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
845 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
850 // SetPosition(float x, float y)
851 int UtcDaliActorSetPosition01(void)
853 TestApplication application;
855 Actor actor = Actor::New();
857 // Set to random to start off with
858 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
860 Vector3 vector(100.0f, 100.0f, 0.0f);
862 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
864 actor.SetPosition(vector.x, vector.y);
865 // flush the queue and render once
866 application.SendNotification();
867 application.Render();
868 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
870 Stage::GetCurrent().Add( actor );
871 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
872 // flush the queue and render once
873 application.SendNotification();
874 application.Render();
875 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
880 // flush the queue and render once
881 application.SendNotification();
882 application.Render();
883 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
885 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
886 // flush the queue and render once
887 application.SendNotification();
888 application.Render();
889 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
891 Stage::GetCurrent().Remove( actor );
895 // SetPosition(float x, float y, float z)
896 int UtcDaliActorSetPosition02(void)
898 TestApplication application;
900 Actor actor = Actor::New();
902 // Set to random to start off with
903 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
905 Vector3 vector(100.0f, 100.0f, 100.0f);
907 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
909 actor.SetPosition(vector.x, vector.y, vector.z);
911 // flush the queue and render once
912 application.SendNotification();
913 application.Render();
915 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
919 // SetPosition(Vector3 position)
920 int UtcDaliActorSetPosition03(void)
922 TestApplication application;
924 Actor actor = Actor::New();
926 // Set to random to start off with
927 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
929 Vector3 vector(100.0f, 100.0f, 100.0f);
931 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
933 actor.SetPosition(vector);
935 // flush the queue and render once
936 application.SendNotification();
937 application.Render();
939 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
943 int UtcDaliActorSetX(void)
945 TestApplication application;
947 Actor actor = Actor::New();
949 Vector3 vector(100.0f, 0.0f, 0.0f);
951 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
955 // flush the queue and render once
956 application.SendNotification();
957 application.Render();
959 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
963 int UtcDaliActorSetY(void)
965 TestApplication application;
967 Actor actor = Actor::New();
969 Vector3 vector(0.0f, 100.0f, 0.0f);
971 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
975 // flush the queue and render once
976 application.SendNotification();
977 application.Render();
979 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
983 int UtcDaliActorSetZ(void)
985 TestApplication application;
987 Actor actor = Actor::New();
989 Vector3 vector(0.0f, 0.0f, 100.0f);
991 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
995 // flush the queue and render once
996 application.SendNotification();
997 application.Render();
999 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1003 int UtcDaliActorTranslateBy(void)
1005 TestApplication application;
1007 Actor actor = Actor::New();
1008 Vector3 vector(100.0f, 100.0f, 100.0f);
1010 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1012 actor.SetPosition(vector);
1014 // flush the queue and render once
1015 application.SendNotification();
1016 application.Render();
1018 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1020 actor.TranslateBy(vector);
1022 // flush the queue and render once
1023 application.SendNotification();
1024 application.Render();
1026 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1030 int UtcDaliActorGetCurrentPosition(void)
1032 TestApplication application;
1034 Actor actor = Actor::New();
1035 Vector3 setVector(100.0f, 100.0f, 0.0f);
1036 actor.SetPosition(setVector);
1038 // flush the queue and render once
1039 application.SendNotification();
1040 application.Render();
1042 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1046 int UtcDaliActorGetCurrentWorldPosition(void)
1048 TestApplication application;
1050 Actor parent = Actor::New();
1051 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1052 parent.SetPosition( parentPosition );
1053 parent.SetParentOrigin( ParentOrigin::CENTER );
1054 parent.SetAnchorPoint( AnchorPoint::CENTER );
1055 Stage::GetCurrent().Add( parent );
1057 Actor child = Actor::New();
1058 child.SetParentOrigin( ParentOrigin::CENTER );
1059 child.SetAnchorPoint( AnchorPoint::CENTER );
1060 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1061 child.SetPosition( childPosition );
1062 parent.Add( child );
1064 // The actors should not have a world position yet
1065 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1066 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1068 application.SendNotification();
1069 application.Render(0);
1071 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1072 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1074 // The actors should have a world position now
1075 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1076 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1080 int UtcDaliActorInheritPosition(void)
1082 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1083 TestApplication application;
1085 Actor parent = Actor::New();
1086 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1087 parent.SetPosition( parentPosition );
1088 parent.SetParentOrigin( ParentOrigin::CENTER );
1089 parent.SetAnchorPoint( AnchorPoint::CENTER );
1090 Stage::GetCurrent().Add( parent );
1092 Actor child = Actor::New();
1093 child.SetParentOrigin( ParentOrigin::CENTER );
1094 child.SetAnchorPoint( AnchorPoint::CENTER );
1095 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1096 child.SetPosition( childPosition );
1097 parent.Add( child );
1099 // The actors should not have a world position yet
1100 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1101 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1103 // first test default, which is INHERIT_PARENT_POSITION
1104 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1105 application.SendNotification();
1106 application.Render(0); // should only really call Update as Render is not required to update scene
1107 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1108 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1109 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1110 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1112 // Change inheritance mode to use parent
1113 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1114 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1115 application.SendNotification();
1116 application.Render(0); // should only really call Update as Render is not required to update scene
1117 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1118 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1119 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1120 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1122 // Change inheritance mode to use parent + offset
1123 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1124 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1125 child.SetPosition( childOffset );
1126 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1127 application.SendNotification();
1128 application.Render(0); // should only really call Update as Render is not required to update scene
1129 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1130 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1131 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1132 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1134 // Change inheritance mode to not inherit
1135 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1136 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1137 application.SendNotification();
1138 application.Render(0); // should only really call Update as Render is not required to update scene
1139 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1140 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1141 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1142 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1146 // SetOrientation(float angleRadians, Vector3 axis)
1147 int UtcDaliActorSetOrientation01(void)
1149 TestApplication application;
1151 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1152 Actor actor = Actor::New();
1154 actor.SetOrientation(rotation);
1156 // flush the queue and render once
1157 application.SendNotification();
1158 application.Render();
1160 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1164 int UtcDaliActorSetOrientation02(void)
1166 TestApplication application;
1168 Actor actor = Actor::New();
1170 Radian angle( 0.785f );
1171 Vector3 axis(1.0f, 1.0f, 0.0f);
1173 actor.SetOrientation( angle, axis);
1174 Quaternion rotation( angle, axis );
1175 // flush the queue and render once
1176 application.SendNotification();
1177 application.Render();
1178 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1180 Stage::GetCurrent().Add( actor );
1181 actor.RotateBy( Degree( 360 ), axis);
1182 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1184 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1185 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1186 // flush the queue and render once
1187 application.SendNotification();
1188 application.Render();
1189 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1191 actor.SetOrientation( angle, axis);
1192 // flush the queue and render once
1193 application.SendNotification();
1194 application.Render();
1195 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1197 Stage::GetCurrent().Remove( actor );
1201 // RotateBy(float angleRadians, Vector3 axis)
1202 int UtcDaliActorRotateBy01(void)
1204 TestApplication application;
1206 Actor actor = Actor::New();
1208 Radian angle( M_PI * 0.25f );
1209 actor.RotateBy(( angle ), Vector3::ZAXIS);
1210 // flush the queue and render once
1211 application.SendNotification();
1212 application.Render();
1213 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1215 Stage::GetCurrent().Add( actor );
1217 actor.RotateBy( angle, Vector3::ZAXIS);
1218 // flush the queue and render once
1219 application.SendNotification();
1220 application.Render();
1221 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1223 Stage::GetCurrent().Remove( actor );
1227 // RotateBy(Quaternion relativeRotation)
1228 int UtcDaliActorRotateBy02(void)
1230 TestApplication application;
1232 Actor actor = Actor::New();
1234 Radian angle( M_PI * 0.25f );
1235 Quaternion rotation(angle, Vector3::ZAXIS);
1236 actor.RotateBy(rotation);
1237 // flush the queue and render once
1238 application.SendNotification();
1239 application.Render();
1240 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1242 actor.RotateBy(rotation);
1243 // flush the queue and render once
1244 application.SendNotification();
1245 application.Render();
1246 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1250 int UtcDaliActorGetCurrentOrientation(void)
1252 TestApplication application;
1253 Actor actor = Actor::New();
1255 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1256 actor.SetOrientation(rotation);
1257 // flush the queue and render once
1258 application.SendNotification();
1259 application.Render();
1260 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1264 int UtcDaliActorGetCurrentWorldOrientation(void)
1266 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1267 TestApplication application;
1269 Actor parent = Actor::New();
1270 Radian rotationAngle( Degree(90.0f) );
1271 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1272 parent.SetOrientation( rotation );
1273 Stage::GetCurrent().Add( parent );
1275 Actor child = Actor::New();
1276 child.SetOrientation( rotation );
1277 parent.Add( child );
1279 // The actors should not have a world rotation yet
1280 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1281 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1283 application.SendNotification();
1284 application.Render(0);
1286 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1287 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1289 // The actors should have a world rotation now
1290 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1291 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1293 // turn off child rotation inheritance
1294 child.SetInheritOrientation( false );
1295 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1296 application.SendNotification();
1297 application.Render(0);
1299 // The actors should have a world rotation now
1300 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1301 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1305 // SetScale(float scale)
1306 int UtcDaliActorSetScale01(void)
1308 TestApplication application;
1310 Actor actor = Actor::New();
1312 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1313 actor.SetScale(0.25f);
1315 Vector3 scale(10.0f, 10.0f, 10.0f);
1316 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1318 actor.SetScale(scale.x);
1320 // flush the queue and render once
1321 application.SendNotification();
1322 application.Render();
1324 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1328 // SetScale(float scaleX, float scaleY, float scaleZ)
1329 int UtcDaliActorSetScale02(void)
1331 TestApplication application;
1332 Vector3 scale(10.0f, 10.0f, 10.0f);
1334 Actor actor = Actor::New();
1336 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1337 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1339 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1341 actor.SetScale(scale.x, scale.y, scale.z);
1342 // flush the queue and render once
1343 application.SendNotification();
1344 application.Render();
1345 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1347 // add to stage and test
1348 Stage::GetCurrent().Add( actor );
1349 actor.SetScale( 2.0f, 2.0f, 2.0f );
1350 // flush the queue and render once
1351 application.SendNotification();
1352 application.Render();
1353 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1355 Stage::GetCurrent().Remove( actor );
1360 // SetScale(Vector3 scale)
1361 int UtcDaliActorSetScale03(void)
1363 TestApplication application;
1364 Vector3 scale(10.0f, 10.0f, 10.0f);
1366 Actor actor = Actor::New();
1368 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1369 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1371 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1373 actor.SetScale(scale);
1375 // flush the queue and render once
1376 application.SendNotification();
1377 application.Render();
1379 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1383 int UtcDaliActorScaleBy(void)
1385 TestApplication application;
1386 Actor actor = Actor::New();
1387 Vector3 vector(100.0f, 100.0f, 100.0f);
1389 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1391 actor.SetScale(vector);
1393 // flush the queue and render once
1394 application.SendNotification();
1395 application.Render();
1397 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1399 actor.ScaleBy(vector);
1401 // flush the queue and render once
1402 application.SendNotification();
1403 application.Render();
1405 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1409 int UtcDaliActorGetCurrentScale(void)
1411 TestApplication application;
1412 Vector3 scale(12.0f, 1.0f, 2.0f);
1414 Actor actor = Actor::New();
1416 actor.SetScale(scale);
1418 // flush the queue and render once
1419 application.SendNotification();
1420 application.Render();
1422 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1426 int UtcDaliActorGetCurrentWorldScale(void)
1428 TestApplication application;
1430 Actor parent = Actor::New();
1431 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1432 parent.SetScale( parentScale );
1433 Stage::GetCurrent().Add( parent );
1435 Actor child = Actor::New();
1436 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1437 child.SetScale( childScale );
1438 parent.Add( child );
1440 // The actors should not have a scale yet
1441 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1442 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1444 // The actors should not have a world scale yet
1445 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1446 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1448 application.SendNotification();
1449 application.Render(0);
1451 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1452 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1454 // The actors should have a world scale now
1455 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1456 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1460 int UtcDaliActorInheritScale(void)
1462 tet_infoline("Testing Actor::SetInheritScale");
1463 TestApplication application;
1465 Actor parent = Actor::New();
1466 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1467 parent.SetScale( parentScale );
1468 Stage::GetCurrent().Add( parent );
1470 Actor child = Actor::New();
1471 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1472 child.SetScale( childScale );
1473 parent.Add( child );
1475 application.SendNotification();
1476 application.Render(0);
1478 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1479 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1481 child.SetInheritScale( false );
1482 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1484 application.SendNotification();
1485 application.Render(0);
1487 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1491 int UtcDaliActorSetVisible(void)
1493 TestApplication application;
1495 Actor actor = Actor::New();
1496 actor.SetVisible(false);
1497 // flush the queue and render once
1498 application.SendNotification();
1499 application.Render();
1500 DALI_TEST_CHECK(actor.IsVisible() == false);
1502 actor.SetVisible(true);
1503 // flush the queue and render once
1504 application.SendNotification();
1505 application.Render();
1506 DALI_TEST_CHECK(actor.IsVisible() == true);
1508 // put actor on stage
1509 Stage::GetCurrent().Add( actor );
1510 actor.SetVisible(false);
1511 // flush the queue and render once
1512 application.SendNotification();
1513 application.Render();
1514 DALI_TEST_CHECK(actor.IsVisible() == false);
1518 int UtcDaliActorIsVisible(void)
1520 TestApplication application;
1522 Actor actor = Actor::New();
1524 DALI_TEST_CHECK(actor.IsVisible() == true);
1528 int UtcDaliActorSetOpacity(void)
1530 TestApplication application;
1532 Actor actor = Actor::New();
1533 // initial opacity is 1
1534 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1536 actor.SetOpacity( 0.4f);
1537 // flush the queue and render once
1538 application.SendNotification();
1539 application.Render();
1540 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1542 // change opacity, actor is on stage to change is not immediate
1543 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1544 // flush the queue and render once
1545 application.SendNotification();
1546 application.Render();
1547 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1549 // put actor on stage
1550 Stage::GetCurrent().Add( actor );
1552 // change opacity, actor is on stage to change is not immediate
1553 actor.SetOpacity( 0.9f );
1554 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1555 // flush the queue and render once
1556 application.SendNotification();
1557 application.Render();
1558 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1560 // change opacity, actor is on stage to change is not immediate
1561 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1562 // flush the queue and render once
1563 application.SendNotification();
1564 application.Render();
1565 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1569 int UtcDaliActorGetCurrentOpacity(void)
1571 TestApplication application;
1573 Actor actor = Actor::New();
1574 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1576 actor.SetOpacity(0.5f);
1577 // flush the queue and render once
1578 application.SendNotification();
1579 application.Render();
1580 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1584 int UtcDaliActorSetSensitive(void)
1586 TestApplication application;
1587 Actor actor = Actor::New();
1589 bool sensitive = !actor.IsSensitive();
1591 actor.SetSensitive(sensitive);
1593 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1597 int UtcDaliActorIsSensitive(void)
1599 TestApplication application;
1600 Actor actor = Actor::New();
1601 actor.SetSensitive(false);
1603 DALI_TEST_CHECK(false == actor.IsSensitive());
1607 int UtcDaliActorSetColor(void)
1609 TestApplication application;
1610 Actor actor = Actor::New();
1611 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1613 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1615 actor.SetColor(color);
1616 // flush the queue and render once
1617 application.SendNotification();
1618 application.Render();
1619 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1621 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1622 // flush the queue and render once
1623 application.SendNotification();
1624 application.Render();
1625 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1627 Stage::GetCurrent().Add( actor );
1628 actor.SetColor( color );
1629 // flush the queue and render once
1630 application.SendNotification();
1631 application.Render();
1632 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1634 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1635 // flush the queue and render once
1636 application.SendNotification();
1637 application.Render();
1638 // Actor color is not clamped
1639 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1640 // world color is clamped
1641 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1643 Stage::GetCurrent().Remove( actor );
1647 int UtcDaliActorGetCurrentColor(void)
1649 TestApplication application;
1650 Actor actor = Actor::New();
1651 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1653 actor.SetColor(color);
1654 // flush the queue and render once
1655 application.SendNotification();
1656 application.Render();
1657 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1661 int UtcDaliActorGetCurrentWorldColor(void)
1663 tet_infoline("Actor::GetCurrentWorldColor");
1664 TestApplication application;
1666 Actor parent = Actor::New();
1667 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1668 parent.SetColor( parentColor );
1669 Stage::GetCurrent().Add( parent );
1671 Actor child = Actor::New();
1672 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1673 child.SetColor( childColor );
1674 parent.Add( child );
1676 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1677 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1679 // verify the default color mode
1680 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1682 // The actors should not have a world color yet
1683 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1684 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1686 application.SendNotification();
1687 application.Render(0);
1689 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1690 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1692 // The actors should have a world color now
1693 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1694 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1697 child.SetColorMode( USE_OWN_COLOR );
1698 application.SendNotification();
1699 application.Render(0);
1700 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1703 child.SetColorMode( USE_PARENT_COLOR );
1704 application.SendNotification();
1705 application.Render(0);
1706 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1707 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1710 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1711 application.SendNotification();
1712 application.Render(0);
1713 Vector4 expectedColor( childColor );
1714 expectedColor.a *= parentColor.a;
1715 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1716 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1720 int UtcDaliActorSetColorMode(void)
1722 tet_infoline("Actor::SetColorMode");
1723 TestApplication application;
1724 Actor actor = Actor::New();
1725 Actor child = Actor::New();
1728 actor.SetColorMode( USE_OWN_COLOR );
1729 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1731 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1732 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1734 actor.SetColorMode( USE_PARENT_COLOR );
1735 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1737 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1738 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1742 int UtcDaliActorScreenToLocal(void)
1744 TestApplication application;
1745 Actor actor = Actor::New();
1746 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1747 actor.SetSize(100.0f, 100.0f);
1748 actor.SetPosition(10.0f, 10.0f);
1749 Stage::GetCurrent().Add(actor);
1751 // flush the queue and render once
1752 application.SendNotification();
1753 application.Render();
1758 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1760 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1761 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1765 int UtcDaliActorSetLeaveRequired(void)
1767 TestApplication application;
1769 Actor actor = Actor::New();
1771 actor.SetLeaveRequired(false);
1772 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1774 actor.SetLeaveRequired(true);
1775 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1779 int UtcDaliActorGetLeaveRequired(void)
1781 TestApplication application;
1783 Actor actor = Actor::New();
1785 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1789 int UtcDaliActorSetKeyboardFocusable(void)
1791 TestApplication application;
1793 Actor actor = Actor::New();
1795 actor.SetKeyboardFocusable(true);
1796 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1798 actor.SetKeyboardFocusable(false);
1799 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1803 int UtcDaliActorIsKeyboardFocusable(void)
1805 TestApplication application;
1807 Actor actor = Actor::New();
1809 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1813 int UtcDaliActorRemoveConstraints(void)
1815 tet_infoline(" UtcDaliActorRemoveConstraints");
1816 TestApplication application;
1818 gTestConstraintCalled = false;
1820 Actor actor = Actor::New();
1822 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
1824 actor.RemoveConstraints();
1826 DALI_TEST_CHECK( gTestConstraintCalled == false );
1828 Stage::GetCurrent().Add( actor );
1831 // flush the queue and render once
1832 application.SendNotification();
1833 application.Render();
1835 actor.RemoveConstraints();
1837 DALI_TEST_CHECK( gTestConstraintCalled == true );
1841 int UtcDaliActorRemoveConstraintTag(void)
1843 tet_infoline(" UtcDaliActorRemoveConstraintTag");
1844 TestApplication application;
1846 Actor actor = Actor::New();
1848 // 1. Apply Constraint1 and Constraint2, and test...
1849 unsigned int result1 = 0u;
1850 unsigned int result2 = 0u;
1852 unsigned constraint1Tag = 1u;
1853 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
1854 constraint1.SetTag( constraint1Tag );
1855 constraint1.Apply();
1857 unsigned constraint2Tag = 2u;
1858 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
1859 constraint2.SetTag( constraint2Tag );
1860 constraint2.Apply();
1862 Stage::GetCurrent().Add( actor );
1863 // flush the queue and render once
1864 application.SendNotification();
1865 application.Render();
1867 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1868 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1870 // 2. Remove Constraint1 and test...
1873 actor.RemoveConstraints(constraint1Tag);
1874 // make color property dirty, which will trigger constraints to be reapplied.
1875 actor.SetColor( Color::WHITE );
1876 // flush the queue and render once
1877 application.SendNotification();
1878 application.Render();
1880 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1881 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1883 // 3. Re-Apply Constraint1 and test...
1886 constraint1.Apply();
1887 // make color property dirty, which will trigger constraints to be reapplied.
1888 actor.SetColor( Color::WHITE );
1889 // flush the queue and render once
1890 application.SendNotification();
1891 application.Render();
1893 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1894 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1896 // 2. Remove Constraint2 and test...
1899 actor.RemoveConstraints(constraint2Tag);
1900 // make color property dirty, which will trigger constraints to be reapplied.
1901 actor.SetColor( Color::WHITE );
1902 // flush the queue and render once
1903 application.SendNotification();
1904 application.Render();
1906 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1907 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1909 // 2. Remove Constraint1 as well and test...
1912 actor.RemoveConstraints(constraint1Tag);
1913 // make color property dirty, which will trigger constraints to be reapplied.
1914 actor.SetColor( Color::WHITE );
1915 // flush the queue and render once
1916 application.SendNotification();
1917 application.Render();
1919 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1920 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1924 int UtcDaliActorTouchedSignal(void)
1926 TestApplication application;
1928 gTouchCallBackCalled = false;
1930 // get the root layer
1931 Actor actor = Stage::GetCurrent().GetRootLayer();
1932 DALI_TEST_CHECK( gTouchCallBackCalled == false );
1934 application.SendNotification();
1935 application.Render();
1937 // connect to its touch signal
1938 actor.TouchedSignal().Connect( TestCallback );
1940 // simulate a touch event in the middle of the screen
1941 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1942 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
1943 Dali::Integration::TouchEvent event;
1944 event.AddPoint( point );
1945 application.ProcessEvent( event );
1947 DALI_TEST_CHECK( gTouchCallBackCalled == true );
1951 int UtcDaliActorHoveredSignal(void)
1953 TestApplication application;
1955 gHoverCallBackCalled = false;
1957 // get the root layer
1958 Actor actor = Stage::GetCurrent().GetRootLayer();
1959 DALI_TEST_CHECK( gHoverCallBackCalled == false );
1961 application.SendNotification();
1962 application.Render();
1964 // connect to its hover signal
1965 actor.HoveredSignal().Connect( TestCallback3 );
1967 // simulate a hover event in the middle of the screen
1968 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1969 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
1970 Dali::Integration::HoverEvent event;
1971 event.AddPoint( point );
1972 application.ProcessEvent( event );
1974 DALI_TEST_CHECK( gHoverCallBackCalled == true );
1978 int UtcDaliActorOnOffStageSignal(void)
1980 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
1982 TestApplication application;
1985 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
1986 gActorNamesOnOffStage.clear();
1988 Actor parent = Actor::New();
1989 parent.SetName( "parent" );
1990 parent.OnStageSignal().Connect( OnStageCallback );
1991 parent.OffStageSignal().Connect( OffStageCallback );
1993 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
1994 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
1996 // add parent to stage
1997 Stage::GetCurrent().Add( parent );
1998 // onstage emitted, offstage not
1999 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2000 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2001 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2003 // test adding a child, should get onstage emitted
2005 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2006 gActorNamesOnOffStage.clear();
2008 Actor child = Actor::New();
2009 child.SetName( "child" );
2010 child.OnStageSignal().Connect( OnStageCallback );
2011 child.OffStageSignal().Connect( OffStageCallback );
2012 parent.Add( child ); // add child
2013 // onstage emitted, offstage not
2014 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2015 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2016 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2018 // test removing parent from stage
2020 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2021 gActorNamesOnOffStage.clear();
2023 Stage::GetCurrent().Remove( parent );
2024 // onstage not emitted, offstage is
2025 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2026 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2027 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2028 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2030 // test adding parent back to stage
2032 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2033 gActorNamesOnOffStage.clear();
2035 Stage::GetCurrent().Add( parent );
2036 // onstage emitted, offstage not
2037 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2038 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2039 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2040 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2042 // test removing child
2044 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2045 gActorNamesOnOffStage.clear();
2047 parent.Remove( child );
2048 // onstage not emitted, offstage is
2049 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2050 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2051 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2053 // test removing parent
2055 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2056 gActorNamesOnOffStage.clear();
2058 Stage::GetCurrent().Remove( parent );
2059 // onstage not emitted, offstage is
2060 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2061 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2062 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2066 int UtcDaliActorFindChildByName(void)
2068 tet_infoline("Testing Dali::Actor::FindChildByName()");
2069 TestApplication application;
2071 Actor parent = Actor::New();
2072 parent.SetName( "parent" );
2073 Actor first = Actor::New();
2074 first .SetName( "first" );
2075 Actor second = Actor::New();
2076 second.SetName( "second" );
2081 Actor found = parent.FindChildByName( "foo" );
2082 DALI_TEST_CHECK( !found );
2084 found = parent.FindChildByName( "parent" );
2085 DALI_TEST_CHECK( found == parent );
2087 found = parent.FindChildByName( "first" );
2088 DALI_TEST_CHECK( found == first );
2090 found = parent.FindChildByName( "second" );
2091 DALI_TEST_CHECK( found == second );
2095 int UtcDaliActorFindChildById(void)
2097 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2098 TestApplication application;
2100 Actor parent = Actor::New();
2101 Actor first = Actor::New();
2102 Actor second = Actor::New();
2107 Actor found = parent.FindChildById( 100000 );
2108 DALI_TEST_CHECK( !found );
2110 found = parent.FindChildById( parent.GetId() );
2111 DALI_TEST_CHECK( found == parent );
2113 found = parent.FindChildById( first.GetId() );
2114 DALI_TEST_CHECK( found == first );
2116 found = parent.FindChildById( second.GetId() );
2117 DALI_TEST_CHECK( found == second );
2121 int UtcDaliActorHitTest(void)
2126 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2128 mTouchPoint( touchPoint ),
2133 Vector2 mTouchPoint;
2137 TestApplication application;
2138 tet_infoline(" UtcDaliActorHitTest");
2140 // Fill a vector with different hit tests.
2141 struct HitTestData* hitTestData[] = {
2142 // scale touch point result
2143 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2144 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2145 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.
2146 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2147 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.
2151 // get the root layer
2152 Actor actor = Actor::New();
2153 actor.SetAnchorPoint( AnchorPoint::CENTER );
2154 actor.SetParentOrigin( ParentOrigin::CENTER );
2156 Stage::GetCurrent().Add( actor );
2158 gTouchCallBackCalled = false;
2160 unsigned int index = 0;
2161 while( NULL != hitTestData[index] )
2163 actor.SetSize( 1.f, 1.f );
2164 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2166 // flush the queue and render once
2167 application.SendNotification();
2168 application.Render();
2170 DALI_TEST_CHECK( !gTouchCallBackCalled );
2172 // connect to its touch signal
2173 actor.TouchedSignal().Connect(TestCallback);
2175 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2176 Dali::Integration::TouchEvent event;
2177 event.AddPoint( point );
2179 // flush the queue and render once
2180 application.SendNotification();
2181 application.Render();
2182 application.ProcessEvent( event );
2184 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2186 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2187 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2188 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2189 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2190 hitTestData[index]->mResult );
2192 gTouchCallBackCalled = false;
2198 int UtcDaliActorSetDrawMode(void)
2200 TestApplication app;
2201 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2203 Actor a = Actor::New();
2205 Stage::GetCurrent().Add(a);
2206 app.SendNotification();
2208 app.SendNotification();
2211 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2213 a.SetDrawMode( DrawMode::OVERLAY );
2214 app.SendNotification();
2217 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2219 a.SetDrawMode( DrawMode::STENCIL );
2220 app.SendNotification();
2223 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2225 a.SetDrawMode( DrawMode::NORMAL );
2226 app.SendNotification();
2229 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2233 int UtcDaliActorSetDrawModeOverlayRender(void)
2235 TestApplication app;
2236 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2238 app.SendNotification();
2241 std::vector<GLuint> ids;
2242 ids.push_back( 8 ); // first rendered actor
2243 ids.push_back( 9 ); // second rendered actor
2244 ids.push_back( 10 ); // third rendered actor
2245 app.GetGlAbstraction().SetNextTextureIds( ids );
2247 BufferImage imageA = BufferImage::New(16, 16);
2248 BufferImage imageB = BufferImage::New(16, 16);
2249 BufferImage imageC = BufferImage::New(16, 16);
2250 ImageActor a = ImageActor::New( imageA );
2251 ImageActor b = ImageActor::New( imageB );
2252 ImageActor c = ImageActor::New( imageC );
2254 // Render a,b,c as regular non-overlays. so order will be:
2258 Stage::GetCurrent().Add(a);
2259 Stage::GetCurrent().Add(b);
2260 Stage::GetCurrent().Add(c);
2262 app.SendNotification();
2265 // Should be 3 textures changes.
2266 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2267 typedef std::vector<GLuint>::size_type TextureSize;
2268 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2269 if( boundTextures.size() == 3 )
2271 DALI_TEST_CHECK( boundTextures[0] == 8u );
2272 DALI_TEST_CHECK( boundTextures[1] == 9u );
2273 DALI_TEST_CHECK( boundTextures[2] == 10u );
2276 // Now texture ids have been set, we can monitor their render order.
2277 // render a as an overlay (last), so order will be:
2281 a.SetDrawMode( DrawMode::OVERLAY );
2282 app.GetGlAbstraction().ClearBoundTextures();
2284 app.SendNotification();
2287 // Should be 3 texture changes.
2288 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2289 if( boundTextures.size() == 3 )
2291 DALI_TEST_CHECK( boundTextures[0] == 9u );
2292 DALI_TEST_CHECK( boundTextures[1] == 10u );
2293 DALI_TEST_CHECK( boundTextures[2] == 8u );
2298 int UtcDaliActorGetCurrentWorldMatrix(void)
2300 TestApplication app;
2301 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2303 Actor parent = Actor::New();
2304 parent.SetParentOrigin(ParentOrigin::CENTER);
2305 parent.SetAnchorPoint(AnchorPoint::CENTER);
2306 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2307 Radian rotationAngle(Degree(85.0f));
2308 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2309 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2310 parent.SetPosition( parentPosition );
2311 parent.SetOrientation( parentRotation );
2312 parent.SetScale( parentScale );
2313 Stage::GetCurrent().Add( parent );
2315 Actor child = Actor::New();
2316 child.SetParentOrigin(ParentOrigin::CENTER);
2317 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2318 Radian childRotationAngle(Degree(23.0f));
2319 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2320 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2321 child.SetPosition( childPosition );
2322 child.SetOrientation( childRotation );
2323 child.SetScale( childScale );
2324 parent.Add( child );
2326 // The actors should not have a world matrix yet
2327 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2328 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2330 app.SendNotification();
2333 app.SendNotification();
2335 Matrix parentMatrix(false);
2336 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2338 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2339 Quaternion childWorldRotation = parentRotation * childRotation;
2340 Vector3 childWorldScale = parentScale * childScale;
2342 Matrix childWorldMatrix(false);
2343 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2345 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2346 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2352 int UtcDaliActorConstrainedToWorldMatrix(void)
2354 TestApplication app;
2355 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2357 Actor parent = Actor::New();
2358 parent.SetParentOrigin(ParentOrigin::CENTER);
2359 parent.SetAnchorPoint(AnchorPoint::CENTER);
2360 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2361 Radian rotationAngle(Degree(85.0f));
2362 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2363 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2364 parent.SetPosition( parentPosition );
2365 parent.SetOrientation( parentRotation );
2366 parent.SetScale( parentScale );
2367 Stage::GetCurrent().Add( parent );
2369 Actor child = Actor::New();
2370 child.SetParentOrigin(ParentOrigin::CENTER);
2371 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2372 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2373 posConstraint.Apply();
2375 Stage::GetCurrent().Add( child );
2377 // The actors should not have a world matrix yet
2378 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2379 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2381 app.SendNotification();
2384 app.SendNotification();
2386 Matrix parentMatrix(false);
2387 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2389 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2390 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2394 int UtcDaliActorUnparent(void)
2396 TestApplication app;
2397 tet_infoline(" UtcDaliActorUnparent");
2399 Actor parent = Actor::New();
2400 Stage::GetCurrent().Add( parent );
2402 Actor child = Actor::New();
2404 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2405 DALI_TEST_CHECK( !child.GetParent() );
2407 // Test that calling Unparent with no parent is a NOOP
2410 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2411 DALI_TEST_CHECK( !child.GetParent() );
2413 // Test that Unparent works
2414 parent.Add( child );
2416 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2417 DALI_TEST_CHECK( parent == child.GetParent() );
2421 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2422 DALI_TEST_CHECK( !child.GetParent() );
2424 // Test that UnparentAndReset works
2425 parent.Add( child );
2427 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2428 DALI_TEST_CHECK( parent == child.GetParent() );
2430 UnparentAndReset( child );
2432 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2433 DALI_TEST_CHECK( !child );
2435 // Test that UnparentAndReset is a NOOP with empty handle
2436 UnparentAndReset( child );
2438 DALI_TEST_CHECK( !child );
2442 int UtcDaliActorGetChildAt(void)
2444 TestApplication app;
2445 tet_infoline(" UtcDaliActorGetChildAt");
2447 Actor parent = Actor::New();
2448 Stage::GetCurrent().Add( parent );
2450 Actor child0 = Actor::New();
2451 parent.Add( child0 );
2453 Actor child1 = Actor::New();
2454 parent.Add( child1 );
2456 Actor child2 = Actor::New();
2457 parent.Add( child2 );
2459 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2460 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2461 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2465 int UtcDaliActorSetGetOverlay(void)
2467 TestApplication app;
2468 tet_infoline(" UtcDaliActorSetGetOverlay");
2470 Actor parent = Actor::New();
2471 parent.SetDrawMode(DrawMode::OVERLAY );
2472 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2477 // Current Dynamics functions are crashing, so testing these sections are futile
2479 int UtcDaliActorDynamics(void)
2481 DALI_TEST_CHECK( true );
2485 int UtcDaliActorCreateDestroy(void)
2487 Actor* actor = new Actor;
2488 DALI_TEST_CHECK( actor );
2495 struct PropertyStringIndex
2497 const char * const name;
2498 const Property::Index index;
2499 const Property::Type type;
2502 const PropertyStringIndex PROPERTY_TABLE[] =
2504 { "parent-origin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2505 { "parent-origin-x", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2506 { "parent-origin-y", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2507 { "parent-origin-z", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2508 { "anchor-point", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2509 { "anchor-point-x", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2510 { "anchor-point-y", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2511 { "anchor-point-z", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2512 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2513 { "size-width", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2514 { "size-height", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2515 { "size-depth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2516 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2517 { "position-x", Actor::Property::POSITION_X, Property::FLOAT },
2518 { "position-y", Actor::Property::POSITION_Y, Property::FLOAT },
2519 { "position-z", Actor::Property::POSITION_Z, Property::FLOAT },
2520 { "world-position", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2521 { "world-position-x", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2522 { "world-position-y", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2523 { "world-position-z", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2524 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2525 { "world-orientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2526 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2527 { "scale-x", Actor::Property::SCALE_X, Property::FLOAT },
2528 { "scale-y", Actor::Property::SCALE_Y, Property::FLOAT },
2529 { "scale-z", Actor::Property::SCALE_Z, Property::FLOAT },
2530 { "world-scale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2531 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2532 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2533 { "color-red", Actor::Property::COLOR_RED, Property::FLOAT },
2534 { "color-green", Actor::Property::COLOR_GREEN, Property::FLOAT },
2535 { "color-blue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2536 { "color-alpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2537 { "world-color", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2538 { "world-matrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2539 { "name", Actor::Property::NAME, Property::STRING },
2540 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2541 { "leave-required", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2542 { "inherit-orientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2543 { "inherit-scale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2544 { "color-mode", Actor::Property::COLOR_MODE, Property::STRING },
2545 { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2546 { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING },
2547 { "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2548 { "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2549 { "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2550 { "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2551 { "width-for-height", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2552 { "height-for-width", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2553 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2554 { "minimum-size", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2555 { "maximum-size", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2557 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2558 } // unnamed namespace
2560 int UtcDaliActorProperties(void)
2562 TestApplication app;
2564 Actor actor = Actor::New();
2566 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2568 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2569 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2570 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2571 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2576 int UtcDaliRelayoutProperties_ResizePolicies(void)
2578 TestApplication app;
2580 Actor actor = Actor::New();
2583 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2584 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2586 // Set resize policy for all dimensions
2587 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2588 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2590 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2593 // Set individual dimensions
2594 const char* const widthPolicy = "FILL_TO_PARENT";
2595 const char* const heightPolicy = "FIXED";
2597 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2598 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2600 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2601 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2606 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2608 TestApplication app;
2610 Actor actor = Actor::New();
2613 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2614 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2616 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2617 actor.SetSizeScalePolicy( policy );
2618 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2621 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2622 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2624 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2625 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2627 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2628 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2633 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2635 TestApplication app;
2637 Actor actor = Actor::New();
2640 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2641 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2643 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2644 actor.SetSizeModeFactor( sizeMode );
2645 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2648 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2650 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2651 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2656 int UtcDaliRelayoutProperties_DimensionDependency(void)
2658 TestApplication app;
2660 Actor actor = Actor::New();
2663 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2664 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2667 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2668 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2670 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2671 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2673 // Test setting another resize policy
2674 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2675 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2680 int UtcDaliRelayoutProperties_Padding(void)
2682 TestApplication app;
2684 Actor actor = Actor::New();
2687 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2690 actor.SetProperty( Actor::Property::PADDING, padding );
2691 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2693 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2698 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2700 TestApplication app;
2702 Actor actor = Actor::New();
2705 Vector2 minSize( 1.0f, 2.0f );
2707 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2708 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2710 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2712 Vector2 maxSize( 3.0f, 4.0f );
2714 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2715 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2717 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2722 int UtcDaliActorGetHeightForWidth(void)
2724 TestApplication app;
2726 Actor actor = Actor::New();
2728 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
2733 int UtcDaliActorGetWidthForHeight(void)
2735 TestApplication app;
2737 Actor actor = Actor::New();
2739 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
2744 int UtcDaliActorGetRelayoutSize(void)
2746 TestApplication app;
2748 Actor actor = Actor::New();
2750 // Add actor to stage
2751 Stage::GetCurrent().Add( actor );
2753 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
2755 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
2756 actor.SetSize( Vector2( 1.0f, 0.0f ) );
2758 // Flush the queue and render once
2759 app.SendNotification();
2762 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
2767 int UtcDaliActorSetPadding(void)
2769 TestApplication app;
2771 Actor actor = Actor::New();
2774 actor.GetPadding( padding );
2776 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
2777 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
2778 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
2779 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
2781 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
2782 actor.SetPadding( padding2 );
2784 actor.GetPadding( padding );
2786 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
2787 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
2788 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
2789 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
2794 int UtcDaliActorSetMinimumSize(void)
2796 TestApplication app;
2798 Actor actor = Actor::New();
2800 Vector2 size = actor.GetMinimumSize();
2802 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
2803 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
2805 Vector2 size2( 1.0f, 2.0f );
2806 actor.SetMinimumSize( size2 );
2808 size = actor.GetMinimumSize();
2810 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2811 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2816 int UtcDaliActorSetMaximumSize(void)
2818 TestApplication app;
2820 Actor actor = Actor::New();
2822 Vector2 size = actor.GetMaximumSize();
2824 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
2825 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
2827 Vector2 size2( 1.0f, 2.0f );
2828 actor.SetMaximumSize( size2 );
2830 size = actor.GetMaximumSize();
2832 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2833 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2838 int UtcDaliActorOnRelayoutSignal(void)
2840 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
2842 TestApplication application;
2845 gOnRelayoutCallBackCalled = 0;
2846 gActorNamesRelayout.clear();
2848 Actor actor = Actor::New();
2849 actor.SetName( "actor" );
2850 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
2853 DALI_TEST_CHECK( gOnRelayoutCallBackCalled == 0 );
2855 // Add actor to stage
2856 Stage::GetCurrent().Add( actor );
2858 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2859 actor.SetSize( Vector2( 1.0f, 2.0 ) );
2861 // Flush the queue and render once
2862 application.SendNotification();
2863 application.Render();
2865 // OnRelayout emitted
2866 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, 1, TEST_LOCATION );
2867 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );