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::Integration::Point point;
62 point.SetState( PointState::DOWN );
63 point.SetScreenPosition( Vector2( 25.0f, 25.0f ) );
64 Dali::Integration::TouchEvent event;
65 event.AddPoint( point );
66 app.ProcessEvent( event );
68 app.SendNotification();
70 app.SendNotification();
76 static bool gTestConstraintCalled;
80 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
82 gTestConstraintCalled = true;
87 * TestConstraint reference.
88 * When constraint is called, the resultRef is updated
89 * with the value supplied.
92 struct TestConstraintRef
94 TestConstraintRef(unsigned int& resultRef, unsigned int value)
95 : mResultRef(resultRef),
100 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
105 unsigned int& mResultRef;
109 static bool TestCallback(Actor actor, const TouchEvent& event)
111 gTouchCallBackCalled = true;
116 static bool TestCallback3(Actor actor, const HoverEvent& event)
118 gHoverCallBackCalled = true;
123 static Vector3 gSetSize;
124 static bool gSetSizeCallBackCalled;
125 void SetSizeCallback( Actor actor, const Vector3& size )
127 gSetSizeCallBackCalled = true;
130 // validation stuff for onstage & offstage signals
131 static std::vector< std::string > gActorNamesOnOffStage;
132 static int gOnStageCallBackCalled;
133 void OnStageCallback( Actor actor )
135 ++gOnStageCallBackCalled;
136 gActorNamesOnOffStage.push_back( actor.GetName() );
137 DALI_TEST_CHECK( actor.OnStage() == true );
139 static int gOffStageCallBackCalled;
140 void OffStageCallback( Actor actor )
142 ++gOffStageCallBackCalled;
143 gActorNamesOnOffStage.push_back( actor.GetName() );
144 DALI_TEST_CHECK( actor.OnStage() == false );
147 struct PositionComponentConstraint
149 PositionComponentConstraint(){}
151 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
153 const Matrix& m = inputs[0]->GetMatrix();
156 m.GetTransformComponents(pos, rot, scale);
160 struct OrientationComponentConstraint
162 OrientationComponentConstraint(){}
164 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
166 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
169 orientation = parentOrientation;
174 static bool gOnRelayoutCallBackCalled = false;
175 static std::vector< std::string > gActorNamesRelayout;
177 void OnRelayoutCallback( Actor actor )
179 gOnRelayoutCallBackCalled = true;
180 gActorNamesRelayout.push_back( actor.GetName() );
183 } // anonymous namespace
186 //& purpose: Testing New API
187 int UtcDaliActorNew(void)
189 TestApplication application;
191 Actor actor = Actor::New();
193 DALI_TEST_CHECK(actor);
197 //& purpose: Testing Dali::Actor::DownCast()
198 int UtcDaliActorDownCastP(void)
200 TestApplication application;
201 tet_infoline("Testing Dali::Actor::DownCast()");
203 Actor actor = Actor::New();
204 BaseHandle object(actor);
205 Actor actor2 = Actor::DownCast(object);
206 DALI_TEST_CHECK(actor2);
210 //& purpose: Testing Dali::Actor::DownCast()
211 int UtcDaliActorDownCastN(void)
213 TestApplication application;
214 tet_infoline("Testing Dali::Actor::DownCast()");
216 BaseHandle unInitializedObject;
217 Actor actor = Actor::DownCast(unInitializedObject);
218 DALI_TEST_CHECK(!actor);
222 //& purpose: Testing Dali::Actor::GetName()
223 int UtcDaliActorGetName(void)
225 TestApplication application;
227 Actor actor = Actor::New();
229 DALI_TEST_CHECK(actor.GetName().empty());
233 //& purpose: Testing Dali::Actor::SetName()
234 int UtcDaliActorSetName(void)
236 TestApplication application;
238 string str("ActorName");
239 Actor actor = Actor::New();
242 DALI_TEST_CHECK(actor.GetName() == str);
246 int UtcDaliActorGetId(void)
248 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
249 TestApplication application;
251 Actor first = Actor::New();
252 Actor second = Actor::New();
253 Actor third = Actor::New();
255 DALI_TEST_CHECK(first.GetId() != second.GetId());
256 DALI_TEST_CHECK(second.GetId() != third.GetId());
260 int UtcDaliActorIsRoot(void)
262 TestApplication application;
264 Actor actor = Actor::New();
265 DALI_TEST_CHECK(!actor.IsRoot());
267 // get the root layer
268 actor = Stage::GetCurrent().GetLayer( 0 );
269 DALI_TEST_CHECK( actor.IsRoot() );
273 int UtcDaliActorOnStage(void)
275 TestApplication application;
277 Actor actor = Actor::New();
278 DALI_TEST_CHECK( !actor.OnStage() );
280 // get the root layer
281 actor = Stage::GetCurrent().GetLayer( 0 );
282 DALI_TEST_CHECK( actor.OnStage() );
286 int UtcDaliActorIsLayer(void)
288 TestApplication application;
290 Actor actor = Actor::New();
291 DALI_TEST_CHECK( !actor.IsLayer() );
293 // get the root layer
294 actor = Stage::GetCurrent().GetLayer( 0 );
295 DALI_TEST_CHECK( actor.IsLayer() );
299 int UtcDaliActorGetLayer(void)
301 TestApplication application;
303 Actor actor = Actor::New();
304 Stage::GetCurrent().Add(actor);
305 Layer layer = actor.GetLayer();
307 DALI_TEST_CHECK(layer);
309 // get the root layers layer
310 actor = Stage::GetCurrent().GetLayer( 0 );
311 DALI_TEST_CHECK( actor.GetLayer() );
315 int UtcDaliActorAddP(void)
317 tet_infoline("Testing Actor::Add");
318 TestApplication application;
320 Actor parent = Actor::New();
321 Actor child = Actor::New();
323 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
327 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
329 Actor parent2 = Actor::New();
330 parent2.Add( child );
332 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
333 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
335 // try Adding to same parent again, works
336 parent2.Add( child );
337 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
339 // try reparenting an orphaned child
341 Actor temporaryParent = Actor::New();
342 temporaryParent.Add( child );
343 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
345 // temporaryParent has now died, reparent the orphaned child
346 parent2.Add( child );
347 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
352 int UtcDaliActorAddN(void)
354 tet_infoline("Testing Actor::Add");
355 TestApplication application;
357 Actor child = Actor::New();
359 Actor parent2 = Actor::New();
360 parent2.Add( child );
365 parent2.Add( parent2 );
366 tet_printf("Assertion test failed - no Exception\n" );
367 tet_result(TET_FAIL);
369 catch(Dali::DaliException& e)
371 DALI_TEST_PRINT_ASSERT( e );
372 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
373 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
377 tet_printf("Assertion test failed - wrong Exception\n" );
378 tet_result(TET_FAIL);
381 // try reparenting root
384 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
385 tet_printf("Assertion test failed - no Exception\n" );
386 tet_result(TET_FAIL);
388 catch(Dali::DaliException& e)
390 DALI_TEST_PRINT_ASSERT( e );
391 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
392 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
396 tet_printf("Assertion test failed - wrong Exception\n" );
397 tet_result(TET_FAIL);
404 parent2.Add( empty );
405 tet_printf("Assertion test failed - no Exception\n" );
406 tet_result(TET_FAIL);
408 catch(Dali::DaliException& e)
410 DALI_TEST_PRINT_ASSERT( e );
411 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
412 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
416 tet_printf("Assertion test failed - wrong Exception\n" );
417 tet_result(TET_FAIL);
423 int UtcDaliActorRemoveN(void)
425 tet_infoline("Testing Actor::Remove");
426 TestApplication application;
428 Actor parent = Actor::New();
429 Actor child = Actor::New();
430 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
433 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
435 parent.Remove(child);
436 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
438 // remove again, no problem
439 parent.Remove(child);
440 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
444 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
445 // try Remove self, its a no-op
446 parent.Remove( parent );
447 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
453 parent.Remove( empty );
454 tet_printf("Assertion test failed - no Exception\n" );
455 tet_result(TET_FAIL);
457 catch(Dali::DaliException& e)
459 DALI_TEST_PRINT_ASSERT( e );
460 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
461 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
465 tet_printf("Assertion test failed - wrong Exception\n" );
466 tet_result(TET_FAIL);
471 int UtcDaliActorRemoveP(void)
473 TestApplication application;
475 Actor parent = Actor::New();
476 Actor child = Actor::New();
477 Actor random = Actor::New();
479 Stage::GetCurrent().Add( parent );
481 DALI_TEST_CHECK(parent.GetChildCount() == 0);
485 DALI_TEST_CHECK(parent.GetChildCount() == 1);
487 parent.Remove(random);
489 DALI_TEST_CHECK(parent.GetChildCount() == 1);
491 Stage::GetCurrent().Remove( parent );
493 DALI_TEST_CHECK(parent.GetChildCount() == 1);
497 int UtcDaliActorGetChildCount(void)
499 TestApplication application;
501 Actor parent = Actor::New();
502 Actor child = Actor::New();
504 DALI_TEST_CHECK(parent.GetChildCount() == 0);
508 DALI_TEST_CHECK(parent.GetChildCount() == 1);
512 int UtcDaliActorGetChildren01(void)
514 TestApplication application;
516 Actor parent = Actor::New();
517 Actor first = Actor::New();
518 Actor second = Actor::New();
519 Actor third = Actor::New();
525 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
526 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
527 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
531 int UtcDaliActorGetChildren02(void)
533 TestApplication application;
535 Actor parent = Actor::New();
536 Actor first = Actor::New();
537 Actor second = Actor::New();
538 Actor third = Actor::New();
544 const Actor& constParent = parent;
546 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
547 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
548 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
552 int UtcDaliActorGetParent01(void)
554 TestApplication application;
556 Actor parent = Actor::New();
557 Actor child = Actor::New();
561 DALI_TEST_CHECK(child.GetParent() == parent);
565 int UtcDaliActorGetParent02(void)
567 TestApplication application;
569 Actor actor = Actor::New();
571 DALI_TEST_CHECK(!actor.GetParent());
575 int UtcDaliActorSetParentOrigin(void)
577 TestApplication application;
579 Actor actor = Actor::New();
581 Vector3 vector(0.7f, 0.8f, 0.9f);
582 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
584 actor.SetParentOrigin(vector);
586 // flush the queue and render once
587 application.SendNotification();
588 application.Render();
590 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
592 Stage::GetCurrent().Add( actor );
594 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
596 // flush the queue and render once
597 application.SendNotification();
598 application.Render();
600 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
602 Stage::GetCurrent().Remove( actor );
606 int UtcDaliActorGetCurrentParentOrigin(void)
608 TestApplication application;
610 Actor actor = Actor::New();
612 Vector3 vector(0.7f, 0.8f, 0.9f);
613 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
615 actor.SetParentOrigin(vector);
617 // flush the queue and render once
618 application.SendNotification();
619 application.Render();
621 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
625 int UtcDaliActorSetAnchorPoint(void)
627 TestApplication application;
629 Actor actor = Actor::New();
631 Vector3 vector(0.7f, 0.8f, 0.9f);
632 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
634 actor.SetAnchorPoint(vector);
636 // flush the queue and render once
637 application.SendNotification();
638 application.Render();
640 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
642 Stage::GetCurrent().Add( actor );
644 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
645 // flush the queue and render once
646 application.SendNotification();
647 application.Render();
649 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
651 Stage::GetCurrent().Remove( actor );
655 int UtcDaliActorGetCurrentAnchorPoint(void)
657 TestApplication application;
659 Actor actor = Actor::New();
661 Vector3 vector(0.7f, 0.8f, 0.9f);
662 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
664 actor.SetAnchorPoint(vector);
666 // flush the queue and render once
667 application.SendNotification();
668 application.Render();
670 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
674 // SetSize(float width, float height)
675 int UtcDaliActorSetSize01(void)
677 TestApplication application;
679 Actor actor = Actor::New();
680 Vector3 vector(100.0f, 100.0f, 0.0f);
682 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
684 actor.SetSize(vector.x, vector.y);
686 // flush the queue and render once
687 application.SendNotification();
688 application.Render();
690 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
694 // SetSize(float width, float height, float depth)
695 int UtcDaliActorSetSize02(void)
697 TestApplication application;
699 Actor actor = Actor::New();
700 Vector3 vector(100.0f, 100.0f, 100.0f);
702 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
704 actor.SetSize(vector.x, vector.y, vector.z);
706 // flush the queue and render once
707 application.SendNotification();
708 application.Render();
710 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
714 // SetSize(Vector2 size)
715 int UtcDaliActorSetSize03(void)
717 TestApplication application;
719 Actor actor = Actor::New();
720 Vector3 vector(100.0f, 100.0f, 0.0f);
722 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
724 actor.SetSize(Vector2(vector.x, vector.y));
726 // flush the queue and render once
727 application.SendNotification();
728 application.Render();
730 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
734 // SetSize(Vector3 size)
735 int UtcDaliActorSetSize04(void)
737 TestApplication application;
739 Actor actor = Actor::New();
740 Vector3 vector(100.0f, 100.0f, 100.0f);
742 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
744 actor.SetSize(vector);
746 // flush the queue and render once
747 application.SendNotification();
748 application.Render();
750 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
752 Stage::GetCurrent().Add( actor );
753 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
755 // flush the queue and render once
756 application.SendNotification();
757 application.Render();
759 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
760 Stage::GetCurrent().Remove( actor );
764 int UtcDaliActorGetCurrentSize(void)
766 TestApplication application;
768 Actor actor = Actor::New();
769 Vector3 vector(100.0f, 100.0f, 20.0f);
771 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
773 actor.SetSize(vector);
775 // flush the queue and render once
776 application.SendNotification();
777 application.Render();
779 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
783 int UtcDaliActorGetNaturalSize(void)
785 TestApplication application;
787 Actor actor = Actor::New();
788 Vector3 vector( 0.0f, 0.0f, 0.0f );
790 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
795 int UtcDaliActorGetCurrentSizeImmediate(void)
797 TestApplication application;
799 Actor actor = Actor::New();
800 Vector3 vector(100.0f, 100.0f, 20.0f);
802 DALI_TEST_CHECK(vector != actor.GetTargetSize());
803 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
805 actor.SetSize(vector);
807 DALI_TEST_CHECK(vector == actor.GetTargetSize());
808 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
810 // flush the queue and render once
811 application.SendNotification();
812 application.Render();
814 DALI_TEST_CHECK(vector == actor.GetTargetSize());
815 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
818 // Build the animation
819 const float durationSeconds = 2.0f;
820 Animation animation = Animation::New( durationSeconds );
821 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
822 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
824 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
826 // Start the animation
829 application.SendNotification();
830 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
832 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
837 // SetPosition(float x, float y)
838 int UtcDaliActorSetPosition01(void)
840 TestApplication application;
842 Actor actor = Actor::New();
844 // Set to random to start off with
845 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
847 Vector3 vector(100.0f, 100.0f, 0.0f);
849 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
851 actor.SetPosition(vector.x, vector.y);
852 // flush the queue and render once
853 application.SendNotification();
854 application.Render();
855 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
857 Stage::GetCurrent().Add( actor );
858 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
859 // flush the queue and render once
860 application.SendNotification();
861 application.Render();
862 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
867 // flush the queue and render once
868 application.SendNotification();
869 application.Render();
870 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
872 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
873 // flush the queue and render once
874 application.SendNotification();
875 application.Render();
876 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
878 Stage::GetCurrent().Remove( actor );
882 // SetPosition(float x, float y, float z)
883 int UtcDaliActorSetPosition02(void)
885 TestApplication application;
887 Actor actor = Actor::New();
889 // Set to random to start off with
890 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
892 Vector3 vector(100.0f, 100.0f, 100.0f);
894 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
896 actor.SetPosition(vector.x, vector.y, vector.z);
898 // flush the queue and render once
899 application.SendNotification();
900 application.Render();
902 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
906 // SetPosition(Vector3 position)
907 int UtcDaliActorSetPosition03(void)
909 TestApplication application;
911 Actor actor = Actor::New();
913 // Set to random to start off with
914 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
916 Vector3 vector(100.0f, 100.0f, 100.0f);
918 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
920 actor.SetPosition(vector);
922 // flush the queue and render once
923 application.SendNotification();
924 application.Render();
926 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
930 int UtcDaliActorSetX(void)
932 TestApplication application;
934 Actor actor = Actor::New();
936 Vector3 vector(100.0f, 0.0f, 0.0f);
938 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
942 // flush the queue and render once
943 application.SendNotification();
944 application.Render();
946 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
950 int UtcDaliActorSetY(void)
952 TestApplication application;
954 Actor actor = Actor::New();
956 Vector3 vector(0.0f, 100.0f, 0.0f);
958 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
962 // flush the queue and render once
963 application.SendNotification();
964 application.Render();
966 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
970 int UtcDaliActorSetZ(void)
972 TestApplication application;
974 Actor actor = Actor::New();
976 Vector3 vector(0.0f, 0.0f, 100.0f);
978 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
982 // flush the queue and render once
983 application.SendNotification();
984 application.Render();
986 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
990 int UtcDaliActorTranslateBy(void)
992 TestApplication application;
994 Actor actor = Actor::New();
995 Vector3 vector(100.0f, 100.0f, 100.0f);
997 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
999 actor.SetPosition(vector);
1001 // flush the queue and render once
1002 application.SendNotification();
1003 application.Render();
1005 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1007 actor.TranslateBy(vector);
1009 // flush the queue and render once
1010 application.SendNotification();
1011 application.Render();
1013 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1017 int UtcDaliActorGetCurrentPosition(void)
1019 TestApplication application;
1021 Actor actor = Actor::New();
1022 Vector3 setVector(100.0f, 100.0f, 0.0f);
1023 actor.SetPosition(setVector);
1025 // flush the queue and render once
1026 application.SendNotification();
1027 application.Render();
1029 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1033 int UtcDaliActorGetCurrentWorldPosition(void)
1035 TestApplication application;
1037 Actor parent = Actor::New();
1038 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1039 parent.SetPosition( parentPosition );
1040 parent.SetParentOrigin( ParentOrigin::CENTER );
1041 parent.SetAnchorPoint( AnchorPoint::CENTER );
1042 Stage::GetCurrent().Add( parent );
1044 Actor child = Actor::New();
1045 child.SetParentOrigin( ParentOrigin::CENTER );
1046 child.SetAnchorPoint( AnchorPoint::CENTER );
1047 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1048 child.SetPosition( childPosition );
1049 parent.Add( child );
1051 // The actors should not have a world position yet
1052 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1053 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1055 application.SendNotification();
1056 application.Render(0);
1058 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1059 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1061 // The actors should have a world position now
1062 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1063 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1067 int UtcDaliActorInheritPosition(void)
1069 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1070 TestApplication application;
1072 Actor parent = Actor::New();
1073 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1074 parent.SetPosition( parentPosition );
1075 parent.SetParentOrigin( ParentOrigin::CENTER );
1076 parent.SetAnchorPoint( AnchorPoint::CENTER );
1077 Stage::GetCurrent().Add( parent );
1079 Actor child = Actor::New();
1080 child.SetParentOrigin( ParentOrigin::CENTER );
1081 child.SetAnchorPoint( AnchorPoint::CENTER );
1082 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1083 child.SetPosition( childPosition );
1084 parent.Add( child );
1086 // The actors should not have a world position yet
1087 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1088 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1090 // first test default, which is to inherit position
1091 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1092 application.SendNotification();
1093 application.Render(0); // should only really call Update as Render is not required to update scene
1094 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1095 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1096 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1097 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1100 //Change child position
1101 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1102 child.SetPosition( childOffset );
1104 // Change inheritance mode to not inherit
1105 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1106 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1107 application.SendNotification();
1108 application.Render(0); // should only really call Update as Render is not required to update scene
1109 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1110 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1111 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1112 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1116 int UtcDaliActorSetInheritPosition(void)
1118 tet_infoline("Testing Actor::SetInheritPosition");
1119 TestApplication application;
1121 Actor parent = Actor::New();
1122 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1123 parent.SetPosition( parentPosition );
1124 parent.SetParentOrigin( ParentOrigin::CENTER );
1125 parent.SetAnchorPoint( AnchorPoint::CENTER );
1126 Stage::GetCurrent().Add( parent );
1128 Actor child = Actor::New();
1129 child.SetParentOrigin( ParentOrigin::CENTER );
1130 child.SetAnchorPoint( AnchorPoint::CENTER );
1131 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1132 child.SetPosition( childPosition );
1133 parent.Add( child );
1135 // The actors should not have a world position yet
1136 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1137 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1139 // first test default, which is to inherit position
1140 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1141 application.SendNotification();
1142 application.Render(0); // should only really call Update as Render is not required to update scene
1143 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1144 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1145 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1146 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1148 //Change child position
1149 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1150 child.SetPosition( childOffset );
1152 // Use local position as world postion
1153 child.SetInheritPosition( false );
1154 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1155 application.SendNotification();
1156 application.Render(0); // should only really call Update as Render is not required to update scene
1157 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1158 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1159 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1160 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1162 //Change back to inherit position from parent
1163 child.SetInheritPosition( true );
1164 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1165 application.SendNotification();
1166 application.Render(0); // should only really call Update as Render is not required to update scene
1167 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1168 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1169 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1170 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1174 // SetOrientation(float angleRadians, Vector3 axis)
1175 int UtcDaliActorSetOrientation01(void)
1177 TestApplication application;
1179 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1180 Actor actor = Actor::New();
1182 actor.SetOrientation(rotation);
1184 // flush the queue and render once
1185 application.SendNotification();
1186 application.Render();
1188 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1192 int UtcDaliActorSetOrientation02(void)
1194 TestApplication application;
1196 Actor actor = Actor::New();
1198 Radian angle( 0.785f );
1199 Vector3 axis(1.0f, 1.0f, 0.0f);
1201 actor.SetOrientation( angle, axis);
1202 Quaternion rotation( angle, axis );
1203 // flush the queue and render once
1204 application.SendNotification();
1205 application.Render();
1206 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1208 Stage::GetCurrent().Add( actor );
1209 actor.RotateBy( Degree( 360 ), axis);
1210 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1212 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1213 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1214 // flush the queue and render once
1215 application.SendNotification();
1216 application.Render();
1217 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1219 actor.SetOrientation( angle, axis);
1220 // flush the queue and render once
1221 application.SendNotification();
1222 application.Render();
1223 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1225 Stage::GetCurrent().Remove( actor );
1229 // RotateBy(float angleRadians, Vector3 axis)
1230 int UtcDaliActorRotateBy01(void)
1232 TestApplication application;
1234 Actor actor = Actor::New();
1236 Radian angle( M_PI * 0.25f );
1237 actor.RotateBy(( angle ), Vector3::ZAXIS);
1238 // flush the queue and render once
1239 application.SendNotification();
1240 application.Render();
1241 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1243 Stage::GetCurrent().Add( actor );
1245 actor.RotateBy( angle, Vector3::ZAXIS);
1246 // flush the queue and render once
1247 application.SendNotification();
1248 application.Render();
1249 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1251 Stage::GetCurrent().Remove( actor );
1255 // RotateBy(Quaternion relativeRotation)
1256 int UtcDaliActorRotateBy02(void)
1258 TestApplication application;
1260 Actor actor = Actor::New();
1262 Radian angle( M_PI * 0.25f );
1263 Quaternion rotation(angle, Vector3::ZAXIS);
1264 actor.RotateBy(rotation);
1265 // flush the queue and render once
1266 application.SendNotification();
1267 application.Render();
1268 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1270 actor.RotateBy(rotation);
1271 // flush the queue and render once
1272 application.SendNotification();
1273 application.Render();
1274 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1278 int UtcDaliActorGetCurrentOrientation(void)
1280 TestApplication application;
1281 Actor actor = Actor::New();
1283 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1284 actor.SetOrientation(rotation);
1285 // flush the queue and render once
1286 application.SendNotification();
1287 application.Render();
1288 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1292 int UtcDaliActorGetCurrentWorldOrientation(void)
1294 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1295 TestApplication application;
1297 Actor parent = Actor::New();
1298 Radian rotationAngle( Degree(90.0f) );
1299 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1300 parent.SetOrientation( rotation );
1301 Stage::GetCurrent().Add( parent );
1303 Actor child = Actor::New();
1304 child.SetOrientation( rotation );
1305 parent.Add( child );
1307 // The actors should not have a world rotation yet
1308 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1309 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1311 application.SendNotification();
1312 application.Render(0);
1314 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1315 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1317 // The actors should have a world rotation now
1318 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1319 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1321 // turn off child rotation inheritance
1322 child.SetInheritOrientation( false );
1323 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1324 application.SendNotification();
1325 application.Render(0);
1327 // The actors should have a world rotation now
1328 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1329 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1333 // SetScale(float scale)
1334 int UtcDaliActorSetScale01(void)
1336 TestApplication application;
1338 Actor actor = Actor::New();
1340 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1341 actor.SetScale(0.25f);
1343 Vector3 scale(10.0f, 10.0f, 10.0f);
1344 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1346 actor.SetScale(scale.x);
1348 // flush the queue and render once
1349 application.SendNotification();
1350 application.Render();
1352 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1356 // SetScale(float scaleX, float scaleY, float scaleZ)
1357 int UtcDaliActorSetScale02(void)
1359 TestApplication application;
1360 Vector3 scale(10.0f, 10.0f, 10.0f);
1362 Actor actor = Actor::New();
1364 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1365 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1367 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1369 actor.SetScale(scale.x, scale.y, scale.z);
1370 // flush the queue and render once
1371 application.SendNotification();
1372 application.Render();
1373 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1375 // add to stage and test
1376 Stage::GetCurrent().Add( actor );
1377 actor.SetScale( 2.0f, 2.0f, 2.0f );
1378 // flush the queue and render once
1379 application.SendNotification();
1380 application.Render();
1381 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1383 Stage::GetCurrent().Remove( actor );
1388 // SetScale(Vector3 scale)
1389 int UtcDaliActorSetScale03(void)
1391 TestApplication application;
1392 Vector3 scale(10.0f, 10.0f, 10.0f);
1394 Actor actor = Actor::New();
1396 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1397 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1399 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1401 actor.SetScale(scale);
1403 // flush the queue and render once
1404 application.SendNotification();
1405 application.Render();
1407 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1411 int UtcDaliActorScaleBy(void)
1413 TestApplication application;
1414 Actor actor = Actor::New();
1415 Vector3 vector(100.0f, 100.0f, 100.0f);
1417 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1419 actor.SetScale(vector);
1421 // flush the queue and render once
1422 application.SendNotification();
1423 application.Render();
1425 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1427 actor.ScaleBy(vector);
1429 // flush the queue and render once
1430 application.SendNotification();
1431 application.Render();
1433 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1437 int UtcDaliActorGetCurrentScale(void)
1439 TestApplication application;
1440 Vector3 scale(12.0f, 1.0f, 2.0f);
1442 Actor actor = Actor::New();
1444 actor.SetScale(scale);
1446 // flush the queue and render once
1447 application.SendNotification();
1448 application.Render();
1450 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1454 int UtcDaliActorGetCurrentWorldScale(void)
1456 TestApplication application;
1458 Actor parent = Actor::New();
1459 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1460 parent.SetScale( parentScale );
1461 Stage::GetCurrent().Add( parent );
1463 Actor child = Actor::New();
1464 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1465 child.SetScale( childScale );
1466 parent.Add( child );
1468 // The actors should not have a scale yet
1469 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1470 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1472 // The actors should not have a world scale yet
1473 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1474 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1476 application.SendNotification();
1477 application.Render(0);
1479 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1480 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1482 // The actors should have a world scale now
1483 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1484 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1488 int UtcDaliActorInheritScale(void)
1490 tet_infoline("Testing Actor::SetInheritScale");
1491 TestApplication application;
1493 Actor parent = Actor::New();
1494 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1495 parent.SetScale( parentScale );
1496 Stage::GetCurrent().Add( parent );
1498 Actor child = Actor::New();
1499 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1500 child.SetScale( childScale );
1501 parent.Add( child );
1503 application.SendNotification();
1504 application.Render(0);
1506 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1507 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1509 child.SetInheritScale( false );
1510 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1512 application.SendNotification();
1513 application.Render(0);
1515 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1519 int UtcDaliActorSetVisible(void)
1521 TestApplication application;
1523 Actor actor = Actor::New();
1524 actor.SetVisible(false);
1525 // flush the queue and render once
1526 application.SendNotification();
1527 application.Render();
1528 DALI_TEST_CHECK(actor.IsVisible() == false);
1530 actor.SetVisible(true);
1531 // flush the queue and render once
1532 application.SendNotification();
1533 application.Render();
1534 DALI_TEST_CHECK(actor.IsVisible() == true);
1536 // put actor on stage
1537 Stage::GetCurrent().Add( actor );
1538 actor.SetVisible(false);
1539 // flush the queue and render once
1540 application.SendNotification();
1541 application.Render();
1542 DALI_TEST_CHECK(actor.IsVisible() == false);
1546 int UtcDaliActorIsVisible(void)
1548 TestApplication application;
1550 Actor actor = Actor::New();
1552 DALI_TEST_CHECK(actor.IsVisible() == true);
1556 int UtcDaliActorSetOpacity(void)
1558 TestApplication application;
1560 Actor actor = Actor::New();
1561 // initial opacity is 1
1562 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1564 actor.SetOpacity( 0.4f);
1565 // flush the queue and render once
1566 application.SendNotification();
1567 application.Render();
1568 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1570 // change opacity, actor is on stage to change is not immediate
1571 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1572 // flush the queue and render once
1573 application.SendNotification();
1574 application.Render();
1575 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1577 // put actor on stage
1578 Stage::GetCurrent().Add( actor );
1580 // change opacity, actor is on stage to change is not immediate
1581 actor.SetOpacity( 0.9f );
1582 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1583 // flush the queue and render once
1584 application.SendNotification();
1585 application.Render();
1586 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1588 // change opacity, actor is on stage to change is not immediate
1589 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1590 // flush the queue and render once
1591 application.SendNotification();
1592 application.Render();
1593 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1597 int UtcDaliActorGetCurrentOpacity(void)
1599 TestApplication application;
1601 Actor actor = Actor::New();
1602 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1604 actor.SetOpacity(0.5f);
1605 // flush the queue and render once
1606 application.SendNotification();
1607 application.Render();
1608 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1612 int UtcDaliActorSetSensitive(void)
1614 TestApplication application;
1615 Actor actor = Actor::New();
1617 bool sensitive = !actor.IsSensitive();
1619 actor.SetSensitive(sensitive);
1621 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1625 int UtcDaliActorIsSensitive(void)
1627 TestApplication application;
1628 Actor actor = Actor::New();
1629 actor.SetSensitive(false);
1631 DALI_TEST_CHECK(false == actor.IsSensitive());
1635 int UtcDaliActorSetColor(void)
1637 TestApplication application;
1638 Actor actor = Actor::New();
1639 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1641 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1643 actor.SetColor(color);
1644 // flush the queue and render once
1645 application.SendNotification();
1646 application.Render();
1647 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1649 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1650 // flush the queue and render once
1651 application.SendNotification();
1652 application.Render();
1653 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1655 Stage::GetCurrent().Add( actor );
1656 actor.SetColor( color );
1657 // flush the queue and render once
1658 application.SendNotification();
1659 application.Render();
1660 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1662 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1663 // flush the queue and render once
1664 application.SendNotification();
1665 application.Render();
1666 // Actor color is not clamped
1667 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1668 // world color is clamped
1669 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1671 Stage::GetCurrent().Remove( actor );
1675 int UtcDaliActorGetCurrentColor(void)
1677 TestApplication application;
1678 Actor actor = Actor::New();
1679 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1681 actor.SetColor(color);
1682 // flush the queue and render once
1683 application.SendNotification();
1684 application.Render();
1685 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1689 int UtcDaliActorGetCurrentWorldColor(void)
1691 tet_infoline("Actor::GetCurrentWorldColor");
1692 TestApplication application;
1694 Actor parent = Actor::New();
1695 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1696 parent.SetColor( parentColor );
1697 Stage::GetCurrent().Add( parent );
1699 Actor child = Actor::New();
1700 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1701 child.SetColor( childColor );
1702 parent.Add( child );
1704 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1705 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1707 // verify the default color mode
1708 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1710 // The actors should not have a world color yet
1711 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1712 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1714 application.SendNotification();
1715 application.Render(0);
1717 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1718 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1720 // The actors should have a world color now
1721 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1722 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1725 child.SetColorMode( USE_OWN_COLOR );
1726 application.SendNotification();
1727 application.Render(0);
1728 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1731 child.SetColorMode( USE_PARENT_COLOR );
1732 application.SendNotification();
1733 application.Render(0);
1734 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1735 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1738 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1739 application.SendNotification();
1740 application.Render(0);
1741 Vector4 expectedColor( childColor );
1742 expectedColor.a *= parentColor.a;
1743 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1744 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1748 int UtcDaliActorSetColorMode(void)
1750 tet_infoline("Actor::SetColorMode");
1751 TestApplication application;
1752 Actor actor = Actor::New();
1753 Actor child = Actor::New();
1756 actor.SetColorMode( USE_OWN_COLOR );
1757 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1759 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1760 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1762 actor.SetColorMode( USE_PARENT_COLOR );
1763 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1765 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1766 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1770 int UtcDaliActorScreenToLocal(void)
1772 TestApplication application;
1773 Actor actor = Actor::New();
1774 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1775 actor.SetSize(100.0f, 100.0f);
1776 actor.SetPosition(10.0f, 10.0f);
1777 Stage::GetCurrent().Add(actor);
1779 // flush the queue and render once
1780 application.SendNotification();
1781 application.Render();
1786 application.SendNotification();
1787 application.Render();
1789 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1791 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1792 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1796 int UtcDaliActorSetLeaveRequired(void)
1798 TestApplication application;
1800 Actor actor = Actor::New();
1802 actor.SetLeaveRequired(false);
1803 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1805 actor.SetLeaveRequired(true);
1806 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1810 int UtcDaliActorGetLeaveRequired(void)
1812 TestApplication application;
1814 Actor actor = Actor::New();
1816 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1820 int UtcDaliActorSetKeyboardFocusable(void)
1822 TestApplication application;
1824 Actor actor = Actor::New();
1826 actor.SetKeyboardFocusable(true);
1827 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1829 actor.SetKeyboardFocusable(false);
1830 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1834 int UtcDaliActorIsKeyboardFocusable(void)
1836 TestApplication application;
1838 Actor actor = Actor::New();
1840 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1844 int UtcDaliActorRemoveConstraints(void)
1846 tet_infoline(" UtcDaliActorRemoveConstraints");
1847 TestApplication application;
1849 gTestConstraintCalled = false;
1851 Actor actor = Actor::New();
1853 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
1855 actor.RemoveConstraints();
1857 DALI_TEST_CHECK( gTestConstraintCalled == false );
1859 Stage::GetCurrent().Add( actor );
1862 // flush the queue and render once
1863 application.SendNotification();
1864 application.Render();
1866 actor.RemoveConstraints();
1868 DALI_TEST_CHECK( gTestConstraintCalled == true );
1872 int UtcDaliActorRemoveConstraintTag(void)
1874 tet_infoline(" UtcDaliActorRemoveConstraintTag");
1875 TestApplication application;
1877 Actor actor = Actor::New();
1879 // 1. Apply Constraint1 and Constraint2, and test...
1880 unsigned int result1 = 0u;
1881 unsigned int result2 = 0u;
1883 unsigned constraint1Tag = 1u;
1884 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
1885 constraint1.SetTag( constraint1Tag );
1886 constraint1.Apply();
1888 unsigned constraint2Tag = 2u;
1889 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
1890 constraint2.SetTag( constraint2Tag );
1891 constraint2.Apply();
1893 Stage::GetCurrent().Add( actor );
1894 // flush the queue and render once
1895 application.SendNotification();
1896 application.Render();
1898 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1899 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1901 // 2. Remove Constraint1 and test...
1904 actor.RemoveConstraints(constraint1Tag);
1905 // make color property dirty, which will trigger constraints to be reapplied.
1906 actor.SetColor( Color::WHITE );
1907 // flush the queue and render once
1908 application.SendNotification();
1909 application.Render();
1911 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1912 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1914 // 3. Re-Apply Constraint1 and test...
1917 constraint1.Apply();
1918 // make color property dirty, which will trigger constraints to be reapplied.
1919 actor.SetColor( Color::WHITE );
1920 // flush the queue and render once
1921 application.SendNotification();
1922 application.Render();
1924 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1925 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1927 // 2. Remove Constraint2 and test...
1930 actor.RemoveConstraints(constraint2Tag);
1931 // make color property dirty, which will trigger constraints to be reapplied.
1932 actor.SetColor( Color::WHITE );
1933 // flush the queue and render once
1934 application.SendNotification();
1935 application.Render();
1937 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1938 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1940 // 2. Remove Constraint1 as well and test...
1943 actor.RemoveConstraints(constraint1Tag);
1944 // make color property dirty, which will trigger constraints to be reapplied.
1945 actor.SetColor( Color::WHITE );
1946 // flush the queue and render once
1947 application.SendNotification();
1948 application.Render();
1950 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1951 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1955 int UtcDaliActorTouchedSignal(void)
1957 TestApplication application;
1959 gTouchCallBackCalled = false;
1961 // get the root layer
1962 Actor actor = Stage::GetCurrent().GetRootLayer();
1963 DALI_TEST_CHECK( gTouchCallBackCalled == false );
1965 application.SendNotification();
1966 application.Render();
1968 // connect to its touch signal
1969 actor.TouchedSignal().Connect( TestCallback );
1971 // simulate a touch event in the middle of the screen
1972 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1973 Dali::Integration::Point point;
1974 point.SetDeviceId( 1 );
1975 point.SetState( PointState::DOWN );
1976 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
1977 Dali::Integration::TouchEvent event;
1978 event.AddPoint( point );
1979 application.ProcessEvent( event );
1981 DALI_TEST_CHECK( gTouchCallBackCalled == true );
1985 int UtcDaliActorHoveredSignal(void)
1987 TestApplication application;
1989 gHoverCallBackCalled = false;
1991 // get the root layer
1992 Actor actor = Stage::GetCurrent().GetRootLayer();
1993 DALI_TEST_CHECK( gHoverCallBackCalled == false );
1995 application.SendNotification();
1996 application.Render();
1998 // connect to its hover signal
1999 actor.HoveredSignal().Connect( TestCallback3 );
2001 // simulate a hover event in the middle of the screen
2002 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2003 Dali::Integration::Point point;
2004 point.SetDeviceId( 1 );
2005 point.SetState( PointState::MOTION );
2006 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2007 Dali::Integration::HoverEvent event;
2008 event.AddPoint( point );
2009 application.ProcessEvent( event );
2011 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2015 int UtcDaliActorOnOffStageSignal(void)
2017 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2019 TestApplication application;
2022 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2023 gActorNamesOnOffStage.clear();
2025 Actor parent = Actor::New();
2026 parent.SetName( "parent" );
2027 parent.OnStageSignal().Connect( OnStageCallback );
2028 parent.OffStageSignal().Connect( OffStageCallback );
2030 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2031 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2033 // add parent to stage
2034 Stage::GetCurrent().Add( parent );
2035 // onstage emitted, offstage not
2036 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2037 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2038 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2040 // test adding a child, should get onstage emitted
2042 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2043 gActorNamesOnOffStage.clear();
2045 Actor child = Actor::New();
2046 child.SetName( "child" );
2047 child.OnStageSignal().Connect( OnStageCallback );
2048 child.OffStageSignal().Connect( OffStageCallback );
2049 parent.Add( child ); // add child
2050 // onstage emitted, offstage not
2051 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2052 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2053 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2055 // test removing parent from stage
2057 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2058 gActorNamesOnOffStage.clear();
2060 Stage::GetCurrent().Remove( parent );
2061 // onstage not emitted, offstage is
2062 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2063 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2064 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2065 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2067 // test adding parent back to stage
2069 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2070 gActorNamesOnOffStage.clear();
2072 Stage::GetCurrent().Add( parent );
2073 // onstage emitted, offstage not
2074 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2075 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2076 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2077 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2079 // test removing child
2081 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2082 gActorNamesOnOffStage.clear();
2084 parent.Remove( child );
2085 // onstage not emitted, offstage is
2086 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2087 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2088 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2090 // test removing parent
2092 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2093 gActorNamesOnOffStage.clear();
2095 Stage::GetCurrent().Remove( parent );
2096 // onstage not emitted, offstage is
2097 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2098 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2099 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2103 int UtcDaliActorFindChildByName(void)
2105 tet_infoline("Testing Dali::Actor::FindChildByName()");
2106 TestApplication application;
2108 Actor parent = Actor::New();
2109 parent.SetName( "parent" );
2110 Actor first = Actor::New();
2111 first .SetName( "first" );
2112 Actor second = Actor::New();
2113 second.SetName( "second" );
2118 Actor found = parent.FindChildByName( "foo" );
2119 DALI_TEST_CHECK( !found );
2121 found = parent.FindChildByName( "parent" );
2122 DALI_TEST_CHECK( found == parent );
2124 found = parent.FindChildByName( "first" );
2125 DALI_TEST_CHECK( found == first );
2127 found = parent.FindChildByName( "second" );
2128 DALI_TEST_CHECK( found == second );
2132 int UtcDaliActorFindChildById(void)
2134 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2135 TestApplication application;
2137 Actor parent = Actor::New();
2138 Actor first = Actor::New();
2139 Actor second = Actor::New();
2144 Actor found = parent.FindChildById( 100000 );
2145 DALI_TEST_CHECK( !found );
2147 found = parent.FindChildById( parent.GetId() );
2148 DALI_TEST_CHECK( found == parent );
2150 found = parent.FindChildById( first.GetId() );
2151 DALI_TEST_CHECK( found == first );
2153 found = parent.FindChildById( second.GetId() );
2154 DALI_TEST_CHECK( found == second );
2158 int UtcDaliActorHitTest(void)
2163 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2165 mTouchPoint( touchPoint ),
2170 Vector2 mTouchPoint;
2174 TestApplication application;
2175 tet_infoline(" UtcDaliActorHitTest");
2177 // Fill a vector with different hit tests.
2178 struct HitTestData* hitTestData[] = {
2179 // scale touch point result
2180 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2181 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2182 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.
2183 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2184 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.
2188 // get the root layer
2189 Actor actor = Actor::New();
2190 actor.SetAnchorPoint( AnchorPoint::CENTER );
2191 actor.SetParentOrigin( ParentOrigin::CENTER );
2193 Stage::GetCurrent().Add( actor );
2195 gTouchCallBackCalled = false;
2197 unsigned int index = 0;
2198 while( NULL != hitTestData[index] )
2200 actor.SetSize( 1.f, 1.f );
2201 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2203 // flush the queue and render once
2204 application.SendNotification();
2205 application.Render();
2207 DALI_TEST_CHECK( !gTouchCallBackCalled );
2209 // connect to its touch signal
2210 actor.TouchedSignal().Connect(TestCallback);
2212 Dali::Integration::Point point;
2213 point.SetState( PointState::DOWN );
2214 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2215 Dali::Integration::TouchEvent event;
2216 event.AddPoint( point );
2218 // flush the queue and render once
2219 application.SendNotification();
2220 application.Render();
2221 application.ProcessEvent( event );
2223 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2225 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2226 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2227 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2228 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2229 hitTestData[index]->mResult );
2231 gTouchCallBackCalled = false;
2237 int UtcDaliActorSetDrawMode(void)
2239 TestApplication app;
2240 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2242 Actor a = Actor::New();
2244 Stage::GetCurrent().Add(a);
2245 app.SendNotification();
2247 app.SendNotification();
2250 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2252 a.SetDrawMode( DrawMode::OVERLAY_2D );
2253 app.SendNotification();
2256 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2258 a.SetDrawMode( DrawMode::STENCIL );
2259 app.SendNotification();
2262 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2264 a.SetDrawMode( DrawMode::NORMAL );
2265 app.SendNotification();
2268 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2272 int UtcDaliActorSetDrawModeOverlayRender(void)
2274 TestApplication app;
2275 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2277 app.SendNotification();
2280 std::vector<GLuint> ids;
2281 ids.push_back( 8 ); // first rendered actor
2282 ids.push_back( 9 ); // second rendered actor
2283 ids.push_back( 10 ); // third rendered actor
2284 app.GetGlAbstraction().SetNextTextureIds( ids );
2286 BufferImage imageA = BufferImage::New(16, 16);
2287 BufferImage imageB = BufferImage::New(16, 16);
2288 BufferImage imageC = BufferImage::New(16, 16);
2289 Actor a = CreateRenderableActor( imageA );
2290 Actor b = CreateRenderableActor( imageB );
2291 Actor c = CreateRenderableActor( imageC );
2293 // Render a,b,c as regular non-overlays. so order will be:
2297 Stage::GetCurrent().Add(a);
2298 Stage::GetCurrent().Add(b);
2299 Stage::GetCurrent().Add(c);
2301 app.SendNotification();
2304 // Should be 3 textures changes.
2305 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2306 typedef std::vector<GLuint>::size_type TextureSize;
2307 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2308 if( boundTextures.size() == 3 )
2310 DALI_TEST_CHECK( boundTextures[0] == 8u );
2311 DALI_TEST_CHECK( boundTextures[1] == 9u );
2312 DALI_TEST_CHECK( boundTextures[2] == 10u );
2315 // Now texture ids have been set, we can monitor their render order.
2316 // render a as an overlay (last), so order will be:
2320 a.SetDrawMode( DrawMode::OVERLAY_2D );
2321 app.GetGlAbstraction().ClearBoundTextures();
2323 app.SendNotification();
2326 // Should be 3 texture changes.
2327 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2328 if( boundTextures.size() == 3 )
2330 DALI_TEST_CHECK( boundTextures[0] == 9u );
2331 DALI_TEST_CHECK( boundTextures[1] == 10u );
2332 DALI_TEST_CHECK( boundTextures[2] == 8u );
2337 int UtcDaliActorGetCurrentWorldMatrix(void)
2339 TestApplication app;
2340 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2342 Actor parent = Actor::New();
2343 parent.SetParentOrigin(ParentOrigin::CENTER);
2344 parent.SetAnchorPoint(AnchorPoint::CENTER);
2345 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2346 Radian rotationAngle(Degree(85.0f));
2347 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2348 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2349 parent.SetPosition( parentPosition );
2350 parent.SetOrientation( parentRotation );
2351 parent.SetScale( parentScale );
2352 Stage::GetCurrent().Add( parent );
2354 Actor child = Actor::New();
2355 child.SetParentOrigin(ParentOrigin::CENTER);
2356 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2357 Radian childRotationAngle(Degree(23.0f));
2358 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2359 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2360 child.SetPosition( childPosition );
2361 child.SetOrientation( childRotation );
2362 child.SetScale( childScale );
2363 parent.Add( child );
2365 app.SendNotification();
2368 app.SendNotification();
2370 Matrix parentMatrix(false);
2371 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2373 Matrix childMatrix(false);
2374 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2376 //Child matrix should be the composition of child and parent
2377 Matrix childWorldMatrix(false);
2378 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2380 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2381 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2387 int UtcDaliActorConstrainedToWorldMatrix(void)
2389 TestApplication app;
2390 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2392 Actor parent = Actor::New();
2393 parent.SetParentOrigin(ParentOrigin::CENTER);
2394 parent.SetAnchorPoint(AnchorPoint::CENTER);
2395 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2396 Radian rotationAngle(Degree(85.0f));
2397 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2398 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2399 parent.SetPosition( parentPosition );
2400 parent.SetOrientation( parentRotation );
2401 parent.SetScale( parentScale );
2402 Stage::GetCurrent().Add( parent );
2404 Actor child = Actor::New();
2405 child.SetParentOrigin(ParentOrigin::CENTER);
2406 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2407 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2408 posConstraint.Apply();
2410 Stage::GetCurrent().Add( child );
2412 app.SendNotification();
2415 app.SendNotification();
2417 Matrix parentMatrix(false);
2418 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2420 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2421 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2425 int UtcDaliActorConstrainedToOrientation(void)
2427 TestApplication app;
2428 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2430 Actor parent = Actor::New();
2431 parent.SetParentOrigin(ParentOrigin::CENTER);
2432 parent.SetAnchorPoint(AnchorPoint::CENTER);
2433 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2434 Radian rotationAngle(Degree(85.0f));
2435 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2436 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2437 parent.SetPosition( parentPosition );
2438 parent.SetOrientation( parentRotation );
2439 parent.SetScale( parentScale );
2440 Stage::GetCurrent().Add( parent );
2442 Actor child = Actor::New();
2443 child.SetParentOrigin(ParentOrigin::CENTER);
2444 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2445 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2446 posConstraint.Apply();
2448 Stage::GetCurrent().Add( child );
2450 app.SendNotification();
2453 app.SendNotification();
2455 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2459 int UtcDaliActorUnparent(void)
2461 TestApplication app;
2462 tet_infoline(" UtcDaliActorUnparent");
2464 Actor parent = Actor::New();
2465 Stage::GetCurrent().Add( parent );
2467 Actor child = Actor::New();
2469 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2470 DALI_TEST_CHECK( !child.GetParent() );
2472 // Test that calling Unparent with no parent is a NOOP
2475 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2476 DALI_TEST_CHECK( !child.GetParent() );
2478 // Test that Unparent works
2479 parent.Add( child );
2481 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2482 DALI_TEST_CHECK( parent == child.GetParent() );
2486 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2487 DALI_TEST_CHECK( !child.GetParent() );
2489 // Test that UnparentAndReset works
2490 parent.Add( child );
2492 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2493 DALI_TEST_CHECK( parent == child.GetParent() );
2495 UnparentAndReset( child );
2497 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2498 DALI_TEST_CHECK( !child );
2500 // Test that UnparentAndReset is a NOOP with empty handle
2501 UnparentAndReset( child );
2503 DALI_TEST_CHECK( !child );
2507 int UtcDaliActorGetChildAt(void)
2509 TestApplication app;
2510 tet_infoline(" UtcDaliActorGetChildAt");
2512 Actor parent = Actor::New();
2513 Stage::GetCurrent().Add( parent );
2515 Actor child0 = Actor::New();
2516 parent.Add( child0 );
2518 Actor child1 = Actor::New();
2519 parent.Add( child1 );
2521 Actor child2 = Actor::New();
2522 parent.Add( child2 );
2524 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2525 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2526 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2530 int UtcDaliActorSetGetOverlay(void)
2532 TestApplication app;
2533 tet_infoline(" UtcDaliActorSetGetOverlay");
2535 Actor parent = Actor::New();
2536 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2537 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2542 int UtcDaliActorCreateDestroy(void)
2544 Actor* actor = new Actor;
2545 DALI_TEST_CHECK( actor );
2552 struct PropertyStringIndex
2554 const char * const name;
2555 const Property::Index index;
2556 const Property::Type type;
2559 const PropertyStringIndex PROPERTY_TABLE[] =
2561 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2562 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2563 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2564 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2565 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2566 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2567 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2568 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2569 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2570 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2571 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2572 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2573 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2574 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
2575 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
2576 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
2577 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2578 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2579 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2580 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2581 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2582 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2583 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2584 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
2585 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
2586 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
2587 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2588 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2589 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2590 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
2591 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
2592 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2593 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2594 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2595 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2596 { "name", Actor::Property::NAME, Property::STRING },
2597 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2598 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2599 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2600 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2601 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
2602 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2603 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
2604 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2605 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2606 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2607 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2608 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2609 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2610 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2611 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2612 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2614 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2615 } // unnamed namespace
2617 int UtcDaliActorProperties(void)
2619 TestApplication app;
2621 Actor actor = Actor::New();
2623 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2625 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2626 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2627 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2628 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2633 int UtcDaliRelayoutProperties_ResizePolicies(void)
2635 TestApplication app;
2637 Actor actor = Actor::New();
2640 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2641 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2643 // Set resize policy for all dimensions
2644 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2645 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2647 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2650 // Set individual dimensions
2651 const char* const widthPolicy = "FILL_TO_PARENT";
2652 const char* const heightPolicy = "FIXED";
2654 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2655 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2657 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2658 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2663 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2665 TestApplication app;
2667 Actor actor = Actor::New();
2670 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2671 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2673 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2674 actor.SetSizeScalePolicy( policy );
2675 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2678 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2679 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2681 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2682 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2684 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2685 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2690 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2692 TestApplication app;
2694 Actor actor = Actor::New();
2697 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2698 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2700 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2701 actor.SetSizeModeFactor( sizeMode );
2702 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2705 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2707 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2708 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2713 int UtcDaliRelayoutProperties_DimensionDependency(void)
2715 TestApplication app;
2717 Actor actor = Actor::New();
2720 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2721 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2724 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2725 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2727 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2728 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2730 // Test setting another resize policy
2731 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2732 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2737 int UtcDaliRelayoutProperties_Padding(void)
2739 TestApplication app;
2741 Actor actor = Actor::New();
2744 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2747 actor.SetProperty( Actor::Property::PADDING, padding );
2748 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2750 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2755 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2757 TestApplication app;
2759 Actor actor = Actor::New();
2762 Vector2 minSize( 1.0f, 2.0f );
2764 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2765 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2767 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2769 Vector2 maxSize( 3.0f, 4.0f );
2771 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2772 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2774 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2779 int UtcDaliActorGetHeightForWidth(void)
2781 TestApplication app;
2783 Actor actor = Actor::New();
2785 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
2790 int UtcDaliActorGetWidthForHeight(void)
2792 TestApplication app;
2794 Actor actor = Actor::New();
2796 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
2801 int UtcDaliActorGetRelayoutSize(void)
2803 TestApplication app;
2805 Actor actor = Actor::New();
2807 // Add actor to stage
2808 Stage::GetCurrent().Add( actor );
2810 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
2812 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
2813 actor.SetSize( Vector2( 1.0f, 0.0f ) );
2815 // Flush the queue and render once
2816 app.SendNotification();
2819 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
2824 int UtcDaliActorSetPadding(void)
2826 TestApplication app;
2828 Actor actor = Actor::New();
2831 actor.GetPadding( padding );
2833 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
2834 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
2835 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
2836 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
2838 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
2839 actor.SetPadding( padding2 );
2841 actor.GetPadding( padding );
2843 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
2844 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
2845 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
2846 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
2851 int UtcDaliActorSetMinimumSize(void)
2853 TestApplication app;
2855 Actor actor = Actor::New();
2857 Vector2 size = actor.GetMinimumSize();
2859 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
2860 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
2862 Vector2 size2( 1.0f, 2.0f );
2863 actor.SetMinimumSize( size2 );
2865 size = actor.GetMinimumSize();
2867 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2868 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2873 int UtcDaliActorSetMaximumSize(void)
2875 TestApplication app;
2877 Actor actor = Actor::New();
2879 Vector2 size = actor.GetMaximumSize();
2881 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
2882 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
2884 Vector2 size2( 1.0f, 2.0f );
2885 actor.SetMaximumSize( size2 );
2887 size = actor.GetMaximumSize();
2889 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2890 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2895 int UtcDaliActorOnRelayoutSignal(void)
2897 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
2899 TestApplication application;
2902 gOnRelayoutCallBackCalled = false;
2903 gActorNamesRelayout.clear();
2905 Actor actor = Actor::New();
2906 actor.SetName( "actor" );
2907 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
2910 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
2912 // Add actor to stage
2913 Stage::GetCurrent().Add( actor );
2915 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2916 actor.SetSize( Vector2( 1.0f, 2.0 ) );
2918 // Flush the queue and render once
2919 application.SendNotification();
2920 application.Render();
2922 // OnRelayout emitted
2923 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
2924 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
2929 int UtcDaliActorGetHierachyDepth(void)
2931 TestApplication application;
2932 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
2935 /* Build tree of actors:
2945 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
2947 Stage stage( Stage::GetCurrent() );
2949 Actor actorA = Actor::New();
2950 Actor actorB = Actor::New();
2951 Actor actorC = Actor::New();
2952 Actor actorD = Actor::New();
2953 Actor actorE = Actor::New();
2954 Actor actorF = Actor::New();
2956 //Test that root actor has depth equal 0
2957 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
2959 //Test actors return depth -1 when not connected to the tree
2960 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2961 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2962 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
2963 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2964 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2965 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
2967 //Create the hierarchy
2968 stage.Add( actorA );
2969 actorA.Add( actorB );
2970 actorA.Add( actorC );
2971 actorB.Add( actorD );
2972 actorB.Add( actorE );
2973 actorC.Add( actorF );
2975 //Test actors return correct depth
2976 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2977 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
2978 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
2979 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
2980 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
2981 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
2983 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
2984 actorA.Remove( actorB );
2986 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2987 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2988 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2990 //Removing actorA from the stage. All actors should have depth equal -1
2991 stage.Remove( actorA );
2993 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
2994 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
2995 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
2996 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
2997 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
2998 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3003 int UtcDaliActorAnchorPointPropertyAsString(void)
3005 TestApplication application;
3007 Actor actor = Actor::New();
3009 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3010 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3012 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3013 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3015 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3016 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3018 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3019 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3021 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3022 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3024 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3025 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3027 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3028 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3030 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3031 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3033 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3034 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3036 // Invalid should not change anything
3037 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3038 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3043 int UtcDaliActorParentOriginPropertyAsString(void)
3045 TestApplication application;
3047 Actor actor = Actor::New();
3049 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3050 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3052 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3053 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3055 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3056 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3058 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3059 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3061 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3062 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3064 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3065 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3067 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3068 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3070 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3071 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3073 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3074 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3076 // Invalid should not change anything
3077 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3078 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3083 int UtcDaliActorColorModePropertyAsString(void)
3085 TestApplication application;
3087 Actor actor = Actor::New();
3089 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3090 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3092 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3093 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3095 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3096 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3098 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3099 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3101 // Invalid should not change anything
3102 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3103 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3108 int UtcDaliActorPositionInheritancePropertyAsString(void)
3110 TestApplication application;
3112 Actor actor = Actor::New();
3114 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3115 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3117 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3118 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3120 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3121 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3123 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3124 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3126 // Invalid should not change anything
3127 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3128 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3133 int UtcDaliActorDrawModePropertyAsString(void)
3135 TestApplication application;
3137 Actor actor = Actor::New();
3139 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3140 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3142 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3143 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3145 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3146 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3148 // Invalid should not change anything
3149 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3150 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );