2 * Copyright (c) 2017 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/devel-api/actors/actor-devel.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali-test-suite-utils.h>
26 #include <mesh-builder.h>
34 void utc_dali_actor_startup(void)
36 test_return_value = TET_UNDEF;
39 void utc_dali_actor_cleanup(void)
41 test_return_value = TET_PASS;
46 bool gTouchCallBackCalled=false;
47 bool gHoverCallBackCalled=false;
49 static bool gTestConstraintCalled;
53 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
55 gTestConstraintCalled = true;
60 * TestConstraint reference.
61 * When constraint is called, the resultRef is updated
62 * with the value supplied.
65 struct TestConstraintRef
67 TestConstraintRef(unsigned int& resultRef, unsigned int value)
68 : mResultRef(resultRef),
73 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
78 unsigned int& mResultRef;
82 static bool TestCallback(Actor actor, const TouchEvent& event)
84 gTouchCallBackCalled = true;
89 static bool TestCallback3(Actor actor, const HoverEvent& event)
91 gHoverCallBackCalled = true;
96 // validation stuff for onstage & offstage signals
97 static std::vector< std::string > gActorNamesOnOffStage;
98 static int gOnStageCallBackCalled;
99 void OnStageCallback( Actor actor )
101 ++gOnStageCallBackCalled;
102 gActorNamesOnOffStage.push_back( actor.GetName() );
103 DALI_TEST_CHECK( actor.OnStage() == true );
105 static int gOffStageCallBackCalled;
106 void OffStageCallback( Actor actor )
108 ++gOffStageCallBackCalled;
109 gActorNamesOnOffStage.push_back( actor.GetName() );
110 DALI_TEST_CHECK( actor.OnStage() == false );
113 struct PositionComponentConstraint
115 PositionComponentConstraint(){}
117 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
119 const Matrix& m = inputs[0]->GetMatrix();
122 m.GetTransformComponents(pos, rot, scale);
126 struct OrientationComponentConstraint
128 OrientationComponentConstraint(){}
130 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
132 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
135 orientation = parentOrientation;
140 static bool gOnRelayoutCallBackCalled = false;
141 static std::vector< std::string > gActorNamesRelayout;
143 void OnRelayoutCallback( Actor actor )
145 gOnRelayoutCallBackCalled = true;
146 gActorNamesRelayout.push_back( actor.GetName() );
149 } // anonymous namespace
152 //& purpose: Testing New API
153 int UtcDaliActorNew(void)
155 TestApplication application;
157 Actor actor = Actor::New();
159 DALI_TEST_CHECK(actor);
163 //& purpose: Testing Dali::Actor::DownCast()
164 int UtcDaliActorDownCastP(void)
166 TestApplication application;
167 tet_infoline("Testing Dali::Actor::DownCast()");
169 Actor actor = Actor::New();
170 BaseHandle object(actor);
171 Actor actor2 = Actor::DownCast(object);
172 DALI_TEST_CHECK(actor2);
176 //& purpose: Testing Dali::Actor::DownCast()
177 int UtcDaliActorDownCastN(void)
179 TestApplication application;
180 tet_infoline("Testing Dali::Actor::DownCast()");
182 BaseHandle unInitializedObject;
183 Actor actor = Actor::DownCast(unInitializedObject);
184 DALI_TEST_CHECK(!actor);
188 //& purpose: Testing Dali::Actor::GetName()
189 int UtcDaliActorGetName(void)
191 TestApplication application;
193 Actor actor = Actor::New();
195 DALI_TEST_CHECK(actor.GetName().empty());
199 //& purpose: Testing Dali::Actor::SetName()
200 int UtcDaliActorSetName(void)
202 TestApplication application;
204 string str("ActorName");
205 Actor actor = Actor::New();
208 DALI_TEST_CHECK(actor.GetName() == str);
212 int UtcDaliActorGetId(void)
214 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
215 TestApplication application;
217 Actor first = Actor::New();
218 Actor second = Actor::New();
219 Actor third = Actor::New();
221 DALI_TEST_CHECK(first.GetId() != second.GetId());
222 DALI_TEST_CHECK(second.GetId() != third.GetId());
226 int UtcDaliActorIsRoot(void)
228 TestApplication application;
230 Actor actor = Actor::New();
231 DALI_TEST_CHECK(!actor.IsRoot());
233 // get the root layer
234 actor = Stage::GetCurrent().GetLayer( 0 );
235 DALI_TEST_CHECK( actor.IsRoot() );
239 int UtcDaliActorOnStage(void)
241 TestApplication application;
243 Actor actor = Actor::New();
244 DALI_TEST_CHECK( !actor.OnStage() );
246 // get the root layer
247 actor = Stage::GetCurrent().GetLayer( 0 );
248 DALI_TEST_CHECK( actor.OnStage() );
252 int UtcDaliActorIsLayer(void)
254 TestApplication application;
256 Actor actor = Actor::New();
257 DALI_TEST_CHECK( !actor.IsLayer() );
259 // get the root layer
260 actor = Stage::GetCurrent().GetLayer( 0 );
261 DALI_TEST_CHECK( actor.IsLayer() );
265 int UtcDaliActorGetLayer(void)
267 TestApplication application;
269 Actor actor = Actor::New();
270 Stage::GetCurrent().Add(actor);
271 Layer layer = actor.GetLayer();
273 DALI_TEST_CHECK(layer);
275 // get the root layers layer
276 actor = Stage::GetCurrent().GetLayer( 0 );
277 DALI_TEST_CHECK( actor.GetLayer() );
281 int UtcDaliActorAddP(void)
283 tet_infoline("Testing Actor::Add");
284 TestApplication application;
286 Actor parent = Actor::New();
287 Actor child = Actor::New();
289 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
293 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
295 Actor parent2 = Actor::New();
296 parent2.Add( child );
298 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
299 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
301 // try Adding to same parent again, works
302 parent2.Add( child );
303 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
305 // try reparenting an orphaned child
307 Actor temporaryParent = Actor::New();
308 temporaryParent.Add( child );
309 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
311 // temporaryParent has now died, reparent the orphaned child
312 parent2.Add( child );
313 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
318 int UtcDaliActorAddN(void)
320 tet_infoline("Testing Actor::Add");
321 TestApplication application;
323 Actor child = Actor::New();
325 Actor parent2 = Actor::New();
326 parent2.Add( child );
331 parent2.Add( parent2 );
332 tet_printf("Assertion test failed - no Exception\n" );
333 tet_result(TET_FAIL);
335 catch(Dali::DaliException& e)
337 DALI_TEST_PRINT_ASSERT( e );
338 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
339 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
343 tet_printf("Assertion test failed - wrong Exception\n" );
344 tet_result(TET_FAIL);
347 // try reparenting root
350 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
351 tet_printf("Assertion test failed - no Exception\n" );
352 tet_result(TET_FAIL);
354 catch(Dali::DaliException& e)
356 DALI_TEST_PRINT_ASSERT( e );
357 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
358 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
362 tet_printf("Assertion test failed - wrong Exception\n" );
363 tet_result(TET_FAIL);
370 parent2.Add( empty );
371 tet_printf("Assertion test failed - no Exception\n" );
372 tet_result(TET_FAIL);
374 catch(Dali::DaliException& e)
376 DALI_TEST_PRINT_ASSERT( e );
377 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
378 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
382 tet_printf("Assertion test failed - wrong Exception\n" );
383 tet_result(TET_FAIL);
389 int UtcDaliActorRemoveN(void)
391 tet_infoline("Testing Actor::Remove");
392 TestApplication application;
394 Actor parent = Actor::New();
395 Actor child = Actor::New();
396 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
399 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
401 parent.Remove(child);
402 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
404 // remove again, no problem
405 parent.Remove(child);
406 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
410 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
411 // try Remove self, its a no-op
412 parent.Remove( parent );
413 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
419 parent.Remove( empty );
420 tet_printf("Assertion test failed - no Exception\n" );
421 tet_result(TET_FAIL);
423 catch(Dali::DaliException& e)
425 DALI_TEST_PRINT_ASSERT( e );
426 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
427 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
431 tet_printf("Assertion test failed - wrong Exception\n" );
432 tet_result(TET_FAIL);
437 int UtcDaliActorRemoveP(void)
439 TestApplication application;
441 Actor parent = Actor::New();
442 Actor child = Actor::New();
443 Actor random = Actor::New();
445 Stage::GetCurrent().Add( parent );
447 DALI_TEST_CHECK(parent.GetChildCount() == 0);
451 DALI_TEST_CHECK(parent.GetChildCount() == 1);
453 parent.Remove(random);
455 DALI_TEST_CHECK(parent.GetChildCount() == 1);
457 Stage::GetCurrent().Remove( parent );
459 DALI_TEST_CHECK(parent.GetChildCount() == 1);
463 int UtcDaliActorGetChildCount(void)
465 TestApplication application;
467 Actor parent = Actor::New();
468 Actor child = Actor::New();
470 DALI_TEST_CHECK(parent.GetChildCount() == 0);
474 DALI_TEST_CHECK(parent.GetChildCount() == 1);
478 int UtcDaliActorGetChildren01(void)
480 TestApplication application;
482 Actor parent = Actor::New();
483 Actor first = Actor::New();
484 Actor second = Actor::New();
485 Actor third = Actor::New();
491 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
492 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
493 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
497 int UtcDaliActorGetChildren02(void)
499 TestApplication application;
501 Actor parent = Actor::New();
502 Actor first = Actor::New();
503 Actor second = Actor::New();
504 Actor third = Actor::New();
510 const Actor& constParent = parent;
512 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
513 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
514 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
518 int UtcDaliActorGetParent01(void)
520 TestApplication application;
522 Actor parent = Actor::New();
523 Actor child = Actor::New();
527 DALI_TEST_CHECK(child.GetParent() == parent);
531 int UtcDaliActorGetParent02(void)
533 TestApplication application;
535 Actor actor = Actor::New();
537 DALI_TEST_CHECK(!actor.GetParent());
541 int UtcDaliActorSetParentOrigin(void)
543 TestApplication application;
545 Actor actor = Actor::New();
547 Vector3 vector(0.7f, 0.8f, 0.9f);
548 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
550 actor.SetParentOrigin(vector);
552 // flush the queue and render once
553 application.SendNotification();
554 application.Render();
556 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
558 Stage::GetCurrent().Add( actor );
560 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
562 // flush the queue and render once
563 application.SendNotification();
564 application.Render();
566 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
568 Stage::GetCurrent().Remove( actor );
572 int UtcDaliActorSetParentOriginIndividual(void)
574 TestApplication application;
576 Actor actor = Actor::New();
578 Vector3 vector(0.7f, 0.8f, 0.9f);
579 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
581 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
583 // flush the queue and render once
584 application.SendNotification();
585 application.Render();
587 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
589 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
591 // flush the queue and render once
592 application.SendNotification();
593 application.Render();
595 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
597 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
599 // flush the queue and render once
600 application.SendNotification();
601 application.Render();
603 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
608 int UtcDaliActorGetCurrentParentOrigin(void)
610 TestApplication application;
612 Actor actor = Actor::New();
614 Vector3 vector(0.7f, 0.8f, 0.9f);
615 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
617 actor.SetParentOrigin(vector);
619 // flush the queue and render once
620 application.SendNotification();
621 application.Render();
623 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
627 int UtcDaliActorSetAnchorPoint(void)
629 TestApplication application;
631 Actor actor = Actor::New();
633 Vector3 vector(0.7f, 0.8f, 0.9f);
634 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
636 actor.SetAnchorPoint(vector);
638 // flush the queue and render once
639 application.SendNotification();
640 application.Render();
642 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
644 Stage::GetCurrent().Add( actor );
646 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
647 // flush the queue and render once
648 application.SendNotification();
649 application.Render();
651 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
653 Stage::GetCurrent().Remove( actor );
657 int UtcDaliActorSetAnchorPointIndividual(void)
659 TestApplication application;
661 Actor actor = Actor::New();
663 Vector3 vector(0.7f, 0.8f, 0.9f);
664 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
666 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
668 // flush the queue and render once
669 application.SendNotification();
670 application.Render();
672 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
674 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
676 // flush the queue and render once
677 application.SendNotification();
678 application.Render();
680 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
682 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
684 // flush the queue and render once
685 application.SendNotification();
686 application.Render();
688 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
693 int UtcDaliActorGetCurrentAnchorPoint(void)
695 TestApplication application;
697 Actor actor = Actor::New();
699 Vector3 vector(0.7f, 0.8f, 0.9f);
700 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
702 actor.SetAnchorPoint(vector);
704 // flush the queue and render once
705 application.SendNotification();
706 application.Render();
708 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
712 // SetSize(float width, float height)
713 int UtcDaliActorSetSize01(void)
715 TestApplication application;
717 Actor actor = Actor::New();
718 Vector3 vector(100.0f, 100.0f, 0.0f);
720 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
722 actor.SetSize(vector.x, vector.y);
724 // Immediately retrieve the size after setting
725 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
726 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
728 // Flush the queue and render once
729 application.SendNotification();
730 application.Render();
732 // Check the size in the new frame
733 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
735 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
736 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
738 // Change the resize policy and check whether the size stays the same
739 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
741 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
742 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
744 // Set a new size after resize policy is changed and check the new size
745 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
747 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
748 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
750 // Change the resize policy again and check whether the new size stays the same
751 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
753 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
754 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
756 // Set another new size after resize policy is changed and check the new size
757 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
759 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
760 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
765 // SetSize(float width, float height, float depth)
766 int UtcDaliActorSetSize02(void)
768 TestApplication application;
770 Actor actor = Actor::New();
771 Vector3 vector(100.0f, 100.0f, 100.0f);
773 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
775 actor.SetSize(vector.x, vector.y, vector.z);
777 // Immediately check the size after setting
778 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
779 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
781 // flush the queue and render once
782 application.SendNotification();
783 application.Render();
785 // Check the size in the new frame
786 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
788 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
789 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
794 // SetSize(Vector2 size)
795 int UtcDaliActorSetSize03(void)
797 TestApplication application;
799 Actor actor = Actor::New();
800 Vector3 vector(100.0f, 100.0f, 0.0f);
802 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
804 actor.SetSize(Vector2(vector.x, vector.y));
806 // Immediately check the size after setting
807 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
808 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
810 // flush the queue and render once
811 application.SendNotification();
812 application.Render();
814 // Check the size in the new frame
815 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
817 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
818 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
823 // SetSize(Vector3 size)
824 int UtcDaliActorSetSize04(void)
826 TestApplication application;
828 Actor actor = Actor::New();
829 Vector3 vector(100.0f, 100.0f, 100.0f);
831 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
833 actor.SetSize(vector);
835 // Immediately check the size after setting
836 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
837 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
839 // flush the queue and render once
840 application.SendNotification();
841 application.Render();
843 // Check the size in the new frame
844 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
846 Stage::GetCurrent().Add( actor );
847 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
849 // Immediately check the size after setting
850 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
851 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
853 // flush the queue and render once
854 application.SendNotification();
855 application.Render();
857 // Check the size in the new frame
858 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
860 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
861 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
863 Stage::GetCurrent().Remove( actor );
867 int UtcDaliActorSetSizeIndividual(void)
869 TestApplication application;
871 Actor actor = Actor::New();
873 Vector3 vector(0.7f, 0.8f, 0.9f);
874 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
876 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
878 // Immediately check the width after setting
879 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
880 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
882 // flush the queue and render once
883 application.SendNotification();
884 application.Render();
886 // Check the width in the new frame
887 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
889 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
890 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
892 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
894 // Immediately check the height after setting
895 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
896 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
898 // flush the queue and render once
899 application.SendNotification();
900 application.Render();
902 // Check the height in the new frame
903 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
905 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
906 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
908 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
910 // Immediately check the depth after setting
911 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
912 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
914 // flush the queue and render once
915 application.SendNotification();
916 application.Render();
918 // Check the depth in the new frame
919 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
921 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
922 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
924 // Change the resize policy and check whether the size stays the same
925 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
927 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
928 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
930 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
931 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
933 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
934 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
936 // Change the resize policy again and check whether the size stays the same
937 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
939 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
940 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
942 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
943 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
945 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
946 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
952 int UtcDaliActorGetCurrentSize(void)
954 TestApplication application;
956 Actor actor = Actor::New();
957 Vector3 vector(100.0f, 100.0f, 20.0f);
959 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
961 actor.SetSize(vector);
963 // flush the queue and render once
964 application.SendNotification();
965 application.Render();
967 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
971 int UtcDaliActorGetNaturalSize(void)
973 TestApplication application;
975 Actor actor = Actor::New();
976 Vector3 vector( 0.0f, 0.0f, 0.0f );
978 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
983 int UtcDaliActorGetCurrentSizeImmediate(void)
985 TestApplication application;
987 Actor actor = Actor::New();
988 Vector3 vector(100.0f, 100.0f, 20.0f);
990 DALI_TEST_CHECK(vector != actor.GetTargetSize());
991 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
993 actor.SetSize(vector);
995 DALI_TEST_CHECK(vector == actor.GetTargetSize());
996 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
998 // flush the queue and render once
999 application.SendNotification();
1000 application.Render();
1002 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1003 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1006 // Build the animation
1007 const float durationSeconds = 2.0f;
1008 Animation animation = Animation::New( durationSeconds );
1009 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1010 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1012 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1014 // Start the animation
1017 application.SendNotification();
1018 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1020 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1025 // SetPosition(float x, float y)
1026 int UtcDaliActorSetPosition01(void)
1028 TestApplication application;
1030 Actor actor = Actor::New();
1032 // Set to random to start off with
1033 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1035 Vector3 vector(100.0f, 100.0f, 0.0f);
1037 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1039 actor.SetPosition(vector.x, vector.y);
1040 // flush the queue and render once
1041 application.SendNotification();
1042 application.Render();
1043 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1045 Stage::GetCurrent().Add( actor );
1046 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1047 // flush the queue and render once
1048 application.SendNotification();
1049 application.Render();
1050 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1055 // flush the queue and render once
1056 application.SendNotification();
1057 application.Render();
1058 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1060 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1061 // flush the queue and render once
1062 application.SendNotification();
1063 application.Render();
1064 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1066 Stage::GetCurrent().Remove( actor );
1070 // SetPosition(float x, float y, float z)
1071 int UtcDaliActorSetPosition02(void)
1073 TestApplication application;
1075 Actor actor = Actor::New();
1077 // Set to random to start off with
1078 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1080 Vector3 vector(100.0f, 100.0f, 100.0f);
1082 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1084 actor.SetPosition(vector.x, vector.y, vector.z);
1086 // flush the queue and render once
1087 application.SendNotification();
1088 application.Render();
1090 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1094 // SetPosition(Vector3 position)
1095 int UtcDaliActorSetPosition03(void)
1097 TestApplication application;
1099 Actor actor = Actor::New();
1101 // Set to random to start off with
1102 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1104 Vector3 vector(100.0f, 100.0f, 100.0f);
1106 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1108 actor.SetPosition(vector);
1110 // flush the queue and render once
1111 application.SendNotification();
1112 application.Render();
1114 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1118 int UtcDaliActorSetX(void)
1120 TestApplication application;
1122 Actor actor = Actor::New();
1124 Vector3 vector(100.0f, 0.0f, 0.0f);
1126 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1130 // flush the queue and render once
1131 application.SendNotification();
1132 application.Render();
1134 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1138 int UtcDaliActorSetY(void)
1140 TestApplication application;
1142 Actor actor = Actor::New();
1144 Vector3 vector(0.0f, 100.0f, 0.0f);
1146 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1150 // flush the queue and render once
1151 application.SendNotification();
1152 application.Render();
1154 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1158 int UtcDaliActorSetZ(void)
1160 TestApplication application;
1162 Actor actor = Actor::New();
1164 Vector3 vector(0.0f, 0.0f, 100.0f);
1166 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1170 // flush the queue and render once
1171 application.SendNotification();
1172 application.Render();
1174 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1178 int UtcDaliActorSetPositionProperties(void)
1180 TestApplication application;
1182 Actor actor = Actor::New();
1184 Vector3 vector(0.7f, 0.8f, 0.9f);
1185 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1187 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1189 // flush the queue and render once
1190 application.SendNotification();
1191 application.Render();
1193 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1195 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1197 // flush the queue and render once
1198 application.SendNotification();
1199 application.Render();
1201 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1203 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1205 // flush the queue and render once
1206 application.SendNotification();
1207 application.Render();
1209 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1214 int UtcDaliActorTranslateBy(void)
1216 TestApplication application;
1218 Actor actor = Actor::New();
1219 Vector3 vector(100.0f, 100.0f, 100.0f);
1221 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1223 actor.SetPosition(vector);
1225 // flush the queue and render once
1226 application.SendNotification();
1227 application.Render();
1229 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1231 actor.TranslateBy(vector);
1233 // flush the queue and render once
1234 application.SendNotification();
1235 application.Render();
1237 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1241 int UtcDaliActorGetCurrentPosition(void)
1243 TestApplication application;
1245 Actor actor = Actor::New();
1246 Vector3 setVector(100.0f, 100.0f, 0.0f);
1247 actor.SetPosition(setVector);
1249 // flush the queue and render once
1250 application.SendNotification();
1251 application.Render();
1253 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1257 int UtcDaliActorGetCurrentWorldPosition(void)
1259 TestApplication application;
1261 Actor parent = Actor::New();
1262 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1263 parent.SetPosition( parentPosition );
1264 parent.SetParentOrigin( ParentOrigin::CENTER );
1265 parent.SetAnchorPoint( AnchorPoint::CENTER );
1266 Stage::GetCurrent().Add( parent );
1268 Actor child = Actor::New();
1269 child.SetParentOrigin( ParentOrigin::CENTER );
1270 child.SetAnchorPoint( AnchorPoint::CENTER );
1271 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1272 child.SetPosition( childPosition );
1273 parent.Add( child );
1275 // The actors should not have a world position yet
1276 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1277 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1279 application.SendNotification();
1280 application.Render(0);
1282 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1283 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1285 // The actors should have a world position now
1286 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1287 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1291 int UtcDaliActorInheritPosition(void)
1293 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1294 TestApplication application;
1296 Actor parent = Actor::New();
1297 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1298 parent.SetPosition( parentPosition );
1299 parent.SetParentOrigin( ParentOrigin::CENTER );
1300 parent.SetAnchorPoint( AnchorPoint::CENTER );
1301 Stage::GetCurrent().Add( parent );
1303 Actor child = Actor::New();
1304 child.SetParentOrigin( ParentOrigin::CENTER );
1305 child.SetAnchorPoint( AnchorPoint::CENTER );
1306 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1307 child.SetPosition( childPosition );
1308 parent.Add( child );
1310 // The actors should not have a world position yet
1311 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1312 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1314 // first test default, which is to inherit position
1315 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1316 application.SendNotification();
1317 application.Render(0); // should only really call Update as Render is not required to update scene
1318 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1319 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1320 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1321 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1324 //Change child position
1325 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1326 child.SetPosition( childOffset );
1328 // Change inheritance mode to not inherit
1329 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1330 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1331 application.SendNotification();
1332 application.Render(0); // should only really call Update as Render is not required to update scene
1333 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1334 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1335 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1336 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1340 int UtcDaliActorSetInheritPosition(void)
1342 tet_infoline("Testing Actor::SetInheritPosition");
1343 TestApplication application;
1345 Actor parent = Actor::New();
1346 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1347 parent.SetPosition( parentPosition );
1348 parent.SetParentOrigin( ParentOrigin::CENTER );
1349 parent.SetAnchorPoint( AnchorPoint::CENTER );
1350 Stage::GetCurrent().Add( parent );
1352 Actor child = Actor::New();
1353 child.SetParentOrigin( ParentOrigin::CENTER );
1354 child.SetAnchorPoint( AnchorPoint::CENTER );
1355 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1356 child.SetPosition( childPosition );
1357 parent.Add( child );
1359 // The actors should not have a world position yet
1360 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1361 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1363 // first test default, which is to inherit position
1364 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1365 application.SendNotification();
1366 application.Render(0); // should only really call Update as Render is not required to update scene
1367 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1368 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1369 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1370 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1372 //Change child position
1373 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1374 child.SetPosition( childOffset );
1376 // Use local position as world postion
1377 child.SetInheritPosition( false );
1378 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1379 application.SendNotification();
1380 application.Render(0); // should only really call Update as Render is not required to update scene
1381 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1382 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1383 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1384 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1386 //Change back to inherit position from parent
1387 child.SetInheritPosition( true );
1388 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1389 application.SendNotification();
1390 application.Render(0); // should only really call Update as Render is not required to update scene
1391 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1392 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1393 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1394 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1398 // SetOrientation(float angleRadians, Vector3 axis)
1399 int UtcDaliActorSetOrientation01(void)
1401 TestApplication application;
1403 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1404 Actor actor = Actor::New();
1406 actor.SetOrientation(rotation);
1408 // flush the queue and render once
1409 application.SendNotification();
1410 application.Render();
1412 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1416 int UtcDaliActorSetOrientation02(void)
1418 TestApplication application;
1420 Actor actor = Actor::New();
1422 Radian angle( 0.785f );
1423 Vector3 axis(1.0f, 1.0f, 0.0f);
1425 actor.SetOrientation( angle, axis);
1426 Quaternion rotation( angle, axis );
1427 // flush the queue and render once
1428 application.SendNotification();
1429 application.Render();
1430 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1432 Stage::GetCurrent().Add( actor );
1433 actor.RotateBy( Degree( 360 ), axis);
1434 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1436 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1437 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1438 // flush the queue and render once
1439 application.SendNotification();
1440 application.Render();
1441 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1443 actor.SetOrientation( angle, axis);
1444 // flush the queue and render once
1445 application.SendNotification();
1446 application.Render();
1447 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1449 Stage::GetCurrent().Remove( actor );
1453 // SetOrientation(float angleRadians, Vector3 axis)
1454 int UtcDaliActorSetOrientationProperty(void)
1456 TestApplication application;
1458 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1459 Actor actor = Actor::New();
1461 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1463 // flush the queue and render once
1464 application.SendNotification();
1465 application.Render();
1467 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1471 // RotateBy(float angleRadians, Vector3 axis)
1472 int UtcDaliActorRotateBy01(void)
1474 TestApplication application;
1476 Actor actor = Actor::New();
1478 Radian angle( M_PI * 0.25f );
1479 actor.RotateBy(( angle ), Vector3::ZAXIS);
1480 // flush the queue and render once
1481 application.SendNotification();
1482 application.Render();
1483 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1485 Stage::GetCurrent().Add( actor );
1487 actor.RotateBy( angle, Vector3::ZAXIS);
1488 // flush the queue and render once
1489 application.SendNotification();
1490 application.Render();
1491 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1493 Stage::GetCurrent().Remove( actor );
1497 // RotateBy(Quaternion relativeRotation)
1498 int UtcDaliActorRotateBy02(void)
1500 TestApplication application;
1502 Actor actor = Actor::New();
1504 Radian angle( M_PI * 0.25f );
1505 Quaternion rotation(angle, Vector3::ZAXIS);
1506 actor.RotateBy(rotation);
1507 // flush the queue and render once
1508 application.SendNotification();
1509 application.Render();
1510 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1512 actor.RotateBy(rotation);
1513 // flush the queue and render once
1514 application.SendNotification();
1515 application.Render();
1516 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1520 int UtcDaliActorGetCurrentOrientation(void)
1522 TestApplication application;
1523 Actor actor = Actor::New();
1525 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1526 actor.SetOrientation(rotation);
1527 // flush the queue and render once
1528 application.SendNotification();
1529 application.Render();
1530 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1534 int UtcDaliActorGetCurrentWorldOrientation(void)
1536 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1537 TestApplication application;
1539 Actor parent = Actor::New();
1540 Radian rotationAngle( Degree(90.0f) );
1541 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1542 parent.SetOrientation( rotation );
1543 Stage::GetCurrent().Add( parent );
1545 Actor child = Actor::New();
1546 child.SetOrientation( rotation );
1547 parent.Add( child );
1549 // The actors should not have a world rotation yet
1550 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1551 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1553 application.SendNotification();
1554 application.Render(0);
1556 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1557 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1559 // The actors should have a world rotation now
1560 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1561 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1563 // turn off child rotation inheritance
1564 child.SetInheritOrientation( false );
1565 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1566 application.SendNotification();
1567 application.Render(0);
1569 // The actors should have a world rotation now
1570 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1571 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1575 // SetScale(float scale)
1576 int UtcDaliActorSetScale01(void)
1578 TestApplication application;
1580 Actor actor = Actor::New();
1582 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1583 actor.SetScale(0.25f);
1585 Vector3 scale(10.0f, 10.0f, 10.0f);
1586 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1588 actor.SetScale(scale.x);
1590 // flush the queue and render once
1591 application.SendNotification();
1592 application.Render();
1594 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1598 // SetScale(float scaleX, float scaleY, float scaleZ)
1599 int UtcDaliActorSetScale02(void)
1601 TestApplication application;
1602 Vector3 scale(10.0f, 10.0f, 10.0f);
1604 Actor actor = Actor::New();
1606 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1607 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1609 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1611 actor.SetScale(scale.x, scale.y, scale.z);
1612 // flush the queue and render once
1613 application.SendNotification();
1614 application.Render();
1615 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1617 // add to stage and test
1618 Stage::GetCurrent().Add( actor );
1619 actor.SetScale( 2.0f, 2.0f, 2.0f );
1620 // flush the queue and render once
1621 application.SendNotification();
1622 application.Render();
1623 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1625 Stage::GetCurrent().Remove( actor );
1630 // SetScale(Vector3 scale)
1631 int UtcDaliActorSetScale03(void)
1633 TestApplication application;
1634 Vector3 scale(10.0f, 10.0f, 10.0f);
1636 Actor actor = Actor::New();
1638 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1639 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1641 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1643 actor.SetScale(scale);
1645 // flush the queue and render once
1646 application.SendNotification();
1647 application.Render();
1649 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1653 int UtcDaliActorSetScaleIndividual(void)
1655 TestApplication application;
1657 Actor actor = Actor::New();
1659 Vector3 vector(0.7f, 0.8f, 0.9f);
1660 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1662 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1664 // flush the queue and render once
1665 application.SendNotification();
1666 application.Render();
1668 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1670 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1672 // flush the queue and render once
1673 application.SendNotification();
1674 application.Render();
1676 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1678 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1680 // flush the queue and render once
1681 application.SendNotification();
1682 application.Render();
1684 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1689 int UtcDaliActorScaleBy(void)
1691 TestApplication application;
1692 Actor actor = Actor::New();
1693 Vector3 vector(100.0f, 100.0f, 100.0f);
1695 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1697 actor.SetScale(vector);
1699 // flush the queue and render once
1700 application.SendNotification();
1701 application.Render();
1703 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1705 actor.ScaleBy(vector);
1707 // flush the queue and render once
1708 application.SendNotification();
1709 application.Render();
1711 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1715 int UtcDaliActorGetCurrentScale(void)
1717 TestApplication application;
1718 Vector3 scale(12.0f, 1.0f, 2.0f);
1720 Actor actor = Actor::New();
1722 actor.SetScale(scale);
1724 // flush the queue and render once
1725 application.SendNotification();
1726 application.Render();
1728 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1732 int UtcDaliActorGetCurrentWorldScale(void)
1734 TestApplication application;
1736 Actor parent = Actor::New();
1737 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1738 parent.SetScale( parentScale );
1739 Stage::GetCurrent().Add( parent );
1741 Actor child = Actor::New();
1742 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1743 child.SetScale( childScale );
1744 parent.Add( child );
1746 // The actors should not have a scale yet
1747 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1748 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1750 // The actors should not have a world scale yet
1751 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1752 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1754 application.SendNotification();
1755 application.Render(0);
1757 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1758 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1760 // The actors should have a world scale now
1761 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1762 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1766 int UtcDaliActorInheritScale(void)
1768 tet_infoline("Testing Actor::SetInheritScale");
1769 TestApplication application;
1771 Actor parent = Actor::New();
1772 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1773 parent.SetScale( parentScale );
1774 Stage::GetCurrent().Add( parent );
1776 Actor child = Actor::New();
1777 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1778 child.SetScale( childScale );
1779 parent.Add( child );
1781 application.SendNotification();
1782 application.Render(0);
1784 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1785 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1787 child.SetInheritScale( false );
1788 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1790 application.SendNotification();
1791 application.Render(0);
1793 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1797 int UtcDaliActorSetVisible(void)
1799 TestApplication application;
1801 Actor actor = Actor::New();
1802 actor.SetVisible(false);
1803 // flush the queue and render once
1804 application.SendNotification();
1805 application.Render();
1806 DALI_TEST_CHECK(actor.IsVisible() == false);
1808 actor.SetVisible(true);
1809 // flush the queue and render once
1810 application.SendNotification();
1811 application.Render();
1812 DALI_TEST_CHECK(actor.IsVisible() == true);
1814 // put actor on stage
1815 Stage::GetCurrent().Add( actor );
1816 actor.SetVisible(false);
1817 // flush the queue and render once
1818 application.SendNotification();
1819 application.Render();
1820 DALI_TEST_CHECK(actor.IsVisible() == false);
1824 int UtcDaliActorIsVisible(void)
1826 TestApplication application;
1828 Actor actor = Actor::New();
1830 DALI_TEST_CHECK(actor.IsVisible() == true);
1834 int UtcDaliActorSetOpacity(void)
1836 TestApplication application;
1838 Actor actor = Actor::New();
1839 // initial opacity is 1
1840 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1842 actor.SetOpacity( 0.4f);
1843 // flush the queue and render once
1844 application.SendNotification();
1845 application.Render();
1846 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1848 // change opacity, actor is on stage to change is not immediate
1849 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1850 // flush the queue and render once
1851 application.SendNotification();
1852 application.Render();
1853 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1855 // put actor on stage
1856 Stage::GetCurrent().Add( actor );
1858 // change opacity, actor is on stage to change is not immediate
1859 actor.SetOpacity( 0.9f );
1860 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1861 // flush the queue and render once
1862 application.SendNotification();
1863 application.Render();
1864 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1866 // change opacity, actor is on stage to change is not immediate
1867 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1868 // flush the queue and render once
1869 application.SendNotification();
1870 application.Render();
1871 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1875 int UtcDaliActorGetCurrentOpacity(void)
1877 TestApplication application;
1879 Actor actor = Actor::New();
1880 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1882 actor.SetOpacity(0.5f);
1883 // flush the queue and render once
1884 application.SendNotification();
1885 application.Render();
1886 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1890 int UtcDaliActorSetSensitive(void)
1892 TestApplication application;
1893 Actor actor = Actor::New();
1895 bool sensitive = !actor.IsSensitive();
1897 actor.SetSensitive(sensitive);
1899 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1903 int UtcDaliActorIsSensitive(void)
1905 TestApplication application;
1906 Actor actor = Actor::New();
1907 actor.SetSensitive(false);
1909 DALI_TEST_CHECK(false == actor.IsSensitive());
1913 int UtcDaliActorSetColor(void)
1915 TestApplication application;
1916 Actor actor = Actor::New();
1917 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1919 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1921 actor.SetColor(color);
1922 // flush the queue and render once
1923 application.SendNotification();
1924 application.Render();
1925 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1927 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1928 // flush the queue and render once
1929 application.SendNotification();
1930 application.Render();
1931 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1933 Stage::GetCurrent().Add( actor );
1934 actor.SetColor( color );
1935 // flush the queue and render once
1936 application.SendNotification();
1937 application.Render();
1938 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1940 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1941 // flush the queue and render once
1942 application.SendNotification();
1943 application.Render();
1944 // Actor color is not clamped
1945 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1946 // world color is clamped
1947 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1949 Stage::GetCurrent().Remove( actor );
1953 int UtcDaliActorSetColorIndividual(void)
1955 TestApplication application;
1957 Actor actor = Actor::New();
1959 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
1960 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
1962 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
1964 // flush the queue and render once
1965 application.SendNotification();
1966 application.Render();
1968 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
1970 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
1972 // flush the queue and render once
1973 application.SendNotification();
1974 application.Render();
1976 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
1978 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
1980 // flush the queue and render once
1981 application.SendNotification();
1982 application.Render();
1984 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
1986 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
1988 // flush the queue and render once
1989 application.SendNotification();
1990 application.Render();
1992 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
1994 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
1996 // flush the queue and render once
1997 application.SendNotification();
1998 application.Render();
2000 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2006 int UtcDaliActorGetCurrentColor(void)
2008 TestApplication application;
2009 Actor actor = Actor::New();
2010 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2012 actor.SetColor(color);
2013 // flush the queue and render once
2014 application.SendNotification();
2015 application.Render();
2016 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2020 int UtcDaliActorGetCurrentWorldColor(void)
2022 tet_infoline("Actor::GetCurrentWorldColor");
2023 TestApplication application;
2025 Actor parent = Actor::New();
2026 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2027 parent.SetColor( parentColor );
2028 Stage::GetCurrent().Add( parent );
2030 Actor child = Actor::New();
2031 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2032 child.SetColor( childColor );
2033 parent.Add( child );
2035 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2036 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2038 // verify the default color mode
2039 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2041 // The actors should not have a world color yet
2042 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2043 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2045 application.SendNotification();
2046 application.Render(0);
2048 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2049 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2051 // The actors should have a world color now
2052 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2053 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2056 child.SetColorMode( USE_OWN_COLOR );
2057 application.SendNotification();
2058 application.Render(0);
2059 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2062 child.SetColorMode( USE_PARENT_COLOR );
2063 application.SendNotification();
2064 application.Render(0);
2065 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2066 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2069 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2070 application.SendNotification();
2071 application.Render(0);
2072 Vector4 expectedColor( childColor );
2073 expectedColor.a *= parentColor.a;
2074 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2075 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2079 int UtcDaliActorSetColorMode(void)
2081 tet_infoline("Actor::SetColorMode");
2082 TestApplication application;
2083 Actor actor = Actor::New();
2084 Actor child = Actor::New();
2087 actor.SetColorMode( USE_OWN_COLOR );
2088 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2090 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2091 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2093 actor.SetColorMode( USE_PARENT_COLOR );
2094 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2096 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2097 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2101 int UtcDaliActorScreenToLocal(void)
2103 TestApplication application;
2104 Actor actor = Actor::New();
2105 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2106 actor.SetSize(100.0f, 100.0f);
2107 actor.SetPosition(10.0f, 10.0f);
2108 Stage::GetCurrent().Add(actor);
2110 // flush the queue and render once
2111 application.SendNotification();
2112 application.Render();
2117 application.SendNotification();
2118 application.Render();
2120 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2122 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2123 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2127 int UtcDaliActorSetLeaveRequired(void)
2129 TestApplication application;
2131 Actor actor = Actor::New();
2133 actor.SetLeaveRequired(false);
2134 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2136 actor.SetLeaveRequired(true);
2137 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2141 int UtcDaliActorGetLeaveRequired(void)
2143 TestApplication application;
2145 Actor actor = Actor::New();
2147 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2151 int UtcDaliActorSetKeyboardFocusable(void)
2153 TestApplication application;
2155 Actor actor = Actor::New();
2157 actor.SetKeyboardFocusable(true);
2158 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2160 actor.SetKeyboardFocusable(false);
2161 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2165 int UtcDaliActorIsKeyboardFocusable(void)
2167 TestApplication application;
2169 Actor actor = Actor::New();
2171 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2175 int UtcDaliActorRemoveConstraints(void)
2177 tet_infoline(" UtcDaliActorRemoveConstraints");
2178 TestApplication application;
2180 gTestConstraintCalled = false;
2182 Actor actor = Actor::New();
2184 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2186 actor.RemoveConstraints();
2188 DALI_TEST_CHECK( gTestConstraintCalled == false );
2190 Stage::GetCurrent().Add( actor );
2193 // flush the queue and render once
2194 application.SendNotification();
2195 application.Render();
2197 actor.RemoveConstraints();
2199 DALI_TEST_CHECK( gTestConstraintCalled == true );
2203 int UtcDaliActorRemoveConstraintTag(void)
2205 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2206 TestApplication application;
2208 Actor actor = Actor::New();
2210 // 1. Apply Constraint1 and Constraint2, and test...
2211 unsigned int result1 = 0u;
2212 unsigned int result2 = 0u;
2214 unsigned constraint1Tag = 1u;
2215 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2216 constraint1.SetTag( constraint1Tag );
2217 constraint1.Apply();
2219 unsigned constraint2Tag = 2u;
2220 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2221 constraint2.SetTag( constraint2Tag );
2222 constraint2.Apply();
2224 Stage::GetCurrent().Add( actor );
2225 // flush the queue and render once
2226 application.SendNotification();
2227 application.Render();
2229 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2230 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2232 // 2. Remove Constraint1 and test...
2235 actor.RemoveConstraints(constraint1Tag);
2236 // make color property dirty, which will trigger constraints to be reapplied.
2237 actor.SetColor( Color::WHITE );
2238 // flush the queue and render once
2239 application.SendNotification();
2240 application.Render();
2242 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2243 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2245 // 3. Re-Apply Constraint1 and test...
2248 constraint1.Apply();
2249 // make color property dirty, which will trigger constraints to be reapplied.
2250 actor.SetColor( Color::WHITE );
2251 // flush the queue and render once
2252 application.SendNotification();
2253 application.Render();
2255 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2256 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2258 // 2. Remove Constraint2 and test...
2261 actor.RemoveConstraints(constraint2Tag);
2262 // make color property dirty, which will trigger constraints to be reapplied.
2263 actor.SetColor( Color::WHITE );
2264 // flush the queue and render once
2265 application.SendNotification();
2266 application.Render();
2268 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2269 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2271 // 2. Remove Constraint1 as well and test...
2274 actor.RemoveConstraints(constraint1Tag);
2275 // make color property dirty, which will trigger constraints to be reapplied.
2276 actor.SetColor( Color::WHITE );
2277 // flush the queue and render once
2278 application.SendNotification();
2279 application.Render();
2281 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2282 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2286 int UtcDaliActorTouchedSignal(void)
2288 TestApplication application;
2290 gTouchCallBackCalled = false;
2292 // get the root layer
2293 Actor actor = Stage::GetCurrent().GetRootLayer();
2294 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2296 application.SendNotification();
2297 application.Render();
2299 // connect to its touch signal
2300 actor.TouchedSignal().Connect( TestCallback );
2302 // simulate a touch event in the middle of the screen
2303 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2304 Dali::Integration::Point point;
2305 point.SetDeviceId( 1 );
2306 point.SetState( PointState::DOWN );
2307 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2308 Dali::Integration::TouchEvent event;
2309 event.AddPoint( point );
2310 application.ProcessEvent( event );
2312 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2316 int UtcDaliActorHoveredSignal(void)
2318 TestApplication application;
2320 gHoverCallBackCalled = false;
2322 // get the root layer
2323 Actor actor = Stage::GetCurrent().GetRootLayer();
2324 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2326 application.SendNotification();
2327 application.Render();
2329 // connect to its hover signal
2330 actor.HoveredSignal().Connect( TestCallback3 );
2332 // simulate a hover event in the middle of the screen
2333 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2334 Dali::Integration::Point point;
2335 point.SetDeviceId( 1 );
2336 point.SetState( PointState::MOTION );
2337 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2338 Dali::Integration::HoverEvent event;
2339 event.AddPoint( point );
2340 application.ProcessEvent( event );
2342 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2346 int UtcDaliActorOnOffStageSignal(void)
2348 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2350 TestApplication application;
2353 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2354 gActorNamesOnOffStage.clear();
2356 Actor parent = Actor::New();
2357 parent.SetName( "parent" );
2358 parent.OnStageSignal().Connect( OnStageCallback );
2359 parent.OffStageSignal().Connect( OffStageCallback );
2361 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2362 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2364 // add parent to stage
2365 Stage::GetCurrent().Add( parent );
2366 // onstage emitted, offstage not
2367 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2368 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2369 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2371 // test adding a child, should get onstage emitted
2373 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2374 gActorNamesOnOffStage.clear();
2376 Actor child = Actor::New();
2377 child.SetName( "child" );
2378 child.OnStageSignal().Connect( OnStageCallback );
2379 child.OffStageSignal().Connect( OffStageCallback );
2380 parent.Add( child ); // add child
2381 // onstage emitted, offstage not
2382 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2383 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2384 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2386 // test removing parent from stage
2388 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2389 gActorNamesOnOffStage.clear();
2391 Stage::GetCurrent().Remove( parent );
2392 // onstage not emitted, offstage is
2393 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2394 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2395 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2396 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2398 // test adding parent back to stage
2400 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2401 gActorNamesOnOffStage.clear();
2403 Stage::GetCurrent().Add( parent );
2404 // onstage emitted, offstage not
2405 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2406 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2407 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2408 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2410 // test removing child
2412 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2413 gActorNamesOnOffStage.clear();
2415 parent.Remove( child );
2416 // onstage not emitted, offstage is
2417 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2418 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2419 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2421 // test removing parent
2423 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2424 gActorNamesOnOffStage.clear();
2426 Stage::GetCurrent().Remove( parent );
2427 // onstage not emitted, offstage is
2428 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2429 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2430 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2434 int UtcDaliActorFindChildByName(void)
2436 tet_infoline("Testing Dali::Actor::FindChildByName()");
2437 TestApplication application;
2439 Actor parent = Actor::New();
2440 parent.SetName( "parent" );
2441 Actor first = Actor::New();
2442 first .SetName( "first" );
2443 Actor second = Actor::New();
2444 second.SetName( "second" );
2449 Actor found = parent.FindChildByName( "foo" );
2450 DALI_TEST_CHECK( !found );
2452 found = parent.FindChildByName( "parent" );
2453 DALI_TEST_CHECK( found == parent );
2455 found = parent.FindChildByName( "first" );
2456 DALI_TEST_CHECK( found == first );
2458 found = parent.FindChildByName( "second" );
2459 DALI_TEST_CHECK( found == second );
2463 int UtcDaliActorFindChildById(void)
2465 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2466 TestApplication application;
2468 Actor parent = Actor::New();
2469 Actor first = Actor::New();
2470 Actor second = Actor::New();
2475 Actor found = parent.FindChildById( 100000 );
2476 DALI_TEST_CHECK( !found );
2478 found = parent.FindChildById( parent.GetId() );
2479 DALI_TEST_CHECK( found == parent );
2481 found = parent.FindChildById( first.GetId() );
2482 DALI_TEST_CHECK( found == first );
2484 found = parent.FindChildById( second.GetId() );
2485 DALI_TEST_CHECK( found == second );
2489 int UtcDaliActorHitTest(void)
2494 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2496 mTouchPoint( touchPoint ),
2501 Vector2 mTouchPoint;
2505 TestApplication application;
2506 tet_infoline(" UtcDaliActorHitTest");
2508 // Fill a vector with different hit tests.
2509 struct HitTestData* hitTestData[] = {
2510 // scale touch point result
2511 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2512 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2513 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.
2514 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2515 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.
2519 // get the root layer
2520 Actor actor = Actor::New();
2521 actor.SetAnchorPoint( AnchorPoint::CENTER );
2522 actor.SetParentOrigin( ParentOrigin::CENTER );
2524 Stage::GetCurrent().Add( actor );
2526 gTouchCallBackCalled = false;
2528 unsigned int index = 0;
2529 while( NULL != hitTestData[index] )
2531 actor.SetSize( 1.f, 1.f );
2532 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2534 // flush the queue and render once
2535 application.SendNotification();
2536 application.Render();
2538 DALI_TEST_CHECK( !gTouchCallBackCalled );
2540 // connect to its touch signal
2541 actor.TouchedSignal().Connect(TestCallback);
2543 Dali::Integration::Point point;
2544 point.SetState( PointState::DOWN );
2545 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2546 Dali::Integration::TouchEvent event;
2547 event.AddPoint( point );
2549 // flush the queue and render once
2550 application.SendNotification();
2551 application.Render();
2552 application.ProcessEvent( event );
2554 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2556 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2557 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2558 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2559 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2560 hitTestData[index]->mResult );
2562 gTouchCallBackCalled = false;
2568 int UtcDaliActorSetDrawMode(void)
2570 TestApplication app;
2571 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2573 Actor a = Actor::New();
2575 Stage::GetCurrent().Add(a);
2576 app.SendNotification();
2578 app.SendNotification();
2581 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2583 a.SetDrawMode( DrawMode::OVERLAY_2D );
2584 app.SendNotification();
2587 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2589 a.SetDrawMode( DrawMode::NORMAL );
2590 app.SendNotification();
2593 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2597 int UtcDaliActorSetDrawModeOverlayRender(void)
2599 TestApplication app;
2600 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2602 app.SendNotification();
2605 std::vector<GLuint> ids;
2606 ids.push_back( 8 ); // first rendered actor
2607 ids.push_back( 9 ); // second rendered actor
2608 ids.push_back( 10 ); // third rendered actor
2609 app.GetGlAbstraction().SetNextTextureIds( ids );
2611 BufferImage imageA = BufferImage::New(16, 16);
2612 BufferImage imageB = BufferImage::New(16, 16);
2613 BufferImage imageC = BufferImage::New(16, 16);
2614 Actor a = CreateRenderableActor( imageA );
2615 Actor b = CreateRenderableActor( imageB );
2616 Actor c = CreateRenderableActor( imageC );
2618 app.SendNotification();
2621 //Textures are bound when first created. Clear bound textures vector
2622 app.GetGlAbstraction().ClearBoundTextures();
2624 // Render a,b,c as regular non-overlays. so order will be:
2628 Stage::GetCurrent().Add(a);
2629 Stage::GetCurrent().Add(b);
2630 Stage::GetCurrent().Add(c);
2632 app.SendNotification();
2635 // Should be 3 textures changes.
2636 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2637 typedef std::vector<GLuint>::size_type TextureSize;
2638 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2639 if( boundTextures.size() == 3 )
2641 DALI_TEST_CHECK( boundTextures[0] == 8u );
2642 DALI_TEST_CHECK( boundTextures[1] == 9u );
2643 DALI_TEST_CHECK( boundTextures[2] == 10u );
2646 // Now texture ids have been set, we can monitor their render order.
2647 // render a as an overlay (last), so order will be:
2651 a.SetDrawMode( DrawMode::OVERLAY_2D );
2652 app.GetGlAbstraction().ClearBoundTextures();
2654 app.SendNotification();
2657 // Should be 3 texture changes.
2658 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2659 if( boundTextures.size() == 3 )
2661 DALI_TEST_CHECK( boundTextures[0] == 9u );
2662 DALI_TEST_CHECK( boundTextures[1] == 10u );
2663 DALI_TEST_CHECK( boundTextures[2] == 8u );
2668 int UtcDaliActorGetCurrentWorldMatrix(void)
2670 TestApplication app;
2671 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2673 Actor parent = Actor::New();
2674 parent.SetParentOrigin(ParentOrigin::CENTER);
2675 parent.SetAnchorPoint(AnchorPoint::CENTER);
2676 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2677 Radian rotationAngle(Degree(85.0f));
2678 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2679 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2680 parent.SetPosition( parentPosition );
2681 parent.SetOrientation( parentRotation );
2682 parent.SetScale( parentScale );
2683 Stage::GetCurrent().Add( parent );
2685 Actor child = Actor::New();
2686 child.SetParentOrigin(ParentOrigin::CENTER);
2687 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2688 Radian childRotationAngle(Degree(23.0f));
2689 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2690 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2691 child.SetPosition( childPosition );
2692 child.SetOrientation( childRotation );
2693 child.SetScale( childScale );
2694 parent.Add( child );
2696 app.SendNotification();
2699 app.SendNotification();
2701 Matrix parentMatrix(false);
2702 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2704 Matrix childMatrix(false);
2705 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2707 //Child matrix should be the composition of child and parent
2708 Matrix childWorldMatrix(false);
2709 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2711 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2712 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2718 int UtcDaliActorConstrainedToWorldMatrix(void)
2720 TestApplication app;
2721 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2723 Actor parent = Actor::New();
2724 parent.SetParentOrigin(ParentOrigin::CENTER);
2725 parent.SetAnchorPoint(AnchorPoint::CENTER);
2726 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2727 Radian rotationAngle(Degree(85.0f));
2728 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2729 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2730 parent.SetPosition( parentPosition );
2731 parent.SetOrientation( parentRotation );
2732 parent.SetScale( parentScale );
2733 Stage::GetCurrent().Add( parent );
2735 Actor child = Actor::New();
2736 child.SetParentOrigin(ParentOrigin::CENTER);
2737 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2738 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2739 posConstraint.Apply();
2741 Stage::GetCurrent().Add( child );
2743 app.SendNotification();
2746 app.SendNotification();
2748 Matrix parentMatrix(false);
2749 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2751 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2752 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2756 int UtcDaliActorConstrainedToOrientation(void)
2758 TestApplication app;
2759 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2761 Actor parent = Actor::New();
2762 parent.SetParentOrigin(ParentOrigin::CENTER);
2763 parent.SetAnchorPoint(AnchorPoint::CENTER);
2764 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2765 Radian rotationAngle(Degree(85.0f));
2766 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2767 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2768 parent.SetPosition( parentPosition );
2769 parent.SetOrientation( parentRotation );
2770 parent.SetScale( parentScale );
2771 Stage::GetCurrent().Add( parent );
2773 Actor child = Actor::New();
2774 child.SetParentOrigin(ParentOrigin::CENTER);
2775 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2776 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2777 posConstraint.Apply();
2779 Stage::GetCurrent().Add( child );
2781 app.SendNotification();
2784 app.SendNotification();
2786 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2790 int UtcDaliActorConstrainedToOpacity(void)
2792 TestApplication app;
2793 tet_infoline(" UtcDaliActorConstrainedToOpacity");
2795 Actor parent = Actor::New();
2796 parent.SetOpacity( 0.7f );
2797 Stage::GetCurrent().Add( parent );
2799 Actor child = Actor::New();
2800 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2801 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2802 opacityConstraint.Apply();
2804 Stage::GetCurrent().Add( child );
2806 app.SendNotification();
2809 app.SendNotification();
2811 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2813 parent.SetOpacity( 0.3f );
2815 app.SendNotification();
2818 app.SendNotification();
2820 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2825 int UtcDaliActorUnparent(void)
2827 TestApplication app;
2828 tet_infoline(" UtcDaliActorUnparent");
2830 Actor parent = Actor::New();
2831 Stage::GetCurrent().Add( parent );
2833 Actor child = Actor::New();
2835 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2836 DALI_TEST_CHECK( !child.GetParent() );
2838 // Test that calling Unparent with no parent is a NOOP
2841 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2842 DALI_TEST_CHECK( !child.GetParent() );
2844 // Test that Unparent works
2845 parent.Add( child );
2847 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2848 DALI_TEST_CHECK( parent == child.GetParent() );
2852 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2853 DALI_TEST_CHECK( !child.GetParent() );
2855 // Test that UnparentAndReset works
2856 parent.Add( child );
2858 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2859 DALI_TEST_CHECK( parent == child.GetParent() );
2861 UnparentAndReset( child );
2863 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2864 DALI_TEST_CHECK( !child );
2866 // Test that UnparentAndReset is a NOOP with empty handle
2867 UnparentAndReset( child );
2869 DALI_TEST_CHECK( !child );
2873 int UtcDaliActorGetChildAt(void)
2875 TestApplication app;
2876 tet_infoline(" UtcDaliActorGetChildAt");
2878 Actor parent = Actor::New();
2879 Stage::GetCurrent().Add( parent );
2881 Actor child0 = Actor::New();
2882 parent.Add( child0 );
2884 Actor child1 = Actor::New();
2885 parent.Add( child1 );
2887 Actor child2 = Actor::New();
2888 parent.Add( child2 );
2890 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2891 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2892 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2896 int UtcDaliActorSetGetOverlay(void)
2898 TestApplication app;
2899 tet_infoline(" UtcDaliActorSetGetOverlay");
2901 Actor parent = Actor::New();
2902 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2903 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2908 int UtcDaliActorCreateDestroy(void)
2910 Actor* actor = new Actor;
2911 DALI_TEST_CHECK( actor );
2918 struct PropertyStringIndex
2920 const char * const name;
2921 const Property::Index index;
2922 const Property::Type type;
2925 const PropertyStringIndex PROPERTY_TABLE[] =
2927 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2928 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2929 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2930 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2931 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2932 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2933 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2934 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2935 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2936 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2937 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2938 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2939 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2940 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
2941 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
2942 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
2943 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2944 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2945 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2946 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2947 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2948 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2949 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2950 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
2951 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
2952 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
2953 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2954 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2955 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2956 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
2957 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
2958 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2959 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2960 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2961 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2962 { "name", Actor::Property::NAME, Property::STRING },
2963 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2964 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2965 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2966 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2967 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
2968 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2969 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
2970 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2971 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2972 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2973 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2974 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2975 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2976 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2977 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2978 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2979 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
2980 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
2981 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
2983 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2984 } // unnamed namespace
2986 int UtcDaliActorProperties(void)
2988 TestApplication app;
2990 Actor actor = Actor::New();
2992 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2994 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2995 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2996 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2997 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3002 int UtcDaliRelayoutProperties_ResizePolicies(void)
3004 TestApplication app;
3006 Actor actor = Actor::New();
3009 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3010 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3012 // Set resize policy for all dimensions
3013 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3014 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3016 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3019 // Set individual dimensions
3020 const char* const widthPolicy = "FILL_TO_PARENT";
3021 const char* const heightPolicy = "FIXED";
3023 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3024 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3026 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3027 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3029 // Set individual dimensions using enums
3030 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3031 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3033 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3034 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3036 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3037 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3042 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3044 TestApplication app;
3046 Actor actor = Actor::New();
3049 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3050 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3052 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3053 actor.SetSizeScalePolicy( policy );
3054 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3057 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3058 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3060 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3061 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3063 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3064 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3069 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3071 TestApplication app;
3073 Actor actor = Actor::New();
3076 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3077 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3079 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3080 actor.SetSizeModeFactor( sizeMode );
3081 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3084 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3086 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3087 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3092 int UtcDaliRelayoutProperties_DimensionDependency(void)
3094 TestApplication app;
3096 Actor actor = Actor::New();
3099 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3100 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3103 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3104 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3106 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3107 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3109 // Test setting another resize policy
3110 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3111 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3116 int UtcDaliRelayoutProperties_Padding(void)
3118 TestApplication app;
3120 Actor actor = Actor::New();
3123 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3126 actor.SetProperty( Actor::Property::PADDING, padding );
3127 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3129 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3134 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3136 TestApplication app;
3138 Actor actor = Actor::New();
3141 Vector2 minSize( 1.0f, 2.0f );
3143 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3144 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3146 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3148 Vector2 maxSize( 3.0f, 4.0f );
3150 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3151 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3153 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3158 int UtcDaliActorGetHeightForWidth(void)
3160 TestApplication app;
3162 Actor actor = Actor::New();
3164 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3169 int UtcDaliActorGetWidthForHeight(void)
3171 TestApplication app;
3173 Actor actor = Actor::New();
3175 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3180 int UtcDaliActorGetRelayoutSize(void)
3182 TestApplication app;
3184 Actor actor = Actor::New();
3186 // Add actor to stage
3187 Stage::GetCurrent().Add( actor );
3189 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3191 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3192 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3194 // Flush the queue and render once
3195 app.SendNotification();
3198 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3203 int UtcDaliActorSetPadding(void)
3205 TestApplication app;
3207 Actor actor = Actor::New();
3210 actor.GetPadding( padding );
3212 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3213 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3214 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3215 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3217 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3218 actor.SetPadding( padding2 );
3220 actor.GetPadding( padding );
3222 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3223 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3224 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3225 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3230 int UtcDaliActorSetMinimumSize(void)
3232 TestApplication app;
3234 Actor actor = Actor::New();
3236 Vector2 size = actor.GetMinimumSize();
3238 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3239 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3241 Vector2 size2( 1.0f, 2.0f );
3242 actor.SetMinimumSize( size2 );
3244 size = actor.GetMinimumSize();
3246 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3247 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3252 int UtcDaliActorSetMaximumSize(void)
3254 TestApplication app;
3256 Actor actor = Actor::New();
3258 Vector2 size = actor.GetMaximumSize();
3260 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3261 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3263 Vector2 size2( 1.0f, 2.0f );
3264 actor.SetMaximumSize( size2 );
3266 size = actor.GetMaximumSize();
3268 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3269 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3274 int UtcDaliActorOnRelayoutSignal(void)
3276 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3278 TestApplication application;
3281 gOnRelayoutCallBackCalled = false;
3282 gActorNamesRelayout.clear();
3284 Actor actor = Actor::New();
3285 actor.SetName( "actor" );
3286 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3289 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3291 // Add actor to stage
3292 Stage::GetCurrent().Add( actor );
3294 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3295 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3297 // Flush the queue and render once
3298 application.SendNotification();
3299 application.Render();
3301 // OnRelayout emitted
3302 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3303 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3308 int UtcDaliActorGetHierachyDepth(void)
3310 TestApplication application;
3311 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3314 /* Build tree of actors:
3324 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3326 Stage stage( Stage::GetCurrent() );
3328 Actor actorA = Actor::New();
3329 Actor actorB = Actor::New();
3330 Actor actorC = Actor::New();
3331 Actor actorD = Actor::New();
3332 Actor actorE = Actor::New();
3333 Actor actorF = Actor::New();
3335 //Test that root actor has depth equal 0
3336 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3338 //Test actors return depth -1 when not connected to the tree
3339 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3340 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3341 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3342 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3343 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3344 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3346 //Create the hierarchy
3347 stage.Add( actorA );
3348 actorA.Add( actorB );
3349 actorA.Add( actorC );
3350 actorB.Add( actorD );
3351 actorB.Add( actorE );
3352 actorC.Add( actorF );
3354 //Test actors return correct depth
3355 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3356 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3357 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3358 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3359 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3360 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3362 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3363 actorA.Remove( actorB );
3365 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3366 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3367 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3369 //Removing actorA from the stage. All actors should have depth equal -1
3370 stage.Remove( actorA );
3372 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3373 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3374 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3375 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3376 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3377 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3382 int UtcDaliActorAnchorPointPropertyAsString(void)
3384 TestApplication application;
3386 Actor actor = Actor::New();
3388 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3389 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3391 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3392 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3394 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3395 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3397 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3398 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3400 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3401 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3403 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3404 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3406 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3407 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3409 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3410 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3412 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3413 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3415 // Invalid should not change anything
3416 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3417 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3422 int UtcDaliActorParentOriginPropertyAsString(void)
3424 TestApplication application;
3426 Actor actor = Actor::New();
3428 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3429 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3431 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3432 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3434 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3435 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3437 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3438 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3440 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3441 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3443 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3444 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3446 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3447 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3449 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3450 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3452 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3453 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3455 // Invalid should not change anything
3456 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3457 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3462 int UtcDaliActorColorModePropertyAsString(void)
3464 TestApplication application;
3466 Actor actor = Actor::New();
3468 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3469 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3471 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3472 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3474 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3475 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3477 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3478 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3480 // Invalid should not change anything
3481 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3482 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3487 int UtcDaliActorPositionInheritancePropertyAsString(void)
3489 TestApplication application;
3491 Actor actor = Actor::New();
3493 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3494 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3496 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3497 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3499 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3500 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3502 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3503 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3505 // Invalid should not change anything
3506 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3507 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3512 int UtcDaliActorDrawModePropertyAsString(void)
3514 TestApplication application;
3516 Actor actor = Actor::New();
3518 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3519 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3521 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3522 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3524 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3525 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3527 // Invalid should not change anything
3528 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3529 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3534 int UtcDaliActorColorModePropertyAsEnum(void)
3536 TestApplication application;
3538 Actor actor = Actor::New();
3540 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3541 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3543 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3544 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3546 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3547 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3549 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3550 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3555 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3557 TestApplication application;
3559 Actor actor = Actor::New();
3561 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3562 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3564 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3565 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3567 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3568 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3570 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3571 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3576 int UtcDaliActorDrawModePropertyAsEnum(void)
3578 TestApplication application;
3580 Actor actor = Actor::New();
3582 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3583 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3585 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3586 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3588 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3589 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3594 int UtcDaliActorAddRendererP(void)
3596 tet_infoline("Testing Actor::AddRenderer");
3597 TestApplication application;
3599 Actor actor = Actor::New();
3601 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3603 Geometry geometry = CreateQuadGeometry();
3604 Shader shader = CreateShader();
3605 Renderer renderer = Renderer::New(geometry, shader);
3607 actor.AddRenderer( renderer );
3608 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3609 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3614 int UtcDaliActorAddRendererN(void)
3616 tet_infoline("Testing Actor::AddRenderer");
3617 TestApplication application;
3619 Actor actor = Actor::New();
3625 actor.AddRenderer( renderer );
3626 tet_printf("Assertion test failed - no Exception\n" );
3627 tet_result(TET_FAIL);
3629 catch(Dali::DaliException& e)
3631 DALI_TEST_PRINT_ASSERT( e );
3632 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3633 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3637 tet_printf("Assertion test failed - wrong Exception\n" );
3638 tet_result(TET_FAIL);
3644 int UtcDaliActorAddRendererOnStage(void)
3646 tet_infoline("Testing Actor::AddRenderer");
3647 TestApplication application;
3649 Actor actor = Actor::New();
3650 Stage::GetCurrent().Add(actor);
3652 application.SendNotification();
3653 application.Render(0);
3655 Geometry geometry = CreateQuadGeometry();
3656 Shader shader = CreateShader();
3657 Renderer renderer = Renderer::New(geometry, shader);
3659 application.SendNotification();
3660 application.Render(0);
3664 actor.AddRenderer( renderer );
3665 tet_result(TET_PASS);
3669 tet_result(TET_FAIL);
3675 int UtcDaliActorRemoveRendererP1(void)
3677 tet_infoline("Testing Actor::RemoveRenderer");
3678 TestApplication application;
3680 Actor actor = Actor::New();
3682 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3684 Geometry geometry = CreateQuadGeometry();
3685 Shader shader = CreateShader();
3686 Renderer renderer = Renderer::New(geometry, shader);
3688 actor.AddRenderer( renderer );
3689 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3690 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3692 actor.RemoveRenderer(renderer);
3693 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3699 int UtcDaliActorRemoveRendererP2(void)
3701 tet_infoline("Testing Actor::RemoveRenderer");
3702 TestApplication application;
3704 Actor actor = Actor::New();
3706 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3708 Geometry geometry = CreateQuadGeometry();
3709 Shader shader = CreateShader();
3710 Renderer renderer = Renderer::New(geometry, shader);
3712 actor.AddRenderer( renderer );
3713 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3714 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3716 actor.RemoveRenderer(0);
3717 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3724 int UtcDaliActorRemoveRendererN(void)
3726 tet_infoline("Testing Actor::RemoveRenderer");
3727 TestApplication application;
3729 Actor actor = Actor::New();
3731 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3733 Geometry geometry = CreateQuadGeometry();
3734 Shader shader = CreateShader();
3735 Renderer renderer = Renderer::New(geometry, shader);
3737 actor.AddRenderer( renderer );
3738 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3739 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3741 actor.RemoveRenderer(10);
3742 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3743 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3748 // Clipping test helper functions:
3749 Actor CreateActorWithContent()
3751 BufferImage image = BufferImage::New( 16u, 16u );
3752 Actor actor = CreateRenderableActor( image );
3754 // Setup dimensions and position so actor is not skipped by culling.
3755 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3756 actor.SetSize( 16.0f, 16.0f );
3757 actor.SetParentOrigin( ParentOrigin::CENTER );
3758 actor.SetAnchorPoint( AnchorPoint::CENTER );
3763 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3765 enabledDisableTrace.Reset();
3766 stencilTrace.Reset();
3767 enabledDisableTrace.Enable( true );
3768 stencilTrace.Enable( true );
3770 application.SendNotification();
3771 application.Render();
3773 enabledDisableTrace.Enable( false );
3774 stencilTrace.Enable( false );
3777 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3779 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3781 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3782 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3783 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3784 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3787 int UtcDaliActorPropertyClippingP(void)
3789 // This test checks the clippingMode property.
3790 tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3791 TestApplication application;
3793 Actor actor = Actor::New();
3795 // Check default clippingEnabled value.
3796 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3799 bool getValueResult = getValue.Get( value );
3800 DALI_TEST_CHECK( getValueResult );
3802 if( getValueResult )
3804 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3807 // Check setting the property.
3808 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3810 // Check the new value was set.
3811 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3812 getValueResult = getValue.Get( value );
3813 DALI_TEST_CHECK( getValueResult );
3815 if( getValueResult )
3817 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3823 int UtcDaliActorPropertyClippingN(void)
3825 // Negative test case for Clipping.
3826 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3827 TestApplication application;
3829 Actor actor = Actor::New();
3831 // Check default clippingEnabled value.
3832 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3835 bool getValueResult = getValue.Get( value );
3836 DALI_TEST_CHECK( getValueResult );
3838 if( getValueResult )
3840 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3843 // Check setting an invalid property value won't change the current property value.
3844 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3846 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3847 getValueResult = getValue.Get( value );
3848 DALI_TEST_CHECK( getValueResult );
3850 if( getValueResult )
3852 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3858 int UtcDaliActorPropertyClippingActor(void)
3860 // This test checks that an actor is correctly setup for clipping.
3861 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3862 TestApplication application;
3864 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3865 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3866 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3867 size_t startIndex = 0u;
3869 // Create a clipping actor.
3870 Actor actorDepth1Clip = CreateActorWithContent();
3871 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3872 Stage::GetCurrent().Add( actorDepth1Clip );
3874 // Gather the call trace.
3875 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3877 // Check we are writing to the color buffer.
3878 CheckColorMask( glAbstraction, true );
3880 // Check the stencil buffer was enabled.
3881 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3883 // Check the stencil buffer was cleared.
3884 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3886 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3887 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3888 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3889 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3894 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
3896 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
3897 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
3898 TestApplication application;
3900 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3901 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3902 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3903 size_t startIndex = 0u;
3905 // Create a clipping actor.
3906 Actor actorDepth1Clip = CreateActorWithContent();
3907 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3908 Stage::GetCurrent().Add( actorDepth1Clip );
3910 // Gather the call trace.
3911 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3913 // Check we are writing to the color buffer.
3914 CheckColorMask( glAbstraction, true );
3916 // Check the stencil buffer was enabled.
3917 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3919 // Check the stencil buffer was cleared.
3920 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3922 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3923 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3924 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3925 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3927 // Now disable the clipping
3928 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
3930 // Gather the call trace.
3931 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3933 // Check the stencil buffer was disabled.
3934 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3936 // Ensure all values in stencil-mask are set to 1.
3938 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
3944 int UtcDaliActorPropertyClippingNestedChildren(void)
3946 // This test checks that a hierarchy of actors are clipped correctly by
3947 // writing to and reading from the correct bit-planes of the stencil buffer.
3948 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
3949 TestApplication application;
3950 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3951 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3952 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3954 // Create a clipping actor.
3955 Actor actorDepth1Clip = CreateActorWithContent();
3956 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3957 Stage::GetCurrent().Add( actorDepth1Clip );
3959 // Create a child actor.
3960 Actor childDepth2 = CreateActorWithContent();
3961 actorDepth1Clip.Add( childDepth2 );
3963 // Create another clipping actor.
3964 Actor childDepth2Clip = CreateActorWithContent();
3965 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3966 childDepth2.Add( childDepth2Clip );
3968 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
3969 // This tests the sort algorithm.
3970 Actor childDepth3 = CreateActorWithContent();
3971 childDepth2Clip.Add( childDepth3 );
3972 Actor childDepth4 = CreateActorWithContent();
3973 childDepth3.Add( childDepth4 );
3975 // Gather the call trace.
3976 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3978 // Check we are writing to the color buffer.
3979 CheckColorMask( glAbstraction, true );
3981 // Check the stencil buffer was enabled.
3982 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3984 // Perform the test twice, once for 2D layer, and once for 3D.
3985 for( unsigned int i = 0u ; i < 2u; ++i )
3987 size_t startIndex = 0u;
3989 // Check the stencil buffer was cleared.
3990 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3992 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3993 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3994 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
3995 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3997 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
3998 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
3999 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4001 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4002 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4003 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4004 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4006 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4007 // (Both must be set to pass the check).
4008 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4009 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4011 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4014 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4015 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4022 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4024 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4025 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4026 TestApplication application;
4028 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4029 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4030 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4032 // Create a clipping actor.
4033 Actor actorDepth1Clip = CreateActorWithContent();
4034 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4035 Stage::GetCurrent().Add( actorDepth1Clip );
4037 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4038 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4040 // Gather the call trace.
4041 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4043 // Check we are writing to the color buffer.
4044 CheckColorMask( glAbstraction, true );
4046 // Check the stencil buffer was not enabled.
4047 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4049 // Check stencil functions are not called.
4050 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4051 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4052 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4057 int UtcDaliGetPropertyN(void)
4059 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4060 TestApplication app;
4062 Actor actor = Actor::New();
4064 unsigned int propertyCount = actor.GetPropertyCount();
4065 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );