2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/public-api/dali-core.h>
21 #include <cfloat> // For FLT_MAX
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/hover-event-integ.h>
24 #include <dali-test-suite-utils.h>
32 void utc_dali_actor_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_actor_cleanup(void)
39 test_return_value = TET_PASS;
44 bool gTouchCallBackCalled=false;
45 bool gTouchCallBack2Called=false;
46 bool gHoverCallBackCalled=false;
49 * Simulates a Down Touch at 25.0, 25.0.
50 * @param[in] app Test Application instance.
52 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
54 app.SendNotification();
56 app.SendNotification();
59 gTouchCallBackCalled = false;
60 gTouchCallBack2Called = false;
62 // simulate a touch event
63 Dali::TouchPoint point( 0, TouchPoint::Down, 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 TestCallback2(Actor actor, const TouchEvent& event)
118 gTouchCallBack2Called = true;
123 static bool TestCallback3(Actor actor, const HoverEvent& event)
125 gHoverCallBackCalled = true;
130 static Vector3 gSetSize;
131 static bool gSetSizeCallBackCalled;
132 void SetSizeCallback( Actor actor, const Vector3& size )
134 gSetSizeCallBackCalled = true;
137 // validation stuff for onstage & offstage signals
138 static std::vector< std::string > gActorNamesOnOffStage;
139 static int gOnStageCallBackCalled;
140 void OnStageCallback( Actor actor )
142 ++gOnStageCallBackCalled;
143 gActorNamesOnOffStage.push_back( actor.GetName() );
144 DALI_TEST_CHECK( actor.OnStage() == true );
146 static int gOffStageCallBackCalled;
147 void OffStageCallback( Actor actor )
149 ++gOffStageCallBackCalled;
150 gActorNamesOnOffStage.push_back( actor.GetName() );
151 DALI_TEST_CHECK( actor.OnStage() == false );
154 struct PositionComponentConstraint
156 PositionComponentConstraint(){}
158 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
160 const Matrix& m = inputs[0]->GetMatrix();
163 m.GetTransformComponents(pos, rot, scale);
169 static bool gOnRelayoutCallBackCalled = 0;
170 static std::vector< std::string > gActorNamesRelayout;
172 void OnRelayoutCallback( Actor actor )
174 ++gOnRelayoutCallBackCalled;
175 gActorNamesRelayout.push_back( actor.GetName() );
178 } // anonymous namespace
181 //& purpose: Testing New API
182 int UtcDaliActorNew(void)
184 TestApplication application;
186 Actor actor = Actor::New();
188 DALI_TEST_CHECK(actor);
192 //& purpose: Testing Dali::Actor::DownCast()
193 int UtcDaliActorDownCastP(void)
195 TestApplication application;
196 tet_infoline("Testing Dali::Actor::DownCast()");
198 Actor actor = Actor::New();
199 BaseHandle object(actor);
200 Actor actor2 = Actor::DownCast(object);
201 DALI_TEST_CHECK(actor2);
205 //& purpose: Testing Dali::Actor::DownCast()
206 int UtcDaliActorDownCastN(void)
208 TestApplication application;
209 tet_infoline("Testing Dali::Actor::DownCast()");
211 BaseHandle unInitializedObject;
212 Actor actor = Actor::DownCast(unInitializedObject);
213 DALI_TEST_CHECK(!actor);
217 //& purpose: Testing Dali::Actor::GetName()
218 int UtcDaliActorGetName(void)
220 TestApplication application;
222 Actor actor = Actor::New();
224 DALI_TEST_CHECK(actor.GetName().empty());
228 //& purpose: Testing Dali::Actor::SetName()
229 int UtcDaliActorSetName(void)
231 TestApplication application;
233 string str("ActorName");
234 Actor actor = Actor::New();
237 DALI_TEST_CHECK(actor.GetName() == str);
241 int UtcDaliActorGetId(void)
243 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
244 TestApplication application;
246 Actor first = Actor::New();
247 Actor second = Actor::New();
248 Actor third = Actor::New();
250 DALI_TEST_CHECK(first.GetId() != second.GetId());
251 DALI_TEST_CHECK(second.GetId() != third.GetId());
255 int UtcDaliActorIsRoot(void)
257 TestApplication application;
259 Actor actor = Actor::New();
260 DALI_TEST_CHECK(!actor.IsRoot());
262 // get the root layer
263 actor = Stage::GetCurrent().GetLayer( 0 );
264 DALI_TEST_CHECK( actor.IsRoot() );
268 int UtcDaliActorOnStage(void)
270 TestApplication application;
272 Actor actor = Actor::New();
273 DALI_TEST_CHECK( !actor.OnStage() );
275 // get the root layer
276 actor = Stage::GetCurrent().GetLayer( 0 );
277 DALI_TEST_CHECK( actor.OnStage() );
281 int UtcDaliActorIsLayer(void)
283 TestApplication application;
285 Actor actor = Actor::New();
286 DALI_TEST_CHECK( !actor.IsLayer() );
288 // get the root layer
289 actor = Stage::GetCurrent().GetLayer( 0 );
290 DALI_TEST_CHECK( actor.IsLayer() );
294 int UtcDaliActorGetLayer(void)
296 TestApplication application;
298 Actor actor = Actor::New();
299 Stage::GetCurrent().Add(actor);
300 Layer layer = actor.GetLayer();
302 DALI_TEST_CHECK(layer);
304 // get the root layers layer
305 actor = Stage::GetCurrent().GetLayer( 0 );
306 DALI_TEST_CHECK( actor.GetLayer() );
310 int UtcDaliActorAddP(void)
312 tet_infoline("Testing Actor::Add");
313 TestApplication application;
315 Actor parent = Actor::New();
316 Actor child = Actor::New();
318 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
322 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
324 Actor parent2 = Actor::New();
325 parent2.Add( child );
327 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
328 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
330 // try Adding to same parent again, works
331 parent2.Add( child );
332 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
334 // try reparenting an orphaned child
336 Actor temporaryParent = Actor::New();
337 temporaryParent.Add( child );
338 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
340 // temporaryParent has now died, reparent the orphaned child
341 parent2.Add( child );
342 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
347 int UtcDaliActorAddN(void)
349 tet_infoline("Testing Actor::Add");
350 TestApplication application;
352 Actor child = Actor::New();
354 Actor parent2 = Actor::New();
355 parent2.Add( child );
360 parent2.Add( parent2 );
361 tet_printf("Assertion test failed - no Exception\n" );
362 tet_result(TET_FAIL);
364 catch(Dali::DaliException& e)
366 DALI_TEST_PRINT_ASSERT( e );
367 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
368 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
372 tet_printf("Assertion test failed - wrong Exception\n" );
373 tet_result(TET_FAIL);
376 // try reparenting root
379 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
380 tet_printf("Assertion test failed - no Exception\n" );
381 tet_result(TET_FAIL);
383 catch(Dali::DaliException& e)
385 DALI_TEST_PRINT_ASSERT( e );
386 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
387 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
391 tet_printf("Assertion test failed - wrong Exception\n" );
392 tet_result(TET_FAIL);
399 parent2.Add( empty );
400 tet_printf("Assertion test failed - no Exception\n" );
401 tet_result(TET_FAIL);
403 catch(Dali::DaliException& e)
405 DALI_TEST_PRINT_ASSERT( e );
406 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
407 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
411 tet_printf("Assertion test failed - wrong Exception\n" );
412 tet_result(TET_FAIL);
418 int UtcDaliActorInsert(void)
420 tet_infoline("Testing Actor::Insert");
421 TestApplication application;
423 Actor parent = Actor::New();
424 Stage::GetCurrent().Add( parent );
425 Actor first = Actor::New();
426 Actor second = Actor::New();
427 Actor third = Actor::New();
429 parent.Insert(1, first); // test insert beyond range
430 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
431 parent.Insert(0, second);
432 DALI_TEST_EQUALS( parent.GetChildCount(), 2u, TEST_LOCATION );
433 parent.Insert(1, third);
435 DALI_TEST_EQUALS( parent.GetChildCount(), 3u, TEST_LOCATION );
437 DALI_TEST_CHECK(parent.GetChildAt(0) == second);
438 DALI_TEST_CHECK(parent.GetChildAt(1) == third);
439 DALI_TEST_CHECK(parent.GetChildAt(2) == first);
445 int UtcDaliActorRemoveN(void)
447 tet_infoline("Testing Actor::Remove");
448 TestApplication application;
450 Actor parent = Actor::New();
451 Actor child = Actor::New();
452 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
455 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
457 parent.Remove(child);
458 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
460 // remove again, no problem
461 parent.Remove(child);
462 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
466 // try illegal Remove
469 parent.Remove( parent );
470 tet_printf("Assertion test failed - no Exception\n" );
471 tet_result(TET_FAIL);
473 catch(Dali::DaliException& e)
475 DALI_TEST_PRINT_ASSERT( e );
476 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
477 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
481 tet_printf("Assertion test failed - wrong Exception\n" );
482 tet_result(TET_FAIL);
489 parent.Remove( empty );
490 tet_printf("Assertion test failed - no Exception\n" );
491 tet_result(TET_FAIL);
493 catch(Dali::DaliException& e)
495 DALI_TEST_PRINT_ASSERT( e );
496 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
497 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
501 tet_printf("Assertion test failed - wrong Exception\n" );
502 tet_result(TET_FAIL);
507 int UtcDaliActorRemoveP(void)
509 TestApplication application;
511 Actor parent = Actor::New();
512 Actor child = Actor::New();
513 Actor random = Actor::New();
515 Stage::GetCurrent().Add( parent );
517 DALI_TEST_CHECK(parent.GetChildCount() == 0);
521 DALI_TEST_CHECK(parent.GetChildCount() == 1);
523 parent.Remove(random);
525 DALI_TEST_CHECK(parent.GetChildCount() == 1);
527 Stage::GetCurrent().Remove( parent );
529 DALI_TEST_CHECK(parent.GetChildCount() == 1);
533 int UtcDaliActorGetChildCount(void)
535 TestApplication application;
537 Actor parent = Actor::New();
538 Actor child = Actor::New();
540 DALI_TEST_CHECK(parent.GetChildCount() == 0);
544 DALI_TEST_CHECK(parent.GetChildCount() == 1);
548 int UtcDaliActorGetChildren01(void)
550 TestApplication application;
552 Actor parent = Actor::New();
553 Actor first = Actor::New();
554 Actor second = Actor::New();
555 Actor third = Actor::New();
561 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
562 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
563 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
567 int UtcDaliActorGetChildren02(void)
569 TestApplication application;
571 Actor parent = Actor::New();
572 Actor first = Actor::New();
573 Actor second = Actor::New();
574 Actor third = Actor::New();
580 const Actor& constParent = parent;
582 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
583 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
584 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
588 int UtcDaliActorGetParent01(void)
590 TestApplication application;
592 Actor parent = Actor::New();
593 Actor child = Actor::New();
597 DALI_TEST_CHECK(child.GetParent() == parent);
601 int UtcDaliActorGetParent02(void)
603 TestApplication application;
605 Actor actor = Actor::New();
607 DALI_TEST_CHECK(!actor.GetParent());
611 int UtcDaliActorSetParentOrigin(void)
613 TestApplication application;
615 Actor actor = Actor::New();
617 Vector3 vector(0.7f, 0.8f, 0.9f);
618 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
620 actor.SetParentOrigin(vector);
622 // flush the queue and render once
623 application.SendNotification();
624 application.Render();
626 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
628 Stage::GetCurrent().Add( actor );
630 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
632 // flush the queue and render once
633 application.SendNotification();
634 application.Render();
636 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
638 Stage::GetCurrent().Remove( actor );
642 int UtcDaliActorGetCurrentParentOrigin(void)
644 TestApplication application;
646 Actor actor = Actor::New();
648 Vector3 vector(0.7f, 0.8f, 0.9f);
649 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
651 actor.SetParentOrigin(vector);
653 // flush the queue and render once
654 application.SendNotification();
655 application.Render();
657 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
661 int UtcDaliActorSetAnchorPoint(void)
663 TestApplication application;
665 Actor actor = Actor::New();
667 Vector3 vector(0.7f, 0.8f, 0.9f);
668 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
670 actor.SetAnchorPoint(vector);
672 // flush the queue and render once
673 application.SendNotification();
674 application.Render();
676 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
678 Stage::GetCurrent().Add( actor );
680 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
681 // flush the queue and render once
682 application.SendNotification();
683 application.Render();
685 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
687 Stage::GetCurrent().Remove( actor );
691 int UtcDaliActorGetCurrentAnchorPoint(void)
693 TestApplication application;
695 Actor actor = Actor::New();
697 Vector3 vector(0.7f, 0.8f, 0.9f);
698 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
700 actor.SetAnchorPoint(vector);
702 // flush the queue and render once
703 application.SendNotification();
704 application.Render();
706 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
710 // SetSize(float width, float height)
711 int UtcDaliActorSetSize01(void)
713 TestApplication application;
715 Actor actor = Actor::New();
716 Vector3 vector(100.0f, 100.0f, 100.0f);
718 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
720 actor.SetSize(vector.x, vector.y);
722 // flush the queue and render once
723 application.SendNotification();
724 application.Render();
726 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
730 // SetSize(float width, float height, float depth)
731 int UtcDaliActorSetSize02(void)
733 TestApplication application;
735 Actor actor = Actor::New();
736 Vector3 vector(100.0f, 100.0f, 100.0f);
738 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
740 actor.SetSize(vector.x, vector.y, vector.z);
742 // flush the queue and render once
743 application.SendNotification();
744 application.Render();
746 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
750 // SetSize(Vector2 size)
751 int UtcDaliActorSetSize03(void)
753 TestApplication application;
755 Actor actor = Actor::New();
756 Vector3 vector(100.0f, 100.0f, 100.0f);
758 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
760 actor.SetSize(Vector2(vector.x, vector.y));
762 // flush the queue and render once
763 application.SendNotification();
764 application.Render();
766 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
770 // SetSize(Vector3 size)
771 int UtcDaliActorSetSize04(void)
773 TestApplication application;
775 Actor actor = Actor::New();
776 Vector3 vector(100.0f, 100.0f, 100.0f);
778 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
780 actor.SetSize(vector);
782 // flush the queue and render once
783 application.SendNotification();
784 application.Render();
786 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
788 Stage::GetCurrent().Add( actor );
789 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
791 // flush the queue and render once
792 application.SendNotification();
793 application.Render();
795 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
796 Stage::GetCurrent().Remove( actor );
800 int UtcDaliActorGetCurrentSize(void)
802 TestApplication application;
804 Actor actor = Actor::New();
805 Vector3 vector(100.0f, 100.0f, 20.0f);
807 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
809 actor.SetSize(vector);
811 // flush the queue and render once
812 application.SendNotification();
813 application.Render();
815 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
819 int UtcDaliActorGetNaturalSize(void)
821 TestApplication application;
823 Actor actor = Actor::New();
824 Vector3 vector( 0.0f, 0.0f, 0.0f );
826 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
831 int UtcDaliActorGetCurrentSizeImmediate(void)
833 TestApplication application;
835 Actor actor = Actor::New();
836 Vector3 vector(100.0f, 100.0f, 20.0f);
838 DALI_TEST_CHECK(vector != actor.GetTargetSize());
839 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
841 actor.SetSize(vector);
843 DALI_TEST_CHECK(vector == actor.GetTargetSize());
844 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
846 // flush the queue and render once
847 application.SendNotification();
848 application.Render();
850 DALI_TEST_CHECK(vector == actor.GetTargetSize());
851 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
854 // Build the animation
855 const float durationSeconds = 2.0f;
856 Animation animation = Animation::New( durationSeconds );
857 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
858 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
860 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
862 // Start the animation
865 application.SendNotification();
866 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
868 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
873 // SetPosition(float x, float y)
874 int UtcDaliActorSetPosition01(void)
876 TestApplication application;
878 Actor actor = Actor::New();
880 // Set to random to start off with
881 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
883 Vector3 vector(100.0f, 100.0f, 0.0f);
885 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
887 actor.SetPosition(vector.x, vector.y);
888 // flush the queue and render once
889 application.SendNotification();
890 application.Render();
891 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
893 Stage::GetCurrent().Add( actor );
894 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
895 // flush the queue and render once
896 application.SendNotification();
897 application.Render();
898 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
903 // flush the queue and render once
904 application.SendNotification();
905 application.Render();
906 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
908 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
909 // flush the queue and render once
910 application.SendNotification();
911 application.Render();
912 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
914 Stage::GetCurrent().Remove( actor );
918 // SetPosition(float x, float y, float z)
919 int UtcDaliActorSetPosition02(void)
921 TestApplication application;
923 Actor actor = Actor::New();
925 // Set to random to start off with
926 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
928 Vector3 vector(100.0f, 100.0f, 100.0f);
930 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
932 actor.SetPosition(vector.x, vector.y, vector.z);
934 // flush the queue and render once
935 application.SendNotification();
936 application.Render();
938 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
942 // SetPosition(Vector3 position)
943 int UtcDaliActorSetPosition03(void)
945 TestApplication application;
947 Actor actor = Actor::New();
949 // Set to random to start off with
950 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
952 Vector3 vector(100.0f, 100.0f, 100.0f);
954 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
956 actor.SetPosition(vector);
958 // flush the queue and render once
959 application.SendNotification();
960 application.Render();
962 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
966 int UtcDaliActorSetX(void)
968 TestApplication application;
970 Actor actor = Actor::New();
972 Vector3 vector(100.0f, 0.0f, 0.0f);
974 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
978 // flush the queue and render once
979 application.SendNotification();
980 application.Render();
982 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
986 int UtcDaliActorSetY(void)
988 TestApplication application;
990 Actor actor = Actor::New();
992 Vector3 vector(0.0f, 100.0f, 0.0f);
994 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
998 // flush the queue and render once
999 application.SendNotification();
1000 application.Render();
1002 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1006 int UtcDaliActorSetZ(void)
1008 TestApplication application;
1010 Actor actor = Actor::New();
1012 Vector3 vector(0.0f, 0.0f, 100.0f);
1014 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1018 // flush the queue and render once
1019 application.SendNotification();
1020 application.Render();
1022 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1026 int UtcDaliActorTranslateBy(void)
1028 TestApplication application;
1030 Actor actor = Actor::New();
1031 Vector3 vector(100.0f, 100.0f, 100.0f);
1033 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1035 actor.SetPosition(vector);
1037 // flush the queue and render once
1038 application.SendNotification();
1039 application.Render();
1041 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1043 actor.TranslateBy(vector);
1045 // flush the queue and render once
1046 application.SendNotification();
1047 application.Render();
1049 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1053 int UtcDaliActorGetCurrentPosition(void)
1055 TestApplication application;
1057 Actor actor = Actor::New();
1058 Vector3 setVector(100.0f, 100.0f, 0.0f);
1059 actor.SetPosition(setVector);
1061 // flush the queue and render once
1062 application.SendNotification();
1063 application.Render();
1065 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1069 int UtcDaliActorGetCurrentWorldPosition(void)
1071 TestApplication application;
1073 Actor parent = Actor::New();
1074 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1075 parent.SetPosition( parentPosition );
1076 parent.SetParentOrigin( ParentOrigin::CENTER );
1077 parent.SetAnchorPoint( AnchorPoint::CENTER );
1078 Stage::GetCurrent().Add( parent );
1080 Actor child = Actor::New();
1081 child.SetParentOrigin( ParentOrigin::CENTER );
1082 child.SetAnchorPoint( AnchorPoint::CENTER );
1083 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1084 child.SetPosition( childPosition );
1085 parent.Add( child );
1087 // The actors should not have a world position yet
1088 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1089 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1091 application.SendNotification();
1092 application.Render(0);
1094 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1095 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1097 // The actors should have a world position now
1098 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1099 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1103 int UtcDaliActorInheritPosition(void)
1105 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1106 TestApplication application;
1108 Actor parent = Actor::New();
1109 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1110 parent.SetPosition( parentPosition );
1111 parent.SetParentOrigin( ParentOrigin::CENTER );
1112 parent.SetAnchorPoint( AnchorPoint::CENTER );
1113 Stage::GetCurrent().Add( parent );
1115 Actor child = Actor::New();
1116 child.SetParentOrigin( ParentOrigin::CENTER );
1117 child.SetAnchorPoint( AnchorPoint::CENTER );
1118 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1119 child.SetPosition( childPosition );
1120 parent.Add( child );
1122 // The actors should not have a world position yet
1123 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1124 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1126 // first test default, which is INHERIT_PARENT_POSITION
1127 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1128 application.SendNotification();
1129 application.Render(0); // should only really call Update as Render is not required to update scene
1130 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1131 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1132 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1133 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1135 // Change inheritance mode to use parent
1136 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1137 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1138 application.SendNotification();
1139 application.Render(0); // should only really call Update as Render is not required to update scene
1140 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1141 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1142 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1143 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1145 // Change inheritance mode to use parent + offset
1146 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1147 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1148 child.SetPosition( childOffset );
1149 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1150 application.SendNotification();
1151 application.Render(0); // should only really call Update as Render is not required to update scene
1152 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1153 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1154 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1155 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1157 // Change inheritance mode to not inherit
1158 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1159 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1160 application.SendNotification();
1161 application.Render(0); // should only really call Update as Render is not required to update scene
1162 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1163 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1164 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1165 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1169 // SetOrientation(float angleRadians, Vector3 axis)
1170 int UtcDaliActorSetOrientation01(void)
1172 TestApplication application;
1174 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1175 Actor actor = Actor::New();
1177 actor.SetOrientation(rotation);
1179 // flush the queue and render once
1180 application.SendNotification();
1181 application.Render();
1183 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1187 int UtcDaliActorSetOrientation02(void)
1189 TestApplication application;
1191 Actor actor = Actor::New();
1193 Radian angle( 0.785f );
1194 Vector3 axis(1.0f, 1.0f, 0.0f);
1196 actor.SetOrientation( angle, axis);
1197 Quaternion rotation( angle, axis );
1198 // flush the queue and render once
1199 application.SendNotification();
1200 application.Render();
1201 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1203 Stage::GetCurrent().Add( actor );
1204 actor.RotateBy( Degree( 360 ), axis);
1205 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1207 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1208 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1209 // flush the queue and render once
1210 application.SendNotification();
1211 application.Render();
1212 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1214 actor.SetOrientation( angle, axis);
1215 // flush the queue and render once
1216 application.SendNotification();
1217 application.Render();
1218 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1220 Stage::GetCurrent().Remove( actor );
1224 // RotateBy(float angleRadians, Vector3 axis)
1225 int UtcDaliActorRotateBy01(void)
1227 TestApplication application;
1229 Actor actor = Actor::New();
1231 Radian angle( M_PI * 0.25f );
1232 actor.RotateBy(( angle ), Vector3::ZAXIS);
1233 // flush the queue and render once
1234 application.SendNotification();
1235 application.Render();
1236 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1238 Stage::GetCurrent().Add( actor );
1240 actor.RotateBy( angle, Vector3::ZAXIS);
1241 // flush the queue and render once
1242 application.SendNotification();
1243 application.Render();
1244 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1246 Stage::GetCurrent().Remove( actor );
1250 // RotateBy(Quaternion relativeRotation)
1251 int UtcDaliActorRotateBy02(void)
1253 TestApplication application;
1255 Actor actor = Actor::New();
1257 Radian angle( M_PI * 0.25f );
1258 Quaternion rotation(angle, Vector3::ZAXIS);
1259 actor.RotateBy(rotation);
1260 // flush the queue and render once
1261 application.SendNotification();
1262 application.Render();
1263 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1265 actor.RotateBy(rotation);
1266 // flush the queue and render once
1267 application.SendNotification();
1268 application.Render();
1269 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1273 int UtcDaliActorGetCurrentOrientation(void)
1275 TestApplication application;
1276 Actor actor = Actor::New();
1278 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1279 actor.SetOrientation(rotation);
1280 // flush the queue and render once
1281 application.SendNotification();
1282 application.Render();
1283 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1287 int UtcDaliActorGetCurrentWorldOrientation(void)
1289 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1290 TestApplication application;
1292 Actor parent = Actor::New();
1293 Radian rotationAngle( Degree(90.0f) );
1294 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1295 parent.SetOrientation( rotation );
1296 Stage::GetCurrent().Add( parent );
1298 Actor child = Actor::New();
1299 child.SetOrientation( rotation );
1300 parent.Add( child );
1302 // The actors should not have a world rotation yet
1303 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1304 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1306 application.SendNotification();
1307 application.Render(0);
1309 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1310 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1312 // The actors should have a world rotation now
1313 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1314 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1316 // turn off child rotation inheritance
1317 child.SetInheritOrientation( false );
1318 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1319 application.SendNotification();
1320 application.Render(0);
1322 // The actors should have a world rotation now
1323 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1324 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1328 // SetScale(float scale)
1329 int UtcDaliActorSetScale01(void)
1331 TestApplication application;
1333 Actor actor = Actor::New();
1335 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1336 actor.SetScale(0.25f);
1338 Vector3 scale(10.0f, 10.0f, 10.0f);
1339 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1341 actor.SetScale(scale.x);
1343 // flush the queue and render once
1344 application.SendNotification();
1345 application.Render();
1347 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1351 // SetScale(float scaleX, float scaleY, float scaleZ)
1352 int UtcDaliActorSetScale02(void)
1354 TestApplication application;
1355 Vector3 scale(10.0f, 10.0f, 10.0f);
1357 Actor actor = Actor::New();
1359 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1360 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1362 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1364 actor.SetScale(scale.x, scale.y, scale.z);
1365 // flush the queue and render once
1366 application.SendNotification();
1367 application.Render();
1368 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1370 // add to stage and test
1371 Stage::GetCurrent().Add( actor );
1372 actor.SetScale( 2.0f, 2.0f, 2.0f );
1373 // flush the queue and render once
1374 application.SendNotification();
1375 application.Render();
1376 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1378 Stage::GetCurrent().Remove( actor );
1383 // SetScale(Vector3 scale)
1384 int UtcDaliActorSetScale03(void)
1386 TestApplication application;
1387 Vector3 scale(10.0f, 10.0f, 10.0f);
1389 Actor actor = Actor::New();
1391 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1392 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1394 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1396 actor.SetScale(scale);
1398 // flush the queue and render once
1399 application.SendNotification();
1400 application.Render();
1402 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1406 int UtcDaliActorScaleBy(void)
1408 TestApplication application;
1409 Actor actor = Actor::New();
1410 Vector3 vector(100.0f, 100.0f, 100.0f);
1412 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1414 actor.SetScale(vector);
1416 // flush the queue and render once
1417 application.SendNotification();
1418 application.Render();
1420 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1422 actor.ScaleBy(vector);
1424 // flush the queue and render once
1425 application.SendNotification();
1426 application.Render();
1428 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1432 int UtcDaliActorGetCurrentScale(void)
1434 TestApplication application;
1435 Vector3 scale(12.0f, 1.0f, 2.0f);
1437 Actor actor = Actor::New();
1439 actor.SetScale(scale);
1441 // flush the queue and render once
1442 application.SendNotification();
1443 application.Render();
1445 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1449 int UtcDaliActorGetCurrentWorldScale(void)
1451 TestApplication application;
1453 Actor parent = Actor::New();
1454 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1455 parent.SetScale( parentScale );
1456 Stage::GetCurrent().Add( parent );
1458 Actor child = Actor::New();
1459 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1460 child.SetScale( childScale );
1461 parent.Add( child );
1463 // The actors should not have a scale yet
1464 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1465 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1467 // The actors should not have a world scale yet
1468 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1469 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1471 application.SendNotification();
1472 application.Render(0);
1474 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1475 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1477 // The actors should have a world scale now
1478 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1479 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1483 int UtcDaliActorInheritScale(void)
1485 tet_infoline("Testing Actor::SetInheritScale");
1486 TestApplication application;
1488 Actor parent = Actor::New();
1489 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1490 parent.SetScale( parentScale );
1491 Stage::GetCurrent().Add( parent );
1493 Actor child = Actor::New();
1494 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1495 child.SetScale( childScale );
1496 parent.Add( child );
1498 application.SendNotification();
1499 application.Render(0);
1501 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1502 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1504 child.SetInheritScale( false );
1505 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1507 application.SendNotification();
1508 application.Render(0);
1510 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1514 int UtcDaliActorSetVisible(void)
1516 TestApplication application;
1518 Actor actor = Actor::New();
1519 actor.SetVisible(false);
1520 // flush the queue and render once
1521 application.SendNotification();
1522 application.Render();
1523 DALI_TEST_CHECK(actor.IsVisible() == false);
1525 actor.SetVisible(true);
1526 // flush the queue and render once
1527 application.SendNotification();
1528 application.Render();
1529 DALI_TEST_CHECK(actor.IsVisible() == true);
1531 // put actor on stage
1532 Stage::GetCurrent().Add( actor );
1533 actor.SetVisible(false);
1534 // flush the queue and render once
1535 application.SendNotification();
1536 application.Render();
1537 DALI_TEST_CHECK(actor.IsVisible() == false);
1541 int UtcDaliActorIsVisible(void)
1543 TestApplication application;
1545 Actor actor = Actor::New();
1547 DALI_TEST_CHECK(actor.IsVisible() == true);
1551 int UtcDaliActorSetOpacity(void)
1553 TestApplication application;
1555 Actor actor = Actor::New();
1556 // initial opacity is 1
1557 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1559 actor.SetOpacity( 0.4f);
1560 // flush the queue and render once
1561 application.SendNotification();
1562 application.Render();
1563 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1565 // change opacity, actor is on stage to change is not immediate
1566 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1567 // flush the queue and render once
1568 application.SendNotification();
1569 application.Render();
1570 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1572 // put actor on stage
1573 Stage::GetCurrent().Add( actor );
1575 // change opacity, actor is on stage to change is not immediate
1576 actor.SetOpacity( 0.9f );
1577 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1578 // flush the queue and render once
1579 application.SendNotification();
1580 application.Render();
1581 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1583 // change opacity, actor is on stage to change is not immediate
1584 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1585 // flush the queue and render once
1586 application.SendNotification();
1587 application.Render();
1588 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1592 int UtcDaliActorGetCurrentOpacity(void)
1594 TestApplication application;
1596 Actor actor = Actor::New();
1597 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1599 actor.SetOpacity(0.5f);
1600 // flush the queue and render once
1601 application.SendNotification();
1602 application.Render();
1603 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1607 int UtcDaliActorSetSensitive(void)
1609 TestApplication application;
1610 Actor actor = Actor::New();
1612 bool sensitive = !actor.IsSensitive();
1614 actor.SetSensitive(sensitive);
1616 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1620 int UtcDaliActorIsSensitive(void)
1622 TestApplication application;
1623 Actor actor = Actor::New();
1624 actor.SetSensitive(false);
1626 DALI_TEST_CHECK(false == actor.IsSensitive());
1630 int UtcDaliActorSetColor(void)
1632 TestApplication application;
1633 Actor actor = Actor::New();
1634 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1636 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1638 actor.SetColor(color);
1639 // flush the queue and render once
1640 application.SendNotification();
1641 application.Render();
1642 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1644 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1645 // flush the queue and render once
1646 application.SendNotification();
1647 application.Render();
1648 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1650 Stage::GetCurrent().Add( actor );
1651 actor.SetColor( color );
1652 // flush the queue and render once
1653 application.SendNotification();
1654 application.Render();
1655 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1657 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1658 // flush the queue and render once
1659 application.SendNotification();
1660 application.Render();
1661 // Actor color is not clamped
1662 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1663 // world color is clamped
1664 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1666 Stage::GetCurrent().Remove( actor );
1670 int UtcDaliActorGetCurrentColor(void)
1672 TestApplication application;
1673 Actor actor = Actor::New();
1674 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1676 actor.SetColor(color);
1677 // flush the queue and render once
1678 application.SendNotification();
1679 application.Render();
1680 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1684 int UtcDaliActorGetCurrentWorldColor(void)
1686 tet_infoline("Actor::GetCurrentWorldColor");
1687 TestApplication application;
1689 Actor parent = Actor::New();
1690 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1691 parent.SetColor( parentColor );
1692 Stage::GetCurrent().Add( parent );
1694 Actor child = Actor::New();
1695 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1696 child.SetColor( childColor );
1697 parent.Add( child );
1699 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1700 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1702 // verify the default color mode
1703 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1705 // The actors should not have a world color yet
1706 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1707 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1709 application.SendNotification();
1710 application.Render(0);
1712 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1713 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1715 // The actors should have a world color now
1716 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1717 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1720 child.SetColorMode( USE_OWN_COLOR );
1721 application.SendNotification();
1722 application.Render(0);
1723 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1726 child.SetColorMode( USE_PARENT_COLOR );
1727 application.SendNotification();
1728 application.Render(0);
1729 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1730 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1733 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1734 application.SendNotification();
1735 application.Render(0);
1736 Vector4 expectedColor( childColor );
1737 expectedColor.a *= parentColor.a;
1738 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1739 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1743 int UtcDaliActorSetColorMode(void)
1745 tet_infoline("Actor::SetColorMode");
1746 TestApplication application;
1747 Actor actor = Actor::New();
1748 Actor child = Actor::New();
1751 actor.SetColorMode( USE_OWN_COLOR );
1752 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1754 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1755 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1757 actor.SetColorMode( USE_PARENT_COLOR );
1758 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1760 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1761 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1765 int UtcDaliActorScreenToLocal(void)
1767 TestApplication application;
1768 Actor actor = Actor::New();
1769 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1770 actor.SetSize(100.0f, 100.0f);
1771 actor.SetPosition(10.0f, 10.0f);
1772 Stage::GetCurrent().Add(actor);
1774 // flush the queue and render once
1775 application.SendNotification();
1776 application.Render();
1781 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1783 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1784 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1788 int UtcDaliActorSetLeaveRequired(void)
1790 TestApplication application;
1792 Actor actor = Actor::New();
1794 actor.SetLeaveRequired(false);
1795 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1797 actor.SetLeaveRequired(true);
1798 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1802 int UtcDaliActorGetLeaveRequired(void)
1804 TestApplication application;
1806 Actor actor = Actor::New();
1808 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1812 int UtcDaliActorSetKeyboardFocusable(void)
1814 TestApplication application;
1816 Actor actor = Actor::New();
1818 actor.SetKeyboardFocusable(true);
1819 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1821 actor.SetKeyboardFocusable(false);
1822 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1826 int UtcDaliActorIsKeyboardFocusable(void)
1828 TestApplication application;
1830 Actor actor = Actor::New();
1832 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1836 int UtcDaliActorRemoveConstraints(void)
1838 tet_infoline(" UtcDaliActorRemoveConstraints");
1839 TestApplication application;
1841 gTestConstraintCalled = false;
1843 Actor actor = Actor::New();
1845 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
1847 actor.RemoveConstraints();
1849 DALI_TEST_CHECK( gTestConstraintCalled == false );
1851 Stage::GetCurrent().Add( actor );
1854 // flush the queue and render once
1855 application.SendNotification();
1856 application.Render();
1858 actor.RemoveConstraints();
1860 DALI_TEST_CHECK( gTestConstraintCalled == true );
1864 int UtcDaliActorRemoveConstraintTag(void)
1866 tet_infoline(" UtcDaliActorRemoveConstraintTag");
1867 TestApplication application;
1869 Actor actor = Actor::New();
1871 // 1. Apply Constraint1 and Constraint2, and test...
1872 unsigned int result1 = 0u;
1873 unsigned int result2 = 0u;
1875 unsigned constraint1Tag = 1u;
1876 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
1877 constraint1.SetTag( constraint1Tag );
1878 constraint1.Apply();
1880 unsigned constraint2Tag = 2u;
1881 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
1882 constraint2.SetTag( constraint2Tag );
1883 constraint2.Apply();
1885 Stage::GetCurrent().Add( actor );
1886 // flush the queue and render once
1887 application.SendNotification();
1888 application.Render();
1890 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1891 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1893 // 2. Remove Constraint1 and test...
1896 actor.RemoveConstraints(constraint1Tag);
1897 // make color property dirty, which will trigger constraints to be reapplied.
1898 actor.SetColor( Color::WHITE );
1899 // flush the queue and render once
1900 application.SendNotification();
1901 application.Render();
1903 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1904 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1906 // 3. Re-Apply Constraint1 and test...
1909 constraint1.Apply();
1910 // make color property dirty, which will trigger constraints to be reapplied.
1911 actor.SetColor( Color::WHITE );
1912 // flush the queue and render once
1913 application.SendNotification();
1914 application.Render();
1916 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1917 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1919 // 2. Remove Constraint2 and test...
1922 actor.RemoveConstraints(constraint2Tag);
1923 // make color property dirty, which will trigger constraints to be reapplied.
1924 actor.SetColor( Color::WHITE );
1925 // flush the queue and render once
1926 application.SendNotification();
1927 application.Render();
1929 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1930 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1932 // 2. Remove Constraint1 as well and test...
1935 actor.RemoveConstraints(constraint1Tag);
1936 // make color property dirty, which will trigger constraints to be reapplied.
1937 actor.SetColor( Color::WHITE );
1938 // flush the queue and render once
1939 application.SendNotification();
1940 application.Render();
1942 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1943 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1947 int UtcDaliActorTouchedSignal(void)
1949 TestApplication application;
1951 gTouchCallBackCalled = false;
1953 // get the root layer
1954 Actor actor = Stage::GetCurrent().GetRootLayer();
1955 DALI_TEST_CHECK( gTouchCallBackCalled == false );
1957 application.SendNotification();
1958 application.Render();
1960 // connect to its touch signal
1961 actor.TouchedSignal().Connect( TestCallback );
1963 // simulate a touch event in the middle of the screen
1964 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1965 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
1966 Dali::Integration::TouchEvent event;
1967 event.AddPoint( point );
1968 application.ProcessEvent( event );
1970 DALI_TEST_CHECK( gTouchCallBackCalled == true );
1974 int UtcDaliActorHoveredSignal(void)
1976 TestApplication application;
1978 gHoverCallBackCalled = false;
1980 // get the root layer
1981 Actor actor = Stage::GetCurrent().GetRootLayer();
1982 DALI_TEST_CHECK( gHoverCallBackCalled == false );
1984 application.SendNotification();
1985 application.Render();
1987 // connect to its hover signal
1988 actor.HoveredSignal().Connect( TestCallback3 );
1990 // simulate a hover event in the middle of the screen
1991 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1992 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
1993 Dali::Integration::HoverEvent event;
1994 event.AddPoint( point );
1995 application.ProcessEvent( event );
1997 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2001 int UtcDaliActorOnOffStageSignal(void)
2003 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2005 TestApplication application;
2008 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2009 gActorNamesOnOffStage.clear();
2011 Actor parent = Actor::New();
2012 parent.SetName( "parent" );
2013 parent.OnStageSignal().Connect( OnStageCallback );
2014 parent.OffStageSignal().Connect( OffStageCallback );
2016 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2017 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2019 // add parent to stage
2020 Stage::GetCurrent().Add( parent );
2021 // onstage emitted, offstage not
2022 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2023 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2024 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2026 // test adding a child, should get onstage emitted
2028 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2029 gActorNamesOnOffStage.clear();
2031 Actor child = Actor::New();
2032 child.SetName( "child" );
2033 child.OnStageSignal().Connect( OnStageCallback );
2034 child.OffStageSignal().Connect( OffStageCallback );
2035 parent.Add( child ); // add child
2036 // onstage emitted, offstage not
2037 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2038 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2039 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2041 // test removing parent from stage
2043 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2044 gActorNamesOnOffStage.clear();
2046 Stage::GetCurrent().Remove( parent );
2047 // onstage not emitted, offstage is
2048 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2049 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2050 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2051 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2053 // test adding parent back to stage
2055 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2056 gActorNamesOnOffStage.clear();
2058 Stage::GetCurrent().Add( parent );
2059 // onstage emitted, offstage not
2060 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2061 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2062 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2063 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2065 // test removing child
2067 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2068 gActorNamesOnOffStage.clear();
2070 parent.Remove( child );
2071 // onstage not emitted, offstage is
2072 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2073 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2074 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2076 // test removing parent
2078 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2079 gActorNamesOnOffStage.clear();
2081 Stage::GetCurrent().Remove( parent );
2082 // onstage not emitted, offstage is
2083 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2084 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2085 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2089 int UtcDaliActorFindChildByName(void)
2091 tet_infoline("Testing Dali::Actor::FindChildByName()");
2092 TestApplication application;
2094 Actor parent = Actor::New();
2095 parent.SetName( "parent" );
2096 Actor first = Actor::New();
2097 first .SetName( "first" );
2098 Actor second = Actor::New();
2099 second.SetName( "second" );
2104 Actor found = parent.FindChildByName( "foo" );
2105 DALI_TEST_CHECK( !found );
2107 found = parent.FindChildByName( "parent" );
2108 DALI_TEST_CHECK( found == parent );
2110 found = parent.FindChildByName( "first" );
2111 DALI_TEST_CHECK( found == first );
2113 found = parent.FindChildByName( "second" );
2114 DALI_TEST_CHECK( found == second );
2118 int UtcDaliActorFindChildById(void)
2120 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2121 TestApplication application;
2123 Actor parent = Actor::New();
2124 Actor first = Actor::New();
2125 Actor second = Actor::New();
2130 Actor found = parent.FindChildById( 100000 );
2131 DALI_TEST_CHECK( !found );
2133 found = parent.FindChildById( parent.GetId() );
2134 DALI_TEST_CHECK( found == parent );
2136 found = parent.FindChildById( first.GetId() );
2137 DALI_TEST_CHECK( found == first );
2139 found = parent.FindChildById( second.GetId() );
2140 DALI_TEST_CHECK( found == second );
2144 int UtcDaliActorHitTest(void)
2149 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2151 mTouchPoint( touchPoint ),
2156 Vector2 mTouchPoint;
2160 TestApplication application;
2161 tet_infoline(" UtcDaliActorHitTest");
2163 // Fill a vector with different hit tests.
2164 struct HitTestData* hitTestData[] = {
2165 // scale touch point result
2166 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2167 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2168 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.
2169 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2170 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.
2174 // get the root layer
2175 Actor actor = Actor::New();
2176 actor.SetAnchorPoint( AnchorPoint::CENTER );
2177 actor.SetParentOrigin( ParentOrigin::CENTER );
2179 Stage::GetCurrent().Add( actor );
2181 gTouchCallBackCalled = false;
2183 unsigned int index = 0;
2184 while( NULL != hitTestData[index] )
2186 actor.SetSize( 1.f, 1.f );
2187 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2189 // flush the queue and render once
2190 application.SendNotification();
2191 application.Render();
2193 DALI_TEST_CHECK( !gTouchCallBackCalled );
2195 // connect to its touch signal
2196 actor.TouchedSignal().Connect(TestCallback);
2198 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2199 Dali::Integration::TouchEvent event;
2200 event.AddPoint( point );
2202 // flush the queue and render once
2203 application.SendNotification();
2204 application.Render();
2205 application.ProcessEvent( event );
2207 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2209 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2210 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2211 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2212 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2213 hitTestData[index]->mResult );
2215 gTouchCallBackCalled = false;
2221 int UtcDaliActorSetDrawMode(void)
2223 TestApplication app;
2224 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2226 Actor a = Actor::New();
2228 Stage::GetCurrent().Add(a);
2229 app.SendNotification();
2231 app.SendNotification();
2234 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2236 a.SetDrawMode( DrawMode::OVERLAY );
2237 app.SendNotification();
2240 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2242 a.SetDrawMode( DrawMode::STENCIL );
2243 app.SendNotification();
2246 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2248 a.SetDrawMode( DrawMode::NORMAL );
2249 app.SendNotification();
2252 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2256 int UtcDaliActorSetDrawModeOverlayRender(void)
2258 TestApplication app;
2259 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2261 app.SendNotification();
2264 std::vector<GLuint> ids;
2265 ids.push_back( 8 ); // first rendered actor
2266 ids.push_back( 9 ); // second rendered actor
2267 ids.push_back( 10 ); // third rendered actor
2268 app.GetGlAbstraction().SetNextTextureIds( ids );
2270 BufferImage imageA = BufferImage::New(16, 16);
2271 BufferImage imageB = BufferImage::New(16, 16);
2272 BufferImage imageC = BufferImage::New(16, 16);
2273 ImageActor a = ImageActor::New( imageA );
2274 ImageActor b = ImageActor::New( imageB );
2275 ImageActor c = ImageActor::New( imageC );
2277 // Render a,b,c as regular non-overlays. so order will be:
2281 Stage::GetCurrent().Add(a);
2282 Stage::GetCurrent().Add(b);
2283 Stage::GetCurrent().Add(c);
2285 app.SendNotification();
2288 // Should be 3 textures changes.
2289 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2290 typedef std::vector<GLuint>::size_type TextureSize;
2291 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2292 if( boundTextures.size() == 3 )
2294 DALI_TEST_CHECK( boundTextures[0] == 8u );
2295 DALI_TEST_CHECK( boundTextures[1] == 9u );
2296 DALI_TEST_CHECK( boundTextures[2] == 10u );
2299 // Now texture ids have been set, we can monitor their render order.
2300 // render a as an overlay (last), so order will be:
2304 a.SetDrawMode( DrawMode::OVERLAY );
2305 app.GetGlAbstraction().ClearBoundTextures();
2307 app.SendNotification();
2310 // Should be 3 texture changes.
2311 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2312 if( boundTextures.size() == 3 )
2314 DALI_TEST_CHECK( boundTextures[0] == 9u );
2315 DALI_TEST_CHECK( boundTextures[1] == 10u );
2316 DALI_TEST_CHECK( boundTextures[2] == 8u );
2322 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2324 TestApplication app;
2325 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2327 BufferImage imageA = BufferImage::New(16, 16);
2328 BufferImage imageB = BufferImage::New(16, 16);
2329 ImageActor a = ImageActor::New( imageA );
2330 ImageActor b = ImageActor::New( imageB );
2332 // Render a,b as regular non-overlays. so order will be:
2333 Stage::GetCurrent().Add(a);
2334 Stage::GetCurrent().Add(b);
2336 a.SetSize( 100.0f, 100.0f );
2337 b.SetSize( 100.0f, 100.0f );
2339 // position b overlapping a. (regular non-overlays)
2340 // hit test at point 'x'
2351 // note: b is on top, because it's Z position is higher.
2352 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2353 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2355 // connect to their touch signals
2356 a.TouchedSignal().Connect(TestCallback);
2357 b.TouchedSignal().Connect(TestCallback2);
2359 a.SetDrawMode( DrawMode::NORMAL );
2360 b.SetDrawMode( DrawMode::NORMAL );
2361 SimulateTouchForSetOverlayHitTest(app);
2363 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2364 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2365 // Make Actor a an overlay.
2376 // note: a is on top, because it is an overlay.
2377 a.SetDrawMode( DrawMode::OVERLAY );
2378 b.SetDrawMode( DrawMode::NORMAL );
2379 SimulateTouchForSetOverlayHitTest(app);
2381 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2382 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2383 // Make both Actors as overlays
2394 // note: b is on top, because it is the 2nd child in the hierarchy.
2395 a.SetDrawMode( DrawMode::OVERLAY );
2396 b.SetDrawMode( DrawMode::OVERLAY );
2397 SimulateTouchForSetOverlayHitTest(app);
2399 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2400 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2404 int UtcDaliActorGetCurrentWorldMatrix(void)
2406 TestApplication app;
2407 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2409 Actor parent = Actor::New();
2410 parent.SetParentOrigin(ParentOrigin::CENTER);
2411 parent.SetAnchorPoint(AnchorPoint::CENTER);
2412 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2413 Radian rotationAngle(Degree(85.0f));
2414 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2415 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2416 parent.SetPosition( parentPosition );
2417 parent.SetOrientation( parentRotation );
2418 parent.SetScale( parentScale );
2419 Stage::GetCurrent().Add( parent );
2421 Actor child = Actor::New();
2422 child.SetParentOrigin(ParentOrigin::CENTER);
2423 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2424 Radian childRotationAngle(Degree(23.0f));
2425 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2426 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2427 child.SetPosition( childPosition );
2428 child.SetOrientation( childRotation );
2429 child.SetScale( childScale );
2430 parent.Add( child );
2432 // The actors should not have a world matrix yet
2433 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2434 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2436 app.SendNotification();
2439 app.SendNotification();
2441 Matrix parentMatrix(false);
2442 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2444 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2445 Quaternion childWorldRotation = parentRotation * childRotation;
2446 Vector3 childWorldScale = parentScale * childScale;
2448 Matrix childWorldMatrix(false);
2449 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2451 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2452 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2458 int UtcDaliActorConstrainedToWorldMatrix(void)
2460 TestApplication app;
2461 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2463 Actor parent = Actor::New();
2464 parent.SetParentOrigin(ParentOrigin::CENTER);
2465 parent.SetAnchorPoint(AnchorPoint::CENTER);
2466 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2467 Radian rotationAngle(Degree(85.0f));
2468 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2469 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2470 parent.SetPosition( parentPosition );
2471 parent.SetOrientation( parentRotation );
2472 parent.SetScale( parentScale );
2473 Stage::GetCurrent().Add( parent );
2475 Actor child = Actor::New();
2476 child.SetParentOrigin(ParentOrigin::CENTER);
2477 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2478 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2479 posConstraint.Apply();
2481 Stage::GetCurrent().Add( child );
2483 // The actors should not have a world matrix yet
2484 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2485 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2487 app.SendNotification();
2490 app.SendNotification();
2492 Matrix parentMatrix(false);
2493 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2495 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2496 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2500 int UtcDaliActorUnparent(void)
2502 TestApplication app;
2503 tet_infoline(" UtcDaliActorUnparent");
2505 Actor parent = Actor::New();
2506 Stage::GetCurrent().Add( parent );
2508 Actor child = Actor::New();
2510 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2511 DALI_TEST_CHECK( !child.GetParent() );
2513 // Test that calling Unparent with no parent is a NOOP
2516 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2517 DALI_TEST_CHECK( !child.GetParent() );
2519 // Test that Unparent works
2520 parent.Add( child );
2522 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2523 DALI_TEST_CHECK( parent == child.GetParent() );
2527 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2528 DALI_TEST_CHECK( !child.GetParent() );
2530 // Test that UnparentAndReset works
2531 parent.Add( child );
2533 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2534 DALI_TEST_CHECK( parent == child.GetParent() );
2536 UnparentAndReset( child );
2538 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2539 DALI_TEST_CHECK( !child );
2541 // Test that UnparentAndReset is a NOOP with empty handle
2542 UnparentAndReset( child );
2544 DALI_TEST_CHECK( !child );
2548 int UtcDaliActorGetChildAt(void)
2550 TestApplication app;
2551 tet_infoline(" UtcDaliActorGetChildAt");
2553 Actor parent = Actor::New();
2554 Stage::GetCurrent().Add( parent );
2556 Actor child0 = Actor::New();
2557 parent.Add( child0 );
2559 Actor child1 = Actor::New();
2560 parent.Add( child1 );
2562 Actor child2 = Actor::New();
2563 parent.Add( child2 );
2565 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2566 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2567 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2571 int UtcDaliActorSetGetOverlay(void)
2573 TestApplication app;
2574 tet_infoline(" UtcDaliActorSetGetOverlay");
2576 Actor parent = Actor::New();
2577 parent.SetDrawMode(DrawMode::OVERLAY );
2578 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2583 // Current Dynamics functions are crashing, so testing these sections are futile
2585 int UtcDaliActorDynamics(void)
2587 DALI_TEST_CHECK( true );
2591 int UtcDaliActorCreateDestroy(void)
2593 Actor* actor = new Actor;
2594 DALI_TEST_CHECK( actor );
2601 struct PropertyStringIndex
2603 const char * const name;
2604 const Property::Index index;
2605 const Property::Type type;
2608 const PropertyStringIndex PROPERTY_TABLE[] =
2610 { "parent-origin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2611 { "parent-origin-x", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2612 { "parent-origin-y", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2613 { "parent-origin-z", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2614 { "anchor-point", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2615 { "anchor-point-x", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2616 { "anchor-point-y", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2617 { "anchor-point-z", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2618 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2619 { "size-width", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2620 { "size-height", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2621 { "size-depth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2622 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2623 { "position-x", Actor::Property::POSITION_X, Property::FLOAT },
2624 { "position-y", Actor::Property::POSITION_Y, Property::FLOAT },
2625 { "position-z", Actor::Property::POSITION_Z, Property::FLOAT },
2626 { "world-position", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2627 { "world-position-x", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2628 { "world-position-y", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2629 { "world-position-z", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2630 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2631 { "world-orientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2632 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2633 { "scale-x", Actor::Property::SCALE_X, Property::FLOAT },
2634 { "scale-y", Actor::Property::SCALE_Y, Property::FLOAT },
2635 { "scale-z", Actor::Property::SCALE_Z, Property::FLOAT },
2636 { "world-scale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2637 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2638 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2639 { "color-red", Actor::Property::COLOR_RED, Property::FLOAT },
2640 { "color-green", Actor::Property::COLOR_GREEN, Property::FLOAT },
2641 { "color-blue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2642 { "color-alpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2643 { "world-color", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2644 { "world-matrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2645 { "name", Actor::Property::NAME, Property::STRING },
2646 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2647 { "leave-required", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2648 { "inherit-orientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2649 { "inherit-scale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2650 { "color-mode", Actor::Property::COLOR_MODE, Property::STRING },
2651 { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2652 { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING },
2653 { "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2654 { "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2655 { "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2656 { "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2657 { "width-for-height", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2658 { "height-for-width", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2659 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2660 { "minimum-size", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2661 { "maximum-size", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2663 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2664 } // unnamed namespace
2666 int UtcDaliActorProperties(void)
2668 TestApplication app;
2670 Actor actor = Actor::New();
2672 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2674 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2675 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2676 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2677 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2682 int UtcDaliRelayoutProperties_ResizePolicies(void)
2684 TestApplication app;
2686 Actor actor = Actor::New();
2689 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
2690 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
2692 // Set resize policy for all dimensions
2693 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2694 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2696 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2699 // Set individual dimensions
2700 const char* const widthPolicy = "FILL_TO_PARENT";
2701 const char* const heightPolicy = "FIXED";
2703 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2704 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2706 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2707 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2712 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2714 TestApplication app;
2716 Actor actor = Actor::New();
2719 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2720 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2722 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2723 actor.SetSizeScalePolicy( policy );
2724 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2727 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2728 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2730 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2731 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2733 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2734 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2739 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2741 TestApplication app;
2743 Actor actor = Actor::New();
2746 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2747 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2749 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2750 actor.SetSizeModeFactor( sizeMode );
2751 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2754 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2756 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2757 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2762 int UtcDaliRelayoutProperties_DimensionDependency(void)
2764 TestApplication app;
2766 Actor actor = Actor::New();
2769 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2770 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2773 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2774 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2776 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2777 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2779 // Test setting another resize policy
2780 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2781 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2786 int UtcDaliRelayoutProperties_Padding(void)
2788 TestApplication app;
2790 Actor actor = Actor::New();
2793 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2796 actor.SetProperty( Actor::Property::PADDING, padding );
2797 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2799 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2804 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2806 TestApplication app;
2808 Actor actor = Actor::New();
2811 Vector2 minSize( 1.0f, 2.0f );
2813 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2814 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2816 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2818 Vector2 maxSize( 3.0f, 4.0f );
2820 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2821 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2823 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2828 int UtcDaliActorGetHeightForWidth(void)
2830 TestApplication app;
2832 Actor actor = Actor::New();
2834 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 0.0f, TEST_LOCATION );
2839 int UtcDaliActorGetWidthForHeight(void)
2841 TestApplication app;
2843 Actor actor = Actor::New();
2845 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 0.0f, TEST_LOCATION );
2850 int UtcDaliActorGetRelayoutSize(void)
2852 TestApplication app;
2854 Actor actor = Actor::New();
2856 // Add actor to stage
2857 Stage::GetCurrent().Add( actor );
2859 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
2861 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
2862 actor.SetSize( Vector2( 1.0f, 0.0f ) );
2864 // Flush the queue and render once
2865 app.SendNotification();
2868 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
2873 int UtcDaliActorSetPadding(void)
2875 TestApplication app;
2877 Actor actor = Actor::New();
2880 actor.GetPadding( padding );
2882 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
2883 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
2884 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
2885 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
2887 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
2888 actor.SetPadding( padding2 );
2890 actor.GetPadding( padding );
2892 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
2893 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
2894 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
2895 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
2900 int UtcDaliActorSetMinimumSize(void)
2902 TestApplication app;
2904 Actor actor = Actor::New();
2906 Vector2 size = actor.GetMinimumSize();
2908 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
2909 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
2911 Vector2 size2( 1.0f, 2.0f );
2912 actor.SetMinimumSize( size2 );
2914 size = actor.GetMinimumSize();
2916 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2917 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2922 int UtcDaliActorSetMaximumSize(void)
2924 TestApplication app;
2926 Actor actor = Actor::New();
2928 Vector2 size = actor.GetMaximumSize();
2930 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
2931 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
2933 Vector2 size2( 1.0f, 2.0f );
2934 actor.SetMaximumSize( size2 );
2936 size = actor.GetMaximumSize();
2938 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
2939 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
2944 int UtcDaliActorOnRelayoutSignal(void)
2946 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
2948 TestApplication application;
2951 gOnRelayoutCallBackCalled = 0;
2952 gActorNamesRelayout.clear();
2954 Actor actor = Actor::New();
2955 actor.SetName( "actor" );
2956 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
2959 DALI_TEST_CHECK( gOnRelayoutCallBackCalled == 0 );
2961 // Add actor to stage
2962 Stage::GetCurrent().Add( actor );
2964 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2965 actor.SetSize( Vector2( 1.0f, 2.0 ) );
2967 // Flush the queue and render once
2968 application.SendNotification();
2969 application.Render();
2971 // OnRelayout emitted
2972 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, 1, TEST_LOCATION );
2973 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );