2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/public-api/dali-core.h>
21 #include <cfloat> // For FLT_MAX
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/hover-event-integ.h>
24 #include <dali-test-suite-utils.h>
25 #include <mesh-builder.h>
33 void utc_dali_actor_startup(void)
35 test_return_value = TET_UNDEF;
38 void utc_dali_actor_cleanup(void)
40 test_return_value = TET_PASS;
45 bool gTouchCallBackCalled=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;
61 // simulate a touch event
62 Dali::Integration::Point point;
63 point.SetState( PointState::DOWN );
64 point.SetScreenPosition( Vector2( 25.0f, 25.0f ) );
65 Dali::Integration::TouchEvent event;
66 event.AddPoint( point );
67 app.ProcessEvent( event );
69 app.SendNotification();
71 app.SendNotification();
77 static bool gTestConstraintCalled;
81 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
83 gTestConstraintCalled = true;
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 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
106 unsigned int& mResultRef;
110 static bool TestCallback(Actor actor, const TouchEvent& event)
112 gTouchCallBackCalled = true;
117 static bool TestCallback3(Actor actor, const HoverEvent& event)
119 gHoverCallBackCalled = true;
124 static Vector3 gSetSize;
125 static bool gSetSizeCallBackCalled;
126 void SetSizeCallback( Actor actor, const Vector3& size )
128 gSetSizeCallBackCalled = true;
131 // validation stuff for onstage & offstage signals
132 static std::vector< std::string > gActorNamesOnOffStage;
133 static int gOnStageCallBackCalled;
134 void OnStageCallback( Actor actor )
136 ++gOnStageCallBackCalled;
137 gActorNamesOnOffStage.push_back( actor.GetName() );
138 DALI_TEST_CHECK( actor.OnStage() == true );
140 static int gOffStageCallBackCalled;
141 void OffStageCallback( Actor actor )
143 ++gOffStageCallBackCalled;
144 gActorNamesOnOffStage.push_back( actor.GetName() );
145 DALI_TEST_CHECK( actor.OnStage() == false );
148 struct PositionComponentConstraint
150 PositionComponentConstraint(){}
152 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
154 const Matrix& m = inputs[0]->GetMatrix();
157 m.GetTransformComponents(pos, rot, scale);
161 struct OrientationComponentConstraint
163 OrientationComponentConstraint(){}
165 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
167 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
170 orientation = parentOrientation;
175 static bool gOnRelayoutCallBackCalled = false;
176 static std::vector< std::string > gActorNamesRelayout;
178 void OnRelayoutCallback( Actor actor )
180 gOnRelayoutCallBackCalled = true;
181 gActorNamesRelayout.push_back( actor.GetName() );
184 } // anonymous namespace
187 //& purpose: Testing New API
188 int UtcDaliActorNew(void)
190 TestApplication application;
192 Actor actor = Actor::New();
194 DALI_TEST_CHECK(actor);
198 //& purpose: Testing Dali::Actor::DownCast()
199 int UtcDaliActorDownCastP(void)
201 TestApplication application;
202 tet_infoline("Testing Dali::Actor::DownCast()");
204 Actor actor = Actor::New();
205 BaseHandle object(actor);
206 Actor actor2 = Actor::DownCast(object);
207 DALI_TEST_CHECK(actor2);
211 //& purpose: Testing Dali::Actor::DownCast()
212 int UtcDaliActorDownCastN(void)
214 TestApplication application;
215 tet_infoline("Testing Dali::Actor::DownCast()");
217 BaseHandle unInitializedObject;
218 Actor actor = Actor::DownCast(unInitializedObject);
219 DALI_TEST_CHECK(!actor);
223 //& purpose: Testing Dali::Actor::GetName()
224 int UtcDaliActorGetName(void)
226 TestApplication application;
228 Actor actor = Actor::New();
230 DALI_TEST_CHECK(actor.GetName().empty());
234 //& purpose: Testing Dali::Actor::SetName()
235 int UtcDaliActorSetName(void)
237 TestApplication application;
239 string str("ActorName");
240 Actor actor = Actor::New();
243 DALI_TEST_CHECK(actor.GetName() == str);
247 int UtcDaliActorGetId(void)
249 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
250 TestApplication application;
252 Actor first = Actor::New();
253 Actor second = Actor::New();
254 Actor third = Actor::New();
256 DALI_TEST_CHECK(first.GetId() != second.GetId());
257 DALI_TEST_CHECK(second.GetId() != third.GetId());
261 int UtcDaliActorIsRoot(void)
263 TestApplication application;
265 Actor actor = Actor::New();
266 DALI_TEST_CHECK(!actor.IsRoot());
268 // get the root layer
269 actor = Stage::GetCurrent().GetLayer( 0 );
270 DALI_TEST_CHECK( actor.IsRoot() );
274 int UtcDaliActorOnStage(void)
276 TestApplication application;
278 Actor actor = Actor::New();
279 DALI_TEST_CHECK( !actor.OnStage() );
281 // get the root layer
282 actor = Stage::GetCurrent().GetLayer( 0 );
283 DALI_TEST_CHECK( actor.OnStage() );
287 int UtcDaliActorIsLayer(void)
289 TestApplication application;
291 Actor actor = Actor::New();
292 DALI_TEST_CHECK( !actor.IsLayer() );
294 // get the root layer
295 actor = Stage::GetCurrent().GetLayer( 0 );
296 DALI_TEST_CHECK( actor.IsLayer() );
300 int UtcDaliActorGetLayer(void)
302 TestApplication application;
304 Actor actor = Actor::New();
305 Stage::GetCurrent().Add(actor);
306 Layer layer = actor.GetLayer();
308 DALI_TEST_CHECK(layer);
310 // get the root layers layer
311 actor = Stage::GetCurrent().GetLayer( 0 );
312 DALI_TEST_CHECK( actor.GetLayer() );
316 int UtcDaliActorAddP(void)
318 tet_infoline("Testing Actor::Add");
319 TestApplication application;
321 Actor parent = Actor::New();
322 Actor child = Actor::New();
324 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
328 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
330 Actor parent2 = Actor::New();
331 parent2.Add( child );
333 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
334 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
336 // try Adding to same parent again, works
337 parent2.Add( child );
338 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
340 // try reparenting an orphaned child
342 Actor temporaryParent = Actor::New();
343 temporaryParent.Add( child );
344 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
346 // temporaryParent has now died, reparent the orphaned child
347 parent2.Add( child );
348 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
353 int UtcDaliActorAddN(void)
355 tet_infoline("Testing Actor::Add");
356 TestApplication application;
358 Actor child = Actor::New();
360 Actor parent2 = Actor::New();
361 parent2.Add( child );
366 parent2.Add( parent2 );
367 tet_printf("Assertion test failed - no Exception\n" );
368 tet_result(TET_FAIL);
370 catch(Dali::DaliException& e)
372 DALI_TEST_PRINT_ASSERT( e );
373 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
374 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
378 tet_printf("Assertion test failed - wrong Exception\n" );
379 tet_result(TET_FAIL);
382 // try reparenting root
385 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
386 tet_printf("Assertion test failed - no Exception\n" );
387 tet_result(TET_FAIL);
389 catch(Dali::DaliException& e)
391 DALI_TEST_PRINT_ASSERT( e );
392 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
393 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
397 tet_printf("Assertion test failed - wrong Exception\n" );
398 tet_result(TET_FAIL);
405 parent2.Add( empty );
406 tet_printf("Assertion test failed - no Exception\n" );
407 tet_result(TET_FAIL);
409 catch(Dali::DaliException& e)
411 DALI_TEST_PRINT_ASSERT( e );
412 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
413 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
417 tet_printf("Assertion test failed - wrong Exception\n" );
418 tet_result(TET_FAIL);
424 int UtcDaliActorRemoveN(void)
426 tet_infoline("Testing Actor::Remove");
427 TestApplication application;
429 Actor parent = Actor::New();
430 Actor child = Actor::New();
431 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
434 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
436 parent.Remove(child);
437 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
439 // remove again, no problem
440 parent.Remove(child);
441 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
445 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
446 // try Remove self, its a no-op
447 parent.Remove( parent );
448 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
454 parent.Remove( empty );
455 tet_printf("Assertion test failed - no Exception\n" );
456 tet_result(TET_FAIL);
458 catch(Dali::DaliException& e)
460 DALI_TEST_PRINT_ASSERT( e );
461 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
462 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
466 tet_printf("Assertion test failed - wrong Exception\n" );
467 tet_result(TET_FAIL);
472 int UtcDaliActorRemoveP(void)
474 TestApplication application;
476 Actor parent = Actor::New();
477 Actor child = Actor::New();
478 Actor random = Actor::New();
480 Stage::GetCurrent().Add( parent );
482 DALI_TEST_CHECK(parent.GetChildCount() == 0);
486 DALI_TEST_CHECK(parent.GetChildCount() == 1);
488 parent.Remove(random);
490 DALI_TEST_CHECK(parent.GetChildCount() == 1);
492 Stage::GetCurrent().Remove( parent );
494 DALI_TEST_CHECK(parent.GetChildCount() == 1);
498 int UtcDaliActorGetChildCount(void)
500 TestApplication application;
502 Actor parent = Actor::New();
503 Actor child = Actor::New();
505 DALI_TEST_CHECK(parent.GetChildCount() == 0);
509 DALI_TEST_CHECK(parent.GetChildCount() == 1);
513 int UtcDaliActorGetChildren01(void)
515 TestApplication application;
517 Actor parent = Actor::New();
518 Actor first = Actor::New();
519 Actor second = Actor::New();
520 Actor third = Actor::New();
526 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
527 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
528 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
532 int UtcDaliActorGetChildren02(void)
534 TestApplication application;
536 Actor parent = Actor::New();
537 Actor first = Actor::New();
538 Actor second = Actor::New();
539 Actor third = Actor::New();
545 const Actor& constParent = parent;
547 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
548 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
549 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
553 int UtcDaliActorGetParent01(void)
555 TestApplication application;
557 Actor parent = Actor::New();
558 Actor child = Actor::New();
562 DALI_TEST_CHECK(child.GetParent() == parent);
566 int UtcDaliActorGetParent02(void)
568 TestApplication application;
570 Actor actor = Actor::New();
572 DALI_TEST_CHECK(!actor.GetParent());
576 int UtcDaliActorSetParentOrigin(void)
578 TestApplication application;
580 Actor actor = Actor::New();
582 Vector3 vector(0.7f, 0.8f, 0.9f);
583 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
585 actor.SetParentOrigin(vector);
587 // flush the queue and render once
588 application.SendNotification();
589 application.Render();
591 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
593 Stage::GetCurrent().Add( actor );
595 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
597 // flush the queue and render once
598 application.SendNotification();
599 application.Render();
601 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
603 Stage::GetCurrent().Remove( actor );
607 int UtcDaliActorSetParentOriginIndividual(void)
609 TestApplication application;
611 Actor actor = Actor::New();
613 Vector3 vector(0.7f, 0.8f, 0.9f);
614 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
616 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
618 // flush the queue and render once
619 application.SendNotification();
620 application.Render();
622 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
624 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
626 // flush the queue and render once
627 application.SendNotification();
628 application.Render();
630 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
632 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
634 // flush the queue and render once
635 application.SendNotification();
636 application.Render();
638 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
643 int UtcDaliActorGetCurrentParentOrigin(void)
645 TestApplication application;
647 Actor actor = Actor::New();
649 Vector3 vector(0.7f, 0.8f, 0.9f);
650 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
652 actor.SetParentOrigin(vector);
654 // flush the queue and render once
655 application.SendNotification();
656 application.Render();
658 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
662 int UtcDaliActorSetAnchorPoint(void)
664 TestApplication application;
666 Actor actor = Actor::New();
668 Vector3 vector(0.7f, 0.8f, 0.9f);
669 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
671 actor.SetAnchorPoint(vector);
673 // flush the queue and render once
674 application.SendNotification();
675 application.Render();
677 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
679 Stage::GetCurrent().Add( actor );
681 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
682 // flush the queue and render once
683 application.SendNotification();
684 application.Render();
686 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
688 Stage::GetCurrent().Remove( actor );
692 int UtcDaliActorSetAnchorPointIndividual(void)
694 TestApplication application;
696 Actor actor = Actor::New();
698 Vector3 vector(0.7f, 0.8f, 0.9f);
699 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
701 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
703 // flush the queue and render once
704 application.SendNotification();
705 application.Render();
707 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
709 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
711 // flush the queue and render once
712 application.SendNotification();
713 application.Render();
715 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
717 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
719 // flush the queue and render once
720 application.SendNotification();
721 application.Render();
723 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
728 int UtcDaliActorGetCurrentAnchorPoint(void)
730 TestApplication application;
732 Actor actor = Actor::New();
734 Vector3 vector(0.7f, 0.8f, 0.9f);
735 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
737 actor.SetAnchorPoint(vector);
739 // flush the queue and render once
740 application.SendNotification();
741 application.Render();
743 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
747 // SetSize(float width, float height)
748 int UtcDaliActorSetSize01(void)
750 TestApplication application;
752 Actor actor = Actor::New();
753 Vector3 vector(100.0f, 100.0f, 0.0f);
755 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
757 actor.SetSize(vector.x, vector.y);
759 // flush the queue and render once
760 application.SendNotification();
761 application.Render();
763 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
767 // SetSize(float width, float height, float depth)
768 int UtcDaliActorSetSize02(void)
770 TestApplication application;
772 Actor actor = Actor::New();
773 Vector3 vector(100.0f, 100.0f, 100.0f);
775 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
777 actor.SetSize(vector.x, vector.y, vector.z);
779 // flush the queue and render once
780 application.SendNotification();
781 application.Render();
783 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
787 // SetSize(Vector2 size)
788 int UtcDaliActorSetSize03(void)
790 TestApplication application;
792 Actor actor = Actor::New();
793 Vector3 vector(100.0f, 100.0f, 0.0f);
795 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
797 actor.SetSize(Vector2(vector.x, vector.y));
799 // flush the queue and render once
800 application.SendNotification();
801 application.Render();
803 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
807 // SetSize(Vector3 size)
808 int UtcDaliActorSetSize04(void)
810 TestApplication application;
812 Actor actor = Actor::New();
813 Vector3 vector(100.0f, 100.0f, 100.0f);
815 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
817 actor.SetSize(vector);
819 // flush the queue and render once
820 application.SendNotification();
821 application.Render();
823 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
825 Stage::GetCurrent().Add( actor );
826 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
828 // flush the queue and render once
829 application.SendNotification();
830 application.Render();
832 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
833 Stage::GetCurrent().Remove( actor );
837 int UtcDaliActorSetSizeIndividual(void)
839 TestApplication application;
841 Actor actor = Actor::New();
843 Vector3 vector(0.7f, 0.8f, 0.9f);
844 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
846 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
848 // flush the queue and render once
849 application.SendNotification();
850 application.Render();
852 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
854 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
856 // flush the queue and render once
857 application.SendNotification();
858 application.Render();
860 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
862 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
864 // flush the queue and render once
865 application.SendNotification();
866 application.Render();
868 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
874 int UtcDaliActorGetCurrentSize(void)
876 TestApplication application;
878 Actor actor = Actor::New();
879 Vector3 vector(100.0f, 100.0f, 20.0f);
881 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
883 actor.SetSize(vector);
885 // flush the queue and render once
886 application.SendNotification();
887 application.Render();
889 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
893 int UtcDaliActorGetNaturalSize(void)
895 TestApplication application;
897 Actor actor = Actor::New();
898 Vector3 vector( 0.0f, 0.0f, 0.0f );
900 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
905 int UtcDaliActorGetCurrentSizeImmediate(void)
907 TestApplication application;
909 Actor actor = Actor::New();
910 Vector3 vector(100.0f, 100.0f, 20.0f);
912 DALI_TEST_CHECK(vector != actor.GetTargetSize());
913 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
915 actor.SetSize(vector);
917 DALI_TEST_CHECK(vector == actor.GetTargetSize());
918 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
920 // flush the queue and render once
921 application.SendNotification();
922 application.Render();
924 DALI_TEST_CHECK(vector == actor.GetTargetSize());
925 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
928 // Build the animation
929 const float durationSeconds = 2.0f;
930 Animation animation = Animation::New( durationSeconds );
931 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
932 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
934 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
936 // Start the animation
939 application.SendNotification();
940 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
942 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
947 // SetPosition(float x, float y)
948 int UtcDaliActorSetPosition01(void)
950 TestApplication application;
952 Actor actor = Actor::New();
954 // Set to random to start off with
955 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
957 Vector3 vector(100.0f, 100.0f, 0.0f);
959 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
961 actor.SetPosition(vector.x, vector.y);
962 // flush the queue and render once
963 application.SendNotification();
964 application.Render();
965 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
967 Stage::GetCurrent().Add( actor );
968 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
969 // flush the queue and render once
970 application.SendNotification();
971 application.Render();
972 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
977 // flush the queue and render once
978 application.SendNotification();
979 application.Render();
980 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
982 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
983 // flush the queue and render once
984 application.SendNotification();
985 application.Render();
986 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
988 Stage::GetCurrent().Remove( actor );
992 // SetPosition(float x, float y, float z)
993 int UtcDaliActorSetPosition02(void)
995 TestApplication application;
997 Actor actor = Actor::New();
999 // Set to random to start off with
1000 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1002 Vector3 vector(100.0f, 100.0f, 100.0f);
1004 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1006 actor.SetPosition(vector.x, vector.y, vector.z);
1008 // flush the queue and render once
1009 application.SendNotification();
1010 application.Render();
1012 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1016 // SetPosition(Vector3 position)
1017 int UtcDaliActorSetPosition03(void)
1019 TestApplication application;
1021 Actor actor = Actor::New();
1023 // Set to random to start off with
1024 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1026 Vector3 vector(100.0f, 100.0f, 100.0f);
1028 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1030 actor.SetPosition(vector);
1032 // flush the queue and render once
1033 application.SendNotification();
1034 application.Render();
1036 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1040 int UtcDaliActorSetX(void)
1042 TestApplication application;
1044 Actor actor = Actor::New();
1046 Vector3 vector(100.0f, 0.0f, 0.0f);
1048 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1052 // flush the queue and render once
1053 application.SendNotification();
1054 application.Render();
1056 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1060 int UtcDaliActorSetY(void)
1062 TestApplication application;
1064 Actor actor = Actor::New();
1066 Vector3 vector(0.0f, 100.0f, 0.0f);
1068 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1072 // flush the queue and render once
1073 application.SendNotification();
1074 application.Render();
1076 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1080 int UtcDaliActorSetZ(void)
1082 TestApplication application;
1084 Actor actor = Actor::New();
1086 Vector3 vector(0.0f, 0.0f, 100.0f);
1088 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1092 // flush the queue and render once
1093 application.SendNotification();
1094 application.Render();
1096 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1100 int UtcDaliActorSetPositionProperties(void)
1102 TestApplication application;
1104 Actor actor = Actor::New();
1106 Vector3 vector(0.7f, 0.8f, 0.9f);
1107 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1109 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1111 // flush the queue and render once
1112 application.SendNotification();
1113 application.Render();
1115 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1117 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1119 // flush the queue and render once
1120 application.SendNotification();
1121 application.Render();
1123 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1125 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1127 // flush the queue and render once
1128 application.SendNotification();
1129 application.Render();
1131 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1136 int UtcDaliActorTranslateBy(void)
1138 TestApplication application;
1140 Actor actor = Actor::New();
1141 Vector3 vector(100.0f, 100.0f, 100.0f);
1143 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1145 actor.SetPosition(vector);
1147 // flush the queue and render once
1148 application.SendNotification();
1149 application.Render();
1151 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1153 actor.TranslateBy(vector);
1155 // flush the queue and render once
1156 application.SendNotification();
1157 application.Render();
1159 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1163 int UtcDaliActorGetCurrentPosition(void)
1165 TestApplication application;
1167 Actor actor = Actor::New();
1168 Vector3 setVector(100.0f, 100.0f, 0.0f);
1169 actor.SetPosition(setVector);
1171 // flush the queue and render once
1172 application.SendNotification();
1173 application.Render();
1175 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1179 int UtcDaliActorGetCurrentWorldPosition(void)
1181 TestApplication application;
1183 Actor parent = Actor::New();
1184 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1185 parent.SetPosition( parentPosition );
1186 parent.SetParentOrigin( ParentOrigin::CENTER );
1187 parent.SetAnchorPoint( AnchorPoint::CENTER );
1188 Stage::GetCurrent().Add( parent );
1190 Actor child = Actor::New();
1191 child.SetParentOrigin( ParentOrigin::CENTER );
1192 child.SetAnchorPoint( AnchorPoint::CENTER );
1193 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1194 child.SetPosition( childPosition );
1195 parent.Add( child );
1197 // The actors should not have a world position yet
1198 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1199 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1201 application.SendNotification();
1202 application.Render(0);
1204 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1205 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1207 // The actors should have a world position now
1208 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1209 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1213 int UtcDaliActorInheritPosition(void)
1215 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1216 TestApplication application;
1218 Actor parent = Actor::New();
1219 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1220 parent.SetPosition( parentPosition );
1221 parent.SetParentOrigin( ParentOrigin::CENTER );
1222 parent.SetAnchorPoint( AnchorPoint::CENTER );
1223 Stage::GetCurrent().Add( parent );
1225 Actor child = Actor::New();
1226 child.SetParentOrigin( ParentOrigin::CENTER );
1227 child.SetAnchorPoint( AnchorPoint::CENTER );
1228 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1229 child.SetPosition( childPosition );
1230 parent.Add( child );
1232 // The actors should not have a world position yet
1233 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1234 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1236 // first test default, which is to inherit position
1237 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1238 application.SendNotification();
1239 application.Render(0); // should only really call Update as Render is not required to update scene
1240 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1241 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1242 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1243 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1246 //Change child position
1247 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1248 child.SetPosition( childOffset );
1250 // Change inheritance mode to not inherit
1251 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1252 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1253 application.SendNotification();
1254 application.Render(0); // should only really call Update as Render is not required to update scene
1255 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1256 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1257 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1258 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1262 int UtcDaliActorSetInheritPosition(void)
1264 tet_infoline("Testing Actor::SetInheritPosition");
1265 TestApplication application;
1267 Actor parent = Actor::New();
1268 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1269 parent.SetPosition( parentPosition );
1270 parent.SetParentOrigin( ParentOrigin::CENTER );
1271 parent.SetAnchorPoint( AnchorPoint::CENTER );
1272 Stage::GetCurrent().Add( parent );
1274 Actor child = Actor::New();
1275 child.SetParentOrigin( ParentOrigin::CENTER );
1276 child.SetAnchorPoint( AnchorPoint::CENTER );
1277 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1278 child.SetPosition( childPosition );
1279 parent.Add( child );
1281 // The actors should not have a world position yet
1282 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1283 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1285 // first test default, which is to inherit position
1286 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1287 application.SendNotification();
1288 application.Render(0); // should only really call Update as Render is not required to update scene
1289 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1290 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1291 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1292 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1294 //Change child position
1295 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1296 child.SetPosition( childOffset );
1298 // Use local position as world postion
1299 child.SetInheritPosition( false );
1300 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1301 application.SendNotification();
1302 application.Render(0); // should only really call Update as Render is not required to update scene
1303 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1304 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1305 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1306 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1308 //Change back to inherit position from parent
1309 child.SetInheritPosition( true );
1310 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1311 application.SendNotification();
1312 application.Render(0); // should only really call Update as Render is not required to update scene
1313 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1314 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1315 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1316 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1320 // SetOrientation(float angleRadians, Vector3 axis)
1321 int UtcDaliActorSetOrientation01(void)
1323 TestApplication application;
1325 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1326 Actor actor = Actor::New();
1328 actor.SetOrientation(rotation);
1330 // flush the queue and render once
1331 application.SendNotification();
1332 application.Render();
1334 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1338 int UtcDaliActorSetOrientation02(void)
1340 TestApplication application;
1342 Actor actor = Actor::New();
1344 Radian angle( 0.785f );
1345 Vector3 axis(1.0f, 1.0f, 0.0f);
1347 actor.SetOrientation( angle, axis);
1348 Quaternion rotation( angle, axis );
1349 // flush the queue and render once
1350 application.SendNotification();
1351 application.Render();
1352 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1354 Stage::GetCurrent().Add( actor );
1355 actor.RotateBy( Degree( 360 ), axis);
1356 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1358 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1359 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1360 // flush the queue and render once
1361 application.SendNotification();
1362 application.Render();
1363 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1365 actor.SetOrientation( angle, axis);
1366 // flush the queue and render once
1367 application.SendNotification();
1368 application.Render();
1369 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1371 Stage::GetCurrent().Remove( actor );
1375 // SetOrientation(float angleRadians, Vector3 axis)
1376 int UtcDaliActorSetOrientationProperty(void)
1378 TestApplication application;
1380 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1381 Actor actor = Actor::New();
1383 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1385 // flush the queue and render once
1386 application.SendNotification();
1387 application.Render();
1389 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1393 // RotateBy(float angleRadians, Vector3 axis)
1394 int UtcDaliActorRotateBy01(void)
1396 TestApplication application;
1398 Actor actor = Actor::New();
1400 Radian angle( M_PI * 0.25f );
1401 actor.RotateBy(( angle ), Vector3::ZAXIS);
1402 // flush the queue and render once
1403 application.SendNotification();
1404 application.Render();
1405 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1407 Stage::GetCurrent().Add( actor );
1409 actor.RotateBy( angle, Vector3::ZAXIS);
1410 // flush the queue and render once
1411 application.SendNotification();
1412 application.Render();
1413 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1415 Stage::GetCurrent().Remove( actor );
1419 // RotateBy(Quaternion relativeRotation)
1420 int UtcDaliActorRotateBy02(void)
1422 TestApplication application;
1424 Actor actor = Actor::New();
1426 Radian angle( M_PI * 0.25f );
1427 Quaternion rotation(angle, Vector3::ZAXIS);
1428 actor.RotateBy(rotation);
1429 // flush the queue and render once
1430 application.SendNotification();
1431 application.Render();
1432 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1434 actor.RotateBy(rotation);
1435 // flush the queue and render once
1436 application.SendNotification();
1437 application.Render();
1438 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1442 int UtcDaliActorGetCurrentOrientation(void)
1444 TestApplication application;
1445 Actor actor = Actor::New();
1447 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1448 actor.SetOrientation(rotation);
1449 // flush the queue and render once
1450 application.SendNotification();
1451 application.Render();
1452 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1456 int UtcDaliActorGetCurrentWorldOrientation(void)
1458 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1459 TestApplication application;
1461 Actor parent = Actor::New();
1462 Radian rotationAngle( Degree(90.0f) );
1463 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1464 parent.SetOrientation( rotation );
1465 Stage::GetCurrent().Add( parent );
1467 Actor child = Actor::New();
1468 child.SetOrientation( rotation );
1469 parent.Add( child );
1471 // The actors should not have a world rotation yet
1472 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1473 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1475 application.SendNotification();
1476 application.Render(0);
1478 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1479 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1481 // The actors should have a world rotation now
1482 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1483 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1485 // turn off child rotation inheritance
1486 child.SetInheritOrientation( false );
1487 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1488 application.SendNotification();
1489 application.Render(0);
1491 // The actors should have a world rotation now
1492 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1493 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1497 // SetScale(float scale)
1498 int UtcDaliActorSetScale01(void)
1500 TestApplication application;
1502 Actor actor = Actor::New();
1504 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1505 actor.SetScale(0.25f);
1507 Vector3 scale(10.0f, 10.0f, 10.0f);
1508 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1510 actor.SetScale(scale.x);
1512 // flush the queue and render once
1513 application.SendNotification();
1514 application.Render();
1516 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1520 // SetScale(float scaleX, float scaleY, float scaleZ)
1521 int UtcDaliActorSetScale02(void)
1523 TestApplication application;
1524 Vector3 scale(10.0f, 10.0f, 10.0f);
1526 Actor actor = Actor::New();
1528 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1529 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1531 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1533 actor.SetScale(scale.x, scale.y, scale.z);
1534 // flush the queue and render once
1535 application.SendNotification();
1536 application.Render();
1537 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1539 // add to stage and test
1540 Stage::GetCurrent().Add( actor );
1541 actor.SetScale( 2.0f, 2.0f, 2.0f );
1542 // flush the queue and render once
1543 application.SendNotification();
1544 application.Render();
1545 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1547 Stage::GetCurrent().Remove( actor );
1552 // SetScale(Vector3 scale)
1553 int UtcDaliActorSetScale03(void)
1555 TestApplication application;
1556 Vector3 scale(10.0f, 10.0f, 10.0f);
1558 Actor actor = Actor::New();
1560 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1561 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1563 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1565 actor.SetScale(scale);
1567 // flush the queue and render once
1568 application.SendNotification();
1569 application.Render();
1571 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1575 int UtcDaliActorSetScaleIndividual(void)
1577 TestApplication application;
1579 Actor actor = Actor::New();
1581 Vector3 vector(0.7f, 0.8f, 0.9f);
1582 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1584 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1586 // flush the queue and render once
1587 application.SendNotification();
1588 application.Render();
1590 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1592 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1594 // flush the queue and render once
1595 application.SendNotification();
1596 application.Render();
1598 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1600 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1602 // flush the queue and render once
1603 application.SendNotification();
1604 application.Render();
1606 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1611 int UtcDaliActorScaleBy(void)
1613 TestApplication application;
1614 Actor actor = Actor::New();
1615 Vector3 vector(100.0f, 100.0f, 100.0f);
1617 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1619 actor.SetScale(vector);
1621 // flush the queue and render once
1622 application.SendNotification();
1623 application.Render();
1625 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1627 actor.ScaleBy(vector);
1629 // flush the queue and render once
1630 application.SendNotification();
1631 application.Render();
1633 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1637 int UtcDaliActorGetCurrentScale(void)
1639 TestApplication application;
1640 Vector3 scale(12.0f, 1.0f, 2.0f);
1642 Actor actor = Actor::New();
1644 actor.SetScale(scale);
1646 // flush the queue and render once
1647 application.SendNotification();
1648 application.Render();
1650 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1654 int UtcDaliActorGetCurrentWorldScale(void)
1656 TestApplication application;
1658 Actor parent = Actor::New();
1659 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1660 parent.SetScale( parentScale );
1661 Stage::GetCurrent().Add( parent );
1663 Actor child = Actor::New();
1664 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1665 child.SetScale( childScale );
1666 parent.Add( child );
1668 // The actors should not have a scale yet
1669 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1670 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1672 // The actors should not have a world scale yet
1673 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1674 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1676 application.SendNotification();
1677 application.Render(0);
1679 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1680 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1682 // The actors should have a world scale now
1683 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1684 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1688 int UtcDaliActorInheritScale(void)
1690 tet_infoline("Testing Actor::SetInheritScale");
1691 TestApplication application;
1693 Actor parent = Actor::New();
1694 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1695 parent.SetScale( parentScale );
1696 Stage::GetCurrent().Add( parent );
1698 Actor child = Actor::New();
1699 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1700 child.SetScale( childScale );
1701 parent.Add( child );
1703 application.SendNotification();
1704 application.Render(0);
1706 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1707 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1709 child.SetInheritScale( false );
1710 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1712 application.SendNotification();
1713 application.Render(0);
1715 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1719 int UtcDaliActorSetVisible(void)
1721 TestApplication application;
1723 Actor actor = Actor::New();
1724 actor.SetVisible(false);
1725 // flush the queue and render once
1726 application.SendNotification();
1727 application.Render();
1728 DALI_TEST_CHECK(actor.IsVisible() == false);
1730 actor.SetVisible(true);
1731 // flush the queue and render once
1732 application.SendNotification();
1733 application.Render();
1734 DALI_TEST_CHECK(actor.IsVisible() == true);
1736 // put actor on stage
1737 Stage::GetCurrent().Add( actor );
1738 actor.SetVisible(false);
1739 // flush the queue and render once
1740 application.SendNotification();
1741 application.Render();
1742 DALI_TEST_CHECK(actor.IsVisible() == false);
1746 int UtcDaliActorIsVisible(void)
1748 TestApplication application;
1750 Actor actor = Actor::New();
1752 DALI_TEST_CHECK(actor.IsVisible() == true);
1756 int UtcDaliActorSetOpacity(void)
1758 TestApplication application;
1760 Actor actor = Actor::New();
1761 // initial opacity is 1
1762 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1764 actor.SetOpacity( 0.4f);
1765 // flush the queue and render once
1766 application.SendNotification();
1767 application.Render();
1768 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1770 // change opacity, actor is on stage to change is not immediate
1771 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1772 // flush the queue and render once
1773 application.SendNotification();
1774 application.Render();
1775 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1777 // put actor on stage
1778 Stage::GetCurrent().Add( actor );
1780 // change opacity, actor is on stage to change is not immediate
1781 actor.SetOpacity( 0.9f );
1782 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1783 // flush the queue and render once
1784 application.SendNotification();
1785 application.Render();
1786 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1788 // change opacity, actor is on stage to change is not immediate
1789 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1790 // flush the queue and render once
1791 application.SendNotification();
1792 application.Render();
1793 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1797 int UtcDaliActorGetCurrentOpacity(void)
1799 TestApplication application;
1801 Actor actor = Actor::New();
1802 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1804 actor.SetOpacity(0.5f);
1805 // flush the queue and render once
1806 application.SendNotification();
1807 application.Render();
1808 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1812 int UtcDaliActorSetSensitive(void)
1814 TestApplication application;
1815 Actor actor = Actor::New();
1817 bool sensitive = !actor.IsSensitive();
1819 actor.SetSensitive(sensitive);
1821 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1825 int UtcDaliActorIsSensitive(void)
1827 TestApplication application;
1828 Actor actor = Actor::New();
1829 actor.SetSensitive(false);
1831 DALI_TEST_CHECK(false == actor.IsSensitive());
1835 int UtcDaliActorSetColor(void)
1837 TestApplication application;
1838 Actor actor = Actor::New();
1839 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1841 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1843 actor.SetColor(color);
1844 // flush the queue and render once
1845 application.SendNotification();
1846 application.Render();
1847 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1849 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1850 // flush the queue and render once
1851 application.SendNotification();
1852 application.Render();
1853 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1855 Stage::GetCurrent().Add( actor );
1856 actor.SetColor( color );
1857 // flush the queue and render once
1858 application.SendNotification();
1859 application.Render();
1860 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1862 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1863 // flush the queue and render once
1864 application.SendNotification();
1865 application.Render();
1866 // Actor color is not clamped
1867 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1868 // world color is clamped
1869 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1871 Stage::GetCurrent().Remove( actor );
1875 int UtcDaliActorSetColorIndividual(void)
1877 TestApplication application;
1879 Actor actor = Actor::New();
1881 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
1882 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
1884 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
1886 // flush the queue and render once
1887 application.SendNotification();
1888 application.Render();
1890 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
1892 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
1894 // flush the queue and render once
1895 application.SendNotification();
1896 application.Render();
1898 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
1900 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
1902 // flush the queue and render once
1903 application.SendNotification();
1904 application.Render();
1906 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
1908 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
1910 // flush the queue and render once
1911 application.SendNotification();
1912 application.Render();
1914 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
1920 int UtcDaliActorGetCurrentColor(void)
1922 TestApplication application;
1923 Actor actor = Actor::New();
1924 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1926 actor.SetColor(color);
1927 // flush the queue and render once
1928 application.SendNotification();
1929 application.Render();
1930 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1934 int UtcDaliActorGetCurrentWorldColor(void)
1936 tet_infoline("Actor::GetCurrentWorldColor");
1937 TestApplication application;
1939 Actor parent = Actor::New();
1940 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
1941 parent.SetColor( parentColor );
1942 Stage::GetCurrent().Add( parent );
1944 Actor child = Actor::New();
1945 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
1946 child.SetColor( childColor );
1947 parent.Add( child );
1949 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1950 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1952 // verify the default color mode
1953 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
1955 // The actors should not have a world color yet
1956 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1957 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
1959 application.SendNotification();
1960 application.Render(0);
1962 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
1963 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1965 // The actors should have a world color now
1966 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1967 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
1970 child.SetColorMode( USE_OWN_COLOR );
1971 application.SendNotification();
1972 application.Render(0);
1973 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
1976 child.SetColorMode( USE_PARENT_COLOR );
1977 application.SendNotification();
1978 application.Render(0);
1979 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1980 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
1983 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
1984 application.SendNotification();
1985 application.Render(0);
1986 Vector4 expectedColor( childColor );
1987 expectedColor.a *= parentColor.a;
1988 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
1989 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
1993 int UtcDaliActorSetColorMode(void)
1995 tet_infoline("Actor::SetColorMode");
1996 TestApplication application;
1997 Actor actor = Actor::New();
1998 Actor child = Actor::New();
2001 actor.SetColorMode( USE_OWN_COLOR );
2002 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2004 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2005 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2007 actor.SetColorMode( USE_PARENT_COLOR );
2008 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2010 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2011 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2015 int UtcDaliActorScreenToLocal(void)
2017 TestApplication application;
2018 Actor actor = Actor::New();
2019 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2020 actor.SetSize(100.0f, 100.0f);
2021 actor.SetPosition(10.0f, 10.0f);
2022 Stage::GetCurrent().Add(actor);
2024 // flush the queue and render once
2025 application.SendNotification();
2026 application.Render();
2031 application.SendNotification();
2032 application.Render();
2034 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2036 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2037 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2041 int UtcDaliActorSetLeaveRequired(void)
2043 TestApplication application;
2045 Actor actor = Actor::New();
2047 actor.SetLeaveRequired(false);
2048 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2050 actor.SetLeaveRequired(true);
2051 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2055 int UtcDaliActorGetLeaveRequired(void)
2057 TestApplication application;
2059 Actor actor = Actor::New();
2061 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2065 int UtcDaliActorSetKeyboardFocusable(void)
2067 TestApplication application;
2069 Actor actor = Actor::New();
2071 actor.SetKeyboardFocusable(true);
2072 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2074 actor.SetKeyboardFocusable(false);
2075 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2079 int UtcDaliActorIsKeyboardFocusable(void)
2081 TestApplication application;
2083 Actor actor = Actor::New();
2085 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2089 int UtcDaliActorRemoveConstraints(void)
2091 tet_infoline(" UtcDaliActorRemoveConstraints");
2092 TestApplication application;
2094 gTestConstraintCalled = false;
2096 Actor actor = Actor::New();
2098 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2100 actor.RemoveConstraints();
2102 DALI_TEST_CHECK( gTestConstraintCalled == false );
2104 Stage::GetCurrent().Add( actor );
2107 // flush the queue and render once
2108 application.SendNotification();
2109 application.Render();
2111 actor.RemoveConstraints();
2113 DALI_TEST_CHECK( gTestConstraintCalled == true );
2117 int UtcDaliActorRemoveConstraintTag(void)
2119 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2120 TestApplication application;
2122 Actor actor = Actor::New();
2124 // 1. Apply Constraint1 and Constraint2, and test...
2125 unsigned int result1 = 0u;
2126 unsigned int result2 = 0u;
2128 unsigned constraint1Tag = 1u;
2129 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2130 constraint1.SetTag( constraint1Tag );
2131 constraint1.Apply();
2133 unsigned constraint2Tag = 2u;
2134 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2135 constraint2.SetTag( constraint2Tag );
2136 constraint2.Apply();
2138 Stage::GetCurrent().Add( actor );
2139 // flush the queue and render once
2140 application.SendNotification();
2141 application.Render();
2143 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2144 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2146 // 2. Remove Constraint1 and test...
2149 actor.RemoveConstraints(constraint1Tag);
2150 // make color property dirty, which will trigger constraints to be reapplied.
2151 actor.SetColor( Color::WHITE );
2152 // flush the queue and render once
2153 application.SendNotification();
2154 application.Render();
2156 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2157 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2159 // 3. Re-Apply Constraint1 and test...
2162 constraint1.Apply();
2163 // make color property dirty, which will trigger constraints to be reapplied.
2164 actor.SetColor( Color::WHITE );
2165 // flush the queue and render once
2166 application.SendNotification();
2167 application.Render();
2169 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2170 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2172 // 2. Remove Constraint2 and test...
2175 actor.RemoveConstraints(constraint2Tag);
2176 // make color property dirty, which will trigger constraints to be reapplied.
2177 actor.SetColor( Color::WHITE );
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, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2185 // 2. Remove Constraint1 as well 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, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2200 int UtcDaliActorTouchedSignal(void)
2202 TestApplication application;
2204 gTouchCallBackCalled = false;
2206 // get the root layer
2207 Actor actor = Stage::GetCurrent().GetRootLayer();
2208 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2210 application.SendNotification();
2211 application.Render();
2213 // connect to its touch signal
2214 actor.TouchedSignal().Connect( TestCallback );
2216 // simulate a touch event in the middle of the screen
2217 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2218 Dali::Integration::Point point;
2219 point.SetDeviceId( 1 );
2220 point.SetState( PointState::DOWN );
2221 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2222 Dali::Integration::TouchEvent event;
2223 event.AddPoint( point );
2224 application.ProcessEvent( event );
2226 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2230 int UtcDaliActorHoveredSignal(void)
2232 TestApplication application;
2234 gHoverCallBackCalled = false;
2236 // get the root layer
2237 Actor actor = Stage::GetCurrent().GetRootLayer();
2238 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2240 application.SendNotification();
2241 application.Render();
2243 // connect to its hover signal
2244 actor.HoveredSignal().Connect( TestCallback3 );
2246 // simulate a hover event in the middle of the screen
2247 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2248 Dali::Integration::Point point;
2249 point.SetDeviceId( 1 );
2250 point.SetState( PointState::MOTION );
2251 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2252 Dali::Integration::HoverEvent event;
2253 event.AddPoint( point );
2254 application.ProcessEvent( event );
2256 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2260 int UtcDaliActorOnOffStageSignal(void)
2262 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2264 TestApplication application;
2267 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2268 gActorNamesOnOffStage.clear();
2270 Actor parent = Actor::New();
2271 parent.SetName( "parent" );
2272 parent.OnStageSignal().Connect( OnStageCallback );
2273 parent.OffStageSignal().Connect( OffStageCallback );
2275 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2276 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2278 // add parent to stage
2279 Stage::GetCurrent().Add( parent );
2280 // onstage emitted, offstage not
2281 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2282 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2283 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2285 // test adding a child, should get onstage emitted
2287 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2288 gActorNamesOnOffStage.clear();
2290 Actor child = Actor::New();
2291 child.SetName( "child" );
2292 child.OnStageSignal().Connect( OnStageCallback );
2293 child.OffStageSignal().Connect( OffStageCallback );
2294 parent.Add( child ); // add child
2295 // onstage emitted, offstage not
2296 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2297 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2298 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2300 // test removing parent from stage
2302 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2303 gActorNamesOnOffStage.clear();
2305 Stage::GetCurrent().Remove( parent );
2306 // onstage not emitted, offstage is
2307 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2308 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2309 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2310 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2312 // test adding parent back to stage
2314 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2315 gActorNamesOnOffStage.clear();
2317 Stage::GetCurrent().Add( parent );
2318 // onstage emitted, offstage not
2319 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2320 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2321 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2322 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2324 // test removing child
2326 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2327 gActorNamesOnOffStage.clear();
2329 parent.Remove( child );
2330 // onstage not emitted, offstage is
2331 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2332 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2333 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2335 // test removing parent
2337 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2338 gActorNamesOnOffStage.clear();
2340 Stage::GetCurrent().Remove( parent );
2341 // onstage not emitted, offstage is
2342 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2343 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2344 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2348 int UtcDaliActorFindChildByName(void)
2350 tet_infoline("Testing Dali::Actor::FindChildByName()");
2351 TestApplication application;
2353 Actor parent = Actor::New();
2354 parent.SetName( "parent" );
2355 Actor first = Actor::New();
2356 first .SetName( "first" );
2357 Actor second = Actor::New();
2358 second.SetName( "second" );
2363 Actor found = parent.FindChildByName( "foo" );
2364 DALI_TEST_CHECK( !found );
2366 found = parent.FindChildByName( "parent" );
2367 DALI_TEST_CHECK( found == parent );
2369 found = parent.FindChildByName( "first" );
2370 DALI_TEST_CHECK( found == first );
2372 found = parent.FindChildByName( "second" );
2373 DALI_TEST_CHECK( found == second );
2377 int UtcDaliActorFindChildById(void)
2379 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2380 TestApplication application;
2382 Actor parent = Actor::New();
2383 Actor first = Actor::New();
2384 Actor second = Actor::New();
2389 Actor found = parent.FindChildById( 100000 );
2390 DALI_TEST_CHECK( !found );
2392 found = parent.FindChildById( parent.GetId() );
2393 DALI_TEST_CHECK( found == parent );
2395 found = parent.FindChildById( first.GetId() );
2396 DALI_TEST_CHECK( found == first );
2398 found = parent.FindChildById( second.GetId() );
2399 DALI_TEST_CHECK( found == second );
2403 int UtcDaliActorHitTest(void)
2408 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2410 mTouchPoint( touchPoint ),
2415 Vector2 mTouchPoint;
2419 TestApplication application;
2420 tet_infoline(" UtcDaliActorHitTest");
2422 // Fill a vector with different hit tests.
2423 struct HitTestData* hitTestData[] = {
2424 // scale touch point result
2425 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2426 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2427 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.
2428 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2429 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.
2433 // get the root layer
2434 Actor actor = Actor::New();
2435 actor.SetAnchorPoint( AnchorPoint::CENTER );
2436 actor.SetParentOrigin( ParentOrigin::CENTER );
2438 Stage::GetCurrent().Add( actor );
2440 gTouchCallBackCalled = false;
2442 unsigned int index = 0;
2443 while( NULL != hitTestData[index] )
2445 actor.SetSize( 1.f, 1.f );
2446 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2448 // flush the queue and render once
2449 application.SendNotification();
2450 application.Render();
2452 DALI_TEST_CHECK( !gTouchCallBackCalled );
2454 // connect to its touch signal
2455 actor.TouchedSignal().Connect(TestCallback);
2457 Dali::Integration::Point point;
2458 point.SetState( PointState::DOWN );
2459 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2460 Dali::Integration::TouchEvent event;
2461 event.AddPoint( point );
2463 // flush the queue and render once
2464 application.SendNotification();
2465 application.Render();
2466 application.ProcessEvent( event );
2468 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2470 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2471 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2472 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2473 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2474 hitTestData[index]->mResult );
2476 gTouchCallBackCalled = false;
2482 int UtcDaliActorSetDrawMode(void)
2484 TestApplication app;
2485 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2487 Actor a = Actor::New();
2489 Stage::GetCurrent().Add(a);
2490 app.SendNotification();
2492 app.SendNotification();
2495 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2497 a.SetDrawMode( DrawMode::OVERLAY_2D );
2498 app.SendNotification();
2501 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2503 a.SetDrawMode( DrawMode::STENCIL );
2504 app.SendNotification();
2507 DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay
2509 a.SetDrawMode( DrawMode::NORMAL );
2510 app.SendNotification();
2513 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil
2517 int UtcDaliActorSetDrawModeOverlayRender(void)
2519 TestApplication app;
2520 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2522 app.SendNotification();
2525 std::vector<GLuint> ids;
2526 ids.push_back( 8 ); // first rendered actor
2527 ids.push_back( 9 ); // second rendered actor
2528 ids.push_back( 10 ); // third rendered actor
2529 app.GetGlAbstraction().SetNextTextureIds( ids );
2531 BufferImage imageA = BufferImage::New(16, 16);
2532 BufferImage imageB = BufferImage::New(16, 16);
2533 BufferImage imageC = BufferImage::New(16, 16);
2534 Actor a = CreateRenderableActor( imageA );
2535 Actor b = CreateRenderableActor( imageB );
2536 Actor c = CreateRenderableActor( imageC );
2538 // Render a,b,c as regular non-overlays. so order will be:
2542 Stage::GetCurrent().Add(a);
2543 Stage::GetCurrent().Add(b);
2544 Stage::GetCurrent().Add(c);
2546 app.SendNotification();
2549 // Should be 3 textures changes.
2550 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2551 typedef std::vector<GLuint>::size_type TextureSize;
2552 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2553 if( boundTextures.size() == 3 )
2555 DALI_TEST_CHECK( boundTextures[0] == 8u );
2556 DALI_TEST_CHECK( boundTextures[1] == 9u );
2557 DALI_TEST_CHECK( boundTextures[2] == 10u );
2560 // Now texture ids have been set, we can monitor their render order.
2561 // render a as an overlay (last), so order will be:
2565 a.SetDrawMode( DrawMode::OVERLAY_2D );
2566 app.GetGlAbstraction().ClearBoundTextures();
2568 app.SendNotification();
2571 // Should be 3 texture changes.
2572 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2573 if( boundTextures.size() == 3 )
2575 DALI_TEST_CHECK( boundTextures[0] == 9u );
2576 DALI_TEST_CHECK( boundTextures[1] == 10u );
2577 DALI_TEST_CHECK( boundTextures[2] == 8u );
2582 int UtcDaliActorGetCurrentWorldMatrix(void)
2584 TestApplication app;
2585 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2587 Actor parent = Actor::New();
2588 parent.SetParentOrigin(ParentOrigin::CENTER);
2589 parent.SetAnchorPoint(AnchorPoint::CENTER);
2590 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2591 Radian rotationAngle(Degree(85.0f));
2592 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2593 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2594 parent.SetPosition( parentPosition );
2595 parent.SetOrientation( parentRotation );
2596 parent.SetScale( parentScale );
2597 Stage::GetCurrent().Add( parent );
2599 Actor child = Actor::New();
2600 child.SetParentOrigin(ParentOrigin::CENTER);
2601 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2602 Radian childRotationAngle(Degree(23.0f));
2603 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2604 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2605 child.SetPosition( childPosition );
2606 child.SetOrientation( childRotation );
2607 child.SetScale( childScale );
2608 parent.Add( child );
2610 app.SendNotification();
2613 app.SendNotification();
2615 Matrix parentMatrix(false);
2616 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2618 Matrix childMatrix(false);
2619 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2621 //Child matrix should be the composition of child and parent
2622 Matrix childWorldMatrix(false);
2623 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2625 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2626 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2632 int UtcDaliActorConstrainedToWorldMatrix(void)
2634 TestApplication app;
2635 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2637 Actor parent = Actor::New();
2638 parent.SetParentOrigin(ParentOrigin::CENTER);
2639 parent.SetAnchorPoint(AnchorPoint::CENTER);
2640 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2641 Radian rotationAngle(Degree(85.0f));
2642 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2643 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2644 parent.SetPosition( parentPosition );
2645 parent.SetOrientation( parentRotation );
2646 parent.SetScale( parentScale );
2647 Stage::GetCurrent().Add( parent );
2649 Actor child = Actor::New();
2650 child.SetParentOrigin(ParentOrigin::CENTER);
2651 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2652 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2653 posConstraint.Apply();
2655 Stage::GetCurrent().Add( child );
2657 app.SendNotification();
2660 app.SendNotification();
2662 Matrix parentMatrix(false);
2663 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2665 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2666 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2670 int UtcDaliActorConstrainedToOrientation(void)
2672 TestApplication app;
2673 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2675 Actor parent = Actor::New();
2676 parent.SetParentOrigin(ParentOrigin::CENTER);
2677 parent.SetAnchorPoint(AnchorPoint::CENTER);
2678 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2679 Radian rotationAngle(Degree(85.0f));
2680 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2681 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2682 parent.SetPosition( parentPosition );
2683 parent.SetOrientation( parentRotation );
2684 parent.SetScale( parentScale );
2685 Stage::GetCurrent().Add( parent );
2687 Actor child = Actor::New();
2688 child.SetParentOrigin(ParentOrigin::CENTER);
2689 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2690 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2691 posConstraint.Apply();
2693 Stage::GetCurrent().Add( child );
2695 app.SendNotification();
2698 app.SendNotification();
2700 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2704 int UtcDaliActorUnparent(void)
2706 TestApplication app;
2707 tet_infoline(" UtcDaliActorUnparent");
2709 Actor parent = Actor::New();
2710 Stage::GetCurrent().Add( parent );
2712 Actor child = Actor::New();
2714 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2715 DALI_TEST_CHECK( !child.GetParent() );
2717 // Test that calling Unparent with no parent is a NOOP
2720 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2721 DALI_TEST_CHECK( !child.GetParent() );
2723 // Test that Unparent works
2724 parent.Add( child );
2726 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2727 DALI_TEST_CHECK( parent == child.GetParent() );
2731 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2732 DALI_TEST_CHECK( !child.GetParent() );
2734 // Test that UnparentAndReset works
2735 parent.Add( child );
2737 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2738 DALI_TEST_CHECK( parent == child.GetParent() );
2740 UnparentAndReset( child );
2742 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2743 DALI_TEST_CHECK( !child );
2745 // Test that UnparentAndReset is a NOOP with empty handle
2746 UnparentAndReset( child );
2748 DALI_TEST_CHECK( !child );
2752 int UtcDaliActorGetChildAt(void)
2754 TestApplication app;
2755 tet_infoline(" UtcDaliActorGetChildAt");
2757 Actor parent = Actor::New();
2758 Stage::GetCurrent().Add( parent );
2760 Actor child0 = Actor::New();
2761 parent.Add( child0 );
2763 Actor child1 = Actor::New();
2764 parent.Add( child1 );
2766 Actor child2 = Actor::New();
2767 parent.Add( child2 );
2769 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2770 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2771 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2775 int UtcDaliActorSetGetOverlay(void)
2777 TestApplication app;
2778 tet_infoline(" UtcDaliActorSetGetOverlay");
2780 Actor parent = Actor::New();
2781 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2782 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2787 int UtcDaliActorCreateDestroy(void)
2789 Actor* actor = new Actor;
2790 DALI_TEST_CHECK( actor );
2797 struct PropertyStringIndex
2799 const char * const name;
2800 const Property::Index index;
2801 const Property::Type type;
2804 const PropertyStringIndex PROPERTY_TABLE[] =
2806 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2807 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2808 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2809 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2810 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2811 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2812 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2813 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2814 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2815 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2816 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2817 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2818 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2819 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
2820 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
2821 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
2822 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2823 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2824 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2825 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2826 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2827 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2828 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2829 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
2830 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
2831 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
2832 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2833 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2834 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2835 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
2836 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
2837 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2838 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2839 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2840 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2841 { "name", Actor::Property::NAME, Property::STRING },
2842 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2843 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2844 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2845 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2846 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
2847 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2848 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
2849 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2850 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2851 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2852 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2853 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2854 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2855 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2856 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2857 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2859 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2860 } // unnamed namespace
2862 int UtcDaliActorProperties(void)
2864 TestApplication app;
2866 Actor actor = Actor::New();
2868 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2870 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2871 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2872 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2873 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2878 int UtcDaliRelayoutProperties_ResizePolicies(void)
2880 TestApplication app;
2882 Actor actor = Actor::New();
2885 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2886 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2888 // Set resize policy for all dimensions
2889 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2890 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2892 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2895 // Set individual dimensions
2896 const char* const widthPolicy = "FILL_TO_PARENT";
2897 const char* const heightPolicy = "FIXED";
2899 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2900 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2902 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2903 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2908 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
2910 TestApplication app;
2912 Actor actor = Actor::New();
2915 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
2916 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
2918 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
2919 actor.SetSizeScalePolicy( policy );
2920 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
2923 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
2924 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
2926 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
2927 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
2929 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
2930 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
2935 int UtcDaliRelayoutProperties_SizeModeFactor(void)
2937 TestApplication app;
2939 Actor actor = Actor::New();
2942 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2943 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
2945 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
2946 actor.SetSizeModeFactor( sizeMode );
2947 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
2950 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
2952 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
2953 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
2958 int UtcDaliRelayoutProperties_DimensionDependency(void)
2960 TestApplication app;
2962 Actor actor = Actor::New();
2965 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2966 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
2969 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
2970 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
2972 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
2973 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
2975 // Test setting another resize policy
2976 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
2977 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
2982 int UtcDaliRelayoutProperties_Padding(void)
2984 TestApplication app;
2986 Actor actor = Actor::New();
2989 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
2992 actor.SetProperty( Actor::Property::PADDING, padding );
2993 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
2995 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3000 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3002 TestApplication app;
3004 Actor actor = Actor::New();
3007 Vector2 minSize( 1.0f, 2.0f );
3009 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3010 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3012 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3014 Vector2 maxSize( 3.0f, 4.0f );
3016 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3017 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3019 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3024 int UtcDaliActorGetHeightForWidth(void)
3026 TestApplication app;
3028 Actor actor = Actor::New();
3030 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3035 int UtcDaliActorGetWidthForHeight(void)
3037 TestApplication app;
3039 Actor actor = Actor::New();
3041 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3046 int UtcDaliActorGetRelayoutSize(void)
3048 TestApplication app;
3050 Actor actor = Actor::New();
3052 // Add actor to stage
3053 Stage::GetCurrent().Add( actor );
3055 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3057 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3058 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3060 // Flush the queue and render once
3061 app.SendNotification();
3064 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3069 int UtcDaliActorSetPadding(void)
3071 TestApplication app;
3073 Actor actor = Actor::New();
3076 actor.GetPadding( padding );
3078 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3079 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3080 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3081 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3083 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3084 actor.SetPadding( padding2 );
3086 actor.GetPadding( padding );
3088 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3089 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3090 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3091 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3096 int UtcDaliActorSetMinimumSize(void)
3098 TestApplication app;
3100 Actor actor = Actor::New();
3102 Vector2 size = actor.GetMinimumSize();
3104 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3105 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3107 Vector2 size2( 1.0f, 2.0f );
3108 actor.SetMinimumSize( size2 );
3110 size = actor.GetMinimumSize();
3112 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3113 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3118 int UtcDaliActorSetMaximumSize(void)
3120 TestApplication app;
3122 Actor actor = Actor::New();
3124 Vector2 size = actor.GetMaximumSize();
3126 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3127 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3129 Vector2 size2( 1.0f, 2.0f );
3130 actor.SetMaximumSize( size2 );
3132 size = actor.GetMaximumSize();
3134 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3135 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3140 int UtcDaliActorOnRelayoutSignal(void)
3142 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3144 TestApplication application;
3147 gOnRelayoutCallBackCalled = false;
3148 gActorNamesRelayout.clear();
3150 Actor actor = Actor::New();
3151 actor.SetName( "actor" );
3152 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3155 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3157 // Add actor to stage
3158 Stage::GetCurrent().Add( actor );
3160 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3161 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3163 // Flush the queue and render once
3164 application.SendNotification();
3165 application.Render();
3167 // OnRelayout emitted
3168 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3169 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3174 int UtcDaliActorGetHierachyDepth(void)
3176 TestApplication application;
3177 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3180 /* Build tree of actors:
3190 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3192 Stage stage( Stage::GetCurrent() );
3194 Actor actorA = Actor::New();
3195 Actor actorB = Actor::New();
3196 Actor actorC = Actor::New();
3197 Actor actorD = Actor::New();
3198 Actor actorE = Actor::New();
3199 Actor actorF = Actor::New();
3201 //Test that root actor has depth equal 0
3202 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3204 //Test actors return depth -1 when not connected to the tree
3205 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3206 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3207 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3208 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3209 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3210 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3212 //Create the hierarchy
3213 stage.Add( actorA );
3214 actorA.Add( actorB );
3215 actorA.Add( actorC );
3216 actorB.Add( actorD );
3217 actorB.Add( actorE );
3218 actorC.Add( actorF );
3220 //Test actors return correct depth
3221 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3222 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3223 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3224 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3225 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3226 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3228 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3229 actorA.Remove( actorB );
3231 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3232 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3233 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3235 //Removing actorA from the stage. All actors should have depth equal -1
3236 stage.Remove( actorA );
3238 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3239 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3240 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3241 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3242 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3243 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3248 int UtcDaliActorAnchorPointPropertyAsString(void)
3250 TestApplication application;
3252 Actor actor = Actor::New();
3254 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3255 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3257 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3258 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3260 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3261 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3263 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3264 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3266 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3267 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3269 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3270 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3272 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3273 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3275 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3276 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3278 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3279 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3281 // Invalid should not change anything
3282 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3283 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3288 int UtcDaliActorParentOriginPropertyAsString(void)
3290 TestApplication application;
3292 Actor actor = Actor::New();
3294 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3295 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3297 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3298 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3300 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3301 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3303 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3304 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3306 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3307 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3309 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3310 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3312 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3313 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3315 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3316 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3318 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3319 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3321 // Invalid should not change anything
3322 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3323 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3328 int UtcDaliActorColorModePropertyAsString(void)
3330 TestApplication application;
3332 Actor actor = Actor::New();
3334 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3335 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3337 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3338 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3340 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3341 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3343 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3344 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3346 // Invalid should not change anything
3347 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3348 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3353 int UtcDaliActorPositionInheritancePropertyAsString(void)
3355 TestApplication application;
3357 Actor actor = Actor::New();
3359 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3360 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3362 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3363 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3365 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3366 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3368 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3369 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3371 // Invalid should not change anything
3372 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3373 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3378 int UtcDaliActorDrawModePropertyAsString(void)
3380 TestApplication application;
3382 Actor actor = Actor::New();
3384 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3385 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3387 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3388 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3390 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3391 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3393 // Invalid should not change anything
3394 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3395 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3400 int UtcDaliActorAddRendererP(void)
3402 tet_infoline("Testing Actor::AddRenderer");
3403 TestApplication application;
3405 Actor actor = Actor::New();
3407 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3409 Geometry geometry = CreateQuadGeometry();
3410 Shader shader = CreateShader();
3411 Renderer renderer = Renderer::New(geometry, shader);
3413 actor.AddRenderer( renderer );
3414 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3415 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3420 int UtcDaliActorAddRendererN(void)
3422 tet_infoline("Testing Actor::AddRenderer");
3423 TestApplication application;
3425 Actor actor = Actor::New();
3431 actor.AddRenderer( renderer );
3432 tet_printf("Assertion test failed - no Exception\n" );
3433 tet_result(TET_FAIL);
3435 catch(Dali::DaliException& e)
3437 DALI_TEST_PRINT_ASSERT( e );
3438 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3439 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3443 tet_printf("Assertion test failed - wrong Exception\n" );
3444 tet_result(TET_FAIL);
3450 int UtcDaliActorAddRendererOnStage(void)
3452 tet_infoline("Testing Actor::AddRenderer");
3453 TestApplication application;
3455 Actor actor = Actor::New();
3456 Stage::GetCurrent().Add(actor);
3458 application.SendNotification();
3459 application.Render(0);
3461 Geometry geometry = CreateQuadGeometry();
3462 Shader shader = CreateShader();
3463 Renderer renderer = Renderer::New(geometry, shader);
3465 application.SendNotification();
3466 application.Render(0);
3470 actor.AddRenderer( renderer );
3471 tet_result(TET_PASS);
3475 tet_result(TET_FAIL);
3481 int UtcDaliActorRemoveRendererP1(void)
3483 tet_infoline("Testing Actor::RemoveRenderer");
3484 TestApplication application;
3486 Actor actor = Actor::New();
3488 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3490 Geometry geometry = CreateQuadGeometry();
3491 Shader shader = CreateShader();
3492 Renderer renderer = Renderer::New(geometry, shader);
3494 actor.AddRenderer( renderer );
3495 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3496 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3498 actor.RemoveRenderer(renderer);
3499 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3505 int UtcDaliActorRemoveRendererP2(void)
3507 tet_infoline("Testing Actor::RemoveRenderer");
3508 TestApplication application;
3510 Actor actor = Actor::New();
3512 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3514 Geometry geometry = CreateQuadGeometry();
3515 Shader shader = CreateShader();
3516 Renderer renderer = Renderer::New(geometry, shader);
3518 actor.AddRenderer( renderer );
3519 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3520 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3522 actor.RemoveRenderer(0);
3523 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3530 int UtcDaliActorRemoveRendererN(void)
3532 tet_infoline("Testing Actor::RemoveRenderer");
3533 TestApplication application;
3535 Actor actor = Actor::New();
3537 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3539 Geometry geometry = CreateQuadGeometry();
3540 Shader shader = CreateShader();
3541 Renderer renderer = Renderer::New(geometry, shader);
3543 actor.AddRenderer( renderer );
3544 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3545 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3547 actor.RemoveRenderer(10);
3548 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3549 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );