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 );
1998 int UtcDaliActorGetCurrentColor(void)
2000 TestApplication application;
2001 Actor actor = Actor::New();
2002 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2004 actor.SetColor(color);
2005 // flush the queue and render once
2006 application.SendNotification();
2007 application.Render();
2008 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2012 int UtcDaliActorGetCurrentWorldColor(void)
2014 tet_infoline("Actor::GetCurrentWorldColor");
2015 TestApplication application;
2017 Actor parent = Actor::New();
2018 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2019 parent.SetColor( parentColor );
2020 Stage::GetCurrent().Add( parent );
2022 Actor child = Actor::New();
2023 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2024 child.SetColor( childColor );
2025 parent.Add( child );
2027 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2028 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2030 // verify the default color mode
2031 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2033 // The actors should not have a world color yet
2034 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2035 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2037 application.SendNotification();
2038 application.Render(0);
2040 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2041 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2043 // The actors should have a world color now
2044 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2045 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2048 child.SetColorMode( USE_OWN_COLOR );
2049 application.SendNotification();
2050 application.Render(0);
2051 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2054 child.SetColorMode( USE_PARENT_COLOR );
2055 application.SendNotification();
2056 application.Render(0);
2057 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2058 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2061 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2062 application.SendNotification();
2063 application.Render(0);
2064 Vector4 expectedColor( childColor );
2065 expectedColor.a *= parentColor.a;
2066 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2067 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2071 int UtcDaliActorSetColorMode(void)
2073 tet_infoline("Actor::SetColorMode");
2074 TestApplication application;
2075 Actor actor = Actor::New();
2076 Actor child = Actor::New();
2079 actor.SetColorMode( USE_OWN_COLOR );
2080 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2082 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2083 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2085 actor.SetColorMode( USE_PARENT_COLOR );
2086 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2088 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2089 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2093 int UtcDaliActorScreenToLocal(void)
2095 TestApplication application;
2096 Actor actor = Actor::New();
2097 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2098 actor.SetSize(100.0f, 100.0f);
2099 actor.SetPosition(10.0f, 10.0f);
2100 Stage::GetCurrent().Add(actor);
2102 // flush the queue and render once
2103 application.SendNotification();
2104 application.Render();
2109 application.SendNotification();
2110 application.Render();
2112 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2114 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2115 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2119 int UtcDaliActorSetLeaveRequired(void)
2121 TestApplication application;
2123 Actor actor = Actor::New();
2125 actor.SetLeaveRequired(false);
2126 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2128 actor.SetLeaveRequired(true);
2129 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2133 int UtcDaliActorGetLeaveRequired(void)
2135 TestApplication application;
2137 Actor actor = Actor::New();
2139 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2143 int UtcDaliActorSetKeyboardFocusable(void)
2145 TestApplication application;
2147 Actor actor = Actor::New();
2149 actor.SetKeyboardFocusable(true);
2150 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2152 actor.SetKeyboardFocusable(false);
2153 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2157 int UtcDaliActorIsKeyboardFocusable(void)
2159 TestApplication application;
2161 Actor actor = Actor::New();
2163 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2167 int UtcDaliActorRemoveConstraints(void)
2169 tet_infoline(" UtcDaliActorRemoveConstraints");
2170 TestApplication application;
2172 gTestConstraintCalled = false;
2174 Actor actor = Actor::New();
2176 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2178 actor.RemoveConstraints();
2180 DALI_TEST_CHECK( gTestConstraintCalled == false );
2182 Stage::GetCurrent().Add( actor );
2185 // flush the queue and render once
2186 application.SendNotification();
2187 application.Render();
2189 actor.RemoveConstraints();
2191 DALI_TEST_CHECK( gTestConstraintCalled == true );
2195 int UtcDaliActorRemoveConstraintTag(void)
2197 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2198 TestApplication application;
2200 Actor actor = Actor::New();
2202 // 1. Apply Constraint1 and Constraint2, and test...
2203 unsigned int result1 = 0u;
2204 unsigned int result2 = 0u;
2206 unsigned constraint1Tag = 1u;
2207 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2208 constraint1.SetTag( constraint1Tag );
2209 constraint1.Apply();
2211 unsigned constraint2Tag = 2u;
2212 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2213 constraint2.SetTag( constraint2Tag );
2214 constraint2.Apply();
2216 Stage::GetCurrent().Add( actor );
2217 // flush the queue and render once
2218 application.SendNotification();
2219 application.Render();
2221 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2222 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2224 // 2. Remove Constraint1 and test...
2227 actor.RemoveConstraints(constraint1Tag);
2228 // make color property dirty, which will trigger constraints to be reapplied.
2229 actor.SetColor( Color::WHITE );
2230 // flush the queue and render once
2231 application.SendNotification();
2232 application.Render();
2234 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2235 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2237 // 3. Re-Apply Constraint1 and test...
2240 constraint1.Apply();
2241 // make color property dirty, which will trigger constraints to be reapplied.
2242 actor.SetColor( Color::WHITE );
2243 // flush the queue and render once
2244 application.SendNotification();
2245 application.Render();
2247 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2248 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2250 // 2. Remove Constraint2 and test...
2253 actor.RemoveConstraints(constraint2Tag);
2254 // make color property dirty, which will trigger constraints to be reapplied.
2255 actor.SetColor( Color::WHITE );
2256 // flush the queue and render once
2257 application.SendNotification();
2258 application.Render();
2260 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2261 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2263 // 2. Remove Constraint1 as well and test...
2266 actor.RemoveConstraints(constraint1Tag);
2267 // make color property dirty, which will trigger constraints to be reapplied.
2268 actor.SetColor( Color::WHITE );
2269 // flush the queue and render once
2270 application.SendNotification();
2271 application.Render();
2273 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2274 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2278 int UtcDaliActorTouchedSignal(void)
2280 TestApplication application;
2282 gTouchCallBackCalled = false;
2284 // get the root layer
2285 Actor actor = Stage::GetCurrent().GetRootLayer();
2286 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2288 application.SendNotification();
2289 application.Render();
2291 // connect to its touch signal
2292 actor.TouchedSignal().Connect( TestCallback );
2294 // simulate a touch event in the middle of the screen
2295 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2296 Dali::Integration::Point point;
2297 point.SetDeviceId( 1 );
2298 point.SetState( PointState::DOWN );
2299 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2300 Dali::Integration::TouchEvent event;
2301 event.AddPoint( point );
2302 application.ProcessEvent( event );
2304 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2308 int UtcDaliActorHoveredSignal(void)
2310 TestApplication application;
2312 gHoverCallBackCalled = false;
2314 // get the root layer
2315 Actor actor = Stage::GetCurrent().GetRootLayer();
2316 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2318 application.SendNotification();
2319 application.Render();
2321 // connect to its hover signal
2322 actor.HoveredSignal().Connect( TestCallback3 );
2324 // simulate a hover event in the middle of the screen
2325 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2326 Dali::Integration::Point point;
2327 point.SetDeviceId( 1 );
2328 point.SetState( PointState::MOTION );
2329 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2330 Dali::Integration::HoverEvent event;
2331 event.AddPoint( point );
2332 application.ProcessEvent( event );
2334 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2338 int UtcDaliActorOnOffStageSignal(void)
2340 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2342 TestApplication application;
2345 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2346 gActorNamesOnOffStage.clear();
2348 Actor parent = Actor::New();
2349 parent.SetName( "parent" );
2350 parent.OnStageSignal().Connect( OnStageCallback );
2351 parent.OffStageSignal().Connect( OffStageCallback );
2353 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2354 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2356 // add parent to stage
2357 Stage::GetCurrent().Add( parent );
2358 // onstage emitted, offstage not
2359 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2360 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2361 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2363 // test adding a child, should get onstage emitted
2365 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2366 gActorNamesOnOffStage.clear();
2368 Actor child = Actor::New();
2369 child.SetName( "child" );
2370 child.OnStageSignal().Connect( OnStageCallback );
2371 child.OffStageSignal().Connect( OffStageCallback );
2372 parent.Add( child ); // add child
2373 // onstage emitted, offstage not
2374 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2375 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2376 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2378 // test removing parent from stage
2380 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2381 gActorNamesOnOffStage.clear();
2383 Stage::GetCurrent().Remove( parent );
2384 // onstage not emitted, offstage is
2385 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2386 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2387 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2388 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2390 // test adding parent back to stage
2392 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2393 gActorNamesOnOffStage.clear();
2395 Stage::GetCurrent().Add( parent );
2396 // onstage emitted, offstage not
2397 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2398 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2399 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2400 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2402 // test removing child
2404 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2405 gActorNamesOnOffStage.clear();
2407 parent.Remove( child );
2408 // onstage not emitted, offstage is
2409 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2410 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2411 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2413 // test removing parent
2415 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2416 gActorNamesOnOffStage.clear();
2418 Stage::GetCurrent().Remove( parent );
2419 // onstage not emitted, offstage is
2420 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2421 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2422 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2426 int UtcDaliActorFindChildByName(void)
2428 tet_infoline("Testing Dali::Actor::FindChildByName()");
2429 TestApplication application;
2431 Actor parent = Actor::New();
2432 parent.SetName( "parent" );
2433 Actor first = Actor::New();
2434 first .SetName( "first" );
2435 Actor second = Actor::New();
2436 second.SetName( "second" );
2441 Actor found = parent.FindChildByName( "foo" );
2442 DALI_TEST_CHECK( !found );
2444 found = parent.FindChildByName( "parent" );
2445 DALI_TEST_CHECK( found == parent );
2447 found = parent.FindChildByName( "first" );
2448 DALI_TEST_CHECK( found == first );
2450 found = parent.FindChildByName( "second" );
2451 DALI_TEST_CHECK( found == second );
2455 int UtcDaliActorFindChildById(void)
2457 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2458 TestApplication application;
2460 Actor parent = Actor::New();
2461 Actor first = Actor::New();
2462 Actor second = Actor::New();
2467 Actor found = parent.FindChildById( 100000 );
2468 DALI_TEST_CHECK( !found );
2470 found = parent.FindChildById( parent.GetId() );
2471 DALI_TEST_CHECK( found == parent );
2473 found = parent.FindChildById( first.GetId() );
2474 DALI_TEST_CHECK( found == first );
2476 found = parent.FindChildById( second.GetId() );
2477 DALI_TEST_CHECK( found == second );
2481 int UtcDaliActorHitTest(void)
2486 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2488 mTouchPoint( touchPoint ),
2493 Vector2 mTouchPoint;
2497 TestApplication application;
2498 tet_infoline(" UtcDaliActorHitTest");
2500 // Fill a vector with different hit tests.
2501 struct HitTestData* hitTestData[] = {
2502 // scale touch point result
2503 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2504 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2505 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.
2506 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2507 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.
2511 // get the root layer
2512 Actor actor = Actor::New();
2513 actor.SetAnchorPoint( AnchorPoint::CENTER );
2514 actor.SetParentOrigin( ParentOrigin::CENTER );
2516 Stage::GetCurrent().Add( actor );
2518 gTouchCallBackCalled = false;
2520 unsigned int index = 0;
2521 while( NULL != hitTestData[index] )
2523 actor.SetSize( 1.f, 1.f );
2524 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2526 // flush the queue and render once
2527 application.SendNotification();
2528 application.Render();
2530 DALI_TEST_CHECK( !gTouchCallBackCalled );
2532 // connect to its touch signal
2533 actor.TouchedSignal().Connect(TestCallback);
2535 Dali::Integration::Point point;
2536 point.SetState( PointState::DOWN );
2537 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2538 Dali::Integration::TouchEvent event;
2539 event.AddPoint( point );
2541 // flush the queue and render once
2542 application.SendNotification();
2543 application.Render();
2544 application.ProcessEvent( event );
2546 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2548 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2549 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2550 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2551 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2552 hitTestData[index]->mResult );
2554 gTouchCallBackCalled = false;
2560 int UtcDaliActorSetDrawMode(void)
2562 TestApplication app;
2563 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2565 Actor a = Actor::New();
2567 Stage::GetCurrent().Add(a);
2568 app.SendNotification();
2570 app.SendNotification();
2573 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2575 a.SetDrawMode( DrawMode::OVERLAY_2D );
2576 app.SendNotification();
2579 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2581 a.SetDrawMode( DrawMode::NORMAL );
2582 app.SendNotification();
2585 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2589 int UtcDaliActorSetDrawModeOverlayRender(void)
2591 TestApplication app;
2592 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2594 app.SendNotification();
2597 std::vector<GLuint> ids;
2598 ids.push_back( 8 ); // first rendered actor
2599 ids.push_back( 9 ); // second rendered actor
2600 ids.push_back( 10 ); // third rendered actor
2601 app.GetGlAbstraction().SetNextTextureIds( ids );
2603 BufferImage imageA = BufferImage::New(16, 16);
2604 BufferImage imageB = BufferImage::New(16, 16);
2605 BufferImage imageC = BufferImage::New(16, 16);
2606 Actor a = CreateRenderableActor( imageA );
2607 Actor b = CreateRenderableActor( imageB );
2608 Actor c = CreateRenderableActor( imageC );
2610 app.SendNotification();
2613 //Textures are bound when first created. Clear bound textures vector
2614 app.GetGlAbstraction().ClearBoundTextures();
2616 // Render a,b,c as regular non-overlays. so order will be:
2620 Stage::GetCurrent().Add(a);
2621 Stage::GetCurrent().Add(b);
2622 Stage::GetCurrent().Add(c);
2624 app.SendNotification();
2627 // Should be 3 textures changes.
2628 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2629 typedef std::vector<GLuint>::size_type TextureSize;
2630 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2631 if( boundTextures.size() == 3 )
2633 DALI_TEST_CHECK( boundTextures[0] == 8u );
2634 DALI_TEST_CHECK( boundTextures[1] == 9u );
2635 DALI_TEST_CHECK( boundTextures[2] == 10u );
2638 // Now texture ids have been set, we can monitor their render order.
2639 // render a as an overlay (last), so order will be:
2643 a.SetDrawMode( DrawMode::OVERLAY_2D );
2644 app.GetGlAbstraction().ClearBoundTextures();
2646 app.SendNotification();
2649 // Should be 3 texture changes.
2650 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2651 if( boundTextures.size() == 3 )
2653 DALI_TEST_CHECK( boundTextures[0] == 9u );
2654 DALI_TEST_CHECK( boundTextures[1] == 10u );
2655 DALI_TEST_CHECK( boundTextures[2] == 8u );
2660 int UtcDaliActorGetCurrentWorldMatrix(void)
2662 TestApplication app;
2663 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2665 Actor parent = Actor::New();
2666 parent.SetParentOrigin(ParentOrigin::CENTER);
2667 parent.SetAnchorPoint(AnchorPoint::CENTER);
2668 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2669 Radian rotationAngle(Degree(85.0f));
2670 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2671 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2672 parent.SetPosition( parentPosition );
2673 parent.SetOrientation( parentRotation );
2674 parent.SetScale( parentScale );
2675 Stage::GetCurrent().Add( parent );
2677 Actor child = Actor::New();
2678 child.SetParentOrigin(ParentOrigin::CENTER);
2679 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2680 Radian childRotationAngle(Degree(23.0f));
2681 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2682 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2683 child.SetPosition( childPosition );
2684 child.SetOrientation( childRotation );
2685 child.SetScale( childScale );
2686 parent.Add( child );
2688 app.SendNotification();
2691 app.SendNotification();
2693 Matrix parentMatrix(false);
2694 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2696 Matrix childMatrix(false);
2697 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2699 //Child matrix should be the composition of child and parent
2700 Matrix childWorldMatrix(false);
2701 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2703 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2704 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2710 int UtcDaliActorConstrainedToWorldMatrix(void)
2712 TestApplication app;
2713 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2715 Actor parent = Actor::New();
2716 parent.SetParentOrigin(ParentOrigin::CENTER);
2717 parent.SetAnchorPoint(AnchorPoint::CENTER);
2718 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2719 Radian rotationAngle(Degree(85.0f));
2720 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2721 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2722 parent.SetPosition( parentPosition );
2723 parent.SetOrientation( parentRotation );
2724 parent.SetScale( parentScale );
2725 Stage::GetCurrent().Add( parent );
2727 Actor child = Actor::New();
2728 child.SetParentOrigin(ParentOrigin::CENTER);
2729 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2730 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2731 posConstraint.Apply();
2733 Stage::GetCurrent().Add( child );
2735 app.SendNotification();
2738 app.SendNotification();
2740 Matrix parentMatrix(false);
2741 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2743 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2744 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2748 int UtcDaliActorConstrainedToOrientation(void)
2750 TestApplication app;
2751 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2753 Actor parent = Actor::New();
2754 parent.SetParentOrigin(ParentOrigin::CENTER);
2755 parent.SetAnchorPoint(AnchorPoint::CENTER);
2756 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2757 Radian rotationAngle(Degree(85.0f));
2758 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2759 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2760 parent.SetPosition( parentPosition );
2761 parent.SetOrientation( parentRotation );
2762 parent.SetScale( parentScale );
2763 Stage::GetCurrent().Add( parent );
2765 Actor child = Actor::New();
2766 child.SetParentOrigin(ParentOrigin::CENTER);
2767 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2768 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2769 posConstraint.Apply();
2771 Stage::GetCurrent().Add( child );
2773 app.SendNotification();
2776 app.SendNotification();
2778 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2782 int UtcDaliActorUnparent(void)
2784 TestApplication app;
2785 tet_infoline(" UtcDaliActorUnparent");
2787 Actor parent = Actor::New();
2788 Stage::GetCurrent().Add( parent );
2790 Actor child = Actor::New();
2792 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2793 DALI_TEST_CHECK( !child.GetParent() );
2795 // Test that calling Unparent with no parent is a NOOP
2798 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2799 DALI_TEST_CHECK( !child.GetParent() );
2801 // Test that Unparent works
2802 parent.Add( child );
2804 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2805 DALI_TEST_CHECK( parent == child.GetParent() );
2809 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2810 DALI_TEST_CHECK( !child.GetParent() );
2812 // Test that UnparentAndReset works
2813 parent.Add( child );
2815 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2816 DALI_TEST_CHECK( parent == child.GetParent() );
2818 UnparentAndReset( child );
2820 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2821 DALI_TEST_CHECK( !child );
2823 // Test that UnparentAndReset is a NOOP with empty handle
2824 UnparentAndReset( child );
2826 DALI_TEST_CHECK( !child );
2830 int UtcDaliActorGetChildAt(void)
2832 TestApplication app;
2833 tet_infoline(" UtcDaliActorGetChildAt");
2835 Actor parent = Actor::New();
2836 Stage::GetCurrent().Add( parent );
2838 Actor child0 = Actor::New();
2839 parent.Add( child0 );
2841 Actor child1 = Actor::New();
2842 parent.Add( child1 );
2844 Actor child2 = Actor::New();
2845 parent.Add( child2 );
2847 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2848 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2849 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2853 int UtcDaliActorSetGetOverlay(void)
2855 TestApplication app;
2856 tet_infoline(" UtcDaliActorSetGetOverlay");
2858 Actor parent = Actor::New();
2859 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2860 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2865 int UtcDaliActorCreateDestroy(void)
2867 Actor* actor = new Actor;
2868 DALI_TEST_CHECK( actor );
2875 struct PropertyStringIndex
2877 const char * const name;
2878 const Property::Index index;
2879 const Property::Type type;
2882 const PropertyStringIndex PROPERTY_TABLE[] =
2884 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2885 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2886 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2887 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2888 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2889 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2890 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2891 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2892 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2893 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2894 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2895 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2896 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2897 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
2898 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
2899 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
2900 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2901 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2902 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2903 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2904 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2905 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2906 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2907 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
2908 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
2909 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
2910 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2911 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2912 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2913 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
2914 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
2915 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2916 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2917 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2918 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2919 { "name", Actor::Property::NAME, Property::STRING },
2920 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2921 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2922 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2923 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2924 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
2925 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
2926 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
2927 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
2928 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
2929 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
2930 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
2931 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
2932 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
2933 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
2934 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
2935 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
2936 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
2937 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
2939 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
2940 } // unnamed namespace
2942 int UtcDaliActorProperties(void)
2944 TestApplication app;
2946 Actor actor = Actor::New();
2948 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
2950 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
2951 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
2952 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
2953 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
2958 int UtcDaliRelayoutProperties_ResizePolicies(void)
2960 TestApplication app;
2962 Actor actor = Actor::New();
2965 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2966 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
2968 // Set resize policy for all dimensions
2969 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
2970 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
2972 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
2975 // Set individual dimensions
2976 const char* const widthPolicy = "FILL_TO_PARENT";
2977 const char* const heightPolicy = "FIXED";
2979 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
2980 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
2982 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
2983 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
2985 // Set individual dimensions using enums
2986 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
2987 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
2989 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
2990 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
2992 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
2993 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
2998 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3000 TestApplication app;
3002 Actor actor = Actor::New();
3005 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3006 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3008 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3009 actor.SetSizeScalePolicy( policy );
3010 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3013 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3014 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3016 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3017 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3019 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3020 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3025 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3027 TestApplication app;
3029 Actor actor = Actor::New();
3032 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3033 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3035 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3036 actor.SetSizeModeFactor( sizeMode );
3037 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3040 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3042 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3043 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3048 int UtcDaliRelayoutProperties_DimensionDependency(void)
3050 TestApplication app;
3052 Actor actor = Actor::New();
3055 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3056 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3059 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3060 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3062 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3063 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3065 // Test setting another resize policy
3066 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3067 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3072 int UtcDaliRelayoutProperties_Padding(void)
3074 TestApplication app;
3076 Actor actor = Actor::New();
3079 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3082 actor.SetProperty( Actor::Property::PADDING, padding );
3083 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3085 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3090 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3092 TestApplication app;
3094 Actor actor = Actor::New();
3097 Vector2 minSize( 1.0f, 2.0f );
3099 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3100 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3102 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3104 Vector2 maxSize( 3.0f, 4.0f );
3106 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3107 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3109 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3114 int UtcDaliActorGetHeightForWidth(void)
3116 TestApplication app;
3118 Actor actor = Actor::New();
3120 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3125 int UtcDaliActorGetWidthForHeight(void)
3127 TestApplication app;
3129 Actor actor = Actor::New();
3131 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3136 int UtcDaliActorGetRelayoutSize(void)
3138 TestApplication app;
3140 Actor actor = Actor::New();
3142 // Add actor to stage
3143 Stage::GetCurrent().Add( actor );
3145 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3147 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3148 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3150 // Flush the queue and render once
3151 app.SendNotification();
3154 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3159 int UtcDaliActorSetPadding(void)
3161 TestApplication app;
3163 Actor actor = Actor::New();
3166 actor.GetPadding( padding );
3168 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3169 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3170 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3171 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3173 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3174 actor.SetPadding( padding2 );
3176 actor.GetPadding( padding );
3178 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3179 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3180 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3181 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3186 int UtcDaliActorSetMinimumSize(void)
3188 TestApplication app;
3190 Actor actor = Actor::New();
3192 Vector2 size = actor.GetMinimumSize();
3194 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3195 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3197 Vector2 size2( 1.0f, 2.0f );
3198 actor.SetMinimumSize( size2 );
3200 size = actor.GetMinimumSize();
3202 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3203 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3208 int UtcDaliActorSetMaximumSize(void)
3210 TestApplication app;
3212 Actor actor = Actor::New();
3214 Vector2 size = actor.GetMaximumSize();
3216 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3217 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3219 Vector2 size2( 1.0f, 2.0f );
3220 actor.SetMaximumSize( size2 );
3222 size = actor.GetMaximumSize();
3224 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3225 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3230 int UtcDaliActorOnRelayoutSignal(void)
3232 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3234 TestApplication application;
3237 gOnRelayoutCallBackCalled = false;
3238 gActorNamesRelayout.clear();
3240 Actor actor = Actor::New();
3241 actor.SetName( "actor" );
3242 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3245 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3247 // Add actor to stage
3248 Stage::GetCurrent().Add( actor );
3250 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3251 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3253 // Flush the queue and render once
3254 application.SendNotification();
3255 application.Render();
3257 // OnRelayout emitted
3258 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3259 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3264 int UtcDaliActorGetHierachyDepth(void)
3266 TestApplication application;
3267 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3270 /* Build tree of actors:
3280 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3282 Stage stage( Stage::GetCurrent() );
3284 Actor actorA = Actor::New();
3285 Actor actorB = Actor::New();
3286 Actor actorC = Actor::New();
3287 Actor actorD = Actor::New();
3288 Actor actorE = Actor::New();
3289 Actor actorF = Actor::New();
3291 //Test that root actor has depth equal 0
3292 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3294 //Test actors return depth -1 when not connected to the tree
3295 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3296 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3297 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3298 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3299 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3300 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3302 //Create the hierarchy
3303 stage.Add( actorA );
3304 actorA.Add( actorB );
3305 actorA.Add( actorC );
3306 actorB.Add( actorD );
3307 actorB.Add( actorE );
3308 actorC.Add( actorF );
3310 //Test actors return correct depth
3311 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3312 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3313 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3314 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3315 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3316 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3318 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3319 actorA.Remove( actorB );
3321 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3322 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3323 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3325 //Removing actorA from the stage. All actors should have depth equal -1
3326 stage.Remove( actorA );
3328 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3329 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3330 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3331 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3332 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3333 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3338 int UtcDaliActorAnchorPointPropertyAsString(void)
3340 TestApplication application;
3342 Actor actor = Actor::New();
3344 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3345 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3347 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3348 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3350 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3351 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3353 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3354 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3356 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3357 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3359 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3360 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3362 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3363 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3365 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3366 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3368 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3369 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3371 // Invalid should not change anything
3372 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3373 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3378 int UtcDaliActorParentOriginPropertyAsString(void)
3380 TestApplication application;
3382 Actor actor = Actor::New();
3384 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3385 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3387 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3388 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3390 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3391 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3393 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3394 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3396 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3397 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3399 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3400 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3402 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3403 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3405 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3406 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3408 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3409 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3411 // Invalid should not change anything
3412 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3413 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3418 int UtcDaliActorColorModePropertyAsString(void)
3420 TestApplication application;
3422 Actor actor = Actor::New();
3424 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3425 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3427 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3428 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3430 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3431 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3433 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3434 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3436 // Invalid should not change anything
3437 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3438 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3443 int UtcDaliActorPositionInheritancePropertyAsString(void)
3445 TestApplication application;
3447 Actor actor = Actor::New();
3449 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3450 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3452 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3453 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3455 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3456 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3458 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3459 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3461 // Invalid should not change anything
3462 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3463 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3468 int UtcDaliActorDrawModePropertyAsString(void)
3470 TestApplication application;
3472 Actor actor = Actor::New();
3474 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3475 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3477 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3478 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3480 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3481 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3483 // Invalid should not change anything
3484 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3485 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3490 int UtcDaliActorColorModePropertyAsEnum(void)
3492 TestApplication application;
3494 Actor actor = Actor::New();
3496 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3497 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3499 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3500 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3502 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3503 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3505 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3506 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3511 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3513 TestApplication application;
3515 Actor actor = Actor::New();
3517 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3518 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3520 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3521 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3523 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3524 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3526 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3527 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3532 int UtcDaliActorDrawModePropertyAsEnum(void)
3534 TestApplication application;
3536 Actor actor = Actor::New();
3538 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3539 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3541 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3542 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3544 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3545 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3550 int UtcDaliActorAddRendererP(void)
3552 tet_infoline("Testing Actor::AddRenderer");
3553 TestApplication application;
3555 Actor actor = Actor::New();
3557 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3559 Geometry geometry = CreateQuadGeometry();
3560 Shader shader = CreateShader();
3561 Renderer renderer = Renderer::New(geometry, shader);
3563 actor.AddRenderer( renderer );
3564 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3565 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3570 int UtcDaliActorAddRendererN(void)
3572 tet_infoline("Testing Actor::AddRenderer");
3573 TestApplication application;
3575 Actor actor = Actor::New();
3581 actor.AddRenderer( renderer );
3582 tet_printf("Assertion test failed - no Exception\n" );
3583 tet_result(TET_FAIL);
3585 catch(Dali::DaliException& e)
3587 DALI_TEST_PRINT_ASSERT( e );
3588 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3589 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3593 tet_printf("Assertion test failed - wrong Exception\n" );
3594 tet_result(TET_FAIL);
3600 int UtcDaliActorAddRendererOnStage(void)
3602 tet_infoline("Testing Actor::AddRenderer");
3603 TestApplication application;
3605 Actor actor = Actor::New();
3606 Stage::GetCurrent().Add(actor);
3608 application.SendNotification();
3609 application.Render(0);
3611 Geometry geometry = CreateQuadGeometry();
3612 Shader shader = CreateShader();
3613 Renderer renderer = Renderer::New(geometry, shader);
3615 application.SendNotification();
3616 application.Render(0);
3620 actor.AddRenderer( renderer );
3621 tet_result(TET_PASS);
3625 tet_result(TET_FAIL);
3631 int UtcDaliActorRemoveRendererP1(void)
3633 tet_infoline("Testing Actor::RemoveRenderer");
3634 TestApplication application;
3636 Actor actor = Actor::New();
3638 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3640 Geometry geometry = CreateQuadGeometry();
3641 Shader shader = CreateShader();
3642 Renderer renderer = Renderer::New(geometry, shader);
3644 actor.AddRenderer( renderer );
3645 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3646 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3648 actor.RemoveRenderer(renderer);
3649 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3655 int UtcDaliActorRemoveRendererP2(void)
3657 tet_infoline("Testing Actor::RemoveRenderer");
3658 TestApplication application;
3660 Actor actor = Actor::New();
3662 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3664 Geometry geometry = CreateQuadGeometry();
3665 Shader shader = CreateShader();
3666 Renderer renderer = Renderer::New(geometry, shader);
3668 actor.AddRenderer( renderer );
3669 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3670 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3672 actor.RemoveRenderer(0);
3673 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3680 int UtcDaliActorRemoveRendererN(void)
3682 tet_infoline("Testing Actor::RemoveRenderer");
3683 TestApplication application;
3685 Actor actor = Actor::New();
3687 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3689 Geometry geometry = CreateQuadGeometry();
3690 Shader shader = CreateShader();
3691 Renderer renderer = Renderer::New(geometry, shader);
3693 actor.AddRenderer( renderer );
3694 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3695 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3697 actor.RemoveRenderer(10);
3698 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3699 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3704 // Clipping test helper functions:
3705 Actor CreateActorWithContent()
3707 BufferImage image = BufferImage::New( 16u, 16u );
3708 Actor actor = CreateRenderableActor( image );
3710 // Setup dimensions and position so actor is not skipped by culling.
3711 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3712 actor.SetSize( 16.0f, 16.0f );
3713 actor.SetParentOrigin( ParentOrigin::CENTER );
3714 actor.SetAnchorPoint( AnchorPoint::CENTER );
3719 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3721 enabledDisableTrace.Reset();
3722 stencilTrace.Reset();
3723 enabledDisableTrace.Enable( true );
3724 stencilTrace.Enable( true );
3726 application.SendNotification();
3727 application.Render();
3729 enabledDisableTrace.Enable( false );
3730 stencilTrace.Enable( false );
3733 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3735 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3737 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3738 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3739 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3740 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3743 int UtcDaliActorPropertyClippingP(void)
3745 // This test checks the clippingMode property.
3746 tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3747 TestApplication application;
3749 Actor actor = Actor::New();
3751 // Check default clippingEnabled value.
3752 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3755 bool getValueResult = getValue.Get( value );
3756 DALI_TEST_CHECK( getValueResult );
3758 if( getValueResult )
3760 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3763 // Check setting the property.
3764 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3766 // Check the new value was set.
3767 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3768 getValueResult = getValue.Get( value );
3769 DALI_TEST_CHECK( getValueResult );
3771 if( getValueResult )
3773 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3779 int UtcDaliActorPropertyClippingN(void)
3781 // Negative test case for Clipping.
3782 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3783 TestApplication application;
3785 Actor actor = Actor::New();
3787 // Check default clippingEnabled value.
3788 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3791 bool getValueResult = getValue.Get( value );
3792 DALI_TEST_CHECK( getValueResult );
3794 if( getValueResult )
3796 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3799 // Check setting an invalid property value won't change the current property value.
3800 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3802 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3803 getValueResult = getValue.Get( value );
3804 DALI_TEST_CHECK( getValueResult );
3806 if( getValueResult )
3808 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3814 int UtcDaliActorPropertyClippingActor(void)
3816 // This test checks that an actor is correctly setup for clipping.
3817 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3818 TestApplication application;
3820 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3821 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3822 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3823 size_t startIndex = 0u;
3825 // Create a clipping actor.
3826 Actor actorDepth1Clip = CreateActorWithContent();
3827 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3828 Stage::GetCurrent().Add( actorDepth1Clip );
3830 // Gather the call trace.
3831 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3833 // Check we are writing to the color buffer.
3834 CheckColorMask( glAbstraction, true );
3836 // Check the stencil buffer was enabled.
3837 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3839 // Check the stencil buffer was cleared.
3840 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3842 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3843 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3844 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3845 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3850 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
3852 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
3853 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
3854 TestApplication application;
3856 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3857 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3858 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3859 size_t startIndex = 0u;
3861 // Create a clipping actor.
3862 Actor actorDepth1Clip = CreateActorWithContent();
3863 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3864 Stage::GetCurrent().Add( actorDepth1Clip );
3866 // Gather the call trace.
3867 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3869 // Check we are writing to the color buffer.
3870 CheckColorMask( glAbstraction, true );
3872 // Check the stencil buffer was enabled.
3873 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3875 // Check the stencil buffer was cleared.
3876 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3878 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3879 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3880 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3881 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3883 // Now disable the clipping
3884 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
3886 // Gather the call trace.
3887 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3889 // Check the stencil buffer was disabled.
3890 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3892 // Ensure all values in stencil-mask are set to 1.
3894 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
3900 int UtcDaliActorPropertyClippingNestedChildren(void)
3902 // This test checks that a hierarchy of actors are clipped correctly by
3903 // writing to and reading from the correct bit-planes of the stencil buffer.
3904 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
3905 TestApplication application;
3906 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3907 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3908 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3910 // Create a clipping actor.
3911 Actor actorDepth1Clip = CreateActorWithContent();
3912 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3913 Stage::GetCurrent().Add( actorDepth1Clip );
3915 // Create a child actor.
3916 Actor childDepth2 = CreateActorWithContent();
3917 actorDepth1Clip.Add( childDepth2 );
3919 // Create another clipping actor.
3920 Actor childDepth2Clip = CreateActorWithContent();
3921 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3922 childDepth2.Add( childDepth2Clip );
3924 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
3925 // This tests the sort algorithm.
3926 Actor childDepth3 = CreateActorWithContent();
3927 childDepth2Clip.Add( childDepth3 );
3928 Actor childDepth4 = CreateActorWithContent();
3929 childDepth3.Add( childDepth4 );
3931 // Gather the call trace.
3932 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3934 // Check we are writing to the color buffer.
3935 CheckColorMask( glAbstraction, true );
3937 // Check the stencil buffer was enabled.
3938 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3940 // Perform the test twice, once for 2D layer, and once for 3D.
3941 for( unsigned int i = 0u ; i < 2u; ++i )
3943 size_t startIndex = 0u;
3945 // Check the stencil buffer was cleared.
3946 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3948 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3949 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3950 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
3951 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3953 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
3954 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
3955 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3957 // Check we are set up to write to the second bitplane of the stencil buffer (only).
3958 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3959 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
3960 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3962 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
3963 // (Both must be set to pass the check).
3964 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
3965 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
3967 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
3970 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
3971 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3978 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
3980 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
3981 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
3982 TestApplication application;
3984 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3985 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3986 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3988 // Create a clipping actor.
3989 Actor actorDepth1Clip = CreateActorWithContent();
3990 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3991 Stage::GetCurrent().Add( actorDepth1Clip );
3993 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
3994 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
3996 // Gather the call trace.
3997 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3999 // Check we are writing to the color buffer.
4000 CheckColorMask( glAbstraction, true );
4002 // Check the stencil buffer was not enabled.
4003 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4005 // Check stencil functions are not called.
4006 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4007 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4008 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4013 int UtcDaliGetPropertyN(void)
4015 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4016 TestApplication app;
4018 Actor actor = Actor::New();
4020 unsigned int propertyCount = actor.GetPropertyCount();
4021 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );