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 <dali/integration-api/events/touch-event-integ.h>
22 #include <dali/integration-api/events/hover-event-integ.h>
23 #include <dali-test-suite-utils.h>
31 void utc_dali_actor_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_actor_cleanup(void)
38 test_return_value = TET_PASS;
43 bool gTouchCallBackCalled=false;
44 bool gTouchCallBack2Called=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;
59 gTouchCallBack2Called = false;
61 // simulate a touch event
62 Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f );
63 Dali::Integration::TouchEvent event;
64 event.AddPoint( point );
65 app.ProcessEvent( event );
67 app.SendNotification();
69 app.SendNotification();
75 static bool gTestConstraintCalled;
79 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
81 gTestConstraintCalled = true;
86 * TestConstraint reference.
87 * When constraint is called, the resultRef is updated
88 * with the value supplied.
91 struct TestConstraintRef
93 TestConstraintRef(unsigned int& resultRef, unsigned int value)
94 : mResultRef(resultRef),
99 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
104 unsigned int& mResultRef;
108 static bool TestCallback(Actor actor, const TouchEvent& event)
110 gTouchCallBackCalled = true;
115 static bool TestCallback2(Actor actor, const TouchEvent& event)
117 gTouchCallBack2Called = true;
122 static bool TestCallback3(Actor actor, const HoverEvent& event)
124 gHoverCallBackCalled = true;
129 static Vector3 gSetSize;
130 static bool gSetSizeCallBackCalled;
131 void SetSizeCallback( Actor actor, const Vector3& size )
133 gSetSizeCallBackCalled = true;
136 // validation stuff for onstage & offstage signals
137 static std::vector< std::string > gActorNamesOnOffStage;
138 static int gOnStageCallBackCalled;
139 void OnStageCallback( Actor actor )
141 ++gOnStageCallBackCalled;
142 gActorNamesOnOffStage.push_back( actor.GetName() );
143 DALI_TEST_CHECK( actor.OnStage() == true );
145 static int gOffStageCallBackCalled;
146 void OffStageCallback( Actor actor )
148 ++gOffStageCallBackCalled;
149 gActorNamesOnOffStage.push_back( actor.GetName() );
150 DALI_TEST_CHECK( actor.OnStage() == false );
153 struct PositionComponentConstraint
155 PositionComponentConstraint(){}
157 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
159 const Matrix& m = inputs[0]->GetMatrix();
162 m.GetTransformComponents(pos, rot, scale);
168 } // anonymous namespace
171 //& purpose: Testing New API
172 int UtcDaliActorNew(void)
174 TestApplication application;
176 Actor actor = Actor::New();
178 DALI_TEST_CHECK(actor);
182 //& purpose: Testing Dali::Actor::DownCast()
183 int UtcDaliActorDownCast(void)
185 TestApplication application;
186 tet_infoline("Testing Dali::Actor::DownCast()");
188 Actor actor = Actor::New();
189 BaseHandle object(actor);
190 Actor actor2 = Actor::DownCast(object);
191 DALI_TEST_CHECK(actor2);
195 //& purpose: Testing Dali::Actor::DownCast()
196 int UtcDaliActorDownCast2(void)
198 TestApplication application;
199 tet_infoline("Testing Dali::Actor::DownCast()");
201 BaseHandle unInitializedObject;
202 Actor actor = Actor::DownCast(unInitializedObject);
203 DALI_TEST_CHECK(!actor);
207 //& purpose: Testing Dali::Actor::GetName()
208 int UtcDaliActorGetName(void)
210 TestApplication application;
212 Actor actor = Actor::New();
214 DALI_TEST_CHECK(actor.GetName().empty());
218 //& purpose: Testing Dali::Actor::SetName()
219 int UtcDaliActorSetName(void)
221 TestApplication application;
223 string str("ActorName");
224 Actor actor = Actor::New();
227 DALI_TEST_CHECK(actor.GetName() == str);
231 int UtcDaliActorGetId(void)
233 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
234 TestApplication application;
236 Actor first = Actor::New();
237 Actor second = Actor::New();
238 Actor third = Actor::New();
240 DALI_TEST_CHECK(first.GetId() != second.GetId());
241 DALI_TEST_CHECK(second.GetId() != third.GetId());
245 int UtcDaliActorIsRoot(void)
247 TestApplication application;
249 Actor actor = Actor::New();
250 DALI_TEST_CHECK(!actor.IsRoot());
252 // get the root layer
253 actor = Stage::GetCurrent().GetLayer( 0 );
254 DALI_TEST_CHECK( actor.IsRoot() );
258 int UtcDaliActorOnStage(void)
260 TestApplication application;
262 Actor actor = Actor::New();
263 DALI_TEST_CHECK( !actor.OnStage() );
265 // get the root layer
266 actor = Stage::GetCurrent().GetLayer( 0 );
267 DALI_TEST_CHECK( actor.OnStage() );
271 int UtcDaliActorIsLayer(void)
273 TestApplication application;
275 Actor actor = Actor::New();
276 DALI_TEST_CHECK( !actor.IsLayer() );
278 // get the root layer
279 actor = Stage::GetCurrent().GetLayer( 0 );
280 DALI_TEST_CHECK( actor.IsLayer() );
284 int UtcDaliActorGetLayer(void)
286 TestApplication application;
288 Actor actor = Actor::New();
289 Stage::GetCurrent().Add(actor);
290 Layer layer = actor.GetLayer();
292 DALI_TEST_CHECK(layer);
294 // get the root layers layer
295 actor = Stage::GetCurrent().GetLayer( 0 );
296 DALI_TEST_CHECK( actor.GetLayer() );
300 int UtcDaliActorAdd(void)
302 tet_infoline("Testing Actor::Add");
303 TestApplication application;
305 Actor parent = Actor::New();
306 Actor child = Actor::New();
308 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
312 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
314 Actor parent2 = Actor::New();
315 parent2.Add( child );
317 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
318 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
320 // try Adding to same parent again, works
321 parent2.Add( child );
322 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
324 // try reparenting an orphaned child
326 Actor temporaryParent = Actor::New();
327 temporaryParent.Add( child );
328 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
330 // temporaryParent has now died, reparent the orphaned child
331 parent2.Add( child );
332 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
337 parent2.Add( parent2 );
338 tet_printf("Assertion test failed - no Exception\n" );
339 tet_result(TET_FAIL);
341 catch(Dali::DaliException& e)
343 DALI_TEST_PRINT_ASSERT( e );
344 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
345 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
349 tet_printf("Assertion test failed - wrong Exception\n" );
350 tet_result(TET_FAIL);
353 // try reparenting root
356 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
357 tet_printf("Assertion test failed - no Exception\n" );
358 tet_result(TET_FAIL);
360 catch(Dali::DaliException& e)
362 DALI_TEST_PRINT_ASSERT( e );
363 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
364 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
368 tet_printf("Assertion test failed - wrong Exception\n" );
369 tet_result(TET_FAIL);
376 parent2.Add( empty );
377 tet_printf("Assertion test failed - no Exception\n" );
378 tet_result(TET_FAIL);
380 catch(Dali::DaliException& e)
382 DALI_TEST_PRINT_ASSERT( e );
383 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
384 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
388 tet_printf("Assertion test failed - wrong Exception\n" );
389 tet_result(TET_FAIL);
394 int UtcDaliActorInsert(void)
396 tet_infoline("Testing Actor::Insert");
397 TestApplication application;
399 Actor parent = Actor::New();
400 Stage::GetCurrent().Add( parent );
401 Actor first = Actor::New();
402 Actor second = Actor::New();
403 Actor third = Actor::New();
405 parent.Insert(1, first); // test insert beyond range
406 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
407 parent.Insert(0, second);
408 DALI_TEST_EQUALS( parent.GetChildCount(), 2u, TEST_LOCATION );
409 parent.Insert(1, third);
411 DALI_TEST_EQUALS( parent.GetChildCount(), 3u, TEST_LOCATION );
413 DALI_TEST_CHECK(parent.GetChildAt(0) == second);
414 DALI_TEST_CHECK(parent.GetChildAt(1) == third);
415 DALI_TEST_CHECK(parent.GetChildAt(2) == first);
421 int UtcDaliActorRemove01(void)
423 tet_infoline("Testing Actor::Remove");
424 TestApplication application;
426 Actor parent = Actor::New();
427 Actor child = Actor::New();
428 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
431 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
433 parent.Remove(child);
434 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
436 // remove again, no problem
437 parent.Remove(child);
438 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
442 // try illegal Remove
445 parent.Remove( parent );
446 tet_printf("Assertion test failed - no Exception\n" );
447 tet_result(TET_FAIL);
449 catch(Dali::DaliException& e)
451 DALI_TEST_PRINT_ASSERT( e );
452 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
453 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
457 tet_printf("Assertion test failed - wrong Exception\n" );
458 tet_result(TET_FAIL);
465 parent.Remove( empty );
466 tet_printf("Assertion test failed - no Exception\n" );
467 tet_result(TET_FAIL);
469 catch(Dali::DaliException& e)
471 DALI_TEST_PRINT_ASSERT( e );
472 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
473 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
477 tet_printf("Assertion test failed - wrong Exception\n" );
478 tet_result(TET_FAIL);
483 int UtcDaliActorRemove02(void)
485 TestApplication application;
487 Actor parent = Actor::New();
488 Actor child = Actor::New();
489 Actor random = Actor::New();
491 Stage::GetCurrent().Add( parent );
493 DALI_TEST_CHECK(parent.GetChildCount() == 0);
497 DALI_TEST_CHECK(parent.GetChildCount() == 1);
499 parent.Remove(random);
501 DALI_TEST_CHECK(parent.GetChildCount() == 1);
503 Stage::GetCurrent().Remove( parent );
505 DALI_TEST_CHECK(parent.GetChildCount() == 1);
509 int UtcDaliActorGetChildCount(void)
511 TestApplication application;
513 Actor parent = Actor::New();
514 Actor child = Actor::New();
516 DALI_TEST_CHECK(parent.GetChildCount() == 0);
520 DALI_TEST_CHECK(parent.GetChildCount() == 1);
524 int UtcDaliActorGetChildren01(void)
526 TestApplication application;
528 Actor parent = Actor::New();
529 Actor first = Actor::New();
530 Actor second = Actor::New();
531 Actor third = Actor::New();
537 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
538 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
539 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
543 int UtcDaliActorGetChildren02(void)
545 TestApplication application;
547 Actor parent = Actor::New();
548 Actor first = Actor::New();
549 Actor second = Actor::New();
550 Actor third = Actor::New();
556 const Actor& constParent = parent;
558 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
559 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
560 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
564 int UtcDaliActorGetParent01(void)
566 TestApplication application;
568 Actor parent = Actor::New();
569 Actor child = Actor::New();
573 DALI_TEST_CHECK(child.GetParent() == parent);
577 int UtcDaliActorGetParent02(void)
579 TestApplication application;
581 Actor actor = Actor::New();
583 DALI_TEST_CHECK(!actor.GetParent());
587 int UtcDaliActorSetParentOrigin(void)
589 TestApplication application;
591 Actor actor = Actor::New();
593 Vector3 vector(0.7f, 0.8f, 0.9f);
594 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
596 actor.SetParentOrigin(vector);
598 // flush the queue and render once
599 application.SendNotification();
600 application.Render();
602 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
604 Stage::GetCurrent().Add( actor );
606 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
608 // flush the queue and render once
609 application.SendNotification();
610 application.Render();
612 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
614 Stage::GetCurrent().Remove( actor );
618 int UtcDaliActorGetCurrentParentOrigin(void)
620 TestApplication application;
622 Actor actor = Actor::New();
624 Vector3 vector(0.7f, 0.8f, 0.9f);
625 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
627 actor.SetParentOrigin(vector);
629 // flush the queue and render once
630 application.SendNotification();
631 application.Render();
633 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
637 int UtcDaliActorSetAnchorPoint(void)
639 TestApplication application;
641 Actor actor = Actor::New();
643 Vector3 vector(0.7f, 0.8f, 0.9f);
644 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
646 actor.SetAnchorPoint(vector);
648 // flush the queue and render once
649 application.SendNotification();
650 application.Render();
652 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
654 Stage::GetCurrent().Add( actor );
656 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
657 // flush the queue and render once
658 application.SendNotification();
659 application.Render();
661 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
663 Stage::GetCurrent().Remove( actor );
667 int UtcDaliActorGetCurrentAnchorPoint(void)
669 TestApplication application;
671 Actor actor = Actor::New();
673 Vector3 vector(0.7f, 0.8f, 0.9f);
674 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
676 actor.SetAnchorPoint(vector);
678 // flush the queue and render once
679 application.SendNotification();
680 application.Render();
682 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
686 // SetSize(float width, float height)
687 int UtcDaliActorSetSize01(void)
689 TestApplication application;
691 Actor actor = Actor::New();
692 Vector3 vector(100.0f, 100.0f, 100.0f);
694 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
696 actor.SetSize(vector.x, vector.y);
698 // flush the queue and render once
699 application.SendNotification();
700 application.Render();
702 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
706 // SetSize(float width, float height, float depth)
707 int UtcDaliActorSetSize02(void)
709 TestApplication application;
711 Actor actor = Actor::New();
712 Vector3 vector(100.0f, 100.0f, 100.0f);
714 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
716 actor.SetSize(vector.x, vector.y, vector.z);
718 // flush the queue and render once
719 application.SendNotification();
720 application.Render();
722 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
726 // SetSize(Vector2 size)
727 int UtcDaliActorSetSize03(void)
729 TestApplication application;
731 Actor actor = Actor::New();
732 Vector3 vector(100.0f, 100.0f, 100.0f);
734 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
736 actor.SetSize(Vector2(vector.x, vector.y));
738 // flush the queue and render once
739 application.SendNotification();
740 application.Render();
742 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
746 // SetSize(Vector3 size)
747 int UtcDaliActorSetSize04(void)
749 TestApplication application;
751 Actor actor = Actor::New();
752 Vector3 vector(100.0f, 100.0f, 100.0f);
754 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
756 actor.SetSize(vector);
758 // flush the queue and render once
759 application.SendNotification();
760 application.Render();
762 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
764 Stage::GetCurrent().Add( actor );
765 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
767 // flush the queue and render once
768 application.SendNotification();
769 application.Render();
771 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
772 Stage::GetCurrent().Remove( actor );
776 int UtcDaliActorGetCurrentSize(void)
778 TestApplication application;
780 Actor actor = Actor::New();
781 Vector3 vector(100.0f, 100.0f, 20.0f);
783 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
785 actor.SetSize(vector);
787 // flush the queue and render once
788 application.SendNotification();
789 application.Render();
791 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
795 int UtcDaliActorGetNaturalSize(void)
797 TestApplication application;
799 Actor actor = Actor::New();
800 Vector3 vector( 0.0f, 0.0f, 0.0f );
802 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
807 int UtcDaliActorGetCurrentSizeImmediate(void)
809 TestApplication application;
811 Actor actor = Actor::New();
812 Vector3 vector(100.0f, 100.0f, 20.0f);
814 DALI_TEST_CHECK(vector != actor.GetTargetSize());
815 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
817 actor.SetSize(vector);
819 DALI_TEST_CHECK(vector == actor.GetTargetSize());
820 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
822 // flush the queue and render once
823 application.SendNotification();
824 application.Render();
826 DALI_TEST_CHECK(vector == actor.GetTargetSize());
827 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
830 // Build the animation
831 const float durationSeconds = 2.0f;
832 Animation animation = Animation::New( durationSeconds );
833 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
834 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
836 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
838 // Start the animation
841 application.SendNotification();
842 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
844 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
849 // SetPosition(float x, float y)
850 int UtcDaliActorSetPosition01(void)
852 TestApplication application;
854 Actor actor = Actor::New();
856 // Set to random to start off with
857 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
859 Vector3 vector(100.0f, 100.0f, 0.0f);
861 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
863 actor.SetPosition(vector.x, vector.y);
864 // flush the queue and render once
865 application.SendNotification();
866 application.Render();
867 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
869 Stage::GetCurrent().Add( actor );
870 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
871 // flush the queue and render once
872 application.SendNotification();
873 application.Render();
874 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
879 // flush the queue and render once
880 application.SendNotification();
881 application.Render();
882 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
884 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
885 // flush the queue and render once
886 application.SendNotification();
887 application.Render();
888 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
890 Stage::GetCurrent().Remove( actor );
894 // SetPosition(float x, float y, float z)
895 int UtcDaliActorSetPosition02(void)
897 TestApplication application;
899 Actor actor = Actor::New();
901 // Set to random to start off with
902 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
904 Vector3 vector(100.0f, 100.0f, 100.0f);
906 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
908 actor.SetPosition(vector.x, vector.y, vector.z);
910 // flush the queue and render once
911 application.SendNotification();
912 application.Render();
914 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
918 // SetPosition(Vector3 position)
919 int UtcDaliActorSetPosition03(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);
934 // flush the queue and render once
935 application.SendNotification();
936 application.Render();
938 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
942 int UtcDaliActorSetX(void)
944 TestApplication application;
946 Actor actor = Actor::New();
948 Vector3 vector(100.0f, 0.0f, 0.0f);
950 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
954 // flush the queue and render once
955 application.SendNotification();
956 application.Render();
958 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
962 int UtcDaliActorSetY(void)
964 TestApplication application;
966 Actor actor = Actor::New();
968 Vector3 vector(0.0f, 100.0f, 0.0f);
970 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
974 // flush the queue and render once
975 application.SendNotification();
976 application.Render();
978 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
982 int UtcDaliActorSetZ(void)
984 TestApplication application;
986 Actor actor = Actor::New();
988 Vector3 vector(0.0f, 0.0f, 100.0f);
990 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
994 // flush the queue and render once
995 application.SendNotification();
996 application.Render();
998 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1002 int UtcDaliActorTranslateBy(void)
1004 TestApplication application;
1006 Actor actor = Actor::New();
1007 Vector3 vector(100.0f, 100.0f, 100.0f);
1009 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1011 actor.SetPosition(vector);
1013 // flush the queue and render once
1014 application.SendNotification();
1015 application.Render();
1017 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1019 actor.TranslateBy(vector);
1021 // flush the queue and render once
1022 application.SendNotification();
1023 application.Render();
1025 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1029 int UtcDaliActorGetCurrentPosition(void)
1031 TestApplication application;
1033 Actor actor = Actor::New();
1034 Vector3 setVector(100.0f, 100.0f, 0.0f);
1035 actor.SetPosition(setVector);
1037 // flush the queue and render once
1038 application.SendNotification();
1039 application.Render();
1041 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1045 int UtcDaliActorGetCurrentWorldPosition(void)
1047 TestApplication application;
1049 Actor parent = Actor::New();
1050 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1051 parent.SetPosition( parentPosition );
1052 parent.SetParentOrigin( ParentOrigin::CENTER );
1053 parent.SetAnchorPoint( AnchorPoint::CENTER );
1054 Stage::GetCurrent().Add( parent );
1056 Actor child = Actor::New();
1057 child.SetParentOrigin( ParentOrigin::CENTER );
1058 child.SetAnchorPoint( AnchorPoint::CENTER );
1059 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1060 child.SetPosition( childPosition );
1061 parent.Add( child );
1063 // The actors should not have a world position yet
1064 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1065 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1067 application.SendNotification();
1068 application.Render(0);
1070 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1071 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1073 // The actors should have a world position now
1074 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1075 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1079 int UtcDaliActorInheritPosition(void)
1081 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1082 TestApplication application;
1084 Actor parent = Actor::New();
1085 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1086 parent.SetPosition( parentPosition );
1087 parent.SetParentOrigin( ParentOrigin::CENTER );
1088 parent.SetAnchorPoint( AnchorPoint::CENTER );
1089 Stage::GetCurrent().Add( parent );
1091 Actor child = Actor::New();
1092 child.SetParentOrigin( ParentOrigin::CENTER );
1093 child.SetAnchorPoint( AnchorPoint::CENTER );
1094 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1095 child.SetPosition( childPosition );
1096 parent.Add( child );
1098 // The actors should not have a world position yet
1099 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1100 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1102 // first test default, which is INHERIT_PARENT_POSITION
1103 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1104 application.SendNotification();
1105 application.Render(0); // should only really call Update as Render is not required to update scene
1106 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1107 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1108 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1109 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1111 // Change inheritance mode to use parent
1112 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1113 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1114 application.SendNotification();
1115 application.Render(0); // should only really call Update as Render is not required to update scene
1116 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1117 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1118 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1119 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1121 // Change inheritance mode to use parent + offset
1122 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1123 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1124 child.SetPosition( childOffset );
1125 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1126 application.SendNotification();
1127 application.Render(0); // should only really call Update as Render is not required to update scene
1128 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1129 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1130 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1131 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1133 // Change inheritance mode to not inherit
1134 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1135 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1136 application.SendNotification();
1137 application.Render(0); // should only really call Update as Render is not required to update scene
1138 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1139 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1140 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1141 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1145 // SetOrientation(float angleRadians, Vector3 axis)
1146 int UtcDaliActorSetOrientation01(void)
1148 TestApplication application;
1150 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1151 Actor actor = Actor::New();
1153 actor.SetOrientation(rotation);
1155 // flush the queue and render once
1156 application.SendNotification();
1157 application.Render();
1159 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1163 int UtcDaliActorSetOrientation02(void)
1165 TestApplication application;
1167 Actor actor = Actor::New();
1169 Radian angle( 0.785f );
1170 Vector3 axis(1.0f, 1.0f, 0.0f);
1172 actor.SetOrientation( angle, axis);
1173 Quaternion rotation( angle, axis );
1174 // flush the queue and render once
1175 application.SendNotification();
1176 application.Render();
1177 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1179 Stage::GetCurrent().Add( actor );
1180 actor.RotateBy( Degree( 360 ), axis);
1181 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1183 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1184 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1185 // flush the queue and render once
1186 application.SendNotification();
1187 application.Render();
1188 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1190 actor.SetOrientation( angle, axis);
1191 // flush the queue and render once
1192 application.SendNotification();
1193 application.Render();
1194 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1196 Stage::GetCurrent().Remove( actor );
1200 // RotateBy(float angleRadians, Vector3 axis)
1201 int UtcDaliActorRotateBy01(void)
1203 TestApplication application;
1205 Actor actor = Actor::New();
1207 Radian angle( M_PI * 0.25f );
1208 actor.RotateBy(( angle ), Vector3::ZAXIS);
1209 // flush the queue and render once
1210 application.SendNotification();
1211 application.Render();
1212 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1214 Stage::GetCurrent().Add( actor );
1216 actor.RotateBy( angle, Vector3::ZAXIS);
1217 // flush the queue and render once
1218 application.SendNotification();
1219 application.Render();
1220 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1222 Stage::GetCurrent().Remove( actor );
1226 // RotateBy(Quaternion relativeRotation)
1227 int UtcDaliActorRotateBy02(void)
1229 TestApplication application;
1231 Actor actor = Actor::New();
1233 Radian angle( M_PI * 0.25f );
1234 Quaternion rotation(angle, Vector3::ZAXIS);
1235 actor.RotateBy(rotation);
1236 // flush the queue and render once
1237 application.SendNotification();
1238 application.Render();
1239 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1241 actor.RotateBy(rotation);
1242 // flush the queue and render once
1243 application.SendNotification();
1244 application.Render();
1245 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1249 int UtcDaliActorGetCurrentOrientation(void)
1251 TestApplication application;
1252 Actor actor = Actor::New();
1254 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1255 actor.SetOrientation(rotation);
1256 // flush the queue and render once
1257 application.SendNotification();
1258 application.Render();
1259 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1263 int UtcDaliActorGetCurrentWorldOrientation(void)
1265 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1266 TestApplication application;
1268 Actor parent = Actor::New();
1269 Radian rotationAngle( Degree(90.0f) );
1270 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1271 parent.SetOrientation( rotation );
1272 Stage::GetCurrent().Add( parent );
1274 Actor child = Actor::New();
1275 child.SetOrientation( rotation );
1276 parent.Add( child );
1278 // The actors should not have a world rotation yet
1279 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1280 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1282 application.SendNotification();
1283 application.Render(0);
1285 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1286 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1288 // The actors should have a world rotation now
1289 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1290 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1292 // turn off child rotation inheritance
1293 child.SetInheritOrientation( false );
1294 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1295 application.SendNotification();
1296 application.Render(0);
1298 // The actors should have a world rotation now
1299 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1300 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1304 // SetScale(float scale)
1305 int UtcDaliActorSetScale01(void)
1307 TestApplication application;
1309 Actor actor = Actor::New();
1311 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1312 actor.SetScale(0.25f);
1314 Vector3 scale(10.0f, 10.0f, 10.0f);
1315 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1317 actor.SetScale(scale.x);
1319 // flush the queue and render once
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1327 // SetScale(float scaleX, float scaleY, float scaleZ)
1328 int UtcDaliActorSetScale02(void)
1330 TestApplication application;
1331 Vector3 scale(10.0f, 10.0f, 10.0f);
1333 Actor actor = Actor::New();
1335 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1336 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1338 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1340 actor.SetScale(scale.x, scale.y, scale.z);
1341 // flush the queue and render once
1342 application.SendNotification();
1343 application.Render();
1344 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1346 // add to stage and test
1347 Stage::GetCurrent().Add( actor );
1348 actor.SetScale( 2.0f, 2.0f, 2.0f );
1349 // flush the queue and render once
1350 application.SendNotification();
1351 application.Render();
1352 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1354 Stage::GetCurrent().Remove( actor );
1359 // SetScale(Vector3 scale)
1360 int UtcDaliActorSetScale03(void)
1362 TestApplication application;
1363 Vector3 scale(10.0f, 10.0f, 10.0f);
1365 Actor actor = Actor::New();
1367 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1368 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1370 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1372 actor.SetScale(scale);
1374 // flush the queue and render once
1375 application.SendNotification();
1376 application.Render();
1378 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1382 int UtcDaliActorScaleBy(void)
1384 TestApplication application;
1385 Actor actor = Actor::New();
1386 Vector3 vector(100.0f, 100.0f, 100.0f);
1388 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1390 actor.SetScale(vector);
1392 // flush the queue and render once
1393 application.SendNotification();
1394 application.Render();
1396 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1398 actor.ScaleBy(vector);
1400 // flush the queue and render once
1401 application.SendNotification();
1402 application.Render();
1404 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1408 int UtcDaliActorGetCurrentScale(void)
1410 TestApplication application;
1411 Vector3 scale(12.0f, 1.0f, 2.0f);
1413 Actor actor = Actor::New();
1415 actor.SetScale(scale);
1417 // flush the queue and render once
1418 application.SendNotification();
1419 application.Render();
1421 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1425 int UtcDaliActorGetCurrentWorldScale(void)
1427 TestApplication application;
1429 Actor parent = Actor::New();
1430 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1431 parent.SetScale( parentScale );
1432 Stage::GetCurrent().Add( parent );
1434 Actor child = Actor::New();
1435 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1436 child.SetScale( childScale );
1437 parent.Add( child );
1439 // The actors should not have a scale yet
1440 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1441 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1443 // The actors should not have a world scale yet
1444 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1445 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1447 application.SendNotification();
1448 application.Render(0);
1450 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1451 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1453 // The actors should have a world scale now
1454 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1455 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1459 int UtcDaliActorInheritScale(void)
1461 tet_infoline("Testing Actor::SetInheritScale");
1462 TestApplication application;
1464 Actor parent = Actor::New();
1465 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1466 parent.SetScale( parentScale );
1467 Stage::GetCurrent().Add( parent );
1469 Actor child = Actor::New();
1470 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1471 child.SetScale( childScale );
1472 parent.Add( child );
1474 application.SendNotification();
1475 application.Render(0);
1477 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1478 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1480 child.SetInheritScale( false );
1481 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1483 application.SendNotification();
1484 application.Render(0);
1486 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1490 int UtcDaliActorSetVisible(void)
1492 TestApplication application;
1494 Actor actor = Actor::New();
1495 actor.SetVisible(false);
1496 // flush the queue and render once
1497 application.SendNotification();
1498 application.Render();
1499 DALI_TEST_CHECK(actor.IsVisible() == false);
1501 actor.SetVisible(true);
1502 // flush the queue and render once
1503 application.SendNotification();
1504 application.Render();
1505 DALI_TEST_CHECK(actor.IsVisible() == true);
1507 // put actor on stage
1508 Stage::GetCurrent().Add( actor );
1509 actor.SetVisible(false);
1510 // flush the queue and render once
1511 application.SendNotification();
1512 application.Render();
1513 DALI_TEST_CHECK(actor.IsVisible() == false);
1517 int UtcDaliActorIsVisible(void)
1519 TestApplication application;
1521 Actor actor = Actor::New();
1523 DALI_TEST_CHECK(actor.IsVisible() == true);
1527 int UtcDaliActorSetOpacity(void)
1529 TestApplication application;
1531 Actor actor = Actor::New();
1532 // initial opacity is 1
1533 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1535 actor.SetOpacity( 0.4f);
1536 // flush the queue and render once
1537 application.SendNotification();
1538 application.Render();
1539 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1541 // change opacity, actor is on stage to change is not immediate
1542 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1543 // flush the queue and render once
1544 application.SendNotification();
1545 application.Render();
1546 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1548 // put actor on stage
1549 Stage::GetCurrent().Add( actor );
1551 // change opacity, actor is on stage to change is not immediate
1552 actor.SetOpacity( 0.9f );
1553 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1554 // flush the queue and render once
1555 application.SendNotification();
1556 application.Render();
1557 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1559 // change opacity, actor is on stage to change is not immediate
1560 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1561 // flush the queue and render once
1562 application.SendNotification();
1563 application.Render();
1564 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1568 int UtcDaliActorGetCurrentOpacity(void)
1570 TestApplication application;
1572 Actor actor = Actor::New();
1573 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1575 actor.SetOpacity(0.5f);
1576 // flush the queue and render once
1577 application.SendNotification();
1578 application.Render();
1579 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1583 int UtcDaliActorSetSensitive(void)
1585 TestApplication application;
1586 Actor actor = Actor::New();
1588 bool sensitive = !actor.IsSensitive();
1590 actor.SetSensitive(sensitive);
1592 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1596 int UtcDaliActorIsSensitive(void)
1598 TestApplication application;
1599 Actor actor = Actor::New();
1600 actor.SetSensitive(false);
1602 DALI_TEST_CHECK(false == actor.IsSensitive());
1606 int UtcDaliActorSetColor(void)
1608 TestApplication application;
1609 Actor actor = Actor::New();
1610 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1612 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1614 actor.SetColor(color);
1615 // flush the queue and render once
1616 application.SendNotification();
1617 application.Render();
1618 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1620 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1621 // flush the queue and render once
1622 application.SendNotification();
1623 application.Render();
1624 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1626 Stage::GetCurrent().Add( actor );
1627 actor.SetColor( color );
1628 // flush the queue and render once
1629 application.SendNotification();
1630 application.Render();
1631 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1633 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1634 // flush the queue and render once
1635 application.SendNotification();
1636 application.Render();
1637 // Actor color is not clamped
1638 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1639 // world color is clamped
1640 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1642 Stage::GetCurrent().Remove( actor );
1646 int UtcDaliActorGetCurrentColor(void)
1648 TestApplication application;
1649 Actor actor = Actor::New();
1650 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1652 actor.SetColor(color);
1653 // flush the queue and render once
1654 application.SendNotification();
1655 application.Render();
1656 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1660 int UtcDaliActorGetCurrentWorldColor(void)
1662 tet_infoline("Actor::GetCurrentWorldColor");
1663 TestApplication application;
1665 Actor parent = Actor::New();
1666 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1667 parent.SetColor( parentColor );
1668 Stage::GetCurrent().Add( parent );
1670 Actor child = Actor::New();
1671 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1672 child.SetColor( childColor );
1673 parent.Add( child );
1675 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1676 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1678 // verify the default color mode
1679 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1681 // The actors should not have a world color yet
1682 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1683 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1685 application.SendNotification();
1686 application.Render(0);
1688 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1689 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1691 // The actors should have a world color now
1692 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1693 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1696 child.SetColorMode( USE_OWN_COLOR );
1697 application.SendNotification();
1698 application.Render(0);
1699 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1702 child.SetColorMode( USE_PARENT_COLOR );
1703 application.SendNotification();
1704 application.Render(0);
1705 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1706 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1709 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1710 application.SendNotification();
1711 application.Render(0);
1712 Vector4 expectedColor( childColor );
1713 expectedColor.a *= parentColor.a;
1714 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1715 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1719 int UtcDaliActorSetColorMode(void)
1721 tet_infoline("Actor::SetColorMode");
1722 TestApplication application;
1723 Actor actor = Actor::New();
1724 Actor child = Actor::New();
1727 actor.SetColorMode( USE_OWN_COLOR );
1728 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1730 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1731 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1733 actor.SetColorMode( USE_PARENT_COLOR );
1734 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1736 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1737 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1741 int UtcDaliActorScreenToLocal(void)
1743 TestApplication application;
1744 Actor actor = Actor::New();
1745 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1746 actor.SetSize(100.0f, 100.0f);
1747 actor.SetPosition(10.0f, 10.0f);
1748 Stage::GetCurrent().Add(actor);
1750 // flush the queue and render once
1751 application.SendNotification();
1752 application.Render();
1757 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1759 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1760 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1764 int UtcDaliActorSetLeaveRequired(void)
1766 TestApplication application;
1768 Actor actor = Actor::New();
1770 actor.SetLeaveRequired(false);
1771 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1773 actor.SetLeaveRequired(true);
1774 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1778 int UtcDaliActorGetLeaveRequired(void)
1780 TestApplication application;
1782 Actor actor = Actor::New();
1784 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1788 int UtcDaliActorSetKeyboardFocusable(void)
1790 TestApplication application;
1792 Actor actor = Actor::New();
1794 actor.SetKeyboardFocusable(true);
1795 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1797 actor.SetKeyboardFocusable(false);
1798 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1802 int UtcDaliActorIsKeyboardFocusable(void)
1804 TestApplication application;
1806 Actor actor = Actor::New();
1808 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1812 int UtcDaliActorRemoveConstraints(void)
1814 tet_infoline(" UtcDaliActorRemoveConstraints");
1815 TestApplication application;
1817 gTestConstraintCalled = false;
1819 Actor actor = Actor::New();
1821 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
1823 actor.RemoveConstraints();
1825 DALI_TEST_CHECK( gTestConstraintCalled == false );
1827 Stage::GetCurrent().Add( actor );
1830 // flush the queue and render once
1831 application.SendNotification();
1832 application.Render();
1834 actor.RemoveConstraints();
1836 DALI_TEST_CHECK( gTestConstraintCalled == true );
1840 int UtcDaliActorRemoveConstraintTag(void)
1842 tet_infoline(" UtcDaliActorRemoveConstraintTag");
1843 TestApplication application;
1845 Actor actor = Actor::New();
1847 // 1. Apply Constraint1 and Constraint2, and test...
1848 unsigned int result1 = 0u;
1849 unsigned int result2 = 0u;
1851 unsigned constraint1Tag = 1u;
1852 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
1853 constraint1.SetTag( constraint1Tag );
1854 constraint1.Apply();
1856 unsigned constraint2Tag = 2u;
1857 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
1858 constraint2.SetTag( constraint2Tag );
1859 constraint2.Apply();
1861 Stage::GetCurrent().Add( actor );
1862 // flush the queue and render once
1863 application.SendNotification();
1864 application.Render();
1866 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1867 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1869 // 2. Remove Constraint1 and test...
1872 actor.RemoveConstraints(constraint1Tag);
1873 // make color property dirty, which will trigger constraints to be reapplied.
1874 actor.SetColor( Color::WHITE );
1875 // flush the queue and render once
1876 application.SendNotification();
1877 application.Render();
1879 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1880 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1882 // 3. Re-Apply Constraint1 and test...
1885 constraint1.Apply();
1886 // make color property dirty, which will trigger constraints to be reapplied.
1887 actor.SetColor( Color::WHITE );
1888 // flush the queue and render once
1889 application.SendNotification();
1890 application.Render();
1892 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1893 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1895 // 2. Remove Constraint2 and test...
1898 actor.RemoveConstraints(constraint2Tag);
1899 // make color property dirty, which will trigger constraints to be reapplied.
1900 actor.SetColor( Color::WHITE );
1901 // flush the queue and render once
1902 application.SendNotification();
1903 application.Render();
1905 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1906 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1908 // 2. Remove Constraint1 as well and test...
1911 actor.RemoveConstraints(constraint1Tag);
1912 // make color property dirty, which will trigger constraints to be reapplied.
1913 actor.SetColor( Color::WHITE );
1914 // flush the queue and render once
1915 application.SendNotification();
1916 application.Render();
1918 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1919 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1923 int UtcDaliActorTouchedSignal(void)
1925 TestApplication application;
1927 gTouchCallBackCalled = false;
1929 // get the root layer
1930 Actor actor = Stage::GetCurrent().GetRootLayer();
1931 DALI_TEST_CHECK( gTouchCallBackCalled == false );
1933 application.SendNotification();
1934 application.Render();
1936 // connect to its touch signal
1937 actor.TouchedSignal().Connect( TestCallback );
1939 // simulate a touch event in the middle of the screen
1940 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1941 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
1942 Dali::Integration::TouchEvent event;
1943 event.AddPoint( point );
1944 application.ProcessEvent( event );
1946 DALI_TEST_CHECK( gTouchCallBackCalled == true );
1950 int UtcDaliActorHoveredSignal(void)
1952 TestApplication application;
1954 gHoverCallBackCalled = false;
1956 // get the root layer
1957 Actor actor = Stage::GetCurrent().GetRootLayer();
1958 DALI_TEST_CHECK( gHoverCallBackCalled == false );
1960 application.SendNotification();
1961 application.Render();
1963 // connect to its hover signal
1964 actor.HoveredSignal().Connect( TestCallback3 );
1966 // simulate a hover event in the middle of the screen
1967 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1968 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
1969 Dali::Integration::HoverEvent event;
1970 event.AddPoint( point );
1971 application.ProcessEvent( event );
1973 DALI_TEST_CHECK( gHoverCallBackCalled == true );
1977 int UtcDaliActorOnOffStageSignal(void)
1979 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
1981 TestApplication application;
1984 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
1985 gActorNamesOnOffStage.clear();
1987 Actor parent = Actor::New();
1988 parent.SetName( "parent" );
1989 parent.OnStageSignal().Connect( OnStageCallback );
1990 parent.OffStageSignal().Connect( OffStageCallback );
1992 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
1993 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
1995 // add parent to stage
1996 Stage::GetCurrent().Add( parent );
1997 // onstage emitted, offstage not
1998 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
1999 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2000 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2002 // test adding a child, should get onstage emitted
2004 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2005 gActorNamesOnOffStage.clear();
2007 Actor child = Actor::New();
2008 child.SetName( "child" );
2009 child.OnStageSignal().Connect( OnStageCallback );
2010 child.OffStageSignal().Connect( OffStageCallback );
2011 parent.Add( child ); // add child
2012 // onstage emitted, offstage not
2013 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2014 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2015 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2017 // test removing parent from stage
2019 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2020 gActorNamesOnOffStage.clear();
2022 Stage::GetCurrent().Remove( parent );
2023 // onstage not emitted, offstage is
2024 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2025 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2026 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2027 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2029 // test adding parent back to stage
2031 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2032 gActorNamesOnOffStage.clear();
2034 Stage::GetCurrent().Add( parent );
2035 // onstage emitted, offstage not
2036 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2037 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2038 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2039 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2041 // test removing child
2043 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2044 gActorNamesOnOffStage.clear();
2046 parent.Remove( child );
2047 // onstage not emitted, offstage is
2048 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2049 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2050 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2052 // test removing parent
2054 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2055 gActorNamesOnOffStage.clear();
2057 Stage::GetCurrent().Remove( parent );
2058 // onstage not emitted, offstage is
2059 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2060 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2061 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2065 int UtcDaliActorFindChildByName(void)
2067 tet_infoline("Testing Dali::Actor::FindChildByName()");
2068 TestApplication application;
2070 Actor parent = Actor::New();
2071 parent.SetName( "parent" );
2072 Actor first = Actor::New();
2073 first .SetName( "first" );
2074 Actor second = Actor::New();
2075 second.SetName( "second" );
2080 Actor found = parent.FindChildByName( "foo" );
2081 DALI_TEST_CHECK( !found );
2083 found = parent.FindChildByName( "parent" );
2084 DALI_TEST_CHECK( found == parent );
2086 found = parent.FindChildByName( "first" );
2087 DALI_TEST_CHECK( found == first );
2089 found = parent.FindChildByName( "second" );
2090 DALI_TEST_CHECK( found == second );
2094 int UtcDaliActorFindChildById(void)
2096 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2097 TestApplication application;
2099 Actor parent = Actor::New();
2100 Actor first = Actor::New();
2101 Actor second = Actor::New();
2106 Actor found = parent.FindChildById( 100000 );
2107 DALI_TEST_CHECK( !found );
2109 found = parent.FindChildById( parent.GetId() );
2110 DALI_TEST_CHECK( found == parent );
2112 found = parent.FindChildById( first.GetId() );
2113 DALI_TEST_CHECK( found == first );
2115 found = parent.FindChildById( second.GetId() );
2116 DALI_TEST_CHECK( found == second );
2120 int UtcDaliActorHitTest(void)
2125 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2127 mTouchPoint( touchPoint ),
2132 Vector2 mTouchPoint;
2136 TestApplication application;
2137 tet_infoline(" UtcDaliActorHitTest");
2139 // Fill a vector with different hit tests.
2140 struct HitTestData* hitTestData[] = {
2141 // scale touch point result
2142 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2143 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2144 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.
2145 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2146 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.
2150 // get the root layer
2151 Actor actor = Actor::New();
2152 actor.SetAnchorPoint( AnchorPoint::CENTER );
2153 actor.SetParentOrigin( ParentOrigin::CENTER );
2155 Stage::GetCurrent().Add( actor );
2157 gTouchCallBackCalled = false;
2159 unsigned int index = 0;
2160 while( NULL != hitTestData[index] )
2162 actor.SetSize( 1.f, 1.f );
2163 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2165 // flush the queue and render once
2166 application.SendNotification();
2167 application.Render();
2169 DALI_TEST_CHECK( !gTouchCallBackCalled );
2171 // connect to its touch signal
2172 actor.TouchedSignal().Connect(TestCallback);
2174 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2175 Dali::Integration::TouchEvent event;
2176 event.AddPoint( point );
2178 // flush the queue and render once
2179 application.SendNotification();
2180 application.Render();
2181 application.ProcessEvent( event );
2183 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2185 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2186 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2187 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2188 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2189 hitTestData[index]->mResult );
2191 gTouchCallBackCalled = false;
2197 int UtcDaliActorSetDrawMode(void)
2199 TestApplication app;
2200 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2202 Actor a = Actor::New();
2204 Stage::GetCurrent().Add(a);
2205 app.SendNotification();
2207 app.SendNotification();
2210 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2212 a.SetDrawMode( DrawMode::OVERLAY );
2213 app.SendNotification();
2216 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2218 a.SetDrawMode( DrawMode::STENCIL );
2219 app.SendNotification();
2222 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2224 a.SetDrawMode( DrawMode::NORMAL );
2225 app.SendNotification();
2228 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2232 int UtcDaliActorSetDrawModeOverlayRender(void)
2234 TestApplication app;
2235 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2237 app.SendNotification();
2240 std::vector<GLuint> ids;
2241 ids.push_back( 8 ); // first rendered actor
2242 ids.push_back( 9 ); // second rendered actor
2243 ids.push_back( 10 ); // third rendered actor
2244 app.GetGlAbstraction().SetNextTextureIds( ids );
2246 BufferImage imageA = BufferImage::New(16, 16);
2247 BufferImage imageB = BufferImage::New(16, 16);
2248 BufferImage imageC = BufferImage::New(16, 16);
2249 ImageActor a = ImageActor::New( imageA );
2250 ImageActor b = ImageActor::New( imageB );
2251 ImageActor c = ImageActor::New( imageC );
2253 // Render a,b,c as regular non-overlays. so order will be:
2257 Stage::GetCurrent().Add(a);
2258 Stage::GetCurrent().Add(b);
2259 Stage::GetCurrent().Add(c);
2261 app.SendNotification();
2264 // Should be 3 textures changes.
2265 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2266 typedef std::vector<GLuint>::size_type TextureSize;
2267 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2268 if( boundTextures.size() == 3 )
2270 DALI_TEST_CHECK( boundTextures[0] == 8u );
2271 DALI_TEST_CHECK( boundTextures[1] == 9u );
2272 DALI_TEST_CHECK( boundTextures[2] == 10u );
2275 // Now texture ids have been set, we can monitor their render order.
2276 // render a as an overlay (last), so order will be:
2280 a.SetDrawMode( DrawMode::OVERLAY );
2281 app.GetGlAbstraction().ClearBoundTextures();
2283 app.SendNotification();
2286 // Should be 3 texture changes.
2287 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2288 if( boundTextures.size() == 3 )
2290 DALI_TEST_CHECK( boundTextures[0] == 9u );
2291 DALI_TEST_CHECK( boundTextures[1] == 10u );
2292 DALI_TEST_CHECK( boundTextures[2] == 8u );
2298 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2300 TestApplication app;
2301 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2303 BufferImage imageA = BufferImage::New(16, 16);
2304 BufferImage imageB = BufferImage::New(16, 16);
2305 ImageActor a = ImageActor::New( imageA );
2306 ImageActor b = ImageActor::New( imageB );
2308 // Render a,b as regular non-overlays. so order will be:
2309 Stage::GetCurrent().Add(a);
2310 Stage::GetCurrent().Add(b);
2312 a.SetSize( 100.0f, 100.0f );
2313 b.SetSize( 100.0f, 100.0f );
2315 // position b overlapping a. (regular non-overlays)
2316 // hit test at point 'x'
2327 // note: b is on top, because it's Z position is higher.
2328 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2329 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2331 // connect to their touch signals
2332 a.TouchedSignal().Connect(TestCallback);
2333 b.TouchedSignal().Connect(TestCallback2);
2335 a.SetDrawMode( DrawMode::NORMAL );
2336 b.SetDrawMode( DrawMode::NORMAL );
2337 SimulateTouchForSetOverlayHitTest(app);
2339 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2340 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2341 // Make Actor a an overlay.
2352 // note: a is on top, because it is an overlay.
2353 a.SetDrawMode( DrawMode::OVERLAY );
2354 b.SetDrawMode( DrawMode::NORMAL );
2355 SimulateTouchForSetOverlayHitTest(app);
2357 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2358 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2359 // Make both Actors as overlays
2370 // note: b is on top, because it is the 2nd child in the hierarchy.
2371 a.SetDrawMode( DrawMode::OVERLAY );
2372 b.SetDrawMode( DrawMode::OVERLAY );
2373 SimulateTouchForSetOverlayHitTest(app);
2375 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2376 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2380 int UtcDaliActorGetCurrentWorldMatrix(void)
2382 TestApplication app;
2383 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2385 Actor parent = Actor::New();
2386 parent.SetParentOrigin(ParentOrigin::CENTER);
2387 parent.SetAnchorPoint(AnchorPoint::CENTER);
2388 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2389 Radian rotationAngle(Degree(85.0f));
2390 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2391 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2392 parent.SetPosition( parentPosition );
2393 parent.SetOrientation( parentRotation );
2394 parent.SetScale( parentScale );
2395 Stage::GetCurrent().Add( parent );
2397 Actor child = Actor::New();
2398 child.SetParentOrigin(ParentOrigin::CENTER);
2399 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2400 Radian childRotationAngle(Degree(23.0f));
2401 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2402 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2403 child.SetPosition( childPosition );
2404 child.SetOrientation( childRotation );
2405 child.SetScale( childScale );
2406 parent.Add( child );
2408 // The actors should not have a world matrix yet
2409 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2410 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2412 app.SendNotification();
2415 app.SendNotification();
2417 Matrix parentMatrix(false);
2418 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2420 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2421 Quaternion childWorldRotation = parentRotation * childRotation;
2422 Vector3 childWorldScale = parentScale * childScale;
2424 Matrix childWorldMatrix(false);
2425 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2427 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2428 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2434 int UtcDaliActorConstrainedToWorldMatrix(void)
2436 TestApplication app;
2437 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2439 Actor parent = Actor::New();
2440 parent.SetParentOrigin(ParentOrigin::CENTER);
2441 parent.SetAnchorPoint(AnchorPoint::CENTER);
2442 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2443 Radian rotationAngle(Degree(85.0f));
2444 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2445 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2446 parent.SetPosition( parentPosition );
2447 parent.SetOrientation( parentRotation );
2448 parent.SetScale( parentScale );
2449 Stage::GetCurrent().Add( parent );
2451 Actor child = Actor::New();
2452 child.SetParentOrigin(ParentOrigin::CENTER);
2453 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2454 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2455 posConstraint.Apply();
2457 Stage::GetCurrent().Add( child );
2459 // The actors should not have a world matrix yet
2460 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2461 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2463 app.SendNotification();
2466 app.SendNotification();
2468 Matrix parentMatrix(false);
2469 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2471 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2472 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2476 int UtcDaliActorUnparent(void)
2478 TestApplication app;
2479 tet_infoline(" UtcDaliActorUnparent");
2481 Actor parent = Actor::New();
2482 Stage::GetCurrent().Add( parent );
2484 Actor child = Actor::New();
2486 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2487 DALI_TEST_CHECK( !child.GetParent() );
2489 // Test that calling Unparent with no parent is a NOOP
2492 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2493 DALI_TEST_CHECK( !child.GetParent() );
2495 // Test that Unparent works
2496 parent.Add( child );
2498 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2499 DALI_TEST_CHECK( parent == child.GetParent() );
2503 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2504 DALI_TEST_CHECK( !child.GetParent() );
2506 // Test that UnparentAndReset works
2507 parent.Add( child );
2509 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2510 DALI_TEST_CHECK( parent == child.GetParent() );
2512 UnparentAndReset( child );
2514 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2515 DALI_TEST_CHECK( !child );
2517 // Test that UnparentAndReset is a NOOP with empty handle
2518 UnparentAndReset( child );
2520 DALI_TEST_CHECK( !child );
2524 int UtcDaliActorGetChildAt(void)
2526 TestApplication app;
2527 tet_infoline(" UtcDaliActorGetChildAt");
2529 Actor parent = Actor::New();
2530 Stage::GetCurrent().Add( parent );
2532 Actor child0 = Actor::New();
2533 parent.Add( child0 );
2535 Actor child1 = Actor::New();
2536 parent.Add( child1 );
2538 Actor child2 = Actor::New();
2539 parent.Add( child2 );
2541 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2542 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2543 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2547 int UtcDaliActorSetGetOverlay(void)
2549 TestApplication app;
2550 tet_infoline(" UtcDaliActorSetGetOverlay");
2552 Actor parent = Actor::New();
2553 parent.SetDrawMode(DrawMode::OVERLAY );
2554 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2559 // Current Dynamics functions are crashing, so testing these sections are futile
2561 int UtcDaliActorDynamics(void)
2563 DALI_TEST_CHECK( true );
2567 int UtcDaliActorCreateDestroy(void)
2569 Actor* actor = new Actor;
2570 DALI_TEST_CHECK( actor );
2577 struct PropertyStringIndex
2579 const char * const name;
2580 const Property::Index index;
2581 const Property::Type type;
2584 const PropertyStringIndex PROPERTY_TABLE[] =
2586 { "parent-origin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2587 { "parent-origin-x", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2588 { "parent-origin-y", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2589 { "parent-origin-z", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2590 { "anchor-point", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2591 { "anchor-point-x", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2592 { "anchor-point-y", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2593 { "anchor-point-z", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2594 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2595 { "size-width", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2596 { "size-height", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2597 { "size-depth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2598 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2599 { "position-x", Actor::Property::POSITION_X, Property::FLOAT },
2600 { "position-y", Actor::Property::POSITION_Y, Property::FLOAT },
2601 { "position-z", Actor::Property::POSITION_Z, Property::FLOAT },
2602 { "world-position", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2603 { "world-position-x", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2604 { "world-position-y", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2605 { "world-position-z", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2606 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2607 { "world-orientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2608 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2609 { "scale-x", Actor::Property::SCALE_X, Property::FLOAT },
2610 { "scale-y", Actor::Property::SCALE_Y, Property::FLOAT },
2611 { "scale-z", Actor::Property::SCALE_Z, Property::FLOAT },
2612 { "world-scale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2613 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2614 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2615 { "color-red", Actor::Property::COLOR_RED, Property::FLOAT },
2616 { "color-green", Actor::Property::COLOR_GREEN, Property::FLOAT },
2617 { "color-blue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2618 { "color-alpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2619 { "world-color", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2620 { "world-matrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2621 { "name", Actor::Property::NAME, Property::STRING },
2622 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2623 { "leave-required", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2624 { "inherit-orientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2625 { "inherit-scale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2626 { "color-mode", Actor::Property::COLOR_MODE, Property::STRING },
2627 { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2628 { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING },
2629 { "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2630 { "relayout-enabled", Actor::Property::RELAYOUT_ENABLED, Property::BOOLEAN },
2631 { "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2632 { "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2633 { "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2634 { "width-for-height", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2635 { "height-for-width", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2636 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2637 { "minimum-size", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2638 { "maximum-size", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2640 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2641 } // unnamed namespace
2643 int UtcDaliActorProperties(void)
2645 TestApplication app;
2647 Actor actor = Actor::New();
2649 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2651 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2652 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2653 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2654 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2659 int UtcDaliRelayoutProperties_RelayoutEnabled(void)
2661 TestApplication app;
2663 Actor actor = Actor::New();
2666 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION );
2668 // Set relayout disabled
2669 actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, false );
2671 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION );
2673 // Set relayout enabled
2674 actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, true );
2676 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), true, TEST_LOCATION );
2681 int UtcDaliRelayoutProperties_ResizePolicies(void)
2683 TestApplication app;
2685 Actor actor = Actor::New();
2688 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
2689 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
2691 // Set resize policy for all dimensions
2692 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2693 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2695 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2698 // Set individual dimensions
2699 const char* const widthPolicy = "FILL_TO_PARENT";
2700 const char* const heightPolicy = "FIXED";
2702 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2703 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2705 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2706 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2711 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2713 TestApplication app;
2715 Actor actor = Actor::New();
2718 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2721 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2722 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2724 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2725 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2727 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2728 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2733 int UtcDaliRelayoutProperties_DimensionDependency(void)
2735 TestApplication app;
2737 Actor actor = Actor::New();
2740 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2741 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2744 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2745 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2747 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2748 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2750 // Test setting another resize policy
2751 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2752 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2757 int UtcDaliRelayoutProperties_Padding(void)
2759 TestApplication app;
2761 Actor actor = Actor::New();
2764 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2767 actor.SetProperty( Actor::Property::PADDING, padding );
2768 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2770 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2775 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2777 TestApplication app;
2779 Actor actor = Actor::New();
2782 Vector2 minSize( 1.0f, 2.0f );
2784 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2785 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2787 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2789 Vector2 maxSize( 3.0f, 4.0f );
2791 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2792 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2794 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );