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(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 float angle = 0.785f;
1170 Vector3 axis(1.0f, 1.0f, 0.0f);
1172 actor.SetOrientation(Radian( 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( 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(Radian( 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 float angle = M_PI * 0.25f;
1208 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1209 // flush the queue and render once
1210 application.SendNotification();
1211 application.Render();
1212 DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1214 Stage::GetCurrent().Add( actor );
1216 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1217 // flush the queue and render once
1218 application.SendNotification();
1219 application.Render();
1220 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, 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 Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
1234 actor.RotateBy(rotation);
1235 // flush the queue and render once
1236 application.SendNotification();
1237 application.Render();
1238 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1240 actor.RotateBy(rotation);
1241 // flush the queue and render once
1242 application.SendNotification();
1243 application.Render();
1244 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1248 int UtcDaliActorGetCurrentOrientation(void)
1250 TestApplication application;
1251 Actor actor = Actor::New();
1253 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1254 actor.SetOrientation(rotation);
1255 // flush the queue and render once
1256 application.SendNotification();
1257 application.Render();
1258 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1262 int UtcDaliActorGetCurrentWorldOrientation(void)
1264 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1265 TestApplication application;
1267 Actor parent = Actor::New();
1268 Radian rotationAngle( Degree(90.0f) );
1269 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1270 parent.SetOrientation( rotation );
1271 Stage::GetCurrent().Add( parent );
1273 Actor child = Actor::New();
1274 child.SetOrientation( rotation );
1275 parent.Add( child );
1277 // The actors should not have a world rotation yet
1278 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1279 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1281 application.SendNotification();
1282 application.Render(0);
1284 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1285 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1287 // The actors should have a world rotation now
1288 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1289 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1291 // turn off child rotation inheritance
1292 child.SetInheritOrientation( false );
1293 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1294 application.SendNotification();
1295 application.Render(0);
1297 // The actors should have a world rotation now
1298 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1299 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1303 // SetScale(float scale)
1304 int UtcDaliActorSetScale01(void)
1306 TestApplication application;
1308 Actor actor = Actor::New();
1310 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1311 actor.SetScale(0.25f);
1313 Vector3 scale(10.0f, 10.0f, 10.0f);
1314 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1316 actor.SetScale(scale.x);
1318 // flush the queue and render once
1319 application.SendNotification();
1320 application.Render();
1322 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1326 // SetScale(float scaleX, float scaleY, float scaleZ)
1327 int UtcDaliActorSetScale02(void)
1329 TestApplication application;
1330 Vector3 scale(10.0f, 10.0f, 10.0f);
1332 Actor actor = Actor::New();
1334 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1335 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1337 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1339 actor.SetScale(scale.x, scale.y, scale.z);
1340 // flush the queue and render once
1341 application.SendNotification();
1342 application.Render();
1343 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1345 // add to stage and test
1346 Stage::GetCurrent().Add( actor );
1347 actor.SetScale( 2.0f, 2.0f, 2.0f );
1348 // flush the queue and render once
1349 application.SendNotification();
1350 application.Render();
1351 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1353 Stage::GetCurrent().Remove( actor );
1358 // SetScale(Vector3 scale)
1359 int UtcDaliActorSetScale03(void)
1361 TestApplication application;
1362 Vector3 scale(10.0f, 10.0f, 10.0f);
1364 Actor actor = Actor::New();
1366 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1367 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1369 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1371 actor.SetScale(scale);
1373 // flush the queue and render once
1374 application.SendNotification();
1375 application.Render();
1377 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1381 int UtcDaliActorScaleBy(void)
1383 TestApplication application;
1384 Actor actor = Actor::New();
1385 Vector3 vector(100.0f, 100.0f, 100.0f);
1387 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1389 actor.SetScale(vector);
1391 // flush the queue and render once
1392 application.SendNotification();
1393 application.Render();
1395 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1397 actor.ScaleBy(vector);
1399 // flush the queue and render once
1400 application.SendNotification();
1401 application.Render();
1403 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1407 int UtcDaliActorGetCurrentScale(void)
1409 TestApplication application;
1410 Vector3 scale(12.0f, 1.0f, 2.0f);
1412 Actor actor = Actor::New();
1414 actor.SetScale(scale);
1416 // flush the queue and render once
1417 application.SendNotification();
1418 application.Render();
1420 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1424 int UtcDaliActorGetCurrentWorldScale(void)
1426 TestApplication application;
1428 Actor parent = Actor::New();
1429 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1430 parent.SetScale( parentScale );
1431 Stage::GetCurrent().Add( parent );
1433 Actor child = Actor::New();
1434 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1435 child.SetScale( childScale );
1436 parent.Add( child );
1438 // The actors should not have a scale yet
1439 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1440 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1442 // The actors should not have a world scale yet
1443 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1444 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1446 application.SendNotification();
1447 application.Render(0);
1449 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1450 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1452 // The actors should have a world scale now
1453 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1454 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1458 int UtcDaliActorInheritScale(void)
1460 tet_infoline("Testing Actor::SetInheritScale");
1461 TestApplication application;
1463 Actor parent = Actor::New();
1464 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1465 parent.SetScale( parentScale );
1466 Stage::GetCurrent().Add( parent );
1468 Actor child = Actor::New();
1469 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1470 child.SetScale( childScale );
1471 parent.Add( child );
1473 application.SendNotification();
1474 application.Render(0);
1476 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1477 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1479 child.SetInheritScale( false );
1480 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1482 application.SendNotification();
1483 application.Render(0);
1485 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1489 int UtcDaliActorSetVisible(void)
1491 TestApplication application;
1493 Actor actor = Actor::New();
1494 actor.SetVisible(false);
1495 // flush the queue and render once
1496 application.SendNotification();
1497 application.Render();
1498 DALI_TEST_CHECK(actor.IsVisible() == false);
1500 actor.SetVisible(true);
1501 // flush the queue and render once
1502 application.SendNotification();
1503 application.Render();
1504 DALI_TEST_CHECK(actor.IsVisible() == true);
1506 // put actor on stage
1507 Stage::GetCurrent().Add( actor );
1508 actor.SetVisible(false);
1509 // flush the queue and render once
1510 application.SendNotification();
1511 application.Render();
1512 DALI_TEST_CHECK(actor.IsVisible() == false);
1516 int UtcDaliActorIsVisible(void)
1518 TestApplication application;
1520 Actor actor = Actor::New();
1522 DALI_TEST_CHECK(actor.IsVisible() == true);
1526 int UtcDaliActorSetOpacity(void)
1528 TestApplication application;
1530 Actor actor = Actor::New();
1531 // initial opacity is 1
1532 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1534 actor.SetOpacity( 0.4f);
1535 // flush the queue and render once
1536 application.SendNotification();
1537 application.Render();
1538 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1540 // change opacity, actor is on stage to change is not immediate
1541 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1542 // flush the queue and render once
1543 application.SendNotification();
1544 application.Render();
1545 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1547 // put actor on stage
1548 Stage::GetCurrent().Add( actor );
1550 // change opacity, actor is on stage to change is not immediate
1551 actor.SetOpacity( 0.9f );
1552 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1553 // flush the queue and render once
1554 application.SendNotification();
1555 application.Render();
1556 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1558 // change opacity, actor is on stage to change is not immediate
1559 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1560 // flush the queue and render once
1561 application.SendNotification();
1562 application.Render();
1563 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1567 int UtcDaliActorGetCurrentOpacity(void)
1569 TestApplication application;
1571 Actor actor = Actor::New();
1572 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1574 actor.SetOpacity(0.5f);
1575 // flush the queue and render once
1576 application.SendNotification();
1577 application.Render();
1578 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1582 int UtcDaliActorSetSensitive(void)
1584 TestApplication application;
1585 Actor actor = Actor::New();
1587 bool sensitive = !actor.IsSensitive();
1589 actor.SetSensitive(sensitive);
1591 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1595 int UtcDaliActorIsSensitive(void)
1597 TestApplication application;
1598 Actor actor = Actor::New();
1599 actor.SetSensitive(false);
1601 DALI_TEST_CHECK(false == actor.IsSensitive());
1605 int UtcDaliActorSetColor(void)
1607 TestApplication application;
1608 Actor actor = Actor::New();
1609 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1611 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1613 actor.SetColor(color);
1614 // flush the queue and render once
1615 application.SendNotification();
1616 application.Render();
1617 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1619 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1620 // flush the queue and render once
1621 application.SendNotification();
1622 application.Render();
1623 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1625 Stage::GetCurrent().Add( actor );
1626 actor.SetColor( color );
1627 // flush the queue and render once
1628 application.SendNotification();
1629 application.Render();
1630 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1632 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1633 // flush the queue and render once
1634 application.SendNotification();
1635 application.Render();
1636 // Actor color is not clamped
1637 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1638 // world color is clamped
1639 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1641 Stage::GetCurrent().Remove( actor );
1645 int UtcDaliActorGetCurrentColor(void)
1647 TestApplication application;
1648 Actor actor = Actor::New();
1649 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1651 actor.SetColor(color);
1652 // flush the queue and render once
1653 application.SendNotification();
1654 application.Render();
1655 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1659 int UtcDaliActorGetCurrentWorldColor(void)
1661 tet_infoline("Actor::GetCurrentWorldColor");
1662 TestApplication application;
1664 Actor parent = Actor::New();
1665 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1666 parent.SetColor( parentColor );
1667 Stage::GetCurrent().Add( parent );
1669 Actor child = Actor::New();
1670 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1671 child.SetColor( childColor );
1672 parent.Add( child );
1674 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1675 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1677 // verify the default color mode
1678 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1680 // The actors should not have a world color yet
1681 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1682 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1684 application.SendNotification();
1685 application.Render(0);
1687 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1688 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1690 // The actors should have a world color now
1691 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1692 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1695 child.SetColorMode( USE_OWN_COLOR );
1696 application.SendNotification();
1697 application.Render(0);
1698 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1701 child.SetColorMode( USE_PARENT_COLOR );
1702 application.SendNotification();
1703 application.Render(0);
1704 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1705 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1708 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1709 application.SendNotification();
1710 application.Render(0);
1711 Vector4 expectedColor( childColor );
1712 expectedColor.a *= parentColor.a;
1713 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1714 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1718 int UtcDaliActorSetColorMode(void)
1720 tet_infoline("Actor::SetColorMode");
1721 TestApplication application;
1722 Actor actor = Actor::New();
1723 Actor child = Actor::New();
1726 actor.SetColorMode( USE_OWN_COLOR );
1727 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1729 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1730 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1732 actor.SetColorMode( USE_PARENT_COLOR );
1733 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1735 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1736 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1740 int UtcDaliActorScreenToLocal(void)
1742 TestApplication application;
1743 Actor actor = Actor::New();
1744 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1745 actor.SetSize(100.0f, 100.0f);
1746 actor.SetPosition(10.0f, 10.0f);
1747 Stage::GetCurrent().Add(actor);
1749 // flush the queue and render once
1750 application.SendNotification();
1751 application.Render();
1756 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1758 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1759 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1763 int UtcDaliActorSetLeaveRequired(void)
1765 TestApplication application;
1767 Actor actor = Actor::New();
1769 actor.SetLeaveRequired(false);
1770 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1772 actor.SetLeaveRequired(true);
1773 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1777 int UtcDaliActorGetLeaveRequired(void)
1779 TestApplication application;
1781 Actor actor = Actor::New();
1783 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1787 int UtcDaliActorSetKeyboardFocusable(void)
1789 TestApplication application;
1791 Actor actor = Actor::New();
1793 actor.SetKeyboardFocusable(true);
1794 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1796 actor.SetKeyboardFocusable(false);
1797 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1801 int UtcDaliActorIsKeyboardFocusable(void)
1803 TestApplication application;
1805 Actor actor = Actor::New();
1807 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1811 int UtcDaliActorRemoveConstraints(void)
1813 tet_infoline(" UtcDaliActorRemoveConstraints");
1814 TestApplication application;
1816 gTestConstraintCalled = false;
1818 Actor actor = Actor::New();
1820 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
1822 actor.RemoveConstraints();
1824 DALI_TEST_CHECK( gTestConstraintCalled == false );
1826 Stage::GetCurrent().Add( actor );
1829 // flush the queue and render once
1830 application.SendNotification();
1831 application.Render();
1833 actor.RemoveConstraints();
1835 DALI_TEST_CHECK( gTestConstraintCalled == true );
1839 int UtcDaliActorRemoveConstraintTag(void)
1841 tet_infoline(" UtcDaliActorRemoveConstraintTag");
1842 TestApplication application;
1844 Actor actor = Actor::New();
1846 // 1. Apply Constraint1 and Constraint2, and test...
1847 unsigned int result1 = 0u;
1848 unsigned int result2 = 0u;
1850 unsigned constraint1Tag = 1u;
1851 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
1852 constraint1.SetTag( constraint1Tag );
1853 constraint1.Apply();
1855 unsigned constraint2Tag = 2u;
1856 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
1857 constraint2.SetTag( constraint2Tag );
1858 constraint2.Apply();
1860 Stage::GetCurrent().Add( actor );
1861 // flush the queue and render once
1862 application.SendNotification();
1863 application.Render();
1865 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1866 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1868 // 2. Remove Constraint1 and test...
1871 actor.RemoveConstraints(constraint1Tag);
1872 // make color property dirty, which will trigger constraints to be reapplied.
1873 actor.SetColor( Color::WHITE );
1874 // flush the queue and render once
1875 application.SendNotification();
1876 application.Render();
1878 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1879 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1881 // 3. Re-Apply Constraint1 and test...
1884 constraint1.Apply();
1885 // make color property dirty, which will trigger constraints to be reapplied.
1886 actor.SetColor( Color::WHITE );
1887 // flush the queue and render once
1888 application.SendNotification();
1889 application.Render();
1891 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1892 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
1894 // 2. Remove Constraint2 and test...
1897 actor.RemoveConstraints(constraint2Tag);
1898 // make color property dirty, which will trigger constraints to be reapplied.
1899 actor.SetColor( Color::WHITE );
1900 // flush the queue and render once
1901 application.SendNotification();
1902 application.Render();
1904 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
1905 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1907 // 2. Remove Constraint1 as well and test...
1910 actor.RemoveConstraints(constraint1Tag);
1911 // make color property dirty, which will trigger constraints to be reapplied.
1912 actor.SetColor( Color::WHITE );
1913 // flush the queue and render once
1914 application.SendNotification();
1915 application.Render();
1917 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
1918 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
1922 int UtcDaliActorTouchedSignal(void)
1924 TestApplication application;
1926 gTouchCallBackCalled = false;
1928 // get the root layer
1929 Actor actor = Stage::GetCurrent().GetRootLayer();
1930 DALI_TEST_CHECK( gTouchCallBackCalled == false );
1932 application.SendNotification();
1933 application.Render();
1935 // connect to its touch signal
1936 actor.TouchedSignal().Connect( TestCallback );
1938 // simulate a touch event in the middle of the screen
1939 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1940 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
1941 Dali::Integration::TouchEvent event;
1942 event.AddPoint( point );
1943 application.ProcessEvent( event );
1945 DALI_TEST_CHECK( gTouchCallBackCalled == true );
1949 int UtcDaliActorHoveredSignal(void)
1951 TestApplication application;
1953 gHoverCallBackCalled = false;
1955 // get the root layer
1956 Actor actor = Stage::GetCurrent().GetRootLayer();
1957 DALI_TEST_CHECK( gHoverCallBackCalled == false );
1959 application.SendNotification();
1960 application.Render();
1962 // connect to its hover signal
1963 actor.HoveredSignal().Connect( TestCallback3 );
1965 // simulate a hover event in the middle of the screen
1966 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
1967 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
1968 Dali::Integration::HoverEvent event;
1969 event.AddPoint( point );
1970 application.ProcessEvent( event );
1972 DALI_TEST_CHECK( gHoverCallBackCalled == true );
1976 int UtcDaliActorOnOffStageSignal(void)
1978 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
1980 TestApplication application;
1983 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
1984 gActorNamesOnOffStage.clear();
1986 Actor parent = Actor::New();
1987 parent.SetName( "parent" );
1988 parent.OnStageSignal().Connect( OnStageCallback );
1989 parent.OffStageSignal().Connect( OffStageCallback );
1991 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
1992 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
1994 // add parent to stage
1995 Stage::GetCurrent().Add( parent );
1996 // onstage emitted, offstage not
1997 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
1998 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
1999 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2001 // test adding a child, should get onstage emitted
2003 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2004 gActorNamesOnOffStage.clear();
2006 Actor child = Actor::New();
2007 child.SetName( "child" );
2008 child.OnStageSignal().Connect( OnStageCallback );
2009 child.OffStageSignal().Connect( OffStageCallback );
2010 parent.Add( child ); // add child
2011 // onstage emitted, offstage not
2012 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2013 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2014 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2016 // test removing parent from stage
2018 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2019 gActorNamesOnOffStage.clear();
2021 Stage::GetCurrent().Remove( parent );
2022 // onstage not emitted, offstage is
2023 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2024 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2025 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2026 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2028 // test adding parent back to stage
2030 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2031 gActorNamesOnOffStage.clear();
2033 Stage::GetCurrent().Add( parent );
2034 // onstage emitted, offstage not
2035 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2036 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2037 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2038 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2040 // test removing child
2042 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2043 gActorNamesOnOffStage.clear();
2045 parent.Remove( child );
2046 // onstage not emitted, offstage is
2047 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2048 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2049 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2051 // test removing parent
2053 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2054 gActorNamesOnOffStage.clear();
2056 Stage::GetCurrent().Remove( parent );
2057 // onstage not emitted, offstage is
2058 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2059 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2060 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2064 int UtcDaliActorFindChildByName(void)
2066 tet_infoline("Testing Dali::Actor::FindChildByName()");
2067 TestApplication application;
2069 Actor parent = Actor::New();
2070 parent.SetName( "parent" );
2071 Actor first = Actor::New();
2072 first .SetName( "first" );
2073 Actor second = Actor::New();
2074 second.SetName( "second" );
2079 Actor found = parent.FindChildByName( "foo" );
2080 DALI_TEST_CHECK( !found );
2082 found = parent.FindChildByName( "parent" );
2083 DALI_TEST_CHECK( found == parent );
2085 found = parent.FindChildByName( "first" );
2086 DALI_TEST_CHECK( found == first );
2088 found = parent.FindChildByName( "second" );
2089 DALI_TEST_CHECK( found == second );
2093 int UtcDaliActorFindChildById(void)
2095 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2096 TestApplication application;
2098 Actor parent = Actor::New();
2099 Actor first = Actor::New();
2100 Actor second = Actor::New();
2105 Actor found = parent.FindChildById( 100000 );
2106 DALI_TEST_CHECK( !found );
2108 found = parent.FindChildById( parent.GetId() );
2109 DALI_TEST_CHECK( found == parent );
2111 found = parent.FindChildById( first.GetId() );
2112 DALI_TEST_CHECK( found == first );
2114 found = parent.FindChildById( second.GetId() );
2115 DALI_TEST_CHECK( found == second );
2119 int UtcDaliActorHitTest(void)
2124 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2126 mTouchPoint( touchPoint ),
2131 Vector2 mTouchPoint;
2135 TestApplication application;
2136 tet_infoline(" UtcDaliActorHitTest");
2138 // Fill a vector with different hit tests.
2139 struct HitTestData* hitTestData[] = {
2140 // scale touch point result
2141 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2142 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2143 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.
2144 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2145 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.
2149 // get the root layer
2150 Actor actor = Actor::New();
2151 actor.SetAnchorPoint( AnchorPoint::CENTER );
2152 actor.SetParentOrigin( ParentOrigin::CENTER );
2154 Stage::GetCurrent().Add( actor );
2156 gTouchCallBackCalled = false;
2158 unsigned int index = 0;
2159 while( NULL != hitTestData[index] )
2161 actor.SetSize( 1.f, 1.f );
2162 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2164 // flush the queue and render once
2165 application.SendNotification();
2166 application.Render();
2168 DALI_TEST_CHECK( !gTouchCallBackCalled );
2170 // connect to its touch signal
2171 actor.TouchedSignal().Connect(TestCallback);
2173 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2174 Dali::Integration::TouchEvent event;
2175 event.AddPoint( point );
2177 // flush the queue and render once
2178 application.SendNotification();
2179 application.Render();
2180 application.ProcessEvent( event );
2182 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2184 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2185 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2186 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2187 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2188 hitTestData[index]->mResult );
2190 gTouchCallBackCalled = false;
2196 int UtcDaliActorSetDrawMode(void)
2198 TestApplication app;
2199 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2201 Actor a = Actor::New();
2203 Stage::GetCurrent().Add(a);
2204 app.SendNotification();
2206 app.SendNotification();
2209 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2211 a.SetDrawMode( DrawMode::OVERLAY );
2212 app.SendNotification();
2215 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2217 a.SetDrawMode( DrawMode::STENCIL );
2218 app.SendNotification();
2221 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2223 a.SetDrawMode( DrawMode::NORMAL );
2224 app.SendNotification();
2227 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2231 int UtcDaliActorSetDrawModeOverlayRender(void)
2233 TestApplication app;
2234 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2236 app.SendNotification();
2239 std::vector<GLuint> ids;
2240 ids.push_back( 8 ); // first rendered actor
2241 ids.push_back( 9 ); // second rendered actor
2242 ids.push_back( 10 ); // third rendered actor
2243 app.GetGlAbstraction().SetNextTextureIds( ids );
2245 BufferImage imageA = BufferImage::New(16, 16);
2246 BufferImage imageB = BufferImage::New(16, 16);
2247 BufferImage imageC = BufferImage::New(16, 16);
2248 ImageActor a = ImageActor::New( imageA );
2249 ImageActor b = ImageActor::New( imageB );
2250 ImageActor c = ImageActor::New( imageC );
2252 // Render a,b,c as regular non-overlays. so order will be:
2256 Stage::GetCurrent().Add(a);
2257 Stage::GetCurrent().Add(b);
2258 Stage::GetCurrent().Add(c);
2260 app.SendNotification();
2263 // Should be 3 textures changes.
2264 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2265 typedef std::vector<GLuint>::size_type TextureSize;
2266 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2267 if( boundTextures.size() == 3 )
2269 DALI_TEST_CHECK( boundTextures[0] == 8u );
2270 DALI_TEST_CHECK( boundTextures[1] == 9u );
2271 DALI_TEST_CHECK( boundTextures[2] == 10u );
2274 // Now texture ids have been set, we can monitor their render order.
2275 // render a as an overlay (last), so order will be:
2279 a.SetDrawMode( DrawMode::OVERLAY );
2280 app.GetGlAbstraction().ClearBoundTextures();
2282 app.SendNotification();
2285 // Should be 3 texture changes.
2286 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2287 if( boundTextures.size() == 3 )
2289 DALI_TEST_CHECK( boundTextures[0] == 9u );
2290 DALI_TEST_CHECK( boundTextures[1] == 10u );
2291 DALI_TEST_CHECK( boundTextures[2] == 8u );
2297 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2299 TestApplication app;
2300 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2302 BufferImage imageA = BufferImage::New(16, 16);
2303 BufferImage imageB = BufferImage::New(16, 16);
2304 ImageActor a = ImageActor::New( imageA );
2305 ImageActor b = ImageActor::New( imageB );
2307 // Render a,b as regular non-overlays. so order will be:
2308 Stage::GetCurrent().Add(a);
2309 Stage::GetCurrent().Add(b);
2311 a.SetSize( 100.0f, 100.0f );
2312 b.SetSize( 100.0f, 100.0f );
2314 // position b overlapping a. (regular non-overlays)
2315 // hit test at point 'x'
2326 // note: b is on top, because it's Z position is higher.
2327 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2328 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2330 // connect to their touch signals
2331 a.TouchedSignal().Connect(TestCallback);
2332 b.TouchedSignal().Connect(TestCallback2);
2334 a.SetDrawMode( DrawMode::NORMAL );
2335 b.SetDrawMode( DrawMode::NORMAL );
2336 SimulateTouchForSetOverlayHitTest(app);
2338 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2339 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2340 // Make Actor a an overlay.
2351 // note: a is on top, because it is an overlay.
2352 a.SetDrawMode( DrawMode::OVERLAY );
2353 b.SetDrawMode( DrawMode::NORMAL );
2354 SimulateTouchForSetOverlayHitTest(app);
2356 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2357 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2358 // Make both Actors as overlays
2369 // note: b is on top, because it is the 2nd child in the hierarchy.
2370 a.SetDrawMode( DrawMode::OVERLAY );
2371 b.SetDrawMode( DrawMode::OVERLAY );
2372 SimulateTouchForSetOverlayHitTest(app);
2374 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2375 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2379 int UtcDaliActorGetCurrentWorldMatrix(void)
2381 TestApplication app;
2382 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2384 Actor parent = Actor::New();
2385 parent.SetParentOrigin(ParentOrigin::CENTER);
2386 parent.SetAnchorPoint(AnchorPoint::CENTER);
2387 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2388 Radian rotationAngle(Degree(85.0f));
2389 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2390 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2391 parent.SetPosition( parentPosition );
2392 parent.SetOrientation( parentRotation );
2393 parent.SetScale( parentScale );
2394 Stage::GetCurrent().Add( parent );
2396 Actor child = Actor::New();
2397 child.SetParentOrigin(ParentOrigin::CENTER);
2398 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2399 Radian childRotationAngle(Degree(23.0f));
2400 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2401 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2402 child.SetPosition( childPosition );
2403 child.SetOrientation( childRotation );
2404 child.SetScale( childScale );
2405 parent.Add( child );
2407 // The actors should not have a world matrix yet
2408 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2409 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2411 app.SendNotification();
2414 app.SendNotification();
2416 Matrix parentMatrix(false);
2417 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2419 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2420 Quaternion childWorldRotation = parentRotation * childRotation;
2421 Vector3 childWorldScale = parentScale * childScale;
2423 Matrix childWorldMatrix(false);
2424 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2426 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2427 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2433 int UtcDaliActorConstrainedToWorldMatrix(void)
2435 TestApplication app;
2436 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2438 Actor parent = Actor::New();
2439 parent.SetParentOrigin(ParentOrigin::CENTER);
2440 parent.SetAnchorPoint(AnchorPoint::CENTER);
2441 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2442 Radian rotationAngle(Degree(85.0f));
2443 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2444 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2445 parent.SetPosition( parentPosition );
2446 parent.SetOrientation( parentRotation );
2447 parent.SetScale( parentScale );
2448 Stage::GetCurrent().Add( parent );
2450 Actor child = Actor::New();
2451 child.SetParentOrigin(ParentOrigin::CENTER);
2452 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2453 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2454 posConstraint.Apply();
2456 Stage::GetCurrent().Add( child );
2458 // The actors should not have a world matrix yet
2459 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2460 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2462 app.SendNotification();
2465 app.SendNotification();
2467 Matrix parentMatrix(false);
2468 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2470 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2471 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2475 int UtcDaliActorUnparent(void)
2477 TestApplication app;
2478 tet_infoline(" UtcDaliActorUnparent");
2480 Actor parent = Actor::New();
2481 Stage::GetCurrent().Add( parent );
2483 Actor child = Actor::New();
2485 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2486 DALI_TEST_CHECK( !child.GetParent() );
2488 // Test that calling Unparent with no parent is a NOOP
2491 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2492 DALI_TEST_CHECK( !child.GetParent() );
2494 // Test that Unparent works
2495 parent.Add( child );
2497 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2498 DALI_TEST_CHECK( parent == child.GetParent() );
2502 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2503 DALI_TEST_CHECK( !child.GetParent() );
2505 // Test that UnparentAndReset works
2506 parent.Add( child );
2508 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2509 DALI_TEST_CHECK( parent == child.GetParent() );
2511 UnparentAndReset( child );
2513 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2514 DALI_TEST_CHECK( !child );
2516 // Test that UnparentAndReset is a NOOP with empty handle
2517 UnparentAndReset( child );
2519 DALI_TEST_CHECK( !child );
2523 int UtcDaliActorGetChildAt(void)
2525 TestApplication app;
2526 tet_infoline(" UtcDaliActorGetChildAt");
2528 Actor parent = Actor::New();
2529 Stage::GetCurrent().Add( parent );
2531 Actor child0 = Actor::New();
2532 parent.Add( child0 );
2534 Actor child1 = Actor::New();
2535 parent.Add( child1 );
2537 Actor child2 = Actor::New();
2538 parent.Add( child2 );
2540 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2541 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2542 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2546 int UtcDaliActorSetGetOverlay(void)
2548 TestApplication app;
2549 tet_infoline(" UtcDaliActorSetGetOverlay");
2551 Actor parent = Actor::New();
2552 parent.SetDrawMode(DrawMode::OVERLAY );
2553 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2558 // Current Dynamics functions are crashing, so testing these sections are futile
2560 int UtcDaliActorDynamics(void)
2562 DALI_TEST_CHECK( true );
2566 int UtcDaliActorCreateDestroy(void)
2568 Actor* actor = new Actor;
2569 DALI_TEST_CHECK( actor );
2576 struct PropertyStringIndex
2578 const char * const name;
2579 const Property::Index index;
2580 const Property::Type type;
2583 const PropertyStringIndex PROPERTY_TABLE[] =
2585 { "parent-origin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2586 { "parent-origin-x", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2587 { "parent-origin-y", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2588 { "parent-origin-z", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2589 { "anchor-point", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2590 { "anchor-point-x", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2591 { "anchor-point-y", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2592 { "anchor-point-z", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2593 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2594 { "size-width", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2595 { "size-height", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2596 { "size-depth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2597 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2598 { "position-x", Actor::Property::POSITION_X, Property::FLOAT },
2599 { "position-y", Actor::Property::POSITION_Y, Property::FLOAT },
2600 { "position-z", Actor::Property::POSITION_Z, Property::FLOAT },
2601 { "world-position", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2602 { "world-position-x", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2603 { "world-position-y", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2604 { "world-position-z", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2605 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2606 { "world-orientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2607 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2608 { "scale-x", Actor::Property::SCALE_X, Property::FLOAT },
2609 { "scale-y", Actor::Property::SCALE_Y, Property::FLOAT },
2610 { "scale-z", Actor::Property::SCALE_Z, Property::FLOAT },
2611 { "world-scale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2612 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2613 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2614 { "color-red", Actor::Property::COLOR_RED, Property::FLOAT },
2615 { "color-green", Actor::Property::COLOR_GREEN, Property::FLOAT },
2616 { "color-blue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2617 { "color-alpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2618 { "world-color", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2619 { "world-matrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2620 { "name", Actor::Property::NAME, Property::STRING },
2621 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2622 { "leave-required", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2623 { "inherit-orientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2624 { "inherit-scale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2625 { "color-mode", Actor::Property::COLOR_MODE, Property::STRING },
2626 { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2627 { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING },
2628 { "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2629 { "relayout-enabled", Actor::Property::RELAYOUT_ENABLED, Property::BOOLEAN },
2630 { "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2631 { "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2632 { "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2633 { "width-for-height", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2634 { "height-for-width", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2635 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2636 { "minimum-size", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2637 { "maximum-size", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2639 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2640 } // unnamed namespace
2642 int UtcDaliActorProperties(void)
2644 TestApplication app;
2646 Actor actor = Actor::New();
2648 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2650 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2651 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2652 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2653 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2658 int UtcDaliRelayoutProperties_RelayoutEnabled(void)
2660 TestApplication app;
2662 Actor actor = Actor::New();
2665 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION );
2667 // Set relayout disabled
2668 actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, false );
2670 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION );
2672 // Set relayout enabled
2673 actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, true );
2675 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), true, TEST_LOCATION );
2680 int UtcDaliRelayoutProperties_ResizePolicies(void)
2682 TestApplication app;
2684 Actor actor = Actor::New();
2687 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
2688 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
2690 // Set resize policy for all dimensions
2691 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2692 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2694 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2697 // Set individual dimensions
2698 const char* const widthPolicy = "FILL_TO_PARENT";
2699 const char* const heightPolicy = "FIXED";
2701 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2702 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2704 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2705 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2710 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2712 TestApplication app;
2714 Actor actor = Actor::New();
2717 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2720 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2721 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2723 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2724 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2726 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2727 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2732 int UtcDaliRelayoutProperties_DimensionDependency(void)
2734 TestApplication app;
2736 Actor actor = Actor::New();
2739 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2740 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2743 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2744 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2746 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2747 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2749 // Test setting another resize policy
2750 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2751 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2756 int UtcDaliRelayoutProperties_Padding(void)
2758 TestApplication app;
2760 Actor actor = Actor::New();
2763 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2766 actor.SetProperty( Actor::Property::PADDING, padding );
2767 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2769 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2774 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
2776 TestApplication app;
2778 Actor actor = Actor::New();
2781 Vector2 minSize( 1.0f, 2.0f );
2783 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
2784 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
2786 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2788 Vector2 maxSize( 3.0f, 4.0f );
2790 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
2791 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
2793 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );