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;
44 bool gTouchCallBackCalled=false;
45 bool gTouchCallBack2Called=false;
46 bool gHoverCallBackCalled=false;
49 * Simulates a Down Touch at 25.0, 25.0.
50 * @param[in] app Test Application instance.
52 int SimulateTouchForSetOverlayHitTest(TestApplication& app)
54 app.SendNotification();
56 app.SendNotification();
59 gTouchCallBackCalled = false;
60 gTouchCallBack2Called = false;
62 // simulate a touch event
63 Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f );
64 Dali::Integration::TouchEvent event;
65 event.AddPoint( point );
66 app.ProcessEvent( event );
68 app.SendNotification();
70 app.SendNotification();
76 static bool gTestConstraintCalled;
80 Vector4 operator()(const Vector4& color)
82 gTestConstraintCalled = true;
83 return Vector4(color.x, color.y, color.z, 0.1f);
88 * TestConstraint reference.
89 * When constraint is called, the resultRef is updated
90 * with the value supplied.
93 struct TestConstraintRef
95 TestConstraintRef(unsigned int& resultRef, unsigned int value)
96 : mResultRef(resultRef),
101 T operator()(const T& current)
107 unsigned int& mResultRef;
111 bool wasConstraintCallbackCalled1 = false;
112 void TestConstraintCallback1( ActiveConstraint& constraint )
114 wasConstraintCallbackCalled1 = true;
117 bool wasConstraintCallbackCalled2 = false;
118 void TestConstraintCallback2( ActiveConstraint& constraint )
120 wasConstraintCallbackCalled2 = true;
123 bool wasConstraintCallbackCalled3 = false;
124 void TestConstraintCallback3( ActiveConstraint& constraint )
126 wasConstraintCallbackCalled3 = true;
129 static bool TestCallback(Actor actor, const TouchEvent& event)
131 gTouchCallBackCalled = true;
136 static bool TestCallback2(Actor actor, const TouchEvent& event)
138 gTouchCallBack2Called = true;
143 static bool TestCallback3(Actor actor, const HoverEvent& event)
145 gHoverCallBackCalled = true;
150 static Vector3 gSetSize;
151 static bool gSetSizeCallBackCalled;
152 void SetSizeCallback( Actor actor, const Vector3& size )
154 gSetSizeCallBackCalled = true;
157 // validation stuff for onstage & offstage signals
158 static std::vector< std::string > gActorNamesOnOffStage;
159 static int gOnStageCallBackCalled;
160 void OnStageCallback( Actor actor )
162 ++gOnStageCallBackCalled;
163 gActorNamesOnOffStage.push_back( actor.GetName() );
164 DALI_TEST_CHECK( actor.OnStage() == true );
166 static int gOffStageCallBackCalled;
167 void OffStageCallback( Actor actor )
169 ++gOffStageCallBackCalled;
170 gActorNamesOnOffStage.push_back( actor.GetName() );
171 DALI_TEST_CHECK( actor.OnStage() == false );
174 struct PositionComponentConstraint
176 PositionComponentConstraint(){}
178 Vector3 operator()(const Vector3& current, const PropertyInput& property)
180 const Matrix& m = property.GetMatrix();
184 m.GetTransformComponents(pos, rot, scale);
191 } // anonymous namespace
194 //& purpose: Testing New API
195 int UtcDaliActorNew(void)
197 TestApplication application;
199 Actor actor = Actor::New();
201 DALI_TEST_CHECK(actor);
205 //& purpose: Testing Dali::Actor::DownCast()
206 int UtcDaliActorDownCast(void)
208 TestApplication application;
209 tet_infoline("Testing Dali::Actor::DownCast()");
211 Actor actor = Actor::New();
212 BaseHandle object(actor);
213 Actor actor2 = Actor::DownCast(object);
214 DALI_TEST_CHECK(actor2);
218 //& purpose: Testing Dali::Actor::DownCast()
219 int UtcDaliActorDownCast2(void)
221 TestApplication application;
222 tet_infoline("Testing Dali::Actor::DownCast()");
224 BaseHandle unInitializedObject;
225 Actor actor = Actor::DownCast(unInitializedObject);
226 DALI_TEST_CHECK(!actor);
230 //& purpose: Testing Dali::Actor::GetName()
231 int UtcDaliActorGetName(void)
233 TestApplication application;
235 Actor actor = Actor::New();
237 DALI_TEST_CHECK(actor.GetName().empty());
241 //& purpose: Testing Dali::Actor::SetName()
242 int UtcDaliActorSetName(void)
244 TestApplication application;
246 string str("ActorName");
247 Actor actor = Actor::New();
250 DALI_TEST_CHECK(actor.GetName() == str);
254 int UtcDaliActorGetId(void)
256 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
257 TestApplication application;
259 Actor first = Actor::New();
260 Actor second = Actor::New();
261 Actor third = Actor::New();
263 DALI_TEST_CHECK(first.GetId() != second.GetId());
264 DALI_TEST_CHECK(second.GetId() != third.GetId());
268 int UtcDaliActorIsRoot(void)
270 TestApplication application;
272 Actor actor = Actor::New();
273 DALI_TEST_CHECK(!actor.IsRoot());
275 // get the root layer
276 actor = Stage::GetCurrent().GetLayer( 0 );
277 DALI_TEST_CHECK( actor.IsRoot() );
281 int UtcDaliActorOnStage(void)
283 TestApplication application;
285 Actor actor = Actor::New();
286 DALI_TEST_CHECK( !actor.OnStage() );
288 // get the root layer
289 actor = Stage::GetCurrent().GetLayer( 0 );
290 DALI_TEST_CHECK( actor.OnStage() );
294 int UtcDaliActorIsLayer(void)
296 TestApplication application;
298 Actor actor = Actor::New();
299 DALI_TEST_CHECK( !actor.IsLayer() );
301 // get the root layer
302 actor = Stage::GetCurrent().GetLayer( 0 );
303 DALI_TEST_CHECK( actor.IsLayer() );
307 int UtcDaliActorGetLayer(void)
309 TestApplication application;
311 Actor actor = Actor::New();
312 Stage::GetCurrent().Add(actor);
313 Layer layer = actor.GetLayer();
315 DALI_TEST_CHECK(layer);
317 // get the root layers layer
318 actor = Stage::GetCurrent().GetLayer( 0 );
319 DALI_TEST_CHECK( actor.GetLayer() );
323 int UtcDaliActorAdd(void)
325 tet_infoline("Testing Actor::Add");
326 TestApplication application;
328 Actor parent = Actor::New();
329 Actor child = Actor::New();
331 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
335 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
337 Actor parent2 = Actor::New();
338 parent2.Add( child );
340 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
341 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
343 // try Adding to same parent again, works
344 parent2.Add( child );
345 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
347 // try reparenting an orphaned child
349 Actor temporaryParent = Actor::New();
350 temporaryParent.Add( child );
351 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
353 // temporaryParent has now died, reparent the orphaned child
354 parent2.Add( child );
355 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
360 parent2.Add( parent2 );
361 tet_printf("Assertion test failed - no Exception\n" );
362 tet_result(TET_FAIL);
364 catch(Dali::DaliException& e)
366 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
367 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
368 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
372 tet_printf("Assertion test failed - wrong Exception\n" );
373 tet_result(TET_FAIL);
376 // try reparenting root
379 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
380 tet_printf("Assertion test failed - no Exception\n" );
381 tet_result(TET_FAIL);
383 catch(Dali::DaliException& e)
385 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
386 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
387 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
391 tet_printf("Assertion test failed - wrong Exception\n" );
392 tet_result(TET_FAIL);
399 parent2.Add( empty );
400 tet_printf("Assertion test failed - no Exception\n" );
401 tet_result(TET_FAIL);
403 catch(Dali::DaliException& e)
405 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
406 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
407 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
411 tet_printf("Assertion test failed - wrong Exception\n" );
412 tet_result(TET_FAIL);
417 int UtcDaliActorInsert(void)
419 tet_infoline("Testing Actor::Insert");
420 TestApplication application;
422 Actor parent = Actor::New();
423 Stage::GetCurrent().Add( parent );
424 Actor first = Actor::New();
425 Actor second = Actor::New();
426 Actor third = Actor::New();
428 parent.Insert(1, first); // test insert beyond range
429 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
430 parent.Insert(0, second);
431 DALI_TEST_EQUALS( parent.GetChildCount(), 2u, TEST_LOCATION );
432 parent.Insert(1, third);
434 DALI_TEST_EQUALS( parent.GetChildCount(), 3u, TEST_LOCATION );
436 DALI_TEST_CHECK(parent.GetChildAt(0) == second);
437 DALI_TEST_CHECK(parent.GetChildAt(1) == third);
438 DALI_TEST_CHECK(parent.GetChildAt(2) == first);
444 int UtcDaliActorRemove01(void)
446 tet_infoline("Testing Actor::Remove");
447 TestApplication application;
449 Actor parent = Actor::New();
450 Actor child = Actor::New();
451 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
454 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
456 parent.Remove(child);
457 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
459 // remove again, no problem
460 parent.Remove(child);
461 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
465 // try illegal Remove
468 parent.Remove( parent );
469 tet_printf("Assertion test failed - no Exception\n" );
470 tet_result(TET_FAIL);
472 catch(Dali::DaliException& e)
474 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
475 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
476 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
480 tet_printf("Assertion test failed - wrong Exception\n" );
481 tet_result(TET_FAIL);
488 parent.Remove( empty );
489 tet_printf("Assertion test failed - no Exception\n" );
490 tet_result(TET_FAIL);
492 catch(Dali::DaliException& e)
494 tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
495 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
496 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
500 tet_printf("Assertion test failed - wrong Exception\n" );
501 tet_result(TET_FAIL);
506 int UtcDaliActorRemove02(void)
508 TestApplication application;
510 Actor parent = Actor::New();
511 Actor child = Actor::New();
512 Actor random = Actor::New();
514 Stage::GetCurrent().Add( parent );
516 DALI_TEST_CHECK(parent.GetChildCount() == 0);
520 DALI_TEST_CHECK(parent.GetChildCount() == 1);
522 parent.Remove(random);
524 DALI_TEST_CHECK(parent.GetChildCount() == 1);
526 Stage::GetCurrent().Remove( parent );
528 DALI_TEST_CHECK(parent.GetChildCount() == 1);
532 int UtcDaliActorGetChildCount(void)
534 TestApplication application;
536 Actor parent = Actor::New();
537 Actor child = Actor::New();
539 DALI_TEST_CHECK(parent.GetChildCount() == 0);
543 DALI_TEST_CHECK(parent.GetChildCount() == 1);
547 int UtcDaliActorGetChildren01(void)
549 TestApplication application;
551 Actor parent = Actor::New();
552 Actor first = Actor::New();
553 Actor second = Actor::New();
554 Actor third = Actor::New();
560 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
561 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
562 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
566 int UtcDaliActorGetChildren02(void)
568 TestApplication application;
570 Actor parent = Actor::New();
571 Actor first = Actor::New();
572 Actor second = Actor::New();
573 Actor third = Actor::New();
579 const Actor& constParent = parent;
581 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
582 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
583 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
587 int UtcDaliActorGetParent01(void)
589 TestApplication application;
591 Actor parent = Actor::New();
592 Actor child = Actor::New();
596 DALI_TEST_CHECK(child.GetParent() == parent);
600 int UtcDaliActorGetParent02(void)
602 TestApplication application;
604 Actor actor = Actor::New();
606 DALI_TEST_CHECK(!actor.GetParent());
610 int UtcDaliActorSetParentOrigin(void)
612 TestApplication application;
614 Actor actor = Actor::New();
616 Vector3 vector(0.7f, 0.8f, 0.9f);
617 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
619 actor.SetParentOrigin(vector);
621 // flush the queue and render once
622 application.SendNotification();
623 application.Render();
625 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
627 Stage::GetCurrent().Add( actor );
629 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
631 // flush the queue and render once
632 application.SendNotification();
633 application.Render();
635 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
637 Stage::GetCurrent().Remove( actor );
641 int UtcDaliActorGetCurrentParentOrigin(void)
643 TestApplication application;
645 Actor actor = Actor::New();
647 Vector3 vector(0.7f, 0.8f, 0.9f);
648 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
650 actor.SetParentOrigin(vector);
652 // flush the queue and render once
653 application.SendNotification();
654 application.Render();
656 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
660 int UtcDaliActorSetAnchorPoint(void)
662 TestApplication application;
664 Actor actor = Actor::New();
666 Vector3 vector(0.7f, 0.8f, 0.9f);
667 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
669 actor.SetAnchorPoint(vector);
671 // flush the queue and render once
672 application.SendNotification();
673 application.Render();
675 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
677 Stage::GetCurrent().Add( actor );
679 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
680 // flush the queue and render once
681 application.SendNotification();
682 application.Render();
684 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
686 Stage::GetCurrent().Remove( actor );
690 int UtcDaliActorGetCurrentAnchorPoint(void)
692 TestApplication application;
694 Actor actor = Actor::New();
696 Vector3 vector(0.7f, 0.8f, 0.9f);
697 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
699 actor.SetAnchorPoint(vector);
701 // flush the queue and render once
702 application.SendNotification();
703 application.Render();
705 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
709 // SetSize(float width, float height)
710 int UtcDaliActorSetSize01(void)
712 TestApplication application;
714 Actor actor = Actor::New();
715 Vector3 vector(100.0f, 100.0f, 100.0f);
717 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
719 actor.SetSize(vector.x, vector.y);
721 // flush the queue and render once
722 application.SendNotification();
723 application.Render();
725 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
729 // SetSize(float width, float height, float depth)
730 int UtcDaliActorSetSize02(void)
732 TestApplication application;
734 Actor actor = Actor::New();
735 Vector3 vector(100.0f, 100.0f, 100.0f);
737 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
739 actor.SetSize(vector.x, vector.y, vector.z);
741 // flush the queue and render once
742 application.SendNotification();
743 application.Render();
745 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
749 // SetSize(Vector2 size)
750 int UtcDaliActorSetSize03(void)
752 TestApplication application;
754 Actor actor = Actor::New();
755 Vector3 vector(100.0f, 100.0f, 100.0f);
757 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
759 actor.SetSize(Vector2(vector.x, vector.y));
761 // flush the queue and render once
762 application.SendNotification();
763 application.Render();
765 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
769 // SetSize(Vector3 size)
770 int UtcDaliActorSetSize04(void)
772 TestApplication application;
774 Actor actor = Actor::New();
775 Vector3 vector(100.0f, 100.0f, 100.0f);
777 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
779 actor.SetSize(vector);
781 // flush the queue and render once
782 application.SendNotification();
783 application.Render();
785 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
787 Stage::GetCurrent().Add( actor );
788 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
790 // flush the queue and render once
791 application.SendNotification();
792 application.Render();
794 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
795 Stage::GetCurrent().Remove( actor );
799 int UtcDaliActorGetCurrentSize(void)
801 TestApplication application;
803 Actor actor = Actor::New();
804 Vector3 vector(100.0f, 100.0f, 20.0f);
806 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
808 actor.SetSize(vector);
810 // flush the queue and render once
811 application.SendNotification();
812 application.Render();
814 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
818 int UtcDaliActorGetNaturalSize(void)
820 TestApplication application;
822 Actor actor = Actor::New();
823 Vector3 vector( 0.0f, 0.0f, 0.0f );
825 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
830 int UtcDaliActorGetCurrentSizeImmediate(void)
832 TestApplication application;
834 Actor actor = Actor::New();
835 Vector3 vector(100.0f, 100.0f, 20.0f);
837 DALI_TEST_CHECK(vector != actor.GetSize());
838 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
840 actor.SetSize(vector);
842 DALI_TEST_CHECK(vector == actor.GetSize());
843 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
845 // flush the queue and render once
846 application.SendNotification();
847 application.Render();
849 DALI_TEST_CHECK(vector == actor.GetSize());
850 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
853 // Build the animation
854 const float durationSeconds = 2.0f;
855 Animation animation = Animation::New( durationSeconds );
856 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
857 animation.AnimateTo( Property( actor, Actor::SIZE ), targetValue );
859 DALI_TEST_CHECK( actor.GetSize() == targetValue );
861 // Start the animation
864 application.SendNotification();
865 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
867 DALI_TEST_CHECK( actor.GetSize() == targetValue );
872 // SetPosition(float x, float y)
873 int UtcDaliActorSetPosition01(void)
875 TestApplication application;
877 Actor actor = Actor::New();
879 // Set to random to start off with
880 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
882 Vector3 vector(100.0f, 100.0f, 0.0f);
884 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
886 actor.SetPosition(vector.x, vector.y);
887 // flush the queue and render once
888 application.SendNotification();
889 application.Render();
890 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
892 Stage::GetCurrent().Add( actor );
893 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
894 // flush the queue and render once
895 application.SendNotification();
896 application.Render();
897 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
902 // flush the queue and render once
903 application.SendNotification();
904 application.Render();
905 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
907 actor.MoveBy( Vector3( 0.1f, 0.1f, 0.1f ) );
908 // flush the queue and render once
909 application.SendNotification();
910 application.Render();
911 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
913 Stage::GetCurrent().Remove( actor );
917 // SetPosition(float x, float y, float z)
918 int UtcDaliActorSetPosition02(void)
920 TestApplication application;
922 Actor actor = Actor::New();
924 // Set to random to start off with
925 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
927 Vector3 vector(100.0f, 100.0f, 100.0f);
929 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
931 actor.SetPosition(vector.x, vector.y, vector.z);
933 // flush the queue and render once
934 application.SendNotification();
935 application.Render();
937 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
941 // SetPosition(Vector3 position)
942 int UtcDaliActorSetPosition03(void)
944 TestApplication application;
946 Actor actor = Actor::New();
948 // Set to random to start off with
949 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
951 Vector3 vector(100.0f, 100.0f, 100.0f);
953 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
955 actor.SetPosition(vector);
957 // flush the queue and render once
958 application.SendNotification();
959 application.Render();
961 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
965 int UtcDaliActorSetX(void)
967 TestApplication application;
969 Actor actor = Actor::New();
971 Vector3 vector(100.0f, 0.0f, 0.0f);
973 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
977 // flush the queue and render once
978 application.SendNotification();
979 application.Render();
981 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
985 int UtcDaliActorSetY(void)
987 TestApplication application;
989 Actor actor = Actor::New();
991 Vector3 vector(0.0f, 100.0f, 0.0f);
993 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
997 // flush the queue and render once
998 application.SendNotification();
999 application.Render();
1001 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1005 int UtcDaliActorSetZ(void)
1007 TestApplication application;
1009 Actor actor = Actor::New();
1011 Vector3 vector(0.0f, 0.0f, 100.0f);
1013 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1017 // flush the queue and render once
1018 application.SendNotification();
1019 application.Render();
1021 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1025 int UtcDaliActorMoveBy(void)
1027 TestApplication application;
1029 Actor actor = Actor::New();
1030 Vector3 vector(100.0f, 100.0f, 100.0f);
1032 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1034 actor.SetPosition(vector);
1036 // flush the queue and render once
1037 application.SendNotification();
1038 application.Render();
1040 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1042 actor.MoveBy(vector);
1044 // flush the queue and render once
1045 application.SendNotification();
1046 application.Render();
1048 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1052 int UtcDaliActorGetCurrentPosition(void)
1054 TestApplication application;
1056 Actor actor = Actor::New();
1057 Vector3 setVector(100.0f, 100.0f, 0.0f);
1058 actor.SetPosition(setVector);
1060 // flush the queue and render once
1061 application.SendNotification();
1062 application.Render();
1064 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1068 int UtcDaliActorGetCurrentWorldPosition(void)
1070 TestApplication application;
1072 Actor parent = Actor::New();
1073 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1074 parent.SetPosition( parentPosition );
1075 parent.SetParentOrigin( ParentOrigin::CENTER );
1076 parent.SetAnchorPoint( AnchorPoint::CENTER );
1077 Stage::GetCurrent().Add( parent );
1079 Actor child = Actor::New();
1080 child.SetParentOrigin( ParentOrigin::CENTER );
1081 child.SetAnchorPoint( AnchorPoint::CENTER );
1082 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1083 child.SetPosition( childPosition );
1084 parent.Add( child );
1086 // The actors should not have a world position yet
1087 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1088 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1090 application.SendNotification();
1091 application.Render(0);
1093 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1094 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1096 // The actors should have a world position now
1097 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1098 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1102 int UtcDaliActorInheritPosition(void)
1104 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1105 TestApplication application;
1107 Actor parent = Actor::New();
1108 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1109 parent.SetPosition( parentPosition );
1110 parent.SetParentOrigin( ParentOrigin::CENTER );
1111 parent.SetAnchorPoint( AnchorPoint::CENTER );
1112 Stage::GetCurrent().Add( parent );
1114 Actor child = Actor::New();
1115 child.SetParentOrigin( ParentOrigin::CENTER );
1116 child.SetAnchorPoint( AnchorPoint::CENTER );
1117 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1118 child.SetPosition( childPosition );
1119 parent.Add( child );
1121 // The actors should not have a world position yet
1122 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1123 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1125 // first test default, which is INHERIT_PARENT_POSITION
1126 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1127 application.SendNotification();
1128 application.Render(0); // should only really call Update as Render is not required to update scene
1129 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1130 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1131 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1132 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1134 // Change inheritance mode to use parent
1135 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
1136 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
1137 application.SendNotification();
1138 application.Render(0); // should only really call Update as Render is not required to update scene
1139 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1140 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1141 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1142 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1144 // Change inheritance mode to use parent + offset
1145 child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
1146 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1147 child.SetPosition( childOffset );
1148 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
1149 application.SendNotification();
1150 application.Render(0); // should only really call Update as Render is not required to update scene
1151 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1152 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1153 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1154 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1156 // Change inheritance mode to not inherit
1157 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1158 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1159 application.SendNotification();
1160 application.Render(0); // should only really call Update as Render is not required to update scene
1161 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1162 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1163 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1164 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1168 // SetRotation(float angleRadians, Vector3 axis)
1169 int UtcDaliActorSetRotation01(void)
1171 TestApplication application;
1173 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1174 Actor actor = Actor::New();
1176 actor.SetRotation(rotation);
1178 // flush the queue and render once
1179 application.SendNotification();
1180 application.Render();
1182 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1186 int UtcDaliActorSetRotation02(void)
1188 TestApplication application;
1190 Actor actor = Actor::New();
1192 float angle = 0.785f;
1193 Vector3 axis(1.0f, 1.0f, 0.0f);
1195 actor.SetRotation(Radian( angle ), axis);
1196 Quaternion rotation( angle, axis );
1197 // flush the queue and render once
1198 application.SendNotification();
1199 application.Render();
1200 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1202 Stage::GetCurrent().Add( actor );
1203 actor.RotateBy( Degree( 360 ), axis);
1204 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1206 actor.SetRotation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1207 Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) );
1208 // flush the queue and render once
1209 application.SendNotification();
1210 application.Render();
1211 DALI_TEST_EQUALS( result, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1213 actor.SetRotation(Radian( angle ), axis);
1214 // flush the queue and render once
1215 application.SendNotification();
1216 application.Render();
1217 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1219 Stage::GetCurrent().Remove( actor );
1223 // RotateBy(float angleRadians, Vector3 axis)
1224 int UtcDaliActorRotateBy01(void)
1226 TestApplication application;
1228 Actor actor = Actor::New();
1230 float angle = M_PI * 0.25f;
1231 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1232 // flush the queue and render once
1233 application.SendNotification();
1234 application.Render();
1235 DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1237 Stage::GetCurrent().Add( actor );
1239 actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
1240 // flush the queue and render once
1241 application.SendNotification();
1242 application.Render();
1243 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1245 Stage::GetCurrent().Remove( actor );
1249 // RotateBy(Quaternion relativeRotation)
1250 int UtcDaliActorRotateBy02(void)
1252 TestApplication application;
1254 Actor actor = Actor::New();
1256 Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
1257 actor.RotateBy(rotation);
1258 // flush the queue and render once
1259 application.SendNotification();
1260 application.Render();
1261 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1263 actor.RotateBy(rotation);
1264 // flush the queue and render once
1265 application.SendNotification();
1266 application.Render();
1267 DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1271 int UtcDaliActorGetCurrentRotation(void)
1273 TestApplication application;
1274 Actor actor = Actor::New();
1276 Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
1277 actor.SetRotation(rotation);
1278 // flush the queue and render once
1279 application.SendNotification();
1280 application.Render();
1281 DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION);
1285 int UtcDaliActorGetCurrentWorldRotation(void)
1287 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1288 TestApplication application;
1290 Actor parent = Actor::New();
1291 Radian rotationAngle( Degree(90.0f) );
1292 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1293 parent.SetRotation( rotation );
1294 Stage::GetCurrent().Add( parent );
1296 Actor child = Actor::New();
1297 child.SetRotation( rotation );
1298 parent.Add( child );
1300 // The actors should not have a world rotation yet
1301 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1302 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
1304 application.SendNotification();
1305 application.Render(0);
1307 DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1308 DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION );
1310 // The actors should have a world rotation now
1311 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1312 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1314 // turn off child rotation inheritance
1315 child.SetInheritRotation( false );
1316 DALI_TEST_EQUALS( child.IsRotationInherited(), false, TEST_LOCATION );
1317 application.SendNotification();
1318 application.Render(0);
1320 // The actors should have a world rotation now
1321 DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1322 DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), rotation, 0.001, TEST_LOCATION );
1326 // SetScale(float scale)
1327 int UtcDaliActorSetScale01(void)
1329 TestApplication application;
1331 Actor actor = Actor::New();
1333 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1334 actor.SetScale(0.25f);
1336 Vector3 scale(10.0f, 10.0f, 10.0f);
1337 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1339 actor.SetScale(scale.x);
1341 // flush the queue and render once
1342 application.SendNotification();
1343 application.Render();
1345 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1349 // SetScale(float scaleX, float scaleY, float scaleZ)
1350 int UtcDaliActorSetScale02(void)
1352 TestApplication application;
1353 Vector3 scale(10.0f, 10.0f, 10.0f);
1355 Actor actor = Actor::New();
1357 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1358 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1360 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1362 actor.SetScale(scale.x, scale.y, scale.z);
1363 // flush the queue and render once
1364 application.SendNotification();
1365 application.Render();
1366 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1368 // add to stage and test
1369 Stage::GetCurrent().Add( actor );
1370 actor.SetScale( 2.0f, 2.0f, 2.0f );
1371 // flush the queue and render once
1372 application.SendNotification();
1373 application.Render();
1374 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1376 Stage::GetCurrent().Remove( actor );
1381 // SetScale(Vector3 scale)
1382 int UtcDaliActorSetScale03(void)
1384 TestApplication application;
1385 Vector3 scale(10.0f, 10.0f, 10.0f);
1387 Actor actor = Actor::New();
1389 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1390 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1392 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1394 actor.SetScale(scale);
1396 // flush the queue and render once
1397 application.SendNotification();
1398 application.Render();
1400 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1404 int UtcDaliActorScaleBy(void)
1406 TestApplication application;
1407 Actor actor = Actor::New();
1408 Vector3 vector(100.0f, 100.0f, 100.0f);
1410 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1412 actor.SetScale(vector);
1414 // flush the queue and render once
1415 application.SendNotification();
1416 application.Render();
1418 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1420 actor.ScaleBy(vector);
1422 // flush the queue and render once
1423 application.SendNotification();
1424 application.Render();
1426 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1430 int UtcDaliActorGetCurrentScale(void)
1432 TestApplication application;
1433 Vector3 scale(12.0f, 1.0f, 2.0f);
1435 Actor actor = Actor::New();
1437 actor.SetScale(scale);
1439 // flush the queue and render once
1440 application.SendNotification();
1441 application.Render();
1443 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1447 int UtcDaliActorGetCurrentWorldScale(void)
1449 TestApplication application;
1451 Actor parent = Actor::New();
1452 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1453 parent.SetScale( parentScale );
1454 Stage::GetCurrent().Add( parent );
1456 Actor child = Actor::New();
1457 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1458 child.SetScale( childScale );
1459 parent.Add( child );
1461 // The actors should not have a scale yet
1462 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1463 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1465 // The actors should not have a world scale yet
1466 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1467 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1469 application.SendNotification();
1470 application.Render(0);
1472 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1473 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1475 // The actors should have a world scale now
1476 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1477 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1481 int UtcDaliActorInheritScale(void)
1483 tet_infoline("Testing Actor::SetInheritScale");
1484 TestApplication application;
1486 Actor parent = Actor::New();
1487 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1488 parent.SetScale( parentScale );
1489 Stage::GetCurrent().Add( parent );
1491 Actor child = Actor::New();
1492 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1493 child.SetScale( childScale );
1494 parent.Add( child );
1496 application.SendNotification();
1497 application.Render(0);
1499 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1500 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1502 child.SetInheritScale( false );
1503 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1505 application.SendNotification();
1506 application.Render(0);
1508 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1512 int UtcDaliActorSetVisible(void)
1514 TestApplication application;
1516 Actor actor = Actor::New();
1517 actor.SetVisible(false);
1518 // flush the queue and render once
1519 application.SendNotification();
1520 application.Render();
1521 DALI_TEST_CHECK(actor.IsVisible() == false);
1523 actor.SetVisible(true);
1524 // flush the queue and render once
1525 application.SendNotification();
1526 application.Render();
1527 DALI_TEST_CHECK(actor.IsVisible() == true);
1529 // put actor on stage
1530 Stage::GetCurrent().Add( actor );
1531 actor.SetVisible(false);
1532 // flush the queue and render once
1533 application.SendNotification();
1534 application.Render();
1535 DALI_TEST_CHECK(actor.IsVisible() == false);
1539 int UtcDaliActorIsVisible(void)
1541 TestApplication application;
1543 Actor actor = Actor::New();
1545 DALI_TEST_CHECK(actor.IsVisible() == true);
1549 int UtcDaliActorSetOpacity(void)
1551 TestApplication application;
1553 Actor actor = Actor::New();
1554 // initial opacity is 1
1555 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1557 actor.SetOpacity( 0.4f);
1558 // flush the queue and render once
1559 application.SendNotification();
1560 application.Render();
1561 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1563 // change opacity, actor is on stage to change is not immediate
1564 actor.OpacityBy( 0.1f );
1565 // flush the queue and render once
1566 application.SendNotification();
1567 application.Render();
1568 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1570 // put actor on stage
1571 Stage::GetCurrent().Add( actor );
1573 // change opacity, actor is on stage to change is not immediate
1574 actor.SetOpacity( 0.9f );
1575 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1576 // flush the queue and render once
1577 application.SendNotification();
1578 application.Render();
1579 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1581 // change opacity, actor is on stage to change is not immediate
1582 actor.OpacityBy( -0.9f );
1583 // flush the queue and render once
1584 application.SendNotification();
1585 application.Render();
1586 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1590 int UtcDaliActorGetCurrentOpacity(void)
1592 TestApplication application;
1594 Actor actor = Actor::New();
1595 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1597 actor.SetOpacity(0.5f);
1598 // flush the queue and render once
1599 application.SendNotification();
1600 application.Render();
1601 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1605 int UtcDaliActorSetSensitive(void)
1607 TestApplication application;
1608 Actor actor = Actor::New();
1610 bool sensitive = !actor.IsSensitive();
1612 actor.SetSensitive(sensitive);
1614 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1618 int UtcDaliActorIsSensitive(void)
1620 TestApplication application;
1621 Actor actor = Actor::New();
1622 actor.SetSensitive(false);
1624 DALI_TEST_CHECK(false == actor.IsSensitive());
1628 int UtcDaliActorSetColor(void)
1630 TestApplication application;
1631 Actor actor = Actor::New();
1632 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1634 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1636 actor.SetColor(color);
1637 // flush the queue and render once
1638 application.SendNotification();
1639 application.Render();
1640 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1642 actor.ColorBy( Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1643 // flush the queue and render once
1644 application.SendNotification();
1645 application.Render();
1646 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1648 Stage::GetCurrent().Add( actor );
1649 actor.SetColor( color );
1650 // flush the queue and render once
1651 application.SendNotification();
1652 application.Render();
1653 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1655 actor.ColorBy( Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1656 // flush the queue and render once
1657 application.SendNotification();
1658 application.Render();
1659 // Actor color is not clamped
1660 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1661 // world color is clamped
1662 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1664 Stage::GetCurrent().Remove( actor );
1668 int UtcDaliActorGetCurrentColor(void)
1670 TestApplication application;
1671 Actor actor = Actor::New();
1672 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1674 actor.SetColor(color);
1675 // flush the queue and render once
1676 application.SendNotification();
1677 application.Render();
1678 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1682 int UtcDaliActorGetCurrentWorldColor(void)
1684 tet_infoline("Actor::GetCurrentWorldColor");
1685 TestApplication application;
1687 Actor parent = Actor::New();
1688 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1689 parent.SetColor( parentColor );
1690 Stage::GetCurrent().Add( parent );
1692 Actor child = Actor::New();
1693 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1694 child.SetColor( childColor );
1695 parent.Add( child );
1697 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1698 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1700 // verify the default color mode
1701 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1703 // The actors should not have a world color yet
1704 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1705 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1707 application.SendNotification();
1708 application.Render(0);
1710 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1711 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1713 // The actors should have a world color now
1714 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1715 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1718 child.SetColorMode( USE_OWN_COLOR );
1719 application.SendNotification();
1720 application.Render(0);
1721 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1724 child.SetColorMode( USE_PARENT_COLOR );
1725 application.SendNotification();
1726 application.Render(0);
1727 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1728 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1731 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1732 application.SendNotification();
1733 application.Render(0);
1734 Vector4 expectedColor( childColor );
1735 expectedColor.a *= parentColor.a;
1736 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1737 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1741 int UtcDaliActorSetColorMode(void)
1743 tet_infoline("Actor::SetColorMode");
1744 TestApplication application;
1745 Actor actor = Actor::New();
1746 Actor child = Actor::New();
1749 actor.SetColorMode( USE_OWN_COLOR );
1750 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
1752 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
1753 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1755 actor.SetColorMode( USE_PARENT_COLOR );
1756 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
1758 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1759 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
1763 int UtcDaliActorScreenToLocal(void)
1765 TestApplication application;
1766 Actor actor = Actor::New();
1767 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1768 actor.SetSize(100.0f, 100.0f);
1769 actor.SetPosition(10.0f, 10.0f);
1770 Stage::GetCurrent().Add(actor);
1772 // flush the queue and render once
1773 application.SendNotification();
1774 application.Render();
1779 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
1781 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
1782 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
1786 int UtcDaliActorSetLeaveRequired(void)
1788 TestApplication application;
1790 Actor actor = Actor::New();
1792 actor.SetLeaveRequired(false);
1793 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1795 actor.SetLeaveRequired(true);
1796 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
1800 int UtcDaliActorGetLeaveRequired(void)
1802 TestApplication application;
1804 Actor actor = Actor::New();
1806 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
1810 int UtcDaliActorSetKeyboardFocusable(void)
1812 TestApplication application;
1814 Actor actor = Actor::New();
1816 actor.SetKeyboardFocusable(true);
1817 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
1819 actor.SetKeyboardFocusable(false);
1820 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1824 int UtcDaliActorIsKeyboardFocusable(void)
1826 TestApplication application;
1828 Actor actor = Actor::New();
1830 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
1835 int UtcDaliActorApplyConstraint(void)
1837 TestApplication application;
1839 gTestConstraintCalled = false;
1841 Actor actor = Actor::New();
1843 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
1844 actor.ApplyConstraint(constraint);
1846 DALI_TEST_CHECK( gTestConstraintCalled == false );
1848 Stage::GetCurrent().Add( actor );
1850 // flush the queue and render once
1851 application.SendNotification();
1852 application.Render();
1854 DALI_TEST_CHECK( gTestConstraintCalled == true );
1859 int UtcDaliActorApplyConstraintAppliedCallback(void)
1861 TestApplication application;
1863 // Build a reusable constraint
1865 Actor parent = Actor::New();
1866 Vector3 parentSize( 100.0f, 100.0f, 100.0f );
1867 parent.SetSize( parentSize );
1868 Stage::GetCurrent().Add( parent );
1870 Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
1871 Source( parent, Actor::SIZE ),
1872 EqualToConstraint() );
1874 // Create some child actors
1876 Actor child1 = Actor::New();
1877 parent.Add( child1 );
1879 Actor child2 = Actor::New();
1880 parent.Add( child2 );
1882 Actor child3 = Actor::New();
1883 parent.Add( child3 );
1885 // Apply constraint with different timings - everything should be finished after 10 seconds
1887 wasConstraintCallbackCalled1 = false;
1888 wasConstraintCallbackCalled2 = false;
1889 wasConstraintCallbackCalled3 = false;
1891 constraint.SetApplyTime( 5.0f );
1892 ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint );
1893 activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 );
1895 constraint.SetApplyTime( 10.0f );
1896 ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint );
1897 activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 );
1899 constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) );
1900 ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
1901 activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
1903 // Check event-side size
1904 DALI_TEST_EQUALS( child1.GetSize(), Vector3::ZERO, TEST_LOCATION );
1905 DALI_TEST_EQUALS( child2.GetSize(), Vector3::ZERO, TEST_LOCATION );
1906 DALI_TEST_EQUALS( child3.GetSize(), Vector3::ZERO, TEST_LOCATION );
1908 DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1909 DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1910 DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
1912 application.SendNotification();
1914 application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
1916 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20%
1917 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
1918 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1920 // Check signals have not fired
1921 application.SendNotification();
1922 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1923 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1924 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1926 application.Render(static_cast<unsigned int>(1000.0f)); // 2 elapsed seconds
1927 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 / 5 * 100 = 40%
1928 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20%
1929 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
1931 // Check signals have not fired
1932 application.SendNotification();
1933 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1934 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1935 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1937 application.Render(static_cast<unsigned int>(1000.0f)); // 3 elapsed seconds
1938 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 / 5 * 100 = 60%
1939 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30%
1940 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20%
1942 // Check signals have not fired
1943 application.SendNotification();
1944 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1945 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1946 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1948 application.Render(static_cast<unsigned int>(1000.0f)); // 4 elapsed seconds
1949 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 / 5 * 100 = 80%
1950 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40%
1951 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40%
1953 // Check signals have not fired
1954 application.SendNotification();
1955 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1956 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1957 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1959 application.Render(static_cast<unsigned int>(1000.0f)); // 5 elapsed seconds
1960 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // 5 / 5 * 100 = 100%
1961 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50%
1962 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60%
1964 // Check signals have not fired
1965 application.SendNotification();
1966 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1967 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1968 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1970 application.Render(static_cast<unsigned int>(1000.0f)); // 6 elapsed seconds
1971 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 1 should fire)
1972 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60%
1973 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80%
1975 // 1st signal should have fired
1976 application.SendNotification();
1977 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION );
1978 wasConstraintCallbackCalled1 = false;
1979 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1980 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1982 application.Render(static_cast<unsigned int>(1000.0f)); // 7 elapsed seconds
1983 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1984 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70%
1985 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100%
1987 // Check signals have not fired
1988 application.SendNotification();
1989 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
1990 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
1991 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
1993 application.Render(static_cast<unsigned int>(1000.0f)); // 8 elapsed seconds
1994 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
1995 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80%
1996 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 3 should fire)
1998 // 3rd signal should have fired
1999 application.SendNotification();
2001 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2002 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2003 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION );
2004 wasConstraintCallbackCalled3 = false;
2006 application.Render(static_cast<unsigned int>(1000.0f)); // 9 elapsed seconds
2007 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2008 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90%
2009 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2011 // Check signals have not fired
2012 application.SendNotification();
2013 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2014 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2015 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2017 application.Render(static_cast<unsigned int>(1000.0f + 1.0f)); // over 10 elapsed seconds
2018 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2019 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 2 should fire)
2020 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100%
2022 // 2nd signal should have fired
2023 application.SendNotification();
2024 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2025 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION );
2026 wasConstraintCallbackCalled2 = false;
2027 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2029 // Check that nothing has changed after a couple of buffer swaps
2031 application.Render(0);
2032 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2033 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2034 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2036 application.SendNotification();
2037 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2038 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2039 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2041 application.Render(0);
2042 DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION );
2043 DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION );
2044 DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION );
2046 application.SendNotification();
2047 DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION );
2048 DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION );
2049 DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION );
2053 int UtcDaliActorRemoveConstraints(void)
2055 tet_infoline(" UtcDaliActorRemoveConstraints");
2056 TestApplication application;
2058 gTestConstraintCalled = false;
2060 Actor actor = Actor::New();
2062 Constraint constraint = Constraint::New<Vector4>( Actor::COLOR, TestConstraint() );
2063 actor.ApplyConstraint(constraint);
2064 actor.RemoveConstraints();
2066 DALI_TEST_CHECK( gTestConstraintCalled == false );
2068 Stage::GetCurrent().Add( actor );
2069 actor.ApplyConstraint(constraint);
2071 // flush the queue and render once
2072 application.SendNotification();
2073 application.Render();
2075 actor.RemoveConstraints();
2077 DALI_TEST_CHECK( gTestConstraintCalled == true );
2081 int UtcDaliActorRemoveConstraint(void)
2083 tet_infoline(" UtcDaliActorRemoveConstraint");
2084 TestApplication application;
2086 Actor actor = Actor::New();
2088 // 1. Apply Constraint1 and Constraint2, and test...
2089 unsigned int result1 = 0u;
2090 unsigned int result2 = 0u;
2091 ActiveConstraint activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2092 ActiveConstraint activeConstraint2 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) ) );
2094 Stage::GetCurrent().Add( actor );
2095 // flush the queue and render once
2096 application.SendNotification();
2097 application.Render();
2099 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2100 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2102 // 2. Remove Constraint1 and test...
2105 actor.RemoveConstraint(activeConstraint1);
2106 // make color property dirty, which will trigger constraints to be reapplied.
2107 actor.SetColor( Color::WHITE );
2108 // flush the queue and render once
2109 application.SendNotification();
2110 application.Render();
2112 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2113 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2115 // 3. Re-Apply Constraint1 and test...
2118 activeConstraint1 = actor.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) ) );
2119 // make color property dirty, which will trigger constraints to be reapplied.
2120 actor.SetColor( Color::WHITE );
2121 // flush the queue and render once
2122 application.SendNotification();
2123 application.Render();
2125 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2126 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2128 // 2. Remove Constraint2 and test...
2131 actor.RemoveConstraint(activeConstraint2);
2132 // make color property dirty, which will trigger constraints to be reapplied.
2133 actor.SetColor( Color::WHITE );
2134 // flush the queue and render once
2135 application.SendNotification();
2136 application.Render();
2138 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2139 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2141 // 2. Remove Constraint1 as well and test...
2144 actor.RemoveConstraint(activeConstraint1);
2145 // make color property dirty, which will trigger constraints to be reapplied.
2146 actor.SetColor( Color::WHITE );
2147 // flush the queue and render once
2148 application.SendNotification();
2149 application.Render();
2151 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2152 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2156 int UtcDaliActorRemoveConstraintTag(void)
2158 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2159 TestApplication application;
2161 Actor actor = Actor::New();
2163 // 1. Apply Constraint1 and Constraint2, and test...
2164 unsigned int result1 = 0u;
2165 unsigned int result2 = 0u;
2167 unsigned constraint1Tag = 1u;
2168 Constraint constraint1 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2169 constraint1.SetTag( constraint1Tag );
2170 actor.ApplyConstraint( constraint1 );
2172 unsigned constraint2Tag = 2u;
2173 Constraint constraint2 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2174 constraint2.SetTag( constraint2Tag );
2175 actor.ApplyConstraint( constraint2 );
2177 Stage::GetCurrent().Add( actor );
2178 // flush the queue and render once
2179 application.SendNotification();
2180 application.Render();
2182 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2183 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2185 // 2. Remove Constraint1 and test...
2188 actor.RemoveConstraints(constraint1Tag);
2189 // make color property dirty, which will trigger constraints to be reapplied.
2190 actor.SetColor( Color::WHITE );
2191 // flush the queue and render once
2192 application.SendNotification();
2193 application.Render();
2195 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2196 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2198 // 3. Re-Apply Constraint1 and test...
2201 actor.ApplyConstraint( constraint1 );
2202 // make color property dirty, which will trigger constraints to be reapplied.
2203 actor.SetColor( Color::WHITE );
2204 // flush the queue and render once
2205 application.SendNotification();
2206 application.Render();
2208 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2209 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2211 // 2. Remove Constraint2 and test...
2214 actor.RemoveConstraints(constraint2Tag);
2215 // make color property dirty, which will trigger constraints to be reapplied.
2216 actor.SetColor( Color::WHITE );
2217 // flush the queue and render once
2218 application.SendNotification();
2219 application.Render();
2221 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2222 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2224 // 2. Remove Constraint1 as well and test...
2227 actor.RemoveConstraints(constraint1Tag);
2228 // make color property dirty, which will trigger constraints to be reapplied.
2229 actor.SetColor( Color::WHITE );
2230 // flush the queue and render once
2231 application.SendNotification();
2232 application.Render();
2234 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2235 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2239 int UtcDaliActorTouchedSignal(void)
2241 TestApplication application;
2243 gTouchCallBackCalled = false;
2245 // get the root layer
2246 Actor actor = Stage::GetCurrent().GetRootLayer();
2247 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2249 application.SendNotification();
2250 application.Render();
2252 // connect to its touch signal
2253 actor.TouchedSignal().Connect( TestCallback );
2255 // simulate a touch event in the middle of the screen
2256 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2257 Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y );
2258 Dali::Integration::TouchEvent event;
2259 event.AddPoint( point );
2260 application.ProcessEvent( event );
2262 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2266 int UtcDaliActorHoveredSignal(void)
2268 TestApplication application;
2270 gHoverCallBackCalled = false;
2272 // get the root layer
2273 Actor actor = Stage::GetCurrent().GetRootLayer();
2274 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2276 application.SendNotification();
2277 application.Render();
2279 // connect to its hover signal
2280 actor.HoveredSignal().Connect( TestCallback3 );
2282 // simulate a hover event in the middle of the screen
2283 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2284 Dali::TouchPoint point( 1, TouchPoint::Motion, touchPoint.x, touchPoint.y );
2285 Dali::Integration::HoverEvent event;
2286 event.AddPoint( point );
2287 application.ProcessEvent( event );
2289 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2293 int UtcDaliActorSetSizeSignal(void)
2295 TestApplication application;
2297 Actor actor = Actor::New();
2298 actor.SetSizeSignal().Connect( SetSizeCallback );
2300 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2301 gSetSizeCallBackCalled = false;
2302 Vector2 size2d( 1.0f, 2.0f );
2303 actor.SetSize( size2d );
2304 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2305 // SetSize with Vector2 sets depth to be the minimum of width & height
2306 DALI_TEST_EQUALS( Vector3( 1.0f, 2.0f, 1.0f ), gSetSize, TEST_LOCATION );
2308 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2309 gSetSizeCallBackCalled = false;
2310 actor.SetSize( 22.0f, 11.0f );
2311 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2312 // SetSize with Vector2 sets depth to be the minimum of width & height
2313 DALI_TEST_EQUALS( Vector3( 22.0f, 11.0f, 11.0f ), gSetSize, TEST_LOCATION );
2315 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2316 gSetSizeCallBackCalled = false;
2317 Vector3 size( 3.0f, 4.0f, 5.0f );
2318 actor.SetSize( size );
2319 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2320 DALI_TEST_EQUALS( size, gSetSize, TEST_LOCATION );
2322 // add actor to stage to see that signal still works
2323 Stage::GetCurrent().Add( actor );
2325 gSetSize.x = gSetSize.y = gSetSize.z = 0.0f;
2326 gSetSizeCallBackCalled = false;
2327 actor.SetSize( -1.0f, -2.0f, -3.0f );
2328 DALI_TEST_CHECK( gSetSizeCallBackCalled == true );
2329 DALI_TEST_EQUALS( Vector3( -1.0f, -2.0f, -3.0f ), gSetSize, TEST_LOCATION );
2333 int UtcDaliActorOnOffStageSignal(void)
2335 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2337 TestApplication application;
2340 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2341 gActorNamesOnOffStage.clear();
2343 Actor parent = Actor::New();
2344 parent.SetName( "parent" );
2345 parent.OnStageSignal().Connect( OnStageCallback );
2346 parent.OffStageSignal().Connect( OffStageCallback );
2348 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2349 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2351 // add parent to stage
2352 Stage::GetCurrent().Add( parent );
2353 // onstage emitted, offstage not
2354 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2355 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2356 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2358 // test adding a child, should get onstage emitted
2360 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2361 gActorNamesOnOffStage.clear();
2363 Actor child = Actor::New();
2364 child.SetName( "child" );
2365 child.OnStageSignal().Connect( OnStageCallback );
2366 child.OffStageSignal().Connect( OffStageCallback );
2367 parent.Add( child ); // add child
2368 // onstage emitted, offstage not
2369 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2370 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2371 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2373 // test removing parent from stage
2375 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2376 gActorNamesOnOffStage.clear();
2378 Stage::GetCurrent().Remove( parent );
2379 // onstage not emitted, offstage is
2380 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2381 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2382 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2383 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2385 // test adding parent back to stage
2387 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2388 gActorNamesOnOffStage.clear();
2390 Stage::GetCurrent().Add( parent );
2391 // onstage emitted, offstage not
2392 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2393 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2394 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2395 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2397 // test removing child
2399 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2400 gActorNamesOnOffStage.clear();
2402 parent.Remove( child );
2403 // onstage not emitted, offstage is
2404 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2405 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2406 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2408 // test removing parent
2410 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2411 gActorNamesOnOffStage.clear();
2413 Stage::GetCurrent().Remove( parent );
2414 // onstage not emitted, offstage is
2415 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2416 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2417 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2421 int UtcDaliActorFindChildByName(void)
2423 tet_infoline("Testing Dali::Actor::FindChildByName()");
2424 TestApplication application;
2426 Actor parent = Actor::New();
2427 parent.SetName( "parent" );
2428 Actor first = Actor::New();
2429 first .SetName( "first" );
2430 Actor second = Actor::New();
2431 second.SetName( "second" );
2436 Actor found = parent.FindChildByName( "foo" );
2437 DALI_TEST_CHECK( !found );
2439 found = parent.FindChildByName( "parent" );
2440 DALI_TEST_CHECK( found == parent );
2442 found = parent.FindChildByName( "first" );
2443 DALI_TEST_CHECK( found == first );
2445 found = parent.FindChildByName( "second" );
2446 DALI_TEST_CHECK( found == second );
2450 int UtcDaliActorFindChildByAlias(void)
2452 tet_infoline("Testing Dali::Actor::FindChildByAlias()");
2453 TestApplication application;
2455 Actor parent = Actor::New();
2456 parent.SetName( "parent" );
2457 Actor first = Actor::New();
2458 first .SetName( "first" );
2459 Actor second = Actor::New();
2460 second.SetName( "second" );
2465 Actor found = parent.FindChildByAlias( "foo" );
2466 DALI_TEST_CHECK( !found );
2468 found = parent.FindChildByAlias( "parent" );
2469 DALI_TEST_CHECK( found == parent );
2471 found = parent.FindChildByAlias( "first" );
2472 DALI_TEST_CHECK( found == first );
2474 found = parent.FindChildByAlias( "second" );
2475 DALI_TEST_CHECK( found == second );
2479 int UtcDaliActorFindChildById(void)
2481 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2482 TestApplication application;
2484 Actor parent = Actor::New();
2485 Actor first = Actor::New();
2486 Actor second = Actor::New();
2491 Actor found = parent.FindChildById( 100000 );
2492 DALI_TEST_CHECK( !found );
2494 found = parent.FindChildById( parent.GetId() );
2495 DALI_TEST_CHECK( found == parent );
2497 found = parent.FindChildById( first.GetId() );
2498 DALI_TEST_CHECK( found == first );
2500 found = parent.FindChildById( second.GetId() );
2501 DALI_TEST_CHECK( found == second );
2505 int UtcDaliActorHitTest(void)
2510 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2512 mTouchPoint( touchPoint ),
2517 Vector2 mTouchPoint;
2521 TestApplication application;
2522 tet_infoline(" UtcDaliActorHitTest");
2524 // Fill a vector with different hit tests.
2525 struct HitTestData* hitTestData[] = {
2526 // scale touch point result
2527 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2528 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2529 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.
2530 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2531 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.
2535 // get the root layer
2536 Actor actor = Actor::New();
2537 actor.SetAnchorPoint( AnchorPoint::CENTER );
2538 actor.SetParentOrigin( ParentOrigin::CENTER );
2540 Stage::GetCurrent().Add( actor );
2542 gTouchCallBackCalled = false;
2544 unsigned int index = 0;
2545 while( NULL != hitTestData[index] )
2547 actor.SetSize( 1.f, 1.f );
2548 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2550 // flush the queue and render once
2551 application.SendNotification();
2552 application.Render();
2554 DALI_TEST_CHECK( !gTouchCallBackCalled );
2556 // connect to its touch signal
2557 actor.TouchedSignal().Connect(TestCallback);
2559 Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y );
2560 Dali::Integration::TouchEvent event;
2561 event.AddPoint( point );
2563 // flush the queue and render once
2564 application.SendNotification();
2565 application.Render();
2566 application.ProcessEvent( event );
2568 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2570 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2571 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2572 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2573 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2574 hitTestData[index]->mResult );
2576 gTouchCallBackCalled = false;
2582 int UtcDaliActorSetDrawMode(void)
2584 TestApplication app;
2585 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2587 Actor a = Actor::New();
2589 Stage::GetCurrent().Add(a);
2590 app.SendNotification();
2592 app.SendNotification();
2595 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2597 a.SetDrawMode( DrawMode::OVERLAY );
2598 app.SendNotification();
2601 DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay
2603 a.SetDrawMode( DrawMode::STENCIL );
2604 app.SendNotification();
2607 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2609 a.SetDrawMode( DrawMode::NORMAL );
2610 app.SendNotification();
2613 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2617 int UtcDaliActorSetDrawModeOverlayRender(void)
2619 TestApplication app;
2620 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2622 app.SendNotification();
2625 std::vector<GLuint> ids;
2626 ids.push_back( 8 ); // first rendered actor
2627 ids.push_back( 9 ); // second rendered actor
2628 ids.push_back( 10 ); // third rendered actor
2629 app.GetGlAbstraction().SetNextTextureIds( ids );
2631 BitmapImage imageA = BitmapImage::New(16, 16);
2632 BitmapImage imageB = BitmapImage::New(16, 16);
2633 BitmapImage imageC = BitmapImage::New(16, 16);
2634 ImageActor a = ImageActor::New( imageA );
2635 ImageActor b = ImageActor::New( imageB );
2636 ImageActor c = ImageActor::New( imageC );
2638 // Render a,b,c as regular non-overlays. so order will be:
2642 Stage::GetCurrent().Add(a);
2643 Stage::GetCurrent().Add(b);
2644 Stage::GetCurrent().Add(c);
2646 app.SendNotification();
2649 // Should be 3 textures changes.
2650 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2651 typedef std::vector<GLuint>::size_type TextureSize;
2652 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2653 if( boundTextures.size() == 3 )
2655 DALI_TEST_CHECK( boundTextures[0] == 8u );
2656 DALI_TEST_CHECK( boundTextures[1] == 9u );
2657 DALI_TEST_CHECK( boundTextures[2] == 10u );
2660 // Now texture ids have been set, we can monitor their render order.
2661 // render a as an overlay (last), so order will be:
2665 a.SetDrawMode( DrawMode::OVERLAY );
2666 app.GetGlAbstraction().ClearBoundTextures();
2668 app.SendNotification();
2671 // Should be 3 texture changes.
2672 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2673 if( boundTextures.size() == 3 )
2675 DALI_TEST_CHECK( boundTextures[0] == 9u );
2676 DALI_TEST_CHECK( boundTextures[1] == 10u );
2677 DALI_TEST_CHECK( boundTextures[2] == 8u );
2683 int UtcDaliActorSetDrawModeOverlayHitTest(void)
2685 TestApplication app;
2686 tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
2688 BitmapImage imageA = BitmapImage::New(16, 16);
2689 BitmapImage imageB = BitmapImage::New(16, 16);
2690 ImageActor a = ImageActor::New( imageA );
2691 ImageActor b = ImageActor::New( imageB );
2693 // Render a,b as regular non-overlays. so order will be:
2694 Stage::GetCurrent().Add(a);
2695 Stage::GetCurrent().Add(b);
2697 a.SetSize(Vector2(100.0f, 100.0f));
2698 b.SetSize(Vector2(100.0f, 100.0f));
2700 // position b overlapping a. (regular non-overlays)
2701 // hit test at point 'x'
2712 // note: b is on top, because it's Z position is higher.
2713 a.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
2714 b.SetPosition(Vector3(50.0f, 50.0f, 1.0f));
2716 // connect to their touch signals
2717 a.TouchedSignal().Connect(TestCallback);
2718 b.TouchedSignal().Connect(TestCallback2);
2720 a.SetDrawMode( DrawMode::NORMAL );
2721 b.SetDrawMode( DrawMode::NORMAL );
2722 SimulateTouchForSetOverlayHitTest(app);
2724 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2725 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2726 // Make Actor a an overlay.
2737 // note: a is on top, because it is an overlay.
2738 a.SetDrawMode( DrawMode::OVERLAY );
2739 b.SetDrawMode( DrawMode::NORMAL );
2740 SimulateTouchForSetOverlayHitTest(app);
2742 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2743 DALI_TEST_CHECK( gTouchCallBack2Called == false );
2744 // Make both Actors as overlays
2755 // note: b is on top, because it is the 2nd child in the hierarchy.
2756 a.SetDrawMode( DrawMode::OVERLAY );
2757 b.SetDrawMode( DrawMode::OVERLAY );
2758 SimulateTouchForSetOverlayHitTest(app);
2760 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2761 DALI_TEST_CHECK( gTouchCallBack2Called == true );
2765 int UtcDaliActorGetCurrentWorldMatrix(void)
2767 TestApplication app;
2768 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2770 Actor parent = Actor::New();
2771 parent.SetParentOrigin(ParentOrigin::CENTER);
2772 parent.SetAnchorPoint(AnchorPoint::CENTER);
2773 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2774 Radian rotationAngle(Degree(85.0f));
2775 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2776 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2777 parent.SetPosition( parentPosition );
2778 parent.SetRotation( parentRotation );
2779 parent.SetScale( parentScale );
2780 Stage::GetCurrent().Add( parent );
2782 Actor child = Actor::New();
2783 child.SetParentOrigin(ParentOrigin::CENTER);
2784 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2785 Radian childRotationAngle(Degree(23.0f));
2786 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2787 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2788 child.SetPosition( childPosition );
2789 child.SetRotation( childRotation );
2790 child.SetScale( childScale );
2791 parent.Add( child );
2793 // The actors should not have a world matrix yet
2794 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2795 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2797 app.SendNotification();
2800 app.SendNotification();
2802 Matrix parentMatrix(false);
2803 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2805 Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
2806 Quaternion childWorldRotation = parentRotation * childRotation;
2807 Vector3 childWorldScale = parentScale * childScale;
2809 Matrix childWorldMatrix(false);
2810 childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
2812 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2813 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2819 int UtcDaliActorConstrainedToWorldMatrix(void)
2821 TestApplication app;
2822 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2824 Actor parent = Actor::New();
2825 parent.SetParentOrigin(ParentOrigin::CENTER);
2826 parent.SetAnchorPoint(AnchorPoint::CENTER);
2827 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2828 Radian rotationAngle(Degree(85.0f));
2829 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2830 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2831 parent.SetPosition( parentPosition );
2832 parent.SetRotation( parentRotation );
2833 parent.SetScale( parentScale );
2834 Stage::GetCurrent().Add( parent );
2836 Actor child = Actor::New();
2837 child.SetParentOrigin(ParentOrigin::CENTER);
2838 Constraint posConstraint = Constraint::New<Vector3>( Actor::POSITION, Source( parent, Actor::WORLD_MATRIX), PositionComponentConstraint() );
2839 child.ApplyConstraint(posConstraint);
2841 Stage::GetCurrent().Add( child );
2843 // The actors should not have a world matrix yet
2844 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2845 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
2847 app.SendNotification();
2850 app.SendNotification();
2852 Matrix parentMatrix(false);
2853 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2855 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2856 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2860 int UtcDaliActorUnparent(void)
2862 TestApplication app;
2863 tet_infoline(" UtcDaliActorUnparent");
2865 Actor parent = Actor::New();
2866 Stage::GetCurrent().Add( parent );
2868 Actor child = Actor::New();
2870 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2871 DALI_TEST_CHECK( !child.GetParent() );
2873 // Test that calling Unparent with no parent is a NOOP
2876 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2877 DALI_TEST_CHECK( !child.GetParent() );
2879 // Test that Unparent works
2880 parent.Add( child );
2882 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2883 DALI_TEST_CHECK( parent == child.GetParent() );
2887 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2888 DALI_TEST_CHECK( !child.GetParent() );
2890 // Test that UnparentAndReset works
2891 parent.Add( child );
2893 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2894 DALI_TEST_CHECK( parent == child.GetParent() );
2896 UnparentAndReset( child );
2898 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2899 DALI_TEST_CHECK( !child );
2901 // Test that UnparentAndReset is a NOOP with empty handle
2902 UnparentAndReset( child );
2904 DALI_TEST_CHECK( !child );
2908 int UtcDaliActorGetChildAt(void)
2910 TestApplication app;
2911 tet_infoline(" UtcDaliActorGetChildAt");
2913 Actor parent = Actor::New();
2914 Stage::GetCurrent().Add( parent );
2916 Actor child0 = Actor::New();
2917 parent.Add( child0 );
2919 Actor child1 = Actor::New();
2920 parent.Add( child1 );
2922 Actor child2 = Actor::New();
2923 parent.Add( child2 );
2925 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2926 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2927 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2931 int UtcDaliActorSetGetOverlay(void)
2933 TestApplication app;
2934 tet_infoline(" UtcDaliActorSetGetOverlay");
2936 Actor parent = Actor::New();
2937 parent.SetDrawMode(DrawMode::OVERLAY );
2938 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY );
2943 // Current Dynamics functions are crashing, so testing these sections are futile
2945 int UtcDaliActorDynamics(void)
2947 DALI_TEST_CHECK( true );
2951 int UtcDaliActorCreateDestroy(void)
2953 Actor* actor = new Actor;
2954 DALI_TEST_CHECK( actor );
2961 struct PropertyStringIndex
2963 const char * const name;
2964 const Property::Index index;
2965 const Property::Type type;
2968 const PropertyStringIndex PROPERTY_TABLE[] =
2970 { "parent-origin", Actor::PARENT_ORIGIN, Property::VECTOR3 },
2971 { "parent-origin-x", Actor::PARENT_ORIGIN_X, Property::FLOAT },
2972 { "parent-origin-y", Actor::PARENT_ORIGIN_Y, Property::FLOAT },
2973 { "parent-origin-z", Actor::PARENT_ORIGIN_Z, Property::FLOAT },
2974 { "anchor-point", Actor::ANCHOR_POINT, Property::VECTOR3 },
2975 { "anchor-point-x", Actor::ANCHOR_POINT_X, Property::FLOAT },
2976 { "anchor-point-y", Actor::ANCHOR_POINT_Y, Property::FLOAT },
2977 { "anchor-point-z", Actor::ANCHOR_POINT_Z, Property::FLOAT },
2978 { "size", Actor::SIZE, Property::VECTOR3 },
2979 { "size-width", Actor::SIZE_WIDTH, Property::FLOAT },
2980 { "size-height", Actor::SIZE_HEIGHT, Property::FLOAT },
2981 { "size-depth", Actor::SIZE_DEPTH, Property::FLOAT },
2982 { "position", Actor::POSITION, Property::VECTOR3 },
2983 { "position-x", Actor::POSITION_X, Property::FLOAT },
2984 { "position-y", Actor::POSITION_Y, Property::FLOAT },
2985 { "position-z", Actor::POSITION_Z, Property::FLOAT },
2986 { "world-position", Actor::WORLD_POSITION, Property::VECTOR3 },
2987 { "world-position-x", Actor::WORLD_POSITION_X, Property::FLOAT },
2988 { "world-position-y", Actor::WORLD_POSITION_Y, Property::FLOAT },
2989 { "world-position-z", Actor::WORLD_POSITION_Z, Property::FLOAT },
2990 { "rotation", Actor::ROTATION, Property::ROTATION },
2991 { "world-rotation", Actor::WORLD_ROTATION, Property::ROTATION },
2992 { "scale", Actor::SCALE, Property::VECTOR3 },
2993 { "scale-x", Actor::SCALE_X, Property::FLOAT },
2994 { "scale-y", Actor::SCALE_Y, Property::FLOAT },
2995 { "scale-z", Actor::SCALE_Z, Property::FLOAT },
2996 { "world-scale", Actor::WORLD_SCALE, Property::VECTOR3 },
2997 { "visible", Actor::VISIBLE, Property::BOOLEAN },
2998 { "color", Actor::COLOR, Property::VECTOR4 },
2999 { "color-red", Actor::COLOR_RED, Property::FLOAT },
3000 { "color-green", Actor::COLOR_GREEN, Property::FLOAT },
3001 { "color-blue", Actor::COLOR_BLUE, Property::FLOAT },
3002 { "color-alpha", Actor::COLOR_ALPHA, Property::FLOAT },
3003 { "world-color", Actor::WORLD_COLOR, Property::VECTOR4 },
3004 { "world-matrix", Actor::WORLD_MATRIX, Property::MATRIX },
3005 { "name", Actor::NAME, Property::STRING },
3006 { "sensitive", Actor::SENSITIVE, Property::BOOLEAN },
3007 { "leave-required", Actor::LEAVE_REQUIRED, Property::BOOLEAN },
3008 { "inherit-rotation", Actor::INHERIT_ROTATION, Property::BOOLEAN },
3009 { "inherit-scale", Actor::INHERIT_SCALE, Property::BOOLEAN },
3010 { "color-mode", Actor::COLOR_MODE, Property::STRING },
3011 { "position-inheritance", Actor::POSITION_INHERITANCE, Property::STRING },
3012 { "draw-mode", Actor::DRAW_MODE, Property::STRING },
3014 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3015 } // unnamed namespace
3017 int UtcDaliActorProperties(void)
3019 TestApplication app;
3021 Actor actor = Actor::New();
3023 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3025 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3026 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3027 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3028 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );