2 * Copyright (c) 2015 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 UtcDaliActorRemoveN(void)
411 tet_infoline("Testing Actor::Remove");
412 TestApplication application;
414 Actor parent = Actor::New();
415 Actor child = Actor::New();
416 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
419 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
421 parent.Remove(child);
422 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
424 // remove again, no problem
425 parent.Remove(child);
426 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
430 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
431 // try Remove self, its a no-op
432 parent.Remove( parent );
433 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
439 parent.Remove( empty );
440 tet_printf("Assertion test failed - no Exception\n" );
441 tet_result(TET_FAIL);
443 catch(Dali::DaliException& e)
445 DALI_TEST_PRINT_ASSERT( e );
446 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
447 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
451 tet_printf("Assertion test failed - wrong Exception\n" );
452 tet_result(TET_FAIL);
457 int UtcDaliActorRemoveP(void)
459 TestApplication application;
461 Actor parent = Actor::New();
462 Actor child = Actor::New();
463 Actor random = Actor::New();
465 Stage::GetCurrent().Add( parent );
467 DALI_TEST_CHECK(parent.GetChildCount() == 0);
471 DALI_TEST_CHECK(parent.GetChildCount() == 1);
473 parent.Remove(random);
475 DALI_TEST_CHECK(parent.GetChildCount() == 1);
477 Stage::GetCurrent().Remove( parent );
479 DALI_TEST_CHECK(parent.GetChildCount() == 1);
483 int UtcDaliActorGetChildCount(void)
485 TestApplication application;
487 Actor parent = Actor::New();
488 Actor child = Actor::New();
490 DALI_TEST_CHECK(parent.GetChildCount() == 0);
494 DALI_TEST_CHECK(parent.GetChildCount() == 1);
498 int UtcDaliActorGetChildren01(void)
500 TestApplication application;
502 Actor parent = Actor::New();
503 Actor first = Actor::New();
504 Actor second = Actor::New();
505 Actor third = Actor::New();
511 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
512 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
513 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
517 int UtcDaliActorGetChildren02(void)
519 TestApplication application;
521 Actor parent = Actor::New();
522 Actor first = Actor::New();
523 Actor second = Actor::New();
524 Actor third = Actor::New();
530 const Actor& constParent = parent;
532 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
533 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
534 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
538 int UtcDaliActorGetParent01(void)
540 TestApplication application;
542 Actor parent = Actor::New();
543 Actor child = Actor::New();
547 DALI_TEST_CHECK(child.GetParent() == parent);
551 int UtcDaliActorGetParent02(void)
553 TestApplication application;
555 Actor actor = Actor::New();
557 DALI_TEST_CHECK(!actor.GetParent());
561 int UtcDaliActorSetParentOrigin(void)
563 TestApplication application;
565 Actor actor = Actor::New();
567 Vector3 vector(0.7f, 0.8f, 0.9f);
568 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
570 actor.SetParentOrigin(vector);
572 // flush the queue and render once
573 application.SendNotification();
574 application.Render();
576 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
578 Stage::GetCurrent().Add( actor );
580 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
582 // flush the queue and render once
583 application.SendNotification();
584 application.Render();
586 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
588 Stage::GetCurrent().Remove( actor );
592 int UtcDaliActorGetCurrentParentOrigin(void)
594 TestApplication application;
596 Actor actor = Actor::New();
598 Vector3 vector(0.7f, 0.8f, 0.9f);
599 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
601 actor.SetParentOrigin(vector);
603 // flush the queue and render once
604 application.SendNotification();
605 application.Render();
607 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
611 int UtcDaliActorSetAnchorPoint(void)
613 TestApplication application;
615 Actor actor = Actor::New();
617 Vector3 vector(0.7f, 0.8f, 0.9f);
618 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
620 actor.SetAnchorPoint(vector);
622 // flush the queue and render once
623 application.SendNotification();
624 application.Render();
626 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
628 Stage::GetCurrent().Add( actor );
630 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
631 // flush the queue and render once
632 application.SendNotification();
633 application.Render();
635 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
637 Stage::GetCurrent().Remove( actor );
641 int UtcDaliActorGetCurrentAnchorPoint(void)
643 TestApplication application;
645 Actor actor = Actor::New();
647 Vector3 vector(0.7f, 0.8f, 0.9f);
648 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
650 actor.SetAnchorPoint(vector);
652 // flush the queue and render once
653 application.SendNotification();
654 application.Render();
656 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
660 // SetSize(float width, float height)
661 int UtcDaliActorSetSize01(void)
663 TestApplication application;
665 Actor actor = Actor::New();
666 Vector3 vector(100.0f, 100.0f, 0.0f);
668 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
670 actor.SetSize(vector.x, vector.y);
672 // flush the queue and render once
673 application.SendNotification();
674 application.Render();
676 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
680 // SetSize(float width, float height, float depth)
681 int UtcDaliActorSetSize02(void)
683 TestApplication application;
685 Actor actor = Actor::New();
686 Vector3 vector(100.0f, 100.0f, 100.0f);
688 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
690 actor.SetSize(vector.x, vector.y, vector.z);
692 // flush the queue and render once
693 application.SendNotification();
694 application.Render();
696 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
700 // SetSize(Vector2 size)
701 int UtcDaliActorSetSize03(void)
703 TestApplication application;
705 Actor actor = Actor::New();
706 Vector3 vector(100.0f, 100.0f, 0.0f);
708 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
710 actor.SetSize(Vector2(vector.x, vector.y));
712 // flush the queue and render once
713 application.SendNotification();
714 application.Render();
716 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
720 // SetSize(Vector3 size)
721 int UtcDaliActorSetSize04(void)
723 TestApplication application;
725 Actor actor = Actor::New();
726 Vector3 vector(100.0f, 100.0f, 100.0f);
728 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
730 actor.SetSize(vector);
732 // flush the queue and render once
733 application.SendNotification();
734 application.Render();
736 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
738 Stage::GetCurrent().Add( actor );
739 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
741 // flush the queue and render once
742 application.SendNotification();
743 application.Render();
745 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
746 Stage::GetCurrent().Remove( actor );
750 int UtcDaliActorGetCurrentSize(void)
752 TestApplication application;
754 Actor actor = Actor::New();
755 Vector3 vector(100.0f, 100.0f, 20.0f);
757 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
759 actor.SetSize(vector);
761 // flush the queue and render once
762 application.SendNotification();
763 application.Render();
765 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
769 int UtcDaliActorGetNaturalSize(void)
771 TestApplication application;
773 Actor actor = Actor::New();
774 Vector3 vector( 0.0f, 0.0f, 0.0f );
776 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
781 int UtcDaliActorGetCurrentSizeImmediate(void)
783 TestApplication application;
785 Actor actor = Actor::New();
786 Vector3 vector(100.0f, 100.0f, 20.0f);
788 DALI_TEST_CHECK(vector != actor.GetTargetSize());
789 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
791 actor.SetSize(vector);
793 DALI_TEST_CHECK(vector == actor.GetTargetSize());
794 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
796 // flush the queue and render once
797 application.SendNotification();
798 application.Render();
800 DALI_TEST_CHECK(vector == actor.GetTargetSize());
801 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
804 // Build the animation
805 const float durationSeconds = 2.0f;
806 Animation animation = Animation::New( durationSeconds );
807 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
808 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
810 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
812 // Start the animation
815 application.SendNotification();
816 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
818 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
823 // SetPosition(float x, float y)
824 int UtcDaliActorSetPosition01(void)
826 TestApplication application;
828 Actor actor = Actor::New();
830 // Set to random to start off with
831 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
833 Vector3 vector(100.0f, 100.0f, 0.0f);
835 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
837 actor.SetPosition(vector.x, vector.y);
838 // flush the queue and render once
839 application.SendNotification();
840 application.Render();
841 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
843 Stage::GetCurrent().Add( actor );
844 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
845 // flush the queue and render once
846 application.SendNotification();
847 application.Render();
848 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
853 // flush the queue and render once
854 application.SendNotification();
855 application.Render();
856 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
858 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
859 // flush the queue and render once
860 application.SendNotification();
861 application.Render();
862 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
864 Stage::GetCurrent().Remove( actor );
868 // SetPosition(float x, float y, float z)
869 int UtcDaliActorSetPosition02(void)
871 TestApplication application;
873 Actor actor = Actor::New();
875 // Set to random to start off with
876 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
878 Vector3 vector(100.0f, 100.0f, 100.0f);
880 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
882 actor.SetPosition(vector.x, vector.y, vector.z);
884 // flush the queue and render once
885 application.SendNotification();
886 application.Render();
888 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
892 // SetPosition(Vector3 position)
893 int UtcDaliActorSetPosition03(void)
895 TestApplication application;
897 Actor actor = Actor::New();
899 // Set to random to start off with
900 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
902 Vector3 vector(100.0f, 100.0f, 100.0f);
904 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
906 actor.SetPosition(vector);
908 // flush the queue and render once
909 application.SendNotification();
910 application.Render();
912 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
916 int UtcDaliActorSetX(void)
918 TestApplication application;
920 Actor actor = Actor::New();
922 Vector3 vector(100.0f, 0.0f, 0.0f);
924 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
928 // flush the queue and render once
929 application.SendNotification();
930 application.Render();
932 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
936 int UtcDaliActorSetY(void)
938 TestApplication application;
940 Actor actor = Actor::New();
942 Vector3 vector(0.0f, 100.0f, 0.0f);
944 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
948 // flush the queue and render once
949 application.SendNotification();
950 application.Render();
952 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
956 int UtcDaliActorSetZ(void)
958 TestApplication application;
960 Actor actor = Actor::New();
962 Vector3 vector(0.0f, 0.0f, 100.0f);
964 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
968 // flush the queue and render once
969 application.SendNotification();
970 application.Render();
972 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
976 int UtcDaliActorTranslateBy(void)
978 TestApplication application;
980 Actor actor = Actor::New();
981 Vector3 vector(100.0f, 100.0f, 100.0f);
983 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
985 actor.SetPosition(vector);
987 // flush the queue and render once
988 application.SendNotification();
989 application.Render();
991 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
993 actor.TranslateBy(vector);
995 // flush the queue and render once
996 application.SendNotification();
997 application.Render();
999 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1003 int UtcDaliActorGetCurrentPosition(void)
1005 TestApplication application;
1007 Actor actor = Actor::New();
1008 Vector3 setVector(100.0f, 100.0f, 0.0f);
1009 actor.SetPosition(setVector);
1011 // flush the queue and render once
1012 application.SendNotification();
1013 application.Render();
1015 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1019 int UtcDaliActorGetCurrentWorldPosition(void)
1021 TestApplication application;
1023 Actor parent = Actor::New();
1024 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1025 parent.SetPosition( parentPosition );
1026 parent.SetParentOrigin( ParentOrigin::CENTER );
1027 parent.SetAnchorPoint( AnchorPoint::CENTER );
1028 Stage::GetCurrent().Add( parent );
1030 Actor child = Actor::New();
1031 child.SetParentOrigin( ParentOrigin::CENTER );
1032 child.SetAnchorPoint( AnchorPoint::CENTER );
1033 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1034 child.SetPosition( childPosition );
1035 parent.Add( child );
1037 // The actors should not have a world position yet
1038 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1039 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1041 application.SendNotification();
1042 application.Render(0);
1044 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1045 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1047 // The actors should have a world position now
1048 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1049 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1053 int UtcDaliActorInheritPosition(void)
1055 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1056 TestApplication application;
1058 Actor parent = Actor::New();
1059 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1060 parent.SetPosition( parentPosition );
1061 parent.SetParentOrigin( ParentOrigin::CENTER );
1062 parent.SetAnchorPoint( AnchorPoint::CENTER );
1063 Stage::GetCurrent().Add( parent );
1065 Actor child = Actor::New();
1066 child.SetParentOrigin( ParentOrigin::CENTER );
1067 child.SetAnchorPoint( AnchorPoint::CENTER );
1068 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1069 child.SetPosition( childPosition );
1070 parent.Add( child );
1072 // The actors should not have a world position yet
1073 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1074 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1076 // first test default, which is INHERIT_PARENT_POSITION
1077 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1078 application.SendNotification();
1079 application.Render(0); // should only really call Update as Render is not required to update scene
1080 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1081 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1082 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1083 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1085 // Change inheritance mode to use parent
1086 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1087 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1088 application.SendNotification();
1089 application.Render(0); // should only really call Update as Render is not required to update scene
1090 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1091 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1092 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1093 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1095 // Change inheritance mode to use parent + offset
1096 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1097 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1098 child.SetPosition( childOffset );
1099 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1100 application.SendNotification();
1101 application.Render(0); // should only really call Update as Render is not required to update scene
1102 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1103 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1104 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1105 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1107 // Change inheritance mode to not inherit
1108 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1109 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1110 application.SendNotification();
1111 application.Render(0); // should only really call Update as Render is not required to update scene
1112 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1113 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1114 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1115 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1119 // SetOrientation(float angleRadians, Vector3 axis)
1120 int UtcDaliActorSetOrientation01(void)
1122 TestApplication application;
1124 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1125 Actor actor = Actor::New();
1127 actor.SetOrientation(rotation);
1129 // flush the queue and render once
1130 application.SendNotification();
1131 application.Render();
1133 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1137 int UtcDaliActorSetOrientation02(void)
1139 TestApplication application;
1141 Actor actor = Actor::New();
1143 Radian angle( 0.785f );
1144 Vector3 axis(1.0f, 1.0f, 0.0f);
1146 actor.SetOrientation( angle, axis);
1147 Quaternion rotation( angle, axis );
1148 // flush the queue and render once
1149 application.SendNotification();
1150 application.Render();
1151 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1153 Stage::GetCurrent().Add( actor );
1154 actor.RotateBy( Degree( 360 ), axis);
1155 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1157 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1158 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1159 // flush the queue and render once
1160 application.SendNotification();
1161 application.Render();
1162 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1164 actor.SetOrientation( angle, axis);
1165 // flush the queue and render once
1166 application.SendNotification();
1167 application.Render();
1168 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1170 Stage::GetCurrent().Remove( actor );
1174 // RotateBy(float angleRadians, Vector3 axis)
1175 int UtcDaliActorRotateBy01(void)
1177 TestApplication application;
1179 Actor actor = Actor::New();
1181 Radian angle( M_PI * 0.25f );
1182 actor.RotateBy(( angle ), Vector3::ZAXIS);
1183 // flush the queue and render once
1184 application.SendNotification();
1185 application.Render();
1186 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1188 Stage::GetCurrent().Add( actor );
1190 actor.RotateBy( angle, Vector3::ZAXIS);
1191 // flush the queue and render once
1192 application.SendNotification();
1193 application.Render();
1194 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1196 Stage::GetCurrent().Remove( actor );
1200 // RotateBy(Quaternion relativeRotation)
1201 int UtcDaliActorRotateBy02(void)
1203 TestApplication application;
1205 Actor actor = Actor::New();
1207 Radian angle( M_PI * 0.25f );
1208 Quaternion rotation(angle, Vector3::ZAXIS);
1209 actor.RotateBy(rotation);
1210 // flush the queue and render once
1211 application.SendNotification();
1212 application.Render();
1213 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1215 actor.RotateBy(rotation);
1216 // flush the queue and render once
1217 application.SendNotification();
1218 application.Render();
1219 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1223 int UtcDaliActorGetCurrentOrientation(void)
1225 TestApplication application;
1226 Actor actor = Actor::New();
1228 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1229 actor.SetOrientation(rotation);
1230 // flush the queue and render once
1231 application.SendNotification();
1232 application.Render();
1233 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1237 int UtcDaliActorGetCurrentWorldOrientation(void)
1239 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1240 TestApplication application;
1242 Actor parent = Actor::New();
1243 Radian rotationAngle( Degree(90.0f) );
1244 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1245 parent.SetOrientation( rotation );
1246 Stage::GetCurrent().Add( parent );
1248 Actor child = Actor::New();
1249 child.SetOrientation( rotation );
1250 parent.Add( child );
1252 // The actors should not have a world rotation yet
1253 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1254 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1256 application.SendNotification();
1257 application.Render(0);
1259 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1260 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1262 // The actors should have a world rotation now
1263 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1264 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1266 // turn off child rotation inheritance
1267 child.SetInheritOrientation( false );
1268 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1269 application.SendNotification();
1270 application.Render(0);
1272 // The actors should have a world rotation now
1273 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1274 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1278 // SetScale(float scale)
1279 int UtcDaliActorSetScale01(void)
1281 TestApplication application;
1283 Actor actor = Actor::New();
1285 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1286 actor.SetScale(0.25f);
1288 Vector3 scale(10.0f, 10.0f, 10.0f);
1289 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1291 actor.SetScale(scale.x);
1293 // flush the queue and render once
1294 application.SendNotification();
1295 application.Render();
1297 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1301 // SetScale(float scaleX, float scaleY, float scaleZ)
1302 int UtcDaliActorSetScale02(void)
1304 TestApplication application;
1305 Vector3 scale(10.0f, 10.0f, 10.0f);
1307 Actor actor = Actor::New();
1309 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1310 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1312 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1314 actor.SetScale(scale.x, scale.y, scale.z);
1315 // flush the queue and render once
1316 application.SendNotification();
1317 application.Render();
1318 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1320 // add to stage and test
1321 Stage::GetCurrent().Add( actor );
1322 actor.SetScale( 2.0f, 2.0f, 2.0f );
1323 // flush the queue and render once
1324 application.SendNotification();
1325 application.Render();
1326 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1328 Stage::GetCurrent().Remove( actor );
1333 // SetScale(Vector3 scale)
1334 int UtcDaliActorSetScale03(void)
1336 TestApplication application;
1337 Vector3 scale(10.0f, 10.0f, 10.0f);
1339 Actor actor = Actor::New();
1341 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1342 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1344 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1346 actor.SetScale(scale);
1348 // flush the queue and render once
1349 application.SendNotification();
1350 application.Render();
1352 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1356 int UtcDaliActorScaleBy(void)
1358 TestApplication application;
1359 Actor actor = Actor::New();
1360 Vector3 vector(100.0f, 100.0f, 100.0f);
1362 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1364 actor.SetScale(vector);
1366 // flush the queue and render once
1367 application.SendNotification();
1368 application.Render();
1370 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1372 actor.ScaleBy(vector);
1374 // flush the queue and render once
1375 application.SendNotification();
1376 application.Render();
1378 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1382 int UtcDaliActorGetCurrentScale(void)
1384 TestApplication application;
1385 Vector3 scale(12.0f, 1.0f, 2.0f);
1387 Actor actor = Actor::New();
1389 actor.SetScale(scale);
1391 // flush the queue and render once
1392 application.SendNotification();
1393 application.Render();
1395 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1399 int UtcDaliActorGetCurrentWorldScale(void)
1401 TestApplication application;
1403 Actor parent = Actor::New();
1404 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1405 parent.SetScale( parentScale );
1406 Stage::GetCurrent().Add( parent );
1408 Actor child = Actor::New();
1409 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1410 child.SetScale( childScale );
1411 parent.Add( child );
1413 // The actors should not have a scale yet
1414 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1415 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1417 // The actors should not have a world scale yet
1418 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1419 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1421 application.SendNotification();
1422 application.Render(0);
1424 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1425 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1427 // The actors should have a world scale now
1428 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1429 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1433 int UtcDaliActorInheritScale(void)
1435 tet_infoline("Testing Actor::SetInheritScale");
1436 TestApplication application;
1438 Actor parent = Actor::New();
1439 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1440 parent.SetScale( parentScale );
1441 Stage::GetCurrent().Add( parent );
1443 Actor child = Actor::New();
1444 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1445 child.SetScale( childScale );
1446 parent.Add( child );
1448 application.SendNotification();
1449 application.Render(0);
1451 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1452 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1454 child.SetInheritScale( false );
1455 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1457 application.SendNotification();
1458 application.Render(0);
1460 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1464 int UtcDaliActorSetVisible(void)
1466 TestApplication application;
1468 Actor actor = Actor::New();
1469 actor.SetVisible(false);
1470 // flush the queue and render once
1471 application.SendNotification();
1472 application.Render();
1473 DALI_TEST_CHECK(actor.IsVisible() == false);
1475 actor.SetVisible(true);
1476 // flush the queue and render once
1477 application.SendNotification();
1478 application.Render();
1479 DALI_TEST_CHECK(actor.IsVisible() == true);
1481 // put actor on stage
1482 Stage::GetCurrent().Add( actor );
1483 actor.SetVisible(false);
1484 // flush the queue and render once
1485 application.SendNotification();
1486 application.Render();
1487 DALI_TEST_CHECK(actor.IsVisible() == false);
1491 int UtcDaliActorIsVisible(void)
1493 TestApplication application;
1495 Actor actor = Actor::New();
1497 DALI_TEST_CHECK(actor.IsVisible() == true);
1501 int UtcDaliActorSetOpacity(void)
1503 TestApplication application;
1505 Actor actor = Actor::New();
1506 // initial opacity is 1
1507 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1509 actor.SetOpacity( 0.4f);
1510 // flush the queue and render once
1511 application.SendNotification();
1512 application.Render();
1513 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1515 // change opacity, actor is on stage to change is not immediate
1516 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1517 // flush the queue and render once
1518 application.SendNotification();
1519 application.Render();
1520 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1522 // put actor on stage
1523 Stage::GetCurrent().Add( actor );
1525 // change opacity, actor is on stage to change is not immediate
1526 actor.SetOpacity( 0.9f );
1527 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1528 // flush the queue and render once
1529 application.SendNotification();
1530 application.Render();
1531 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1533 // change opacity, actor is on stage to change is not immediate
1534 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1535 // flush the queue and render once
1536 application.SendNotification();
1537 application.Render();
1538 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1542 int UtcDaliActorGetCurrentOpacity(void)
1544 TestApplication application;
1546 Actor actor = Actor::New();
1547 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1549 actor.SetOpacity(0.5f);
1550 // flush the queue and render once
1551 application.SendNotification();
1552 application.Render();
1553 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1557 int UtcDaliActorSetSensitive(void)
1559 TestApplication application;
1560 Actor actor = Actor::New();
1562 bool sensitive = !actor.IsSensitive();
1564 actor.SetSensitive(sensitive);
1566 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1570 int UtcDaliActorIsSensitive(void)
1572 TestApplication application;
1573 Actor actor = Actor::New();
1574 actor.SetSensitive(false);
1576 DALI_TEST_CHECK(false == actor.IsSensitive());
1580 int UtcDaliActorSetColor(void)
1582 TestApplication application;
1583 Actor actor = Actor::New();
1584 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1586 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1588 actor.SetColor(color);
1589 // flush the queue and render once
1590 application.SendNotification();
1591 application.Render();
1592 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1594 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1595 // flush the queue and render once
1596 application.SendNotification();
1597 application.Render();
1598 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1600 Stage::GetCurrent().Add( actor );
1601 actor.SetColor( color );
1602 // flush the queue and render once
1603 application.SendNotification();
1604 application.Render();
1605 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1607 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1608 // flush the queue and render once
1609 application.SendNotification();
1610 application.Render();
1611 // Actor color is not clamped
1612 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1613 // world color is clamped
1614 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1616 Stage::GetCurrent().Remove( actor );
1620 int UtcDaliActorGetCurrentColor(void)
1622 TestApplication application;
1623 Actor actor = Actor::New();
1624 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1626 actor.SetColor(color);
1627 // flush the queue and render once
1628 application.SendNotification();
1629 application.Render();
1630 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1634 int UtcDaliActorGetCurrentWorldColor(void)
1636 tet_infoline("Actor::GetCurrentWorldColor");
1637 TestApplication application;
1639 Actor parent = Actor::New();
1640 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1641 parent.SetColor( parentColor );
1642 Stage::GetCurrent().Add( parent );
1644 Actor child = Actor::New();
1645 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1646 child.SetColor( childColor );
1647 parent.Add( child );
1649 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1650 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1652 // verify the default color mode
1653 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1655 // The actors should not have a world color yet
1656 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1657 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1659 application.SendNotification();
1660 application.Render(0);
1662 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1663 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1665 // The actors should have a world color now
1666 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1667 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1670 child.SetColorMode( USE_OWN_COLOR );
1671 application.SendNotification();
1672 application.Render(0);
1673 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1676 child.SetColorMode( USE_PARENT_COLOR );
1677 application.SendNotification();
1678 application.Render(0);
1679 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1680 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1683 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1684 application.SendNotification();
1685 application.Render(0);
1686 Vector4 expectedColor( childColor );
1687 expectedColor.a *= parentColor.a;
1688 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1689 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1693 int UtcDaliActorSetColorMode(void)
1695 tet_infoline("Actor::SetColorMode");
1696 TestApplication application;
1697 Actor actor = Actor::New();
1698 Actor child = Actor::New();
1701 actor.SetColorMode( USE_OWN_COLOR );
1702 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1704 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1705 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1707 actor.SetColorMode( USE_PARENT_COLOR );
1708 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1710 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1711 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1715 int UtcDaliActorScreenToLocal(void)
1717 TestApplication application;
1718 Actor actor = Actor::New();
1719 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1720 actor.SetSize(100.0f, 100.0f);
1721 actor.SetPosition(10.0f, 10.0f);
1722 Stage::GetCurrent().Add(actor);
1724 // flush the queue and render once
1725 application.SendNotification();
1726 application.Render();
1731 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1733 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1734 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1738 int UtcDaliActorSetLeaveRequired(void)
1740 TestApplication application;
1742 Actor actor = Actor::New();
1744 actor.SetLeaveRequired(false);
1745 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1747 actor.SetLeaveRequired(true);
1748 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1752 int UtcDaliActorGetLeaveRequired(void)
1754 TestApplication application;
1756 Actor actor = Actor::New();
1758 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1762 int UtcDaliActorSetKeyboardFocusable(void)
1764 TestApplication application;
1766 Actor actor = Actor::New();
1768 actor.SetKeyboardFocusable(true);
1769 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1771 actor.SetKeyboardFocusable(false);
1772 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1776 int UtcDaliActorIsKeyboardFocusable(void)
1778 TestApplication application;
1780 Actor actor = Actor::New();
1782 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1786 int UtcDaliActorRemoveConstraints(void)
1788 tet_infoline(" UtcDaliActorRemoveConstraints");
1789 TestApplication application;
1791 gTestConstraintCalled = false;
1793 Actor actor = Actor::New();
1795 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
1797 actor.RemoveConstraints();
1799 DALI_TEST_CHECK( gTestConstraintCalled == false );
1801 Stage::GetCurrent().Add( actor );
1804 // flush the queue and render once
1805 application.SendNotification();
1806 application.Render();
1808 actor.RemoveConstraints();
1810 DALI_TEST_CHECK( gTestConstraintCalled == true );
1814 int UtcDaliActorRemoveConstraintTag(void)
1816 tet_infoline(" UtcDaliActorRemoveConstraintTag");
1817 TestApplication application;
1819 Actor actor = Actor::New();
1821 // 1. Apply Constraint1 and Constraint2, and test...
1822 unsigned int result1 = 0u;
1823 unsigned int result2 = 0u;
1825 unsigned constraint1Tag = 1u;
1826 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
1827 constraint1.SetTag( constraint1Tag );
1828 constraint1.Apply();
1830 unsigned constraint2Tag = 2u;
1831 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
1832 constraint2.SetTag( constraint2Tag );
1833 constraint2.Apply();
1835 Stage::GetCurrent().Add( actor );
1836 // flush the queue and render once
1837 application.SendNotification();
1838 application.Render();
1840 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1841 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1843 // 2. Remove Constraint1 and test...
1846 actor.RemoveConstraints(constraint1Tag);
1847 // make color property dirty, which will trigger constraints to be reapplied.
1848 actor.SetColor( Color::WHITE );
1849 // flush the queue and render once
1850 application.SendNotification();
1851 application.Render();
1853 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1854 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1856 // 3. Re-Apply Constraint1 and test...
1859 constraint1.Apply();
1860 // make color property dirty, which will trigger constraints to be reapplied.
1861 actor.SetColor( Color::WHITE );
1862 // flush the queue and render once
1863 application.SendNotification();
1864 application.Render();
1866 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1867 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1869 // 2. Remove Constraint2 and test...
1872 actor.RemoveConstraints(constraint2Tag);
1873 // make color property dirty, which will trigger constraints to be reapplied.
1874 actor.SetColor( Color::WHITE );
1875 // flush the queue and render once
1876 application.SendNotification();
1877 application.Render();
1879 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1880 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1882 // 2. Remove Constraint1 as well and test...
1885 actor.RemoveConstraints(constraint1Tag);
1886 // make color property dirty, which will trigger constraints to be reapplied.
1887 actor.SetColor( Color::WHITE );
1888 // flush the queue and render once
1889 application.SendNotification();
1890 application.Render();
1892 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1893 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1897 int UtcDaliActorTouchedSignal(void)
1899 TestApplication application;
1901 gTouchCallBackCalled = false;
1903 // get the root layer
1904 Actor actor = Stage::GetCurrent().GetRootLayer();
1905 DALI_TEST_CHECK( gTouchCallBackCalled == false );
1907 application.SendNotification();
1908 application.Render();
1910 // connect to its touch signal
1911 actor.TouchedSignal().Connect( TestCallback );
1913 // simulate a touch event in the middle of the screen
1914 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1915 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
1916 Dali::Integration::TouchEvent event;
1917 event.AddPoint( point );
1918 application.ProcessEvent( event );
1920 DALI_TEST_CHECK( gTouchCallBackCalled == true );
1924 int UtcDaliActorHoveredSignal(void)
1926 TestApplication application;
1928 gHoverCallBackCalled = false;
1930 // get the root layer
1931 Actor actor = Stage::GetCurrent().GetRootLayer();
1932 DALI_TEST_CHECK( gHoverCallBackCalled == false );
1934 application.SendNotification();
1935 application.Render();
1937 // connect to its hover signal
1938 actor.HoveredSignal().Connect( TestCallback3 );
1940 // simulate a hover event in the middle of the screen
1941 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1942 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
1943 Dali::Integration::HoverEvent event;
1944 event.AddPoint( point );
1945 application.ProcessEvent( event );
1947 DALI_TEST_CHECK( gHoverCallBackCalled == true );
1951 int UtcDaliActorOnOffStageSignal(void)
1953 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
1955 TestApplication application;
1958 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
1959 gActorNamesOnOffStage.clear();
1961 Actor parent = Actor::New();
1962 parent.SetName( "parent" );
1963 parent.OnStageSignal().Connect( OnStageCallback );
1964 parent.OffStageSignal().Connect( OffStageCallback );
1966 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
1967 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
1969 // add parent to stage
1970 Stage::GetCurrent().Add( parent );
1971 // onstage emitted, offstage not
1972 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
1973 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
1974 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
1976 // test adding a child, should get onstage emitted
1978 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
1979 gActorNamesOnOffStage.clear();
1981 Actor child = Actor::New();
1982 child.SetName( "child" );
1983 child.OnStageSignal().Connect( OnStageCallback );
1984 child.OffStageSignal().Connect( OffStageCallback );
1985 parent.Add( child ); // add child
1986 // onstage emitted, offstage not
1987 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
1988 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
1989 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
1991 // test removing parent from stage
1993 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
1994 gActorNamesOnOffStage.clear();
1996 Stage::GetCurrent().Remove( parent );
1997 // onstage not emitted, offstage is
1998 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
1999 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2000 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2001 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2003 // test adding parent back to stage
2005 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2006 gActorNamesOnOffStage.clear();
2008 Stage::GetCurrent().Add( parent );
2009 // onstage emitted, offstage not
2010 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2011 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2012 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2013 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2015 // test removing child
2017 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2018 gActorNamesOnOffStage.clear();
2020 parent.Remove( child );
2021 // onstage not emitted, offstage is
2022 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2023 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2024 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2026 // test removing parent
2028 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2029 gActorNamesOnOffStage.clear();
2031 Stage::GetCurrent().Remove( parent );
2032 // onstage not emitted, offstage is
2033 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2034 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2035 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2039 int UtcDaliActorFindChildByName(void)
2041 tet_infoline("Testing Dali::Actor::FindChildByName()");
2042 TestApplication application;
2044 Actor parent = Actor::New();
2045 parent.SetName( "parent" );
2046 Actor first = Actor::New();
2047 first .SetName( "first" );
2048 Actor second = Actor::New();
2049 second.SetName( "second" );
2054 Actor found = parent.FindChildByName( "foo" );
2055 DALI_TEST_CHECK( !found );
2057 found = parent.FindChildByName( "parent" );
2058 DALI_TEST_CHECK( found == parent );
2060 found = parent.FindChildByName( "first" );
2061 DALI_TEST_CHECK( found == first );
2063 found = parent.FindChildByName( "second" );
2064 DALI_TEST_CHECK( found == second );
2068 int UtcDaliActorFindChildById(void)
2070 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2071 TestApplication application;
2073 Actor parent = Actor::New();
2074 Actor first = Actor::New();
2075 Actor second = Actor::New();
2080 Actor found = parent.FindChildById( 100000 );
2081 DALI_TEST_CHECK( !found );
2083 found = parent.FindChildById( parent.GetId() );
2084 DALI_TEST_CHECK( found == parent );
2086 found = parent.FindChildById( first.GetId() );
2087 DALI_TEST_CHECK( found == first );
2089 found = parent.FindChildById( second.GetId() );
2090 DALI_TEST_CHECK( found == second );
2094 int UtcDaliActorHitTest(void)
2099 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2101 mTouchPoint( touchPoint ),
2106 Vector2 mTouchPoint;
2110 TestApplication application;
2111 tet_infoline(" UtcDaliActorHitTest");
2113 // Fill a vector with different hit tests.
2114 struct HitTestData* hitTestData[] = {
2115 // scale touch point result
2116 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2117 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2118 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.
2119 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2120 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.
2124 // get the root layer
2125 Actor actor = Actor::New();
2126 actor.SetAnchorPoint( AnchorPoint::CENTER );
2127 actor.SetParentOrigin( ParentOrigin::CENTER );
2129 Stage::GetCurrent().Add( actor );
2131 gTouchCallBackCalled = false;
2133 unsigned int index = 0;
2134 while( NULL != hitTestData[index] )
2136 actor.SetSize( 1.f, 1.f );
2137 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2139 // flush the queue and render once
2140 application.SendNotification();
2141 application.Render();
2143 DALI_TEST_CHECK( !gTouchCallBackCalled );
2145 // connect to its touch signal
2146 actor.TouchedSignal().Connect(TestCallback);
2148 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2149 Dali::Integration::TouchEvent event;
2150 event.AddPoint( point );
2152 // flush the queue and render once
2153 application.SendNotification();
2154 application.Render();
2155 application.ProcessEvent( event );
2157 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2159 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2160 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2161 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2162 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2163 hitTestData[index]->mResult );
2165 gTouchCallBackCalled = false;
2171 int UtcDaliActorSetDrawMode(void)
2173 TestApplication app;
2174 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2176 Actor a = Actor::New();
2178 Stage::GetCurrent().Add(a);
2179 app.SendNotification();
2181 app.SendNotification();
2184 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2186 a.SetDrawMode( DrawMode::OVERLAY_2D );
2187 app.SendNotification();
2190 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2192 a.SetDrawMode( DrawMode::STENCIL );
2193 app.SendNotification();
2196 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2198 a.SetDrawMode( DrawMode::NORMAL );
2199 app.SendNotification();
2202 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2206 int UtcDaliActorSetDrawModeOverlayRender(void)
2208 TestApplication app;
2209 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2211 app.SendNotification();
2214 std::vector<GLuint> ids;
2215 ids.push_back( 8 ); // first rendered actor
2216 ids.push_back( 9 ); // second rendered actor
2217 ids.push_back( 10 ); // third rendered actor
2218 app.GetGlAbstraction().SetNextTextureIds( ids );
2220 BufferImage imageA = BufferImage::New(16, 16);
2221 BufferImage imageB = BufferImage::New(16, 16);
2222 BufferImage imageC = BufferImage::New(16, 16);
2223 ImageActor a = ImageActor::New( imageA );
2224 ImageActor b = ImageActor::New( imageB );
2225 ImageActor c = ImageActor::New( imageC );
2227 // Render a,b,c as regular non-overlays. so order will be:
2231 Stage::GetCurrent().Add(a);
2232 Stage::GetCurrent().Add(b);
2233 Stage::GetCurrent().Add(c);
2235 app.SendNotification();
2238 // Should be 3 textures changes.
2239 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2240 typedef std::vector<GLuint>::size_type TextureSize;
2241 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2242 if( boundTextures.size() == 3 )
2244 DALI_TEST_CHECK( boundTextures[0] == 8u );
2245 DALI_TEST_CHECK( boundTextures[1] == 9u );
2246 DALI_TEST_CHECK( boundTextures[2] == 10u );
2249 // Now texture ids have been set, we can monitor their render order.
2250 // render a as an overlay (last), so order will be:
2254 a.SetDrawMode( DrawMode::OVERLAY_2D );
2255 app.GetGlAbstraction().ClearBoundTextures();
2257 app.SendNotification();
2260 // Should be 3 texture changes.
2261 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2262 if( boundTextures.size() == 3 )
2264 DALI_TEST_CHECK( boundTextures[0] == 9u );
2265 DALI_TEST_CHECK( boundTextures[1] == 10u );
2266 DALI_TEST_CHECK( boundTextures[2] == 8u );
2271 int UtcDaliActorGetCurrentWorldMatrix(void)
2273 TestApplication app;
2274 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2276 Actor parent = Actor::New();
2277 parent.SetParentOrigin(ParentOrigin::CENTER);
2278 parent.SetAnchorPoint(AnchorPoint::CENTER);
2279 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2280 Radian rotationAngle(Degree(85.0f));
2281 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2282 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2283 parent.SetPosition( parentPosition );
2284 parent.SetOrientation( parentRotation );
2285 parent.SetScale( parentScale );
2286 Stage::GetCurrent().Add( parent );
2288 Actor child = Actor::New();
2289 child.SetParentOrigin(ParentOrigin::CENTER);
2290 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2291 Radian childRotationAngle(Degree(23.0f));
2292 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2293 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2294 child.SetPosition( childPosition );
2295 child.SetOrientation( childRotation );
2296 child.SetScale( childScale );
2297 parent.Add( child );
2299 // The actors should not have a world matrix yet
2300 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2301 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2303 app.SendNotification();
2306 app.SendNotification();
2308 Matrix parentMatrix(false);
2309 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2311 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2312 Quaternion childWorldRotation = parentRotation * childRotation;
2313 Vector3 childWorldScale = parentScale * childScale;
2315 Matrix childWorldMatrix(false);
2316 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2318 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2319 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2325 int UtcDaliActorConstrainedToWorldMatrix(void)
2327 TestApplication app;
2328 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2330 Actor parent = Actor::New();
2331 parent.SetParentOrigin(ParentOrigin::CENTER);
2332 parent.SetAnchorPoint(AnchorPoint::CENTER);
2333 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2334 Radian rotationAngle(Degree(85.0f));
2335 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2336 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2337 parent.SetPosition( parentPosition );
2338 parent.SetOrientation( parentRotation );
2339 parent.SetScale( parentScale );
2340 Stage::GetCurrent().Add( parent );
2342 Actor child = Actor::New();
2343 child.SetParentOrigin(ParentOrigin::CENTER);
2344 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2345 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2346 posConstraint.Apply();
2348 Stage::GetCurrent().Add( child );
2350 // The actors should not have a world matrix yet
2351 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2352 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2354 app.SendNotification();
2357 app.SendNotification();
2359 Matrix parentMatrix(false);
2360 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2362 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2363 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2367 int UtcDaliActorUnparent(void)
2369 TestApplication app;
2370 tet_infoline(" UtcDaliActorUnparent");
2372 Actor parent = Actor::New();
2373 Stage::GetCurrent().Add( parent );
2375 Actor child = Actor::New();
2377 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2378 DALI_TEST_CHECK( !child.GetParent() );
2380 // Test that calling Unparent with no parent is a NOOP
2383 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2384 DALI_TEST_CHECK( !child.GetParent() );
2386 // Test that Unparent works
2387 parent.Add( child );
2389 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2390 DALI_TEST_CHECK( parent == child.GetParent() );
2394 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2395 DALI_TEST_CHECK( !child.GetParent() );
2397 // Test that UnparentAndReset works
2398 parent.Add( child );
2400 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2401 DALI_TEST_CHECK( parent == child.GetParent() );
2403 UnparentAndReset( child );
2405 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2406 DALI_TEST_CHECK( !child );
2408 // Test that UnparentAndReset is a NOOP with empty handle
2409 UnparentAndReset( child );
2411 DALI_TEST_CHECK( !child );
2415 int UtcDaliActorGetChildAt(void)
2417 TestApplication app;
2418 tet_infoline(" UtcDaliActorGetChildAt");
2420 Actor parent = Actor::New();
2421 Stage::GetCurrent().Add( parent );
2423 Actor child0 = Actor::New();
2424 parent.Add( child0 );
2426 Actor child1 = Actor::New();
2427 parent.Add( child1 );
2429 Actor child2 = Actor::New();
2430 parent.Add( child2 );
2432 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2433 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2434 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2438 int UtcDaliActorSetGetOverlay(void)
2440 TestApplication app;
2441 tet_infoline(" UtcDaliActorSetGetOverlay");
2443 Actor parent = Actor::New();
2444 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2445 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2450 int UtcDaliActorCreateDestroy(void)
2452 Actor* actor = new Actor;
2453 DALI_TEST_CHECK( actor );
2460 struct PropertyStringIndex
2462 const char * const name;
2463 const Property::Index index;
2464 const Property::Type type;
2467 const PropertyStringIndex PROPERTY_TABLE[] =
2469 { "parent-origin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2470 { "parent-origin-x", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2471 { "parent-origin-y", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2472 { "parent-origin-z", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2473 { "anchor-point", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2474 { "anchor-point-x", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2475 { "anchor-point-y", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2476 { "anchor-point-z", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2477 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2478 { "size-width", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2479 { "size-height", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2480 { "size-depth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2481 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2482 { "position-x", Actor::Property::POSITION_X, Property::FLOAT },
2483 { "position-y", Actor::Property::POSITION_Y, Property::FLOAT },
2484 { "position-z", Actor::Property::POSITION_Z, Property::FLOAT },
2485 { "world-position", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2486 { "world-position-x", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2487 { "world-position-y", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2488 { "world-position-z", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2489 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2490 { "world-orientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2491 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2492 { "scale-x", Actor::Property::SCALE_X, Property::FLOAT },
2493 { "scale-y", Actor::Property::SCALE_Y, Property::FLOAT },
2494 { "scale-z", Actor::Property::SCALE_Z, Property::FLOAT },
2495 { "world-scale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2496 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2497 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2498 { "color-red", Actor::Property::COLOR_RED, Property::FLOAT },
2499 { "color-green", Actor::Property::COLOR_GREEN, Property::FLOAT },
2500 { "color-blue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2501 { "color-alpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2502 { "world-color", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2503 { "world-matrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2504 { "name", Actor::Property::NAME, Property::STRING },
2505 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2506 { "leave-required", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2507 { "inherit-orientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2508 { "inherit-scale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2509 { "color-mode", Actor::Property::COLOR_MODE, Property::STRING },
2510 { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2511 { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING },
2512 { "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2513 { "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2514 { "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2515 { "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2516 { "width-for-height", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2517 { "height-for-width", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2518 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2519 { "minimum-size", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2520 { "maximum-size", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2522 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2523 } // unnamed namespace
2525 int UtcDaliActorProperties(void)
2527 TestApplication app;
2529 Actor actor = Actor::New();
2531 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2533 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2534 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2535 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2536 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2541 int UtcDaliRelayoutProperties_ResizePolicies(void)
2543 TestApplication app;
2545 Actor actor = Actor::New();
2548 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2549 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2551 // Set resize policy for all dimensions
2552 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2553 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2555 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2558 // Set individual dimensions
2559 const char* const widthPolicy = "FILL_TO_PARENT";
2560 const char* const heightPolicy = "FIXED";
2562 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2563 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2565 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2566 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2571 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2573 TestApplication app;
2575 Actor actor = Actor::New();
2578 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2579 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2581 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2582 actor.SetSizeScalePolicy( policy );
2583 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2586 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2587 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2589 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2590 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2592 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2593 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2598 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2600 TestApplication app;
2602 Actor actor = Actor::New();
2605 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2606 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2608 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2609 actor.SetSizeModeFactor( sizeMode );
2610 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2613 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2615 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2616 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2621 int UtcDaliRelayoutProperties_DimensionDependency(void)
2623 TestApplication app;
2625 Actor actor = Actor::New();
2628 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2629 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2632 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2633 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2635 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2636 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2638 // Test setting another resize policy
2639 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2640 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2645 int UtcDaliRelayoutProperties_Padding(void)
2647 TestApplication app;
2649 Actor actor = Actor::New();
2652 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2655 actor.SetProperty( Actor::Property::PADDING, padding );
2656 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2658 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2663 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2665 TestApplication app;
2667 Actor actor = Actor::New();
2670 Vector2 minSize( 1.0f, 2.0f );
2672 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2673 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2675 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2677 Vector2 maxSize( 3.0f, 4.0f );
2679 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2680 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2682 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2687 int UtcDaliActorGetHeightForWidth(void)
2689 TestApplication app;
2691 Actor actor = Actor::New();
2693 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
2698 int UtcDaliActorGetWidthForHeight(void)
2700 TestApplication app;
2702 Actor actor = Actor::New();
2704 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
2709 int UtcDaliActorGetRelayoutSize(void)
2711 TestApplication app;
2713 Actor actor = Actor::New();
2715 // Add actor to stage
2716 Stage::GetCurrent().Add( actor );
2718 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
2720 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
2721 actor.SetSize( Vector2( 1.0f, 0.0f ) );
2723 // Flush the queue and render once
2724 app.SendNotification();
2727 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
2732 int UtcDaliActorSetPadding(void)
2734 TestApplication app;
2736 Actor actor = Actor::New();
2739 actor.GetPadding( padding );
2741 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
2742 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
2743 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
2744 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
2746 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
2747 actor.SetPadding( padding2 );
2749 actor.GetPadding( padding );
2751 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
2752 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
2753 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
2754 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
2759 int UtcDaliActorSetMinimumSize(void)
2761 TestApplication app;
2763 Actor actor = Actor::New();
2765 Vector2 size = actor.GetMinimumSize();
2767 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
2768 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
2770 Vector2 size2( 1.0f, 2.0f );
2771 actor.SetMinimumSize( size2 );
2773 size = actor.GetMinimumSize();
2775 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2776 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2781 int UtcDaliActorSetMaximumSize(void)
2783 TestApplication app;
2785 Actor actor = Actor::New();
2787 Vector2 size = actor.GetMaximumSize();
2789 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
2790 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
2792 Vector2 size2( 1.0f, 2.0f );
2793 actor.SetMaximumSize( size2 );
2795 size = actor.GetMaximumSize();
2797 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2798 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2803 int UtcDaliActorOnRelayoutSignal(void)
2805 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
2807 TestApplication application;
2810 gOnRelayoutCallBackCalled = 0;
2811 gActorNamesRelayout.clear();
2813 Actor actor = Actor::New();
2814 actor.SetName( "actor" );
2815 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
2818 DALI_TEST_CHECK( gOnRelayoutCallBackCalled == 0 );
2820 // Add actor to stage
2821 Stage::GetCurrent().Add( actor );
2823 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2824 actor.SetSize( Vector2( 1.0f, 2.0 ) );
2826 // Flush the queue and render once
2827 application.SendNotification();
2828 application.Render();
2830 // OnRelayout emitted
2831 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, 1, TEST_LOCATION );
2832 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
2837 int UtcDaliActorGetHierachyDepth(void)
2839 TestApplication application;
2840 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
2843 /* Build tree of actors:
2853 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
2855 Stage stage( Stage::GetCurrent() );
2857 Actor actorA = Actor::New();
2858 Actor actorB = Actor::New();
2859 Actor actorC = Actor::New();
2860 Actor actorD = Actor::New();
2861 Actor actorE = Actor::New();
2862 Actor actorF = Actor::New();
2864 //Test that root actor has depth equal 0
2865 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
2867 //Test actors return depth -1 when not connected to the tree
2868 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2869 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2870 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
2871 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2872 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2873 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
2875 //Create the hierarchy
2876 stage.Add( actorA );
2877 actorA.Add( actorB );
2878 actorA.Add( actorC );
2879 actorB.Add( actorD );
2880 actorB.Add( actorE );
2881 actorC.Add( actorF );
2883 //Test actors return correct depth
2884 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2885 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
2886 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
2887 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
2888 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
2889 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
2891 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
2892 actorA.Remove( actorB );
2894 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2895 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2896 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2898 //Removing actorA from the stage. All actors should have depth equal -1
2899 stage.Remove( actorA );
2901 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2902 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2903 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
2904 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2905 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2906 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );