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 gTouchCallBackCalled2=false;
48 bool gTouchCallBackCalled3=false;
50 bool gHoverCallBackCalled=false;
52 static bool gTestConstraintCalled;
56 void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
58 gTestConstraintCalled = true;
63 * TestConstraint reference.
64 * When constraint is called, the resultRef is updated
65 * with the value supplied.
68 struct TestConstraintRef
70 TestConstraintRef(unsigned int& resultRef, unsigned int value)
71 : mResultRef(resultRef),
76 void operator()( T& current, const PropertyInputContainer& /* inputs */ )
81 unsigned int& mResultRef;
85 static bool TestCallback(Actor actor, const TouchEvent& event)
87 gTouchCallBackCalled = true;
92 static bool TestTouchCallback(Actor actor, const TouchData& touchData )
94 gTouchCallBackCalled = true;
99 static bool TestTouchCallback2(Actor actor, const TouchData& touchData )
101 gTouchCallBackCalled2 = true;
106 static bool TestTouchCallback3(Actor actor, const TouchData& touchData )
108 gTouchCallBackCalled3 = true;
113 static void ResetTouchCallbacks()
115 gTouchCallBackCalled = false;
116 gTouchCallBackCalled2 = false;
117 gTouchCallBackCalled3 = false;
120 static bool TestCallback3(Actor actor, const HoverEvent& event)
122 gHoverCallBackCalled = true;
127 // validation stuff for onstage & offstage signals
128 static std::vector< std::string > gActorNamesOnOffStage;
129 static int gOnStageCallBackCalled;
130 void OnStageCallback( Actor actor )
132 ++gOnStageCallBackCalled;
133 gActorNamesOnOffStage.push_back( actor.GetName() );
134 DALI_TEST_CHECK( actor.OnStage() == true );
136 static int gOffStageCallBackCalled;
137 void OffStageCallback( Actor actor )
139 ++gOffStageCallBackCalled;
140 gActorNamesOnOffStage.push_back( actor.GetName() );
141 DALI_TEST_CHECK( actor.OnStage() == false );
144 struct PositionComponentConstraint
146 PositionComponentConstraint(){}
148 void operator()( Vector3& pos, const PropertyInputContainer& inputs )
150 const Matrix& m = inputs[0]->GetMatrix();
153 m.GetTransformComponents(pos, rot, scale);
157 struct OrientationComponentConstraint
159 OrientationComponentConstraint(){}
161 void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
163 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
166 orientation = parentOrientation;
171 static bool gOnRelayoutCallBackCalled = false;
172 static std::vector< std::string > gActorNamesRelayout;
174 void OnRelayoutCallback( Actor actor )
176 gOnRelayoutCallBackCalled = true;
177 gActorNamesRelayout.push_back( actor.GetName() );
180 } // anonymous namespace
183 //& purpose: Testing New API
184 int UtcDaliActorNew(void)
186 TestApplication application;
188 Actor actor = Actor::New();
190 DALI_TEST_CHECK(actor);
194 //& purpose: Testing Dali::Actor::DownCast()
195 int UtcDaliActorDownCastP(void)
197 TestApplication application;
198 tet_infoline("Testing Dali::Actor::DownCast()");
200 Actor actor = Actor::New();
201 BaseHandle object(actor);
202 Actor actor2 = Actor::DownCast(object);
203 DALI_TEST_CHECK(actor2);
207 //& purpose: Testing Dali::Actor::DownCast()
208 int UtcDaliActorDownCastN(void)
210 TestApplication application;
211 tet_infoline("Testing Dali::Actor::DownCast()");
213 BaseHandle unInitializedObject;
214 Actor actor = Actor::DownCast(unInitializedObject);
215 DALI_TEST_CHECK(!actor);
219 //& purpose: Testing Dali::Actor::GetName()
220 int UtcDaliActorGetName(void)
222 TestApplication application;
224 Actor actor = Actor::New();
226 DALI_TEST_CHECK(actor.GetName().empty());
230 //& purpose: Testing Dali::Actor::SetName()
231 int UtcDaliActorSetName(void)
233 TestApplication application;
235 string str("ActorName");
236 Actor actor = Actor::New();
239 DALI_TEST_CHECK(actor.GetName() == str);
243 int UtcDaliActorGetId(void)
245 tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()");
246 TestApplication application;
248 Actor first = Actor::New();
249 Actor second = Actor::New();
250 Actor third = Actor::New();
252 DALI_TEST_CHECK(first.GetId() != second.GetId());
253 DALI_TEST_CHECK(second.GetId() != third.GetId());
257 int UtcDaliActorIsRoot(void)
259 TestApplication application;
261 Actor actor = Actor::New();
262 DALI_TEST_CHECK(!actor.IsRoot());
264 // get the root layer
265 actor = Stage::GetCurrent().GetLayer( 0 );
266 DALI_TEST_CHECK( actor.IsRoot() );
270 int UtcDaliActorOnStage(void)
272 TestApplication application;
274 Actor actor = Actor::New();
275 DALI_TEST_CHECK( !actor.OnStage() );
277 // get the root layer
278 actor = Stage::GetCurrent().GetLayer( 0 );
279 DALI_TEST_CHECK( actor.OnStage() );
283 int UtcDaliActorIsLayer(void)
285 TestApplication application;
287 Actor actor = Actor::New();
288 DALI_TEST_CHECK( !actor.IsLayer() );
290 // get the root layer
291 actor = Stage::GetCurrent().GetLayer( 0 );
292 DALI_TEST_CHECK( actor.IsLayer() );
296 int UtcDaliActorGetLayer(void)
298 TestApplication application;
300 Actor actor = Actor::New();
301 Stage::GetCurrent().Add(actor);
302 Layer layer = actor.GetLayer();
304 DALI_TEST_CHECK(layer);
306 // get the root layers layer
307 actor = Stage::GetCurrent().GetLayer( 0 );
308 DALI_TEST_CHECK( actor.GetLayer() );
312 int UtcDaliActorAddP(void)
314 tet_infoline("Testing Actor::Add");
315 TestApplication application;
317 Actor parent = Actor::New();
318 Actor child = Actor::New();
320 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
324 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
326 Actor parent2 = Actor::New();
327 parent2.Add( child );
329 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
330 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
332 // try Adding to same parent again, works
333 parent2.Add( child );
334 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
336 // try reparenting an orphaned child
338 Actor temporaryParent = Actor::New();
339 temporaryParent.Add( child );
340 DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION );
342 // temporaryParent has now died, reparent the orphaned child
343 parent2.Add( child );
344 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
349 int UtcDaliActorAddN(void)
351 tet_infoline("Testing Actor::Add");
352 TestApplication application;
354 Actor child = Actor::New();
356 Actor parent2 = Actor::New();
357 parent2.Add( child );
362 parent2.Add( parent2 );
363 tet_printf("Assertion test failed - no Exception\n" );
364 tet_result(TET_FAIL);
366 catch(Dali::DaliException& e)
368 DALI_TEST_PRINT_ASSERT( e );
369 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
370 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
374 tet_printf("Assertion test failed - wrong Exception\n" );
375 tet_result(TET_FAIL);
378 // try reparenting root
381 parent2.Add( Stage::GetCurrent().GetLayer( 0 ) );
382 tet_printf("Assertion test failed - no Exception\n" );
383 tet_result(TET_FAIL);
385 catch(Dali::DaliException& e)
387 DALI_TEST_PRINT_ASSERT( e );
388 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
389 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
393 tet_printf("Assertion test failed - wrong Exception\n" );
394 tet_result(TET_FAIL);
401 parent2.Add( empty );
402 tet_printf("Assertion test failed - no Exception\n" );
403 tet_result(TET_FAIL);
405 catch(Dali::DaliException& e)
407 DALI_TEST_PRINT_ASSERT( e );
408 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
409 DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION );
413 tet_printf("Assertion test failed - wrong Exception\n" );
414 tet_result(TET_FAIL);
420 int UtcDaliActorRemoveN(void)
422 tet_infoline("Testing Actor::Remove");
423 TestApplication application;
425 Actor parent = Actor::New();
426 Actor child = Actor::New();
427 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
430 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
432 parent.Remove(child);
433 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
435 // remove again, no problem
436 parent.Remove(child);
437 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
441 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
442 // try Remove self, its a no-op
443 parent.Remove( parent );
444 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
450 parent.Remove( empty );
451 tet_printf("Assertion test failed - no Exception\n" );
452 tet_result(TET_FAIL);
454 catch(Dali::DaliException& e)
456 DALI_TEST_PRINT_ASSERT( e );
457 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
458 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
462 tet_printf("Assertion test failed - wrong Exception\n" );
463 tet_result(TET_FAIL);
468 int UtcDaliActorRemoveP(void)
470 TestApplication application;
472 Actor parent = Actor::New();
473 Actor child = Actor::New();
474 Actor random = Actor::New();
476 Stage::GetCurrent().Add( parent );
478 DALI_TEST_CHECK(parent.GetChildCount() == 0);
482 DALI_TEST_CHECK(parent.GetChildCount() == 1);
484 parent.Remove(random);
486 DALI_TEST_CHECK(parent.GetChildCount() == 1);
488 Stage::GetCurrent().Remove( parent );
490 DALI_TEST_CHECK(parent.GetChildCount() == 1);
494 int UtcDaliActorGetChildCount(void)
496 TestApplication application;
498 Actor parent = Actor::New();
499 Actor child = Actor::New();
501 DALI_TEST_CHECK(parent.GetChildCount() == 0);
505 DALI_TEST_CHECK(parent.GetChildCount() == 1);
509 int UtcDaliActorGetChildren01(void)
511 TestApplication application;
513 Actor parent = Actor::New();
514 Actor first = Actor::New();
515 Actor second = Actor::New();
516 Actor third = Actor::New();
522 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
523 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
524 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
528 int UtcDaliActorGetChildren02(void)
530 TestApplication application;
532 Actor parent = Actor::New();
533 Actor first = Actor::New();
534 Actor second = Actor::New();
535 Actor third = Actor::New();
541 const Actor& constParent = parent;
543 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
544 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
545 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
549 int UtcDaliActorGetParent01(void)
551 TestApplication application;
553 Actor parent = Actor::New();
554 Actor child = Actor::New();
558 DALI_TEST_CHECK(child.GetParent() == parent);
562 int UtcDaliActorGetParent02(void)
564 TestApplication application;
566 Actor actor = Actor::New();
568 DALI_TEST_CHECK(!actor.GetParent());
572 int UtcDaliActorSetParentOrigin(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.SetParentOrigin(vector);
583 // flush the queue and render once
584 application.SendNotification();
585 application.Render();
587 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
589 Stage::GetCurrent().Add( actor );
591 actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) );
593 // flush the queue and render once
594 application.SendNotification();
595 application.Render();
597 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION );
599 Stage::GetCurrent().Remove( actor );
603 int UtcDaliActorSetParentOriginIndividual(void)
605 TestApplication application;
607 Actor actor = Actor::New();
609 Vector3 vector(0.7f, 0.8f, 0.9f);
610 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
612 actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x );
614 // flush the queue and render once
615 application.SendNotification();
616 application.Render();
618 DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION );
620 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y );
622 // flush the queue and render once
623 application.SendNotification();
624 application.Render();
626 DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION );
628 actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z );
630 // flush the queue and render once
631 application.SendNotification();
632 application.Render();
634 DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION );
639 int UtcDaliActorGetCurrentParentOrigin(void)
641 TestApplication application;
643 Actor actor = Actor::New();
645 Vector3 vector(0.7f, 0.8f, 0.9f);
646 DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin());
648 actor.SetParentOrigin(vector);
650 // flush the queue and render once
651 application.SendNotification();
652 application.Render();
654 DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin());
658 int UtcDaliActorSetAnchorPoint(void)
660 TestApplication application;
662 Actor actor = Actor::New();
664 Vector3 vector(0.7f, 0.8f, 0.9f);
665 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
667 actor.SetAnchorPoint(vector);
669 // flush the queue and render once
670 application.SendNotification();
671 application.Render();
673 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
675 Stage::GetCurrent().Add( actor );
677 actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) );
678 // flush the queue and render once
679 application.SendNotification();
680 application.Render();
682 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION );
684 Stage::GetCurrent().Remove( actor );
688 int UtcDaliActorSetAnchorPointIndividual(void)
690 TestApplication application;
692 Actor actor = Actor::New();
694 Vector3 vector(0.7f, 0.8f, 0.9f);
695 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
697 actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x );
699 // flush the queue and render once
700 application.SendNotification();
701 application.Render();
703 DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION );
705 actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y );
707 // flush the queue and render once
708 application.SendNotification();
709 application.Render();
711 DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION );
713 actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z );
715 // flush the queue and render once
716 application.SendNotification();
717 application.Render();
719 DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION );
724 int UtcDaliActorGetCurrentAnchorPoint(void)
726 TestApplication application;
728 Actor actor = Actor::New();
730 Vector3 vector(0.7f, 0.8f, 0.9f);
731 DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint());
733 actor.SetAnchorPoint(vector);
735 // flush the queue and render once
736 application.SendNotification();
737 application.Render();
739 DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint());
743 // SetSize(float width, float height)
744 int UtcDaliActorSetSize01(void)
746 TestApplication application;
748 Actor actor = Actor::New();
749 Vector3 vector(100.0f, 100.0f, 0.0f);
751 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
753 actor.SetSize(vector.x, vector.y);
755 // Immediately retrieve the size after setting
756 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
757 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
759 // Flush the queue and render once
760 application.SendNotification();
761 application.Render();
763 // Check the size in the new frame
764 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
766 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
767 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
769 // Change the resize policy and check whether the size stays the same
770 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
772 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
773 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
775 // Set a new size after resize policy is changed and check the new size
776 actor.SetSize( Vector3( 0.1f, 0.2f, 0.0f ) );
778 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
779 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
781 // Change the resize policy again and check whether the new size stays the same
782 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
784 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
785 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
787 // Set another new size after resize policy is changed and check the new size
788 actor.SetSize( Vector3( 50.0f, 60.0f, 0.0f ) );
790 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
791 DALI_TEST_EQUALS( currentSize, Vector3( 50.0f, 60.0f, 0.0f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
796 // SetSize(float width, float height, float depth)
797 int UtcDaliActorSetSize02(void)
799 TestApplication application;
801 Actor actor = Actor::New();
802 Vector3 vector(100.0f, 100.0f, 100.0f);
804 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
806 actor.SetSize(vector.x, vector.y, vector.z);
808 // Immediately check the size after setting
809 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
810 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
812 // flush the queue and render once
813 application.SendNotification();
814 application.Render();
816 // Check the size in the new frame
817 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
819 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
820 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
825 // SetSize(Vector2 size)
826 int UtcDaliActorSetSize03(void)
828 TestApplication application;
830 Actor actor = Actor::New();
831 Vector3 vector(100.0f, 100.0f, 0.0f);
833 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
835 actor.SetSize(Vector2(vector.x, vector.y));
837 // Immediately check the size after setting
838 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
839 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
841 // flush the queue and render once
842 application.SendNotification();
843 application.Render();
845 // Check the size in the new frame
846 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
848 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
849 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
854 // SetSize(Vector3 size)
855 int UtcDaliActorSetSize04(void)
857 TestApplication application;
859 Actor actor = Actor::New();
860 Vector3 vector(100.0f, 100.0f, 100.0f);
862 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
864 actor.SetSize(vector);
866 // Immediately check the size after setting
867 Vector3 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
868 DALI_TEST_EQUALS( currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION );
870 // flush the queue and render once
871 application.SendNotification();
872 application.Render();
874 // Check the size in the new frame
875 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
877 Stage::GetCurrent().Add( actor );
878 actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) );
880 // Immediately check the size after setting
881 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
882 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
884 // flush the queue and render once
885 application.SendNotification();
886 application.Render();
888 // Check the size in the new frame
889 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION );
891 currentSize = actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >();
892 DALI_TEST_EQUALS( currentSize, Vector3( 0.1f, 0.2f, 0.3f ), Math::MACHINE_EPSILON_0, TEST_LOCATION );
894 Stage::GetCurrent().Remove( actor );
898 int UtcDaliActorSetSizeIndividual(void)
900 TestApplication application;
902 Actor actor = Actor::New();
904 Vector3 vector(0.7f, 0.8f, 0.9f);
905 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
907 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
909 // Immediately check the width after setting
910 float sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
911 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
913 // flush the queue and render once
914 application.SendNotification();
915 application.Render();
917 // Check the width in the new frame
918 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
920 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
921 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
923 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
925 // Immediately check the height after setting
926 float sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
927 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
929 // flush the queue and render once
930 application.SendNotification();
931 application.Render();
933 // Check the height in the new frame
934 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
936 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
937 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
939 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
941 // Immediately check the depth after setting
942 float sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
943 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
945 // flush the queue and render once
946 application.SendNotification();
947 application.Render();
949 // Check the depth in the new frame
950 DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION );
952 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
953 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
955 // Change the resize policy and check whether the size stays the same
956 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
958 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
959 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
961 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
962 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
964 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
965 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
967 // Change the resize policy again and check whether the size stays the same
968 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
970 sizeWidth = actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >();
971 DALI_TEST_EQUALS( sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
973 sizeHeight = actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >();
974 DALI_TEST_EQUALS( sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
976 sizeDepth = actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >();
977 DALI_TEST_EQUALS( sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
982 int UtcDaliActorSetSizeIndividual02(void)
984 TestApplication application;
986 Actor actor = Actor::New();
987 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
988 Stage::GetCurrent().Add( actor );
990 Vector3 vector( 100.0f, 200.0f, 400.0f );
991 DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
993 actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
994 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
996 actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
997 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
999 actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
1000 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
1002 // flush the queue and render once
1003 application.SendNotification();
1004 application.Render();
1006 // Check the width in the new frame
1007 DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
1008 DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
1014 int UtcDaliActorGetCurrentSize(void)
1016 TestApplication application;
1018 Actor actor = Actor::New();
1019 Vector3 vector(100.0f, 100.0f, 20.0f);
1021 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1023 actor.SetSize(vector);
1025 // flush the queue and render once
1026 application.SendNotification();
1027 application.Render();
1029 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1033 int UtcDaliActorGetNaturalSize(void)
1035 TestApplication application;
1037 Actor actor = Actor::New();
1038 Vector3 vector( 0.0f, 0.0f, 0.0f );
1040 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1045 int UtcDaliActorGetCurrentSizeImmediate(void)
1047 TestApplication application;
1049 Actor actor = Actor::New();
1050 Vector3 vector(100.0f, 100.0f, 20.0f);
1052 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1053 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1055 actor.SetSize(vector);
1057 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1058 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1060 // flush the queue and render once
1061 application.SendNotification();
1062 application.Render();
1064 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1065 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1068 // Build the animation
1069 const float durationSeconds = 2.0f;
1070 Animation animation = Animation::New( durationSeconds );
1071 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1072 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1074 DALI_TEST_CHECK( actor.GetTargetSize() == vector );
1076 // Start the animation
1079 application.SendNotification();
1080 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1082 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1087 // SetPosition(float x, float y)
1088 int UtcDaliActorSetPosition01(void)
1090 TestApplication application;
1092 Actor actor = Actor::New();
1094 // Set to random to start off with
1095 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1097 Vector3 vector(100.0f, 100.0f, 0.0f);
1099 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1101 actor.SetPosition(vector.x, vector.y);
1102 // flush the queue and render once
1103 application.SendNotification();
1104 application.Render();
1105 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1107 Stage::GetCurrent().Add( actor );
1108 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1109 // flush the queue and render once
1110 application.SendNotification();
1111 application.Render();
1112 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1117 // flush the queue and render once
1118 application.SendNotification();
1119 application.Render();
1120 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1122 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1123 // flush the queue and render once
1124 application.SendNotification();
1125 application.Render();
1126 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1128 Stage::GetCurrent().Remove( actor );
1132 // SetPosition(float x, float y, float z)
1133 int UtcDaliActorSetPosition02(void)
1135 TestApplication application;
1137 Actor actor = Actor::New();
1139 // Set to random to start off with
1140 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1142 Vector3 vector(100.0f, 100.0f, 100.0f);
1144 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1146 actor.SetPosition(vector.x, vector.y, vector.z);
1148 // flush the queue and render once
1149 application.SendNotification();
1150 application.Render();
1152 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1156 // SetPosition(Vector3 position)
1157 int UtcDaliActorSetPosition03(void)
1159 TestApplication application;
1161 Actor actor = Actor::New();
1163 // Set to random to start off with
1164 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1166 Vector3 vector(100.0f, 100.0f, 100.0f);
1168 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1170 actor.SetPosition(vector);
1172 // flush the queue and render once
1173 application.SendNotification();
1174 application.Render();
1176 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1180 int UtcDaliActorSetX(void)
1182 TestApplication application;
1184 Actor actor = Actor::New();
1186 Vector3 vector(100.0f, 0.0f, 0.0f);
1188 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1192 // flush the queue and render once
1193 application.SendNotification();
1194 application.Render();
1196 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1200 int UtcDaliActorSetY(void)
1202 TestApplication application;
1204 Actor actor = Actor::New();
1206 Vector3 vector(0.0f, 100.0f, 0.0f);
1208 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1212 // flush the queue and render once
1213 application.SendNotification();
1214 application.Render();
1216 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1220 int UtcDaliActorSetZ(void)
1222 TestApplication application;
1224 Actor actor = Actor::New();
1226 Vector3 vector(0.0f, 0.0f, 100.0f);
1228 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1232 // flush the queue and render once
1233 application.SendNotification();
1234 application.Render();
1236 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1240 int UtcDaliActorSetPositionProperties(void)
1242 TestApplication application;
1244 Actor actor = Actor::New();
1246 Vector3 vector(0.7f, 0.8f, 0.9f);
1247 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1249 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1251 // flush the queue and render once
1252 application.SendNotification();
1253 application.Render();
1255 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1257 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1259 // flush the queue and render once
1260 application.SendNotification();
1261 application.Render();
1263 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1265 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1267 // flush the queue and render once
1268 application.SendNotification();
1269 application.Render();
1271 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1276 int UtcDaliActorTranslateBy(void)
1278 TestApplication application;
1280 Actor actor = Actor::New();
1281 Vector3 vector(100.0f, 100.0f, 100.0f);
1283 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1285 actor.SetPosition(vector);
1287 // flush the queue and render once
1288 application.SendNotification();
1289 application.Render();
1291 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1293 actor.TranslateBy(vector);
1295 // flush the queue and render once
1296 application.SendNotification();
1297 application.Render();
1299 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1303 int UtcDaliActorGetCurrentPosition(void)
1305 TestApplication application;
1307 Actor actor = Actor::New();
1308 Vector3 setVector(100.0f, 100.0f, 0.0f);
1309 actor.SetPosition(setVector);
1311 // flush the queue and render once
1312 application.SendNotification();
1313 application.Render();
1315 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1319 int UtcDaliActorGetCurrentWorldPosition(void)
1321 TestApplication application;
1323 Actor parent = Actor::New();
1324 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1325 parent.SetPosition( parentPosition );
1326 parent.SetParentOrigin( ParentOrigin::CENTER );
1327 parent.SetAnchorPoint( AnchorPoint::CENTER );
1328 Stage::GetCurrent().Add( parent );
1330 Actor child = Actor::New();
1331 child.SetParentOrigin( ParentOrigin::CENTER );
1332 child.SetAnchorPoint( AnchorPoint::CENTER );
1333 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1334 child.SetPosition( childPosition );
1335 parent.Add( child );
1337 // The actors should not have a world position yet
1338 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1339 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1341 application.SendNotification();
1342 application.Render(0);
1344 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1345 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1347 // The actors should have a world position now
1348 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1349 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1353 int UtcDaliActorInheritPosition(void)
1355 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1356 TestApplication application;
1358 Actor parent = Actor::New();
1359 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1360 parent.SetPosition( parentPosition );
1361 parent.SetParentOrigin( ParentOrigin::CENTER );
1362 parent.SetAnchorPoint( AnchorPoint::CENTER );
1363 Stage::GetCurrent().Add( parent );
1365 Actor child = Actor::New();
1366 child.SetParentOrigin( ParentOrigin::CENTER );
1367 child.SetAnchorPoint( AnchorPoint::CENTER );
1368 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1369 child.SetPosition( childPosition );
1370 parent.Add( child );
1372 // The actors should not have a world position yet
1373 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1374 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1376 // first test default, which is to inherit position
1377 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1378 application.SendNotification();
1379 application.Render(0); // should only really call Update as Render is not required to update scene
1380 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1381 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1382 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1383 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1386 //Change child position
1387 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1388 child.SetPosition( childOffset );
1390 // Change inheritance mode to not inherit
1391 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1392 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1393 application.SendNotification();
1394 application.Render(0); // should only really call Update as Render is not required to update scene
1395 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1396 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1397 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1398 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1402 int UtcDaliActorSetInheritPosition(void)
1404 tet_infoline("Testing Actor::SetInheritPosition");
1405 TestApplication application;
1407 Actor parent = Actor::New();
1408 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1409 parent.SetPosition( parentPosition );
1410 parent.SetParentOrigin( ParentOrigin::CENTER );
1411 parent.SetAnchorPoint( AnchorPoint::CENTER );
1412 Stage::GetCurrent().Add( parent );
1414 Actor child = Actor::New();
1415 child.SetParentOrigin( ParentOrigin::CENTER );
1416 child.SetAnchorPoint( AnchorPoint::CENTER );
1417 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1418 child.SetPosition( childPosition );
1419 parent.Add( child );
1421 // The actors should not have a world position yet
1422 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1423 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1425 // first test default, which is to inherit position
1426 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1427 application.SendNotification();
1428 application.Render(0); // should only really call Update as Render is not required to update scene
1429 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1430 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1431 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1432 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1434 //Change child position
1435 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1436 child.SetPosition( childOffset );
1438 // Use local position as world postion
1439 child.SetInheritPosition( false );
1440 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1441 application.SendNotification();
1442 application.Render(0); // should only really call Update as Render is not required to update scene
1443 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1444 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1445 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1446 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1448 //Change back to inherit position from parent
1449 child.SetInheritPosition( true );
1450 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1451 application.SendNotification();
1452 application.Render(0); // should only really call Update as Render is not required to update scene
1453 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1454 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1455 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1456 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1460 // SetOrientation(float angleRadians, Vector3 axis)
1461 int UtcDaliActorSetOrientation01(void)
1463 TestApplication application;
1465 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1466 Actor actor = Actor::New();
1468 actor.SetOrientation(rotation);
1470 // flush the queue and render once
1471 application.SendNotification();
1472 application.Render();
1474 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1478 int UtcDaliActorSetOrientation02(void)
1480 TestApplication application;
1482 Actor actor = Actor::New();
1484 Radian angle( 0.785f );
1485 Vector3 axis(1.0f, 1.0f, 0.0f);
1487 actor.SetOrientation( angle, axis);
1488 Quaternion rotation( angle, axis );
1489 // flush the queue and render once
1490 application.SendNotification();
1491 application.Render();
1492 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1494 Stage::GetCurrent().Add( actor );
1495 actor.RotateBy( Degree( 360 ), axis);
1496 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1498 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1499 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1500 // flush the queue and render once
1501 application.SendNotification();
1502 application.Render();
1503 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1505 actor.SetOrientation( angle, axis);
1506 // flush the queue and render once
1507 application.SendNotification();
1508 application.Render();
1509 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1511 Stage::GetCurrent().Remove( actor );
1515 // SetOrientation(float angleRadians, Vector3 axis)
1516 int UtcDaliActorSetOrientationProperty(void)
1518 TestApplication application;
1520 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1521 Actor actor = Actor::New();
1523 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1525 // flush the queue and render once
1526 application.SendNotification();
1527 application.Render();
1529 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1533 // RotateBy(float angleRadians, Vector3 axis)
1534 int UtcDaliActorRotateBy01(void)
1536 TestApplication application;
1538 Actor actor = Actor::New();
1540 Radian angle( M_PI * 0.25f );
1541 actor.RotateBy(( angle ), Vector3::ZAXIS);
1542 // flush the queue and render once
1543 application.SendNotification();
1544 application.Render();
1545 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1547 Stage::GetCurrent().Add( actor );
1549 actor.RotateBy( angle, Vector3::ZAXIS);
1550 // flush the queue and render once
1551 application.SendNotification();
1552 application.Render();
1553 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1555 Stage::GetCurrent().Remove( actor );
1559 // RotateBy(Quaternion relativeRotation)
1560 int UtcDaliActorRotateBy02(void)
1562 TestApplication application;
1564 Actor actor = Actor::New();
1566 Radian angle( M_PI * 0.25f );
1567 Quaternion rotation(angle, Vector3::ZAXIS);
1568 actor.RotateBy(rotation);
1569 // flush the queue and render once
1570 application.SendNotification();
1571 application.Render();
1572 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1574 actor.RotateBy(rotation);
1575 // flush the queue and render once
1576 application.SendNotification();
1577 application.Render();
1578 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1582 int UtcDaliActorGetCurrentOrientation(void)
1584 TestApplication application;
1585 Actor actor = Actor::New();
1587 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1588 actor.SetOrientation(rotation);
1589 // flush the queue and render once
1590 application.SendNotification();
1591 application.Render();
1592 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1596 int UtcDaliActorGetCurrentWorldOrientation(void)
1598 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1599 TestApplication application;
1601 Actor parent = Actor::New();
1602 Radian rotationAngle( Degree(90.0f) );
1603 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1604 parent.SetOrientation( rotation );
1605 Stage::GetCurrent().Add( parent );
1607 Actor child = Actor::New();
1608 child.SetOrientation( rotation );
1609 parent.Add( child );
1611 // The actors should not have a world rotation yet
1612 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1613 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1615 application.SendNotification();
1616 application.Render(0);
1618 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1619 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1621 // The actors should have a world rotation now
1622 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1623 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1625 // turn off child rotation inheritance
1626 child.SetInheritOrientation( false );
1627 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1628 application.SendNotification();
1629 application.Render(0);
1631 // The actors should have a world rotation now
1632 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1633 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1637 // SetScale(float scale)
1638 int UtcDaliActorSetScale01(void)
1640 TestApplication application;
1642 Actor actor = Actor::New();
1644 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1645 actor.SetScale(0.25f);
1647 Vector3 scale(10.0f, 10.0f, 10.0f);
1648 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1650 actor.SetScale(scale.x);
1652 // flush the queue and render once
1653 application.SendNotification();
1654 application.Render();
1656 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1660 // SetScale(float scaleX, float scaleY, float scaleZ)
1661 int UtcDaliActorSetScale02(void)
1663 TestApplication application;
1664 Vector3 scale(10.0f, 10.0f, 10.0f);
1666 Actor actor = Actor::New();
1668 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1669 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1671 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1673 actor.SetScale(scale.x, scale.y, scale.z);
1674 // flush the queue and render once
1675 application.SendNotification();
1676 application.Render();
1677 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1679 // add to stage and test
1680 Stage::GetCurrent().Add( actor );
1681 actor.SetScale( 2.0f, 2.0f, 2.0f );
1682 // flush the queue and render once
1683 application.SendNotification();
1684 application.Render();
1685 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1687 Stage::GetCurrent().Remove( actor );
1692 // SetScale(Vector3 scale)
1693 int UtcDaliActorSetScale03(void)
1695 TestApplication application;
1696 Vector3 scale(10.0f, 10.0f, 10.0f);
1698 Actor actor = Actor::New();
1700 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1701 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1703 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1705 actor.SetScale(scale);
1707 // flush the queue and render once
1708 application.SendNotification();
1709 application.Render();
1711 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1715 int UtcDaliActorSetScaleIndividual(void)
1717 TestApplication application;
1719 Actor actor = Actor::New();
1721 Vector3 vector(0.7f, 0.8f, 0.9f);
1722 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1724 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1726 // flush the queue and render once
1727 application.SendNotification();
1728 application.Render();
1730 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1732 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1734 // flush the queue and render once
1735 application.SendNotification();
1736 application.Render();
1738 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1740 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1742 // flush the queue and render once
1743 application.SendNotification();
1744 application.Render();
1746 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1751 int UtcDaliActorScaleBy(void)
1753 TestApplication application;
1754 Actor actor = Actor::New();
1755 Vector3 vector(100.0f, 100.0f, 100.0f);
1757 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1759 actor.SetScale(vector);
1761 // flush the queue and render once
1762 application.SendNotification();
1763 application.Render();
1765 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1767 actor.ScaleBy(vector);
1769 // flush the queue and render once
1770 application.SendNotification();
1771 application.Render();
1773 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1777 int UtcDaliActorGetCurrentScale(void)
1779 TestApplication application;
1780 Vector3 scale(12.0f, 1.0f, 2.0f);
1782 Actor actor = Actor::New();
1784 actor.SetScale(scale);
1786 // flush the queue and render once
1787 application.SendNotification();
1788 application.Render();
1790 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1794 int UtcDaliActorGetCurrentWorldScale(void)
1796 TestApplication application;
1798 Actor parent = Actor::New();
1799 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1800 parent.SetScale( parentScale );
1801 Stage::GetCurrent().Add( parent );
1803 Actor child = Actor::New();
1804 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1805 child.SetScale( childScale );
1806 parent.Add( child );
1808 // The actors should not have a scale yet
1809 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1810 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1812 // The actors should not have a world scale yet
1813 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1814 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1816 application.SendNotification();
1817 application.Render(0);
1819 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1820 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1822 // The actors should have a world scale now
1823 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1824 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1828 int UtcDaliActorInheritScale(void)
1830 tet_infoline("Testing Actor::SetInheritScale");
1831 TestApplication application;
1833 Actor parent = Actor::New();
1834 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1835 parent.SetScale( parentScale );
1836 Stage::GetCurrent().Add( parent );
1838 Actor child = Actor::New();
1839 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1840 child.SetScale( childScale );
1841 parent.Add( child );
1843 application.SendNotification();
1844 application.Render(0);
1846 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1847 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1849 child.SetInheritScale( false );
1850 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1852 application.SendNotification();
1853 application.Render(0);
1855 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1859 int UtcDaliActorSetVisible(void)
1861 TestApplication application;
1863 Actor actor = Actor::New();
1864 actor.SetVisible(false);
1865 // flush the queue and render once
1866 application.SendNotification();
1867 application.Render();
1868 DALI_TEST_CHECK(actor.IsVisible() == false);
1870 actor.SetVisible(true);
1871 // flush the queue and render once
1872 application.SendNotification();
1873 application.Render();
1874 DALI_TEST_CHECK(actor.IsVisible() == true);
1876 // put actor on stage
1877 Stage::GetCurrent().Add( actor );
1878 actor.SetVisible(false);
1879 // flush the queue and render once
1880 application.SendNotification();
1881 application.Render();
1882 DALI_TEST_CHECK(actor.IsVisible() == false);
1886 int UtcDaliActorIsVisible(void)
1888 TestApplication application;
1890 Actor actor = Actor::New();
1892 DALI_TEST_CHECK(actor.IsVisible() == true);
1896 int UtcDaliActorSetOpacity(void)
1898 TestApplication application;
1900 Actor actor = Actor::New();
1901 // initial opacity is 1
1902 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1904 actor.SetOpacity( 0.4f);
1905 // flush the queue and render once
1906 application.SendNotification();
1907 application.Render();
1908 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1910 // change opacity, actor is on stage to change is not immediate
1911 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1912 // flush the queue and render once
1913 application.SendNotification();
1914 application.Render();
1915 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1917 // put actor on stage
1918 Stage::GetCurrent().Add( actor );
1920 // change opacity, actor is on stage to change is not immediate
1921 actor.SetOpacity( 0.9f );
1922 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1923 // flush the queue and render once
1924 application.SendNotification();
1925 application.Render();
1926 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1928 // change opacity, actor is on stage to change is not immediate
1929 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1930 // flush the queue and render once
1931 application.SendNotification();
1932 application.Render();
1933 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1937 int UtcDaliActorGetCurrentOpacity(void)
1939 TestApplication application;
1941 Actor actor = Actor::New();
1942 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1944 actor.SetOpacity(0.5f);
1945 // flush the queue and render once
1946 application.SendNotification();
1947 application.Render();
1948 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1952 int UtcDaliActorSetSensitive(void)
1954 TestApplication application;
1955 Actor actor = Actor::New();
1957 bool sensitive = !actor.IsSensitive();
1959 actor.SetSensitive(sensitive);
1961 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1965 int UtcDaliActorIsSensitive(void)
1967 TestApplication application;
1968 Actor actor = Actor::New();
1969 actor.SetSensitive(false);
1971 DALI_TEST_CHECK(false == actor.IsSensitive());
1975 int UtcDaliActorSetColor(void)
1977 TestApplication application;
1978 Actor actor = Actor::New();
1979 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1981 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1983 actor.SetColor(color);
1984 // flush the queue and render once
1985 application.SendNotification();
1986 application.Render();
1987 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1989 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1990 // flush the queue and render once
1991 application.SendNotification();
1992 application.Render();
1993 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1995 Stage::GetCurrent().Add( actor );
1996 actor.SetColor( color );
1997 // flush the queue and render once
1998 application.SendNotification();
1999 application.Render();
2000 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
2002 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
2003 // flush the queue and render once
2004 application.SendNotification();
2005 application.Render();
2006 // Actor color is not clamped
2007 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
2008 // world color is clamped
2009 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
2011 Stage::GetCurrent().Remove( actor );
2015 int UtcDaliActorSetColorIndividual(void)
2017 TestApplication application;
2019 Actor actor = Actor::New();
2021 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2022 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
2024 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
2026 // flush the queue and render once
2027 application.SendNotification();
2028 application.Render();
2030 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2032 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2034 // flush the queue and render once
2035 application.SendNotification();
2036 application.Render();
2038 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2040 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2042 // flush the queue and render once
2043 application.SendNotification();
2044 application.Render();
2046 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2048 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2050 // flush the queue and render once
2051 application.SendNotification();
2052 application.Render();
2054 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2056 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2058 // flush the queue and render once
2059 application.SendNotification();
2060 application.Render();
2062 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2068 int UtcDaliActorGetCurrentColor(void)
2070 TestApplication application;
2071 Actor actor = Actor::New();
2072 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2074 actor.SetColor(color);
2075 // flush the queue and render once
2076 application.SendNotification();
2077 application.Render();
2078 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2082 int UtcDaliActorGetCurrentWorldColor(void)
2084 tet_infoline("Actor::GetCurrentWorldColor");
2085 TestApplication application;
2087 Actor parent = Actor::New();
2088 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2089 parent.SetColor( parentColor );
2090 Stage::GetCurrent().Add( parent );
2092 Actor child = Actor::New();
2093 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2094 child.SetColor( childColor );
2095 parent.Add( child );
2097 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2098 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2100 // verify the default color mode
2101 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2103 // The actors should not have a world color yet
2104 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2105 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2107 application.SendNotification();
2108 application.Render(0);
2110 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2111 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2113 // The actors should have a world color now
2114 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2115 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2118 child.SetColorMode( USE_OWN_COLOR );
2119 application.SendNotification();
2120 application.Render(0);
2121 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2124 child.SetColorMode( USE_PARENT_COLOR );
2125 application.SendNotification();
2126 application.Render(0);
2127 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2128 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2131 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2132 application.SendNotification();
2133 application.Render(0);
2134 Vector4 expectedColor( childColor );
2135 expectedColor.a *= parentColor.a;
2136 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2137 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2141 int UtcDaliActorSetColorMode(void)
2143 tet_infoline("Actor::SetColorMode");
2144 TestApplication application;
2145 Actor actor = Actor::New();
2146 Actor child = Actor::New();
2149 actor.SetColorMode( USE_OWN_COLOR );
2150 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2152 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2153 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2155 actor.SetColorMode( USE_PARENT_COLOR );
2156 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2158 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2159 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2163 int UtcDaliActorScreenToLocal(void)
2165 TestApplication application;
2166 Actor actor = Actor::New();
2167 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2168 actor.SetSize(100.0f, 100.0f);
2169 actor.SetPosition(10.0f, 10.0f);
2170 Stage::GetCurrent().Add(actor);
2172 // flush the queue and render once
2173 application.SendNotification();
2174 application.Render();
2179 application.SendNotification();
2180 application.Render();
2182 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2184 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2185 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2189 int UtcDaliActorSetLeaveRequired(void)
2191 TestApplication application;
2193 Actor actor = Actor::New();
2195 actor.SetLeaveRequired(false);
2196 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2198 actor.SetLeaveRequired(true);
2199 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2203 int UtcDaliActorGetLeaveRequired(void)
2205 TestApplication application;
2207 Actor actor = Actor::New();
2209 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2213 int UtcDaliActorSetKeyboardFocusable(void)
2215 TestApplication application;
2217 Actor actor = Actor::New();
2219 actor.SetKeyboardFocusable(true);
2220 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2222 actor.SetKeyboardFocusable(false);
2223 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2227 int UtcDaliActorIsKeyboardFocusable(void)
2229 TestApplication application;
2231 Actor actor = Actor::New();
2233 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2237 int UtcDaliActorRemoveConstraints(void)
2239 tet_infoline(" UtcDaliActorRemoveConstraints");
2240 TestApplication application;
2242 gTestConstraintCalled = false;
2244 Actor actor = Actor::New();
2246 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2248 actor.RemoveConstraints();
2250 DALI_TEST_CHECK( gTestConstraintCalled == false );
2252 Stage::GetCurrent().Add( actor );
2255 // flush the queue and render once
2256 application.SendNotification();
2257 application.Render();
2259 actor.RemoveConstraints();
2261 DALI_TEST_CHECK( gTestConstraintCalled == true );
2265 int UtcDaliActorRemoveConstraintTag(void)
2267 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2268 TestApplication application;
2270 Actor actor = Actor::New();
2272 // 1. Apply Constraint1 and Constraint2, and test...
2273 unsigned int result1 = 0u;
2274 unsigned int result2 = 0u;
2276 unsigned constraint1Tag = 1u;
2277 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2278 constraint1.SetTag( constraint1Tag );
2279 constraint1.Apply();
2281 unsigned constraint2Tag = 2u;
2282 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2283 constraint2.SetTag( constraint2Tag );
2284 constraint2.Apply();
2286 Stage::GetCurrent().Add( actor );
2287 // flush the queue and render once
2288 application.SendNotification();
2289 application.Render();
2291 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2292 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2294 // 2. Remove Constraint1 and test...
2297 actor.RemoveConstraints(constraint1Tag);
2298 // make color property dirty, which will trigger constraints to be reapplied.
2299 actor.SetColor( Color::WHITE );
2300 // flush the queue and render once
2301 application.SendNotification();
2302 application.Render();
2304 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2305 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2307 // 3. Re-Apply Constraint1 and test...
2310 constraint1.Apply();
2311 // make color property dirty, which will trigger constraints to be reapplied.
2312 actor.SetColor( Color::WHITE );
2313 // flush the queue and render once
2314 application.SendNotification();
2315 application.Render();
2317 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2318 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2320 // 2. Remove Constraint2 and test...
2323 actor.RemoveConstraints(constraint2Tag);
2324 // make color property dirty, which will trigger constraints to be reapplied.
2325 actor.SetColor( Color::WHITE );
2326 // flush the queue and render once
2327 application.SendNotification();
2328 application.Render();
2330 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2331 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2333 // 2. Remove Constraint1 as well and test...
2336 actor.RemoveConstraints(constraint1Tag);
2337 // make color property dirty, which will trigger constraints to be reapplied.
2338 actor.SetColor( Color::WHITE );
2339 // flush the queue and render once
2340 application.SendNotification();
2341 application.Render();
2343 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2344 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2348 int UtcDaliActorTouchedSignal(void)
2350 TestApplication application;
2352 ResetTouchCallbacks();
2354 // get the root layer
2355 Actor actor = Stage::GetCurrent().GetRootLayer();
2356 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2358 application.SendNotification();
2359 application.Render();
2361 // connect to its touch signal
2362 actor.TouchedSignal().Connect( TestCallback );
2364 // simulate a touch event in the middle of the screen
2365 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2366 Dali::Integration::Point point;
2367 point.SetDeviceId( 1 );
2368 point.SetState( PointState::DOWN );
2369 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2370 Dali::Integration::TouchEvent event;
2371 event.AddPoint( point );
2372 application.ProcessEvent( event );
2374 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2378 int UtcDaliActorHoveredSignal(void)
2380 TestApplication application;
2382 gHoverCallBackCalled = false;
2384 // get the root layer
2385 Actor actor = Stage::GetCurrent().GetRootLayer();
2386 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2388 application.SendNotification();
2389 application.Render();
2391 // connect to its hover signal
2392 actor.HoveredSignal().Connect( TestCallback3 );
2394 // simulate a hover event in the middle of the screen
2395 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2396 Dali::Integration::Point point;
2397 point.SetDeviceId( 1 );
2398 point.SetState( PointState::MOTION );
2399 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2400 Dali::Integration::HoverEvent event;
2401 event.AddPoint( point );
2402 application.ProcessEvent( event );
2404 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2408 int UtcDaliActorOnOffStageSignal(void)
2410 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2412 TestApplication application;
2415 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2416 gActorNamesOnOffStage.clear();
2418 Actor parent = Actor::New();
2419 parent.SetName( "parent" );
2420 parent.OnStageSignal().Connect( OnStageCallback );
2421 parent.OffStageSignal().Connect( OffStageCallback );
2423 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2424 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2426 // add parent to stage
2427 Stage::GetCurrent().Add( parent );
2428 // onstage emitted, offstage not
2429 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2430 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2431 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2433 // test adding a child, should get onstage emitted
2435 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2436 gActorNamesOnOffStage.clear();
2438 Actor child = Actor::New();
2439 child.SetName( "child" );
2440 child.OnStageSignal().Connect( OnStageCallback );
2441 child.OffStageSignal().Connect( OffStageCallback );
2442 parent.Add( child ); // add child
2443 // onstage emitted, offstage not
2444 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2445 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2446 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2448 // test removing parent from stage
2450 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2451 gActorNamesOnOffStage.clear();
2453 Stage::GetCurrent().Remove( parent );
2454 // onstage not emitted, offstage is
2455 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2456 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2457 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2458 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2460 // test adding parent back to stage
2462 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2463 gActorNamesOnOffStage.clear();
2465 Stage::GetCurrent().Add( parent );
2466 // onstage emitted, offstage not
2467 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2468 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2469 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2470 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2472 // test removing child
2474 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2475 gActorNamesOnOffStage.clear();
2477 parent.Remove( child );
2478 // onstage not emitted, offstage is
2479 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2480 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2481 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2483 // test removing parent
2485 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2486 gActorNamesOnOffStage.clear();
2488 Stage::GetCurrent().Remove( parent );
2489 // onstage not emitted, offstage is
2490 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2491 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2492 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2496 int UtcDaliActorFindChildByName(void)
2498 tet_infoline("Testing Dali::Actor::FindChildByName()");
2499 TestApplication application;
2501 Actor parent = Actor::New();
2502 parent.SetName( "parent" );
2503 Actor first = Actor::New();
2504 first .SetName( "first" );
2505 Actor second = Actor::New();
2506 second.SetName( "second" );
2511 Actor found = parent.FindChildByName( "foo" );
2512 DALI_TEST_CHECK( !found );
2514 found = parent.FindChildByName( "parent" );
2515 DALI_TEST_CHECK( found == parent );
2517 found = parent.FindChildByName( "first" );
2518 DALI_TEST_CHECK( found == first );
2520 found = parent.FindChildByName( "second" );
2521 DALI_TEST_CHECK( found == second );
2525 int UtcDaliActorFindChildById(void)
2527 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2528 TestApplication application;
2530 Actor parent = Actor::New();
2531 Actor first = Actor::New();
2532 Actor second = Actor::New();
2537 Actor found = parent.FindChildById( 100000 );
2538 DALI_TEST_CHECK( !found );
2540 found = parent.FindChildById( parent.GetId() );
2541 DALI_TEST_CHECK( found == parent );
2543 found = parent.FindChildById( first.GetId() );
2544 DALI_TEST_CHECK( found == first );
2546 found = parent.FindChildById( second.GetId() );
2547 DALI_TEST_CHECK( found == second );
2551 int UtcDaliActorHitTest(void)
2556 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2558 mTouchPoint( touchPoint ),
2563 Vector2 mTouchPoint;
2567 TestApplication application;
2568 tet_infoline(" UtcDaliActorHitTest");
2570 // Fill a vector with different hit tests.
2571 struct HitTestData* hitTestData[] = {
2572 // scale touch point result
2573 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2574 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2575 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.
2576 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2577 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.
2581 // get the root layer
2582 Actor actor = Actor::New();
2583 actor.SetAnchorPoint( AnchorPoint::CENTER );
2584 actor.SetParentOrigin( ParentOrigin::CENTER );
2586 Stage::GetCurrent().Add( actor );
2588 ResetTouchCallbacks();
2590 unsigned int index = 0;
2591 while( NULL != hitTestData[index] )
2593 actor.SetSize( 1.f, 1.f );
2594 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2596 // flush the queue and render once
2597 application.SendNotification();
2598 application.Render();
2600 DALI_TEST_CHECK( !gTouchCallBackCalled );
2602 // connect to its touch signal
2603 actor.TouchedSignal().Connect(TestCallback);
2605 Dali::Integration::Point point;
2606 point.SetState( PointState::DOWN );
2607 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2608 Dali::Integration::TouchEvent event;
2609 event.AddPoint( point );
2611 // flush the queue and render once
2612 application.SendNotification();
2613 application.Render();
2614 application.ProcessEvent( event );
2616 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2618 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2619 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2620 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2621 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2622 hitTestData[index]->mResult );
2624 ResetTouchCallbacks();
2630 int UtcDaliActorSetDrawMode(void)
2632 TestApplication app;
2633 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2635 Actor a = Actor::New();
2637 Stage::GetCurrent().Add(a);
2638 app.SendNotification();
2640 app.SendNotification();
2643 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2645 a.SetDrawMode( DrawMode::OVERLAY_2D );
2646 app.SendNotification();
2649 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2651 a.SetDrawMode( DrawMode::NORMAL );
2652 app.SendNotification();
2655 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2659 int UtcDaliActorSetDrawModeOverlayRender(void)
2661 TestApplication app;
2662 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2664 app.SendNotification();
2667 std::vector<GLuint> ids;
2668 ids.push_back( 8 ); // first rendered actor
2669 ids.push_back( 9 ); // second rendered actor
2670 ids.push_back( 10 ); // third rendered actor
2671 app.GetGlAbstraction().SetNextTextureIds( ids );
2673 BufferImage imageA = BufferImage::New(16, 16);
2674 BufferImage imageB = BufferImage::New(16, 16);
2675 BufferImage imageC = BufferImage::New(16, 16);
2676 Actor a = CreateRenderableActor( imageA );
2677 Actor b = CreateRenderableActor( imageB );
2678 Actor c = CreateRenderableActor( imageC );
2680 app.SendNotification();
2683 //Textures are bound when first created. Clear bound textures vector
2684 app.GetGlAbstraction().ClearBoundTextures();
2686 // Render a,b,c as regular non-overlays. so order will be:
2690 Stage::GetCurrent().Add(a);
2691 Stage::GetCurrent().Add(b);
2692 Stage::GetCurrent().Add(c);
2694 app.SendNotification();
2697 // Should be 3 textures changes.
2698 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2699 typedef std::vector<GLuint>::size_type TextureSize;
2700 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2701 if( boundTextures.size() == 3 )
2703 DALI_TEST_CHECK( boundTextures[0] == 8u );
2704 DALI_TEST_CHECK( boundTextures[1] == 9u );
2705 DALI_TEST_CHECK( boundTextures[2] == 10u );
2708 // Now texture ids have been set, we can monitor their render order.
2709 // render a as an overlay (last), so order will be:
2713 a.SetDrawMode( DrawMode::OVERLAY_2D );
2714 app.GetGlAbstraction().ClearBoundTextures();
2716 app.SendNotification();
2719 // Should be 3 texture changes.
2720 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2721 if( boundTextures.size() == 3 )
2723 DALI_TEST_CHECK( boundTextures[0] == 9u );
2724 DALI_TEST_CHECK( boundTextures[1] == 10u );
2725 DALI_TEST_CHECK( boundTextures[2] == 8u );
2730 int UtcDaliActorGetCurrentWorldMatrix(void)
2732 TestApplication app;
2733 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2735 Actor parent = Actor::New();
2736 parent.SetParentOrigin(ParentOrigin::CENTER);
2737 parent.SetAnchorPoint(AnchorPoint::CENTER);
2738 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2739 Radian rotationAngle(Degree(85.0f));
2740 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2741 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2742 parent.SetPosition( parentPosition );
2743 parent.SetOrientation( parentRotation );
2744 parent.SetScale( parentScale );
2745 Stage::GetCurrent().Add( parent );
2747 Actor child = Actor::New();
2748 child.SetParentOrigin(ParentOrigin::CENTER);
2749 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2750 Radian childRotationAngle(Degree(23.0f));
2751 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2752 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2753 child.SetPosition( childPosition );
2754 child.SetOrientation( childRotation );
2755 child.SetScale( childScale );
2756 parent.Add( child );
2758 app.SendNotification();
2761 app.SendNotification();
2763 Matrix parentMatrix(false);
2764 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2766 Matrix childMatrix(false);
2767 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2769 //Child matrix should be the composition of child and parent
2770 Matrix childWorldMatrix(false);
2771 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2773 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2774 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2780 int UtcDaliActorConstrainedToWorldMatrix(void)
2782 TestApplication app;
2783 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2785 Actor parent = Actor::New();
2786 parent.SetParentOrigin(ParentOrigin::CENTER);
2787 parent.SetAnchorPoint(AnchorPoint::CENTER);
2788 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2789 Radian rotationAngle(Degree(85.0f));
2790 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2791 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2792 parent.SetPosition( parentPosition );
2793 parent.SetOrientation( parentRotation );
2794 parent.SetScale( parentScale );
2795 Stage::GetCurrent().Add( parent );
2797 Actor child = Actor::New();
2798 child.SetParentOrigin(ParentOrigin::CENTER);
2799 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2800 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2801 posConstraint.Apply();
2803 Stage::GetCurrent().Add( child );
2805 app.SendNotification();
2808 app.SendNotification();
2810 Matrix parentMatrix(false);
2811 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2813 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2814 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2818 int UtcDaliActorConstrainedToOrientation(void)
2820 TestApplication app;
2821 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2823 Actor parent = Actor::New();
2824 parent.SetParentOrigin(ParentOrigin::CENTER);
2825 parent.SetAnchorPoint(AnchorPoint::CENTER);
2826 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2827 Radian rotationAngle(Degree(85.0f));
2828 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2829 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2830 parent.SetPosition( parentPosition );
2831 parent.SetOrientation( parentRotation );
2832 parent.SetScale( parentScale );
2833 Stage::GetCurrent().Add( parent );
2835 Actor child = Actor::New();
2836 child.SetParentOrigin(ParentOrigin::CENTER);
2837 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2838 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2839 posConstraint.Apply();
2841 Stage::GetCurrent().Add( child );
2843 app.SendNotification();
2846 app.SendNotification();
2848 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2852 int UtcDaliActorConstrainedToOpacity(void)
2854 TestApplication app;
2855 tet_infoline(" UtcDaliActorConstrainedToOpacity");
2857 Actor parent = Actor::New();
2858 parent.SetOpacity( 0.7f );
2859 Stage::GetCurrent().Add( parent );
2861 Actor child = Actor::New();
2862 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2863 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2864 opacityConstraint.Apply();
2866 Stage::GetCurrent().Add( child );
2868 app.SendNotification();
2871 app.SendNotification();
2873 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2875 parent.SetOpacity( 0.3f );
2877 app.SendNotification();
2880 app.SendNotification();
2882 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2887 int UtcDaliActorUnparent(void)
2889 TestApplication app;
2890 tet_infoline(" UtcDaliActorUnparent");
2892 Actor parent = Actor::New();
2893 Stage::GetCurrent().Add( parent );
2895 Actor child = Actor::New();
2897 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2898 DALI_TEST_CHECK( !child.GetParent() );
2900 // Test that calling Unparent with no parent is a NOOP
2903 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2904 DALI_TEST_CHECK( !child.GetParent() );
2906 // Test that Unparent works
2907 parent.Add( child );
2909 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2910 DALI_TEST_CHECK( parent == child.GetParent() );
2914 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2915 DALI_TEST_CHECK( !child.GetParent() );
2917 // Test that UnparentAndReset works
2918 parent.Add( child );
2920 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2921 DALI_TEST_CHECK( parent == child.GetParent() );
2923 UnparentAndReset( child );
2925 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2926 DALI_TEST_CHECK( !child );
2928 // Test that UnparentAndReset is a NOOP with empty handle
2929 UnparentAndReset( child );
2931 DALI_TEST_CHECK( !child );
2935 int UtcDaliActorGetChildAt(void)
2937 TestApplication app;
2938 tet_infoline(" UtcDaliActorGetChildAt");
2940 Actor parent = Actor::New();
2941 Stage::GetCurrent().Add( parent );
2943 Actor child0 = Actor::New();
2944 parent.Add( child0 );
2946 Actor child1 = Actor::New();
2947 parent.Add( child1 );
2949 Actor child2 = Actor::New();
2950 parent.Add( child2 );
2952 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2953 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2954 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2958 int UtcDaliActorSetGetOverlay(void)
2960 TestApplication app;
2961 tet_infoline(" UtcDaliActorSetGetOverlay");
2963 Actor parent = Actor::New();
2964 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2965 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2970 int UtcDaliActorCreateDestroy(void)
2972 Actor* actor = new Actor;
2973 DALI_TEST_CHECK( actor );
2980 struct PropertyStringIndex
2982 const char * const name;
2983 const Property::Index index;
2984 const Property::Type type;
2987 const PropertyStringIndex PROPERTY_TABLE[] =
2989 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2990 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2991 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2992 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2993 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2994 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2995 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2996 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2997 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2998 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2999 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
3000 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
3001 { "position", Actor::Property::POSITION, Property::VECTOR3 },
3002 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
3003 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
3004 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
3005 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
3006 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
3007 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
3008 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
3009 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
3010 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
3011 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
3012 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
3013 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
3014 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
3015 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
3016 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
3017 { "color", Actor::Property::COLOR, Property::VECTOR4 },
3018 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
3019 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
3020 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
3021 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
3022 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
3023 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
3024 { "name", Actor::Property::NAME, Property::STRING },
3025 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
3026 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
3027 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
3028 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
3029 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
3030 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3031 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3032 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3033 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3034 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3035 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3036 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3037 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3038 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3039 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3040 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3041 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3042 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3043 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3045 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3046 } // unnamed namespace
3048 int UtcDaliActorProperties(void)
3050 TestApplication app;
3052 Actor actor = Actor::New();
3054 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3056 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3057 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3058 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3059 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3064 int UtcDaliRelayoutProperties_ResizePolicies(void)
3066 TestApplication app;
3068 Actor actor = Actor::New();
3071 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3072 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3074 // Set resize policy for all dimensions
3075 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3076 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3078 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3081 // Set individual dimensions
3082 const char* const widthPolicy = "FILL_TO_PARENT";
3083 const char* const heightPolicy = "FIXED";
3085 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3086 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3088 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3089 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3091 // Set individual dimensions using enums
3092 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3093 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3095 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3096 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3098 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3099 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3104 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3106 TestApplication app;
3108 Actor actor = Actor::New();
3111 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3112 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3114 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3115 actor.SetSizeScalePolicy( policy );
3116 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3119 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3120 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3122 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3123 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3125 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3126 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3131 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3133 TestApplication app;
3135 Actor actor = Actor::New();
3138 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3139 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3141 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3142 actor.SetSizeModeFactor( sizeMode );
3143 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3146 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3148 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3149 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3154 int UtcDaliRelayoutProperties_DimensionDependency(void)
3156 TestApplication app;
3158 Actor actor = Actor::New();
3161 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3162 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3165 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3166 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3168 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3169 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3171 // Test setting another resize policy
3172 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3173 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3178 int UtcDaliRelayoutProperties_Padding(void)
3180 TestApplication app;
3182 Actor actor = Actor::New();
3185 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3188 actor.SetProperty( Actor::Property::PADDING, padding );
3189 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3191 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3196 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3198 TestApplication app;
3200 Actor actor = Actor::New();
3203 Vector2 minSize( 1.0f, 2.0f );
3205 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3206 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3208 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3210 Vector2 maxSize( 3.0f, 4.0f );
3212 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3213 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3215 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3220 int UtcDaliActorGetHeightForWidth(void)
3222 TestApplication app;
3224 Actor actor = Actor::New();
3226 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3231 int UtcDaliActorGetWidthForHeight(void)
3233 TestApplication app;
3235 Actor actor = Actor::New();
3237 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3242 int UtcDaliActorGetRelayoutSize(void)
3244 TestApplication app;
3246 Actor actor = Actor::New();
3248 // Add actor to stage
3249 Stage::GetCurrent().Add( actor );
3251 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3253 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3254 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3256 // Flush the queue and render once
3257 app.SendNotification();
3260 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3265 int UtcDaliActorSetPadding(void)
3267 TestApplication app;
3269 Actor actor = Actor::New();
3272 actor.GetPadding( padding );
3274 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3275 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3276 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3277 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3279 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3280 actor.SetPadding( padding2 );
3282 actor.GetPadding( padding );
3284 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3285 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3286 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3287 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3292 int UtcDaliActorSetMinimumSize(void)
3294 TestApplication app;
3296 Actor actor = Actor::New();
3298 Vector2 size = actor.GetMinimumSize();
3300 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3301 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3303 Vector2 size2( 1.0f, 2.0f );
3304 actor.SetMinimumSize( size2 );
3306 size = actor.GetMinimumSize();
3308 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3309 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3314 int UtcDaliActorSetMaximumSize(void)
3316 TestApplication app;
3318 Actor actor = Actor::New();
3320 Vector2 size = actor.GetMaximumSize();
3322 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3323 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3325 Vector2 size2( 1.0f, 2.0f );
3326 actor.SetMaximumSize( size2 );
3328 size = actor.GetMaximumSize();
3330 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3331 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3336 int UtcDaliActorOnRelayoutSignal(void)
3338 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3340 TestApplication application;
3343 gOnRelayoutCallBackCalled = false;
3344 gActorNamesRelayout.clear();
3346 Actor actor = Actor::New();
3347 actor.SetName( "actor" );
3348 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3351 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3353 // Add actor to stage
3354 Stage::GetCurrent().Add( actor );
3356 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3357 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3359 // Flush the queue and render once
3360 application.SendNotification();
3361 application.Render();
3363 // OnRelayout emitted
3364 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3365 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3370 int UtcDaliActorGetHierachyDepth(void)
3372 TestApplication application;
3373 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3376 /* Build tree of actors:
3386 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3388 Stage stage( Stage::GetCurrent() );
3390 Actor actorA = Actor::New();
3391 Actor actorB = Actor::New();
3392 Actor actorC = Actor::New();
3393 Actor actorD = Actor::New();
3394 Actor actorE = Actor::New();
3395 Actor actorF = Actor::New();
3397 //Test that root actor has depth equal 0
3398 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3400 //Test actors return depth -1 when not connected to the tree
3401 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3402 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3403 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3404 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3405 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3406 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3408 //Create the hierarchy
3409 stage.Add( actorA );
3410 actorA.Add( actorB );
3411 actorA.Add( actorC );
3412 actorB.Add( actorD );
3413 actorB.Add( actorE );
3414 actorC.Add( actorF );
3416 //Test actors return correct depth
3417 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3418 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3419 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3420 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3421 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3422 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3424 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3425 actorA.Remove( actorB );
3427 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3428 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3429 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3431 //Removing actorA from the stage. All actors should have depth equal -1
3432 stage.Remove( actorA );
3434 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3435 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3436 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3437 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3438 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3439 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3444 int UtcDaliActorAnchorPointPropertyAsString(void)
3446 TestApplication application;
3448 Actor actor = Actor::New();
3450 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3451 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3453 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3454 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3456 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3457 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3459 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3460 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3462 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3463 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3465 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3466 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3468 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3469 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3471 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3472 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3474 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3475 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3477 // Invalid should not change anything
3478 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3479 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3484 int UtcDaliActorParentOriginPropertyAsString(void)
3486 TestApplication application;
3488 Actor actor = Actor::New();
3490 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3491 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3493 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3494 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3496 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3497 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3499 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3500 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3502 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3503 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3505 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3506 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3508 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3509 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3511 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3512 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3514 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3515 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3517 // Invalid should not change anything
3518 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3519 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3524 int UtcDaliActorColorModePropertyAsString(void)
3526 TestApplication application;
3528 Actor actor = Actor::New();
3530 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3531 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3533 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3534 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3536 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3537 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3539 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3540 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3542 // Invalid should not change anything
3543 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3544 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3549 int UtcDaliActorPositionInheritancePropertyAsString(void)
3551 TestApplication application;
3553 Actor actor = Actor::New();
3555 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3556 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3558 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3559 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3561 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3562 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3564 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3565 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3567 // Invalid should not change anything
3568 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3569 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3574 int UtcDaliActorDrawModePropertyAsString(void)
3576 TestApplication application;
3578 Actor actor = Actor::New();
3580 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3581 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3583 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3584 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3586 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3587 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3589 // Invalid should not change anything
3590 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3591 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3596 int UtcDaliActorColorModePropertyAsEnum(void)
3598 TestApplication application;
3600 Actor actor = Actor::New();
3602 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3603 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3605 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3606 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3608 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3609 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3611 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3612 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3617 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3619 TestApplication application;
3621 Actor actor = Actor::New();
3623 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3624 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3626 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3627 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3629 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3630 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3632 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3633 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3638 int UtcDaliActorDrawModePropertyAsEnum(void)
3640 TestApplication application;
3642 Actor actor = Actor::New();
3644 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3645 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3647 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3648 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3650 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3651 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3656 int UtcDaliActorAddRendererP(void)
3658 tet_infoline("Testing Actor::AddRenderer");
3659 TestApplication application;
3661 Actor actor = Actor::New();
3663 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3665 Geometry geometry = CreateQuadGeometry();
3666 Shader shader = CreateShader();
3667 Renderer renderer = Renderer::New(geometry, shader);
3669 actor.AddRenderer( renderer );
3670 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3671 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3676 int UtcDaliActorAddRendererN(void)
3678 tet_infoline("Testing Actor::AddRenderer");
3679 TestApplication application;
3681 Actor actor = Actor::New();
3687 actor.AddRenderer( renderer );
3688 tet_printf("Assertion test failed - no Exception\n" );
3689 tet_result(TET_FAIL);
3691 catch(Dali::DaliException& e)
3693 DALI_TEST_PRINT_ASSERT( e );
3694 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3695 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3699 tet_printf("Assertion test failed - wrong Exception\n" );
3700 tet_result(TET_FAIL);
3706 int UtcDaliActorAddRendererOnStage(void)
3708 tet_infoline("Testing Actor::AddRenderer");
3709 TestApplication application;
3711 Actor actor = Actor::New();
3712 Stage::GetCurrent().Add(actor);
3714 application.SendNotification();
3715 application.Render(0);
3717 Geometry geometry = CreateQuadGeometry();
3718 Shader shader = CreateShader();
3719 Renderer renderer = Renderer::New(geometry, shader);
3721 application.SendNotification();
3722 application.Render(0);
3726 actor.AddRenderer( renderer );
3727 tet_result(TET_PASS);
3731 tet_result(TET_FAIL);
3737 int UtcDaliActorRemoveRendererP1(void)
3739 tet_infoline("Testing Actor::RemoveRenderer");
3740 TestApplication application;
3742 Actor actor = Actor::New();
3744 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3746 Geometry geometry = CreateQuadGeometry();
3747 Shader shader = CreateShader();
3748 Renderer renderer = Renderer::New(geometry, shader);
3750 actor.AddRenderer( renderer );
3751 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3752 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3754 actor.RemoveRenderer(renderer);
3755 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3761 int UtcDaliActorRemoveRendererP2(void)
3763 tet_infoline("Testing Actor::RemoveRenderer");
3764 TestApplication application;
3766 Actor actor = Actor::New();
3768 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3770 Geometry geometry = CreateQuadGeometry();
3771 Shader shader = CreateShader();
3772 Renderer renderer = Renderer::New(geometry, shader);
3774 actor.AddRenderer( renderer );
3775 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3776 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3778 actor.RemoveRenderer(0);
3779 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3786 int UtcDaliActorRemoveRendererN(void)
3788 tet_infoline("Testing Actor::RemoveRenderer");
3789 TestApplication application;
3791 Actor actor = Actor::New();
3793 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3795 Geometry geometry = CreateQuadGeometry();
3796 Shader shader = CreateShader();
3797 Renderer renderer = Renderer::New(geometry, shader);
3799 actor.AddRenderer( renderer );
3800 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3801 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3803 actor.RemoveRenderer(10);
3804 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3805 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3810 // Clipping test helper functions:
3811 Actor CreateActorWithContent()
3813 BufferImage image = BufferImage::New( 16u, 16u );
3814 Actor actor = CreateRenderableActor( image );
3816 // Setup dimensions and position so actor is not skipped by culling.
3817 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3818 actor.SetSize( 16.0f, 16.0f );
3819 actor.SetParentOrigin( ParentOrigin::CENTER );
3820 actor.SetAnchorPoint( AnchorPoint::CENTER );
3825 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3827 enabledDisableTrace.Reset();
3828 stencilTrace.Reset();
3829 enabledDisableTrace.Enable( true );
3830 stencilTrace.Enable( true );
3832 application.SendNotification();
3833 application.Render();
3835 enabledDisableTrace.Enable( false );
3836 stencilTrace.Enable( false );
3839 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3841 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3843 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3844 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3845 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3846 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3849 int UtcDaliActorPropertyClippingP(void)
3851 // This test checks the clippingMode property.
3852 tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3853 TestApplication application;
3855 Actor actor = Actor::New();
3857 // Check default clippingEnabled value.
3858 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3861 bool getValueResult = getValue.Get( value );
3862 DALI_TEST_CHECK( getValueResult );
3864 if( getValueResult )
3866 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3869 // Check setting the property.
3870 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3872 // Check the new value was set.
3873 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3874 getValueResult = getValue.Get( value );
3875 DALI_TEST_CHECK( getValueResult );
3877 if( getValueResult )
3879 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3885 int UtcDaliActorPropertyClippingN(void)
3887 // Negative test case for Clipping.
3888 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3889 TestApplication application;
3891 Actor actor = Actor::New();
3893 // Check default clippingEnabled value.
3894 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3897 bool getValueResult = getValue.Get( value );
3898 DALI_TEST_CHECK( getValueResult );
3900 if( getValueResult )
3902 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3905 // Check setting an invalid property value won't change the current property value.
3906 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3908 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3909 getValueResult = getValue.Get( value );
3910 DALI_TEST_CHECK( getValueResult );
3912 if( getValueResult )
3914 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3920 int UtcDaliActorPropertyClippingActor(void)
3922 // This test checks that an actor is correctly setup for clipping.
3923 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3924 TestApplication application;
3926 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3927 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3928 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3929 size_t startIndex = 0u;
3931 // Create a clipping actor.
3932 Actor actorDepth1Clip = CreateActorWithContent();
3933 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3934 Stage::GetCurrent().Add( actorDepth1Clip );
3936 // Gather the call trace.
3937 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3939 // Check we are writing to the color buffer.
3940 CheckColorMask( glAbstraction, true );
3942 // Check the stencil buffer was enabled.
3943 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
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 ) );
3951 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3956 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
3958 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
3959 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
3960 TestApplication application;
3962 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3963 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3964 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3965 size_t startIndex = 0u;
3967 // Create a clipping actor.
3968 Actor actorDepth1Clip = CreateActorWithContent();
3969 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3970 Stage::GetCurrent().Add( actorDepth1Clip );
3972 // Gather the call trace.
3973 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3975 // Check we are writing to the color buffer.
3976 CheckColorMask( glAbstraction, true );
3978 // Check the stencil buffer was enabled.
3979 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3981 // Check the stencil buffer was cleared.
3982 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3984 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3985 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3986 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3987 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3989 // Now disable the clipping
3990 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
3992 // Gather the call trace.
3993 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3995 // Check the stencil buffer was disabled.
3996 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3998 // Ensure all values in stencil-mask are set to 1.
4000 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
4006 int UtcDaliActorPropertyClippingNestedChildren(void)
4008 // This test checks that a hierarchy of actors are clipped correctly by
4009 // writing to and reading from the correct bit-planes of the stencil buffer.
4010 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
4011 TestApplication application;
4012 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4013 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4014 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4016 // Create a clipping actor.
4017 Actor actorDepth1Clip = CreateActorWithContent();
4018 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4019 Stage::GetCurrent().Add( actorDepth1Clip );
4021 // Create a child actor.
4022 Actor childDepth2 = CreateActorWithContent();
4023 actorDepth1Clip.Add( childDepth2 );
4025 // Create another clipping actor.
4026 Actor childDepth2Clip = CreateActorWithContent();
4027 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4028 childDepth2.Add( childDepth2Clip );
4030 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4031 // This tests the sort algorithm.
4032 Actor childDepth3 = CreateActorWithContent();
4033 childDepth2Clip.Add( childDepth3 );
4034 Actor childDepth4 = CreateActorWithContent();
4035 childDepth3.Add( childDepth4 );
4037 // Gather the call trace.
4038 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4040 // Check we are writing to the color buffer.
4041 CheckColorMask( glAbstraction, true );
4043 // Check the stencil buffer was enabled.
4044 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4046 // Perform the test twice, once for 2D layer, and once for 3D.
4047 for( unsigned int i = 0u ; i < 2u; ++i )
4049 size_t startIndex = 0u;
4051 // Check the stencil buffer was cleared.
4052 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4054 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4055 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4056 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4057 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4059 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4060 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4061 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4063 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4064 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4065 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4066 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4068 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4069 // (Both must be set to pass the check).
4070 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4071 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4073 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4076 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4077 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4084 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4086 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4087 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4088 TestApplication application;
4090 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4091 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4092 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4094 // Create a clipping actor.
4095 Actor actorDepth1Clip = CreateActorWithContent();
4096 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4097 Stage::GetCurrent().Add( actorDepth1Clip );
4099 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4100 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4102 // Gather the call trace.
4103 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4105 // Check we are writing to the color buffer.
4106 CheckColorMask( glAbstraction, true );
4108 // Check the stencil buffer was not enabled.
4109 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4111 // Check stencil functions are not called.
4112 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4113 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4114 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4119 int UtcDaliGetPropertyN(void)
4121 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4122 TestApplication app;
4124 Actor actor = Actor::New();
4126 unsigned int propertyCount = actor.GetPropertyCount();
4127 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4131 int UtcDaliActorRaiseLower(void)
4133 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4135 TestApplication application;
4137 Stage stage( Stage::GetCurrent() );
4139 Actor actorA = Actor::New();
4140 Actor actorB = Actor::New();
4141 Actor actorC = Actor::New();
4143 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4144 actorA.SetParentOrigin( ParentOrigin::CENTER );
4146 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4147 actorB.SetParentOrigin( ParentOrigin::CENTER );
4149 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4150 actorC.SetParentOrigin( ParentOrigin::CENTER );
4152 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4153 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4155 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4156 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4158 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4159 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4161 stage.Add( actorA );
4162 stage.Add( actorB );
4163 stage.Add( actorC );
4165 ResetTouchCallbacks();
4167 application.SendNotification();
4168 application.Render();
4170 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4171 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4172 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4174 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4175 // Only top actor will get touched.
4176 actorA.TouchSignal().Connect( TestTouchCallback );
4177 actorB.TouchSignal().Connect( TestTouchCallback2 );
4178 actorC.TouchSignal().Connect( TestTouchCallback3 );
4180 Dali::Integration::Point point;
4181 point.SetDeviceId( 1 );
4182 point.SetState( PointState::DOWN );
4183 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4184 Dali::Integration::TouchEvent event;
4185 event.AddPoint( point );
4187 application.ProcessEvent( event );
4189 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4190 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4191 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4193 ResetTouchCallbacks();
4195 tet_printf( "Testing Raising of Actor\n" );
4197 int preActorOrder( 0 );
4198 int postActorOrder( 0 );
4200 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4201 value.Get( preActorOrder );
4203 DevelActor::Raise( actorB );
4205 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4206 value.Get( postActorOrder );
4208 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4210 application.ProcessEvent( event );
4212 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4213 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4214 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4216 ResetTouchCallbacks();
4218 tet_printf( "Testing Lowering of Actor\n" );
4220 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4221 value.Get( preActorOrder );
4223 DevelActor::Lower( actorB );
4225 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4226 value.Get( postActorOrder );
4228 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4230 application.ProcessEvent( event );
4232 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4233 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4234 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4236 ResetTouchCallbacks();
4241 int UtcDaliActorRaiseToTopLowerToBottom(void)
4243 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4245 TestApplication application;
4247 Stage stage( Stage::GetCurrent() );
4249 Actor actorA = Actor::New();
4250 Actor actorB = Actor::New();
4251 Actor actorC = Actor::New();
4253 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4254 // enables checking of which actor the uniform is assigned too
4255 Shader shaderA = CreateShader();
4256 shaderA.RegisterProperty( "uRendererColor",1.f);
4258 Shader shaderB = CreateShader();
4259 shaderB.RegisterProperty( "uRendererColor", 2.f );
4261 Shader shaderC = CreateShader();
4262 shaderC.RegisterProperty( "uRendererColor", 3.f );
4264 Geometry geometry = CreateQuadGeometry();
4266 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4267 Renderer rendererA = Renderer::New(geometry, shaderA);
4268 actorA.AddRenderer(rendererA);
4270 Renderer rendererB = Renderer::New(geometry, shaderB);
4271 actorB.AddRenderer(rendererB);
4273 Renderer rendererC = Renderer::New(geometry, shaderC);
4274 actorC.AddRenderer(rendererC);
4276 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4277 actorA.SetParentOrigin( ParentOrigin::CENTER );
4279 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4280 actorB.SetParentOrigin( ParentOrigin::CENTER );
4282 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4283 actorC.SetParentOrigin( ParentOrigin::CENTER );
4285 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4286 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4288 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4289 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4291 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4292 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4294 stage.Add( actorA );
4295 stage.Add( actorB );
4296 stage.Add( actorC );
4298 ResetTouchCallbacks();
4300 // Set up gl abstraction trace so can query the set uniform order
4301 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4302 glAbstraction.EnableSetUniformCallTrace(true);
4303 glAbstraction.ResetSetUniformCallStack();
4305 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4307 application.SendNotification();
4308 application.Render();
4310 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4313 // Test order of uniforms in stack
4314 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4315 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4316 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4318 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4320 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4322 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4323 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4324 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4326 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4327 // Only top actor will get touched.
4328 actorA.TouchSignal().Connect( TestTouchCallback );
4329 actorB.TouchSignal().Connect( TestTouchCallback2 );
4330 actorC.TouchSignal().Connect( TestTouchCallback3 );
4332 Dali::Integration::Point point;
4333 point.SetDeviceId( 1 );
4334 point.SetState( PointState::DOWN );
4335 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4336 Dali::Integration::TouchEvent event;
4337 event.AddPoint( point );
4339 application.ProcessEvent( event );
4341 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4342 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4343 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4345 ResetTouchCallbacks();
4347 tet_printf( "RaiseToTop ActorA\n" );
4349 DevelActor::RaiseToTop( actorA );
4351 application.ProcessEvent( event );
4353 glAbstraction.ResetSetUniformCallStack();
4354 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4356 application.SendNotification();
4357 application.Render();
4359 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4361 // Test order of uniforms in stack
4362 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4363 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4364 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4366 tet_infoline( "Testing A above C and B at bottom\n" );
4367 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4369 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4371 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4372 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4373 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4375 ResetTouchCallbacks();
4377 tet_printf( "RaiseToTop ActorB\n" );
4379 DevelActor::RaiseToTop( actorB );
4381 application.ProcessEvent( event );
4383 glAbstraction.ResetSetUniformCallStack();
4384 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4386 application.SendNotification();
4387 application.Render();
4389 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4391 // Test order of uniforms in stack
4392 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4393 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4394 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4396 tet_infoline( "Testing B above A and C at bottom\n" );
4397 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4399 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4401 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4402 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4403 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4405 ResetTouchCallbacks();
4407 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4409 DevelActor::LowerToBottom( actorA );
4410 application.SendNotification();
4411 application.Render();
4413 DevelActor::LowerToBottom( actorB );
4414 application.SendNotification();
4415 application.Render();
4417 application.ProcessEvent( event );
4419 glAbstraction.ResetSetUniformCallStack();
4420 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4422 application.SendNotification();
4423 application.Render();
4425 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4427 // Test order of uniforms in stack
4428 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4429 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4430 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4432 tet_infoline( "Testing C above A and B at bottom\n" );
4433 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4435 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4437 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4438 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4439 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4441 ResetTouchCallbacks();
4446 int UtcDaliActorRaiseAbove(void)
4448 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4450 TestApplication application;
4452 Stage stage( Stage::GetCurrent() );
4454 Actor actorA = Actor::New();
4455 Actor actorB = Actor::New();
4456 Actor actorC = Actor::New();
4458 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4459 actorA.SetParentOrigin( ParentOrigin::CENTER );
4461 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4462 actorB.SetParentOrigin( ParentOrigin::CENTER );
4464 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4465 actorC.SetParentOrigin( ParentOrigin::CENTER );
4467 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4468 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4470 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4471 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4473 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4474 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4476 stage.Add( actorA );
4477 stage.Add( actorB );
4478 stage.Add( actorC );
4480 ResetTouchCallbacks();
4482 application.SendNotification();
4483 application.Render();
4485 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4486 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4487 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4489 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4490 // Only top actor will get touched.
4491 actorA.TouchSignal().Connect( TestTouchCallback );
4492 actorB.TouchSignal().Connect( TestTouchCallback2 );
4493 actorC.TouchSignal().Connect( TestTouchCallback3 );
4495 Dali::Integration::Point point;
4496 point.SetDeviceId( 1 );
4497 point.SetState( PointState::DOWN );
4498 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4499 Dali::Integration::TouchEvent event;
4500 event.AddPoint( point );
4502 application.ProcessEvent( event );
4504 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4505 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4506 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4508 ResetTouchCallbacks();
4510 tet_printf( "Raise actor B Above Actor C\n" );
4512 DevelActor::RaiseAbove( actorB, actorC );
4514 application.ProcessEvent( event );
4516 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4517 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4518 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4520 ResetTouchCallbacks();
4522 tet_printf( "Raise actor A Above Actor B\n" );
4524 DevelActor::RaiseAbove( actorA, actorB );
4526 application.ProcessEvent( event );
4528 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4529 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4530 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4532 ResetTouchCallbacks();
4537 int UtcDaliActorLowerBelow(void)
4539 tet_infoline( "UtcDaliActor LowerBelow test \n" );
4541 TestApplication application;
4543 Stage stage( Stage::GetCurrent() );
4545 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4546 // enables checking of which actor the uniform is assigned too
4547 Shader shaderA = CreateShader();
4548 shaderA.RegisterProperty( "uRendererColor",1.f);
4550 Shader shaderB = CreateShader();
4551 shaderB.RegisterProperty( "uRendererColor", 2.f );
4553 Shader shaderC = CreateShader();
4554 shaderC.RegisterProperty( "uRendererColor", 3.f );
4556 Actor actorA = Actor::New();
4557 Actor actorB = Actor::New();
4558 Actor actorC = Actor::New();
4560 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4561 Geometry geometry = CreateQuadGeometry();
4563 Renderer rendererA = Renderer::New(geometry, shaderA);
4564 actorA.AddRenderer(rendererA);
4566 Renderer rendererB = Renderer::New(geometry, shaderB);
4567 actorB.AddRenderer(rendererB);
4569 Renderer rendererC = Renderer::New(geometry, shaderC);
4570 actorC.AddRenderer(rendererC);
4572 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4573 actorA.SetParentOrigin( ParentOrigin::CENTER );
4575 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4576 actorB.SetParentOrigin( ParentOrigin::CENTER );
4578 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4579 actorC.SetParentOrigin( ParentOrigin::CENTER );
4581 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4582 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4584 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4585 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4587 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4588 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4590 stage.Add( actorA );
4591 stage.Add( actorB );
4592 stage.Add( actorC );
4594 ResetTouchCallbacks();
4596 // Set up gl abstraction trace so can query the set uniform order
4597 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4598 glAbstraction.EnableSetUniformCallTrace(true);
4599 glAbstraction.ResetSetUniformCallStack();
4600 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4602 glAbstraction.ResetSetUniformCallStack();
4604 application.SendNotification();
4605 application.Render();
4607 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4609 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4611 // Test order of uniforms in stack
4612 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4613 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4614 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4616 tet_infoline( "Testing C above B and A at bottom\n" );
4617 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4619 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4621 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4622 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4623 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4625 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4626 // Only top actor will get touched.
4627 actorA.TouchSignal().Connect( TestTouchCallback );
4628 actorB.TouchSignal().Connect( TestTouchCallback2 );
4629 actorC.TouchSignal().Connect( TestTouchCallback3 );
4631 Dali::Integration::Point point;
4632 point.SetDeviceId( 1 );
4633 point.SetState( PointState::DOWN );
4634 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4635 Dali::Integration::TouchEvent event;
4636 event.AddPoint( point );
4638 tet_infoline( "UtcDaliActor Test Set up completed \n" );
4640 application.ProcessEvent( event );
4642 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4643 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4644 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4646 ResetTouchCallbacks();
4648 tet_printf( "Lower actor C below Actor B ( actor B and A on same level due to insertion order) so C is below both \n" );
4650 DevelActor::LowerBelow( actorC, actorB );
4652 application.SendNotification();
4653 application.Render();
4655 application.ProcessEvent( event );
4657 glAbstraction.ResetSetUniformCallStack();
4658 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4660 application.SendNotification();
4661 application.Render();
4663 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4665 // Test order of uniforms in stack
4666 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4667 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4668 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4670 tet_infoline( "Testing B above A and C at bottom\n" );
4671 bool BAC = ( indexB > indexA) && ( indexA > indexC ); // B at TOP, then A then C at bottom
4673 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4675 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4676 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4677 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4679 ResetTouchCallbacks();
4681 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4683 DevelActor::LowerBelow( actorB, actorC );
4685 application.SendNotification();
4686 application.Render();
4688 application.ProcessEvent( event );
4690 glAbstraction.ResetSetUniformCallStack();
4691 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4693 application.Render();
4694 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4696 // Test order of uniforms in stack
4697 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4698 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4699 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4701 bool ACB = ( indexA > indexC) && ( indexC > indexB ); // A on TOP, then C then B at bottom
4703 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4705 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4706 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4707 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4709 ResetTouchCallbacks();
4711 tet_printf( "Lower actor A below Actor C leaving C on top\n" );
4713 DevelActor::LowerBelow( actorA, actorC );
4715 application.SendNotification();
4716 application.Render();
4718 application.ProcessEvent( event );
4720 glAbstraction.ResetSetUniformCallStack();
4721 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4723 application.Render();
4724 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4726 // Test order of uniforms in stack
4727 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4728 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4729 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4731 bool CAB = ( indexC > indexA) && ( indexA > indexB );
4733 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4738 int UtcDaliActorMaxSiblingOrder(void)
4740 tet_infoline( "UtcDaliActor De-fragment of sibling order once max index reached\n" );
4742 TestApplication application;
4744 int testOrders[] = { 0,1,3,5,17,998, 999 };
4745 int resultingOrders[] = { 0,1,2,3,4,6,5 };
4747 const int TEST_ORDERS_COUNT = sizeof( testOrders ) / sizeof( testOrders[0] );
4749 Stage stage( Stage::GetCurrent() );
4751 Actor parent = Actor::New();
4753 for ( int index = 0; index < TEST_ORDERS_COUNT; index++ )
4755 Actor newActor = Actor::New();
4756 newActor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, testOrders[index] );
4757 parent.Add( newActor );
4759 stage.Add( parent );
4761 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4762 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4764 Actor sibling = parent.GetChildAt( index );
4765 int siblingOrder = 0;
4766 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4767 value.Get( siblingOrder );
4768 tet_printf( "%d, ", siblingOrder );
4772 Actor sibling = parent.GetChildAt( 5 );
4773 DevelActor::RaiseToTop( sibling );
4775 application.SendNotification();
4776 application.Render();
4778 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4779 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4781 Actor sibling = parent.GetChildAt( index );
4782 int siblingOrder = 0;
4783 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4784 value.Get( siblingOrder );
4785 tet_printf( "%d, ", siblingOrder );
4786 DALI_TEST_EQUALS( siblingOrder, resultingOrders[ index] , TEST_LOCATION );
4794 int UtcDaliActorRaiseAboveLowerBelowDifferentParentsN(void)
4796 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4798 TestApplication application;
4800 Stage stage( Stage::GetCurrent() );
4802 Actor parentA = Actor::New();
4803 Actor parentB = Actor::New();
4804 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4805 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4806 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4807 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4809 parentA.SetAnchorPoint( AnchorPoint::CENTER );
4810 parentA.SetParentOrigin( ParentOrigin::CENTER );
4812 parentB.SetAnchorPoint( AnchorPoint::CENTER );
4813 parentB.SetParentOrigin( ParentOrigin::CENTER );
4815 stage.Add( parentA );
4816 stage.Add( parentB );
4818 Actor actorA = Actor::New();
4819 Actor actorB = Actor::New();
4820 Actor actorC = Actor::New();
4822 parentA.Add( actorA );
4823 parentA.Add( actorB );
4825 tet_printf( "Actor C added to different parent from A and B \n" );
4826 parentB.Add( actorC );
4828 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4829 actorA.SetParentOrigin( ParentOrigin::CENTER );
4831 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4832 actorB.SetParentOrigin( ParentOrigin::CENTER );
4834 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4835 actorC.SetParentOrigin( ParentOrigin::CENTER );
4837 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4838 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4840 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4841 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4843 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4844 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4846 ResetTouchCallbacks();
4848 application.SendNotification();
4849 application.Render();
4851 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4852 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4853 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4855 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4856 // Only top actor will get touched.
4857 actorA.TouchSignal().Connect( TestTouchCallback );
4858 actorB.TouchSignal().Connect( TestTouchCallback2 );
4859 actorC.TouchSignal().Connect( TestTouchCallback3 );
4861 Dali::Integration::Point point;
4862 point.SetDeviceId( 1 );
4863 point.SetState( PointState::DOWN );
4864 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4865 Dali::Integration::TouchEvent event;
4866 event.AddPoint( point );
4868 application.ProcessEvent( event );
4870 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4871 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4872 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4874 ResetTouchCallbacks();
4876 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
4878 DevelActor::RaiseAbove( actorA, actorC );
4880 application.ProcessEvent( event );
4882 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4883 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4884 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4886 ResetTouchCallbacks();
4891 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
4893 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
4895 TestApplication application;
4897 Stage stage( Stage::GetCurrent() );
4899 Actor actorA = Actor::New();
4900 Actor actorB = Actor::New();
4901 Actor actorC = Actor::New();
4903 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4904 actorA.SetParentOrigin( ParentOrigin::CENTER );
4906 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4907 actorB.SetParentOrigin( ParentOrigin::CENTER );
4909 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4910 actorC.SetParentOrigin( ParentOrigin::CENTER );
4912 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4913 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4915 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4916 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4918 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4919 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4921 ResetTouchCallbacks();
4923 application.SendNotification();
4924 application.Render();
4926 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4927 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4928 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4930 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4931 // Only top actor will get touched.
4932 actorA.TouchSignal().Connect( TestTouchCallback );
4933 actorB.TouchSignal().Connect( TestTouchCallback2 );
4934 actorC.TouchSignal().Connect( TestTouchCallback3 );
4936 Dali::Integration::Point point;
4937 point.SetDeviceId( 1 );
4938 point.SetState( PointState::DOWN );
4939 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4940 Dali::Integration::TouchEvent event;
4941 event.AddPoint( point );
4943 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
4945 DevelActor::RaiseAbove( actorA, actorC );
4947 application.ProcessEvent( event );
4949 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
4951 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4952 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4953 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4955 ResetTouchCallbacks();
4957 stage.Add ( actorB );
4959 application.SendNotification();
4960 application.Render();
4962 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
4963 DevelActor::LowerBelow( actorA, actorC );
4964 application.ProcessEvent( event );
4966 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
4967 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4968 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4969 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4971 ResetTouchCallbacks();
4973 tet_printf( "Adding Actor A to stage, will be on top\n" );
4975 stage.Add ( actorA );
4976 application.SendNotification();
4977 application.Render();
4979 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
4980 DevelActor::RaiseAbove( actorB, actorC );
4981 application.ProcessEvent( event );
4983 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
4984 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4985 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4986 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4988 ResetTouchCallbacks();
4990 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
4991 DevelActor::LowerBelow( actorA, actorC );
4992 application.ProcessEvent( event );
4994 tet_printf( "C not parented so LowerBelow should show no effect\n" );
4995 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4996 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4997 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4999 ResetTouchCallbacks();
5001 stage.Add ( actorC );
5003 application.SendNotification();
5004 application.Render();
5006 DevelActor::RaiseAbove( actorA, actorC );
5007 application.ProcessEvent( event );
5009 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
5010 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5011 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5012 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5017 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5019 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
5021 TestApplication application;
5023 Stage stage( Stage::GetCurrent() );
5025 Actor actorA = Actor::New();
5026 Actor actorB = Actor::New();
5027 Actor actorC = Actor::New();
5029 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5030 actorA.SetParentOrigin( ParentOrigin::CENTER );
5032 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5033 actorB.SetParentOrigin( ParentOrigin::CENTER );
5035 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5036 actorC.SetParentOrigin( ParentOrigin::CENTER );
5038 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5039 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5041 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5042 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5044 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5045 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5047 ResetTouchCallbacks();
5049 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5050 // Only top actor will get touched.
5051 actorA.TouchSignal().Connect( TestTouchCallback );
5052 actorB.TouchSignal().Connect( TestTouchCallback2 );
5053 actorC.TouchSignal().Connect( TestTouchCallback3 );
5055 Dali::Integration::Point point;
5056 point.SetDeviceId( 1 );
5057 point.SetState( PointState::DOWN );
5058 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5059 Dali::Integration::TouchEvent event;
5060 event.AddPoint( point );
5062 stage.Add ( actorA );
5064 application.SendNotification();
5065 application.Render();
5067 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5069 DevelActor::Raise( actorB );
5071 application.ProcessEvent( event );
5073 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5075 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5076 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5077 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5079 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5080 ResetTouchCallbacks();
5082 DevelActor::Lower( actorC );
5084 application.ProcessEvent( event );
5086 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5088 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5089 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5090 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5091 ResetTouchCallbacks();
5093 tet_printf( "Lower actor C below B but C not parented\n" );
5095 DevelActor::Lower( actorB );
5097 application.ProcessEvent( event );
5099 tet_printf( "Not parented so Lower should show no effect\n" );
5101 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5102 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5103 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5104 ResetTouchCallbacks();
5106 tet_printf( "Raise actor B to top\n" );
5108 DevelActor::RaiseToTop( actorB );
5110 application.ProcessEvent( event );
5112 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5114 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5115 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5116 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5117 ResetTouchCallbacks();
5119 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5121 stage.Add ( actorB );
5123 application.SendNotification();
5124 application.Render();
5126 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5128 DevelActor::LowerToBottom( actorC );
5130 application.ProcessEvent( event );
5132 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5134 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5135 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5136 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5137 ResetTouchCallbacks();
5143 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5145 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5147 TestApplication application;
5149 Stage stage( Stage::GetCurrent() );
5151 Actor actorA = Actor::New();
5152 Actor actorB = Actor::New();
5153 Actor actorC = Actor::New();
5155 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5156 actorA.SetParentOrigin( ParentOrigin::CENTER );
5158 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5159 actorB.SetParentOrigin( ParentOrigin::CENTER );
5161 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5162 actorC.SetParentOrigin( ParentOrigin::CENTER );
5164 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5165 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5167 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5168 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5170 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5171 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5173 stage.Add( actorA );
5174 stage.Add( actorB );
5175 stage.Add( actorC );
5177 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5178 // Only top actor will get touched.
5179 actorA.TouchSignal().Connect( TestTouchCallback );
5180 actorB.TouchSignal().Connect( TestTouchCallback2 );
5181 actorC.TouchSignal().Connect( TestTouchCallback3 );
5183 ResetTouchCallbacks();
5185 application.SendNotification();
5186 application.Render();
5188 Dali::Integration::Point point;
5189 point.SetDeviceId( 1 );
5190 point.SetState( PointState::DOWN );
5191 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5192 Dali::Integration::TouchEvent event;
5193 event.AddPoint( point );
5195 application.ProcessEvent( event );
5197 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5198 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5199 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5201 ResetTouchCallbacks();
5203 tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
5205 DevelActor::RaiseAbove( actorA, actorA );
5207 application.ProcessEvent( event );
5209 tet_infoline( "No target is source Actor so RaiseAbove should show no effect\n" );
5211 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5212 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5213 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5215 ResetTouchCallbacks();
5217 DevelActor::RaiseAbove( actorA, actorC );
5218 application.ProcessEvent( event );
5220 tet_infoline( "Raise actor A Above Actor C which will now be successful \n" );
5221 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5222 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5223 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5228 int UtcDaliActorGetScreenPosition(void)
5230 tet_infoline( "UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n" );
5232 TestApplication application;
5234 Stage stage( Stage::GetCurrent() );
5236 Actor actorA = Actor::New();
5237 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5239 Vector2 size2( 10.0f, 20.0f );
5240 actorA.SetSize( size2 );
5242 actorA.SetPosition( 0.f, 0.f );
5244 tet_infoline( "UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n" );
5246 stage.Add( actorA );
5248 application.SendNotification();
5249 application.Render();
5251 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5252 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5254 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5255 tet_printf( "Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y );
5257 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5258 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5260 tet_infoline( "UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n" );
5262 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5264 application.SendNotification();
5265 application.Render();
5267 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5268 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5270 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5271 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y );
5273 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5274 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5276 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n" );
5278 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5280 application.SendNotification();
5281 application.Render();
5283 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5284 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5286 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5287 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y );
5289 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5290 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5292 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n" );
5294 actorA.SetPosition( 30.0, 0.0 );
5296 application.SendNotification();
5297 application.Render();
5299 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5300 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5302 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y );
5303 tet_printf( "Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5305 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5306 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5308 tet_infoline( "UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n" );
5310 actorA.SetPosition( 30.0, 420.0 );
5312 application.SendNotification();
5313 application.Render();
5315 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5316 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5318 DALI_TEST_EQUALS( actorScreenPosition.x, 30lu , TEST_LOCATION );
5319 DALI_TEST_EQUALS( actorScreenPosition.y, 420lu , TEST_LOCATION );
5321 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y );
5322 tet_printf( "Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y );
5328 int UtcDaliActorGetScreenPositionAfterScaling(void)
5330 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n" );
5332 TestApplication application;
5334 Stage stage( Stage::GetCurrent() );
5336 Actor actorA = Actor::New();
5337 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5339 Vector2 size2( 10.0f, 20.0f );
5340 actorA.SetSize( size2 );
5341 actorA.SetScale( 1.5f );
5342 actorA.SetPosition( 0.f, 0.f );
5344 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n" );
5346 stage.Add( actorA );
5348 application.SendNotification();
5349 application.Render();
5351 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5352 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5354 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5355 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5357 DALI_TEST_EQUALS( actorScreenPosition.x, 0lu , TEST_LOCATION );
5358 DALI_TEST_EQUALS( actorScreenPosition.y, 0lu , TEST_LOCATION );
5360 tet_infoline( "UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n" );
5362 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5364 application.SendNotification();
5365 application.Render();
5367 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5368 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5370 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5371 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5373 DALI_TEST_EQUALS( actorScreenPosition.x , 0.0f , TEST_LOCATION );
5374 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5379 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
5381 tet_infoline( "UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n" );
5383 TestApplication application;
5385 Stage stage( Stage::GetCurrent() );
5387 Actor actorA = Actor::New();
5388 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5389 actorA.SetParentOrigin( ParentOrigin::CENTER );
5390 Vector2 size2( 10.0f, 20.0f );
5391 actorA.SetSize( size2 );
5392 actorA.SetPosition( 0.f, 0.f );
5394 tet_infoline( " TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5396 stage.Add( actorA );
5398 application.SendNotification();
5399 application.Render();
5401 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5402 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5404 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5405 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5407 DALI_TEST_EQUALS( actorScreenPosition.x, 240.0f , TEST_LOCATION );
5408 DALI_TEST_EQUALS( actorScreenPosition.y, 400.0f , TEST_LOCATION );
5410 tet_infoline( " BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n" );
5412 actorA.SetParentOrigin( ParentOrigin::TOP_RIGHT );
5413 actorA.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5415 application.SendNotification();
5416 application.Render();
5418 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5419 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5421 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y );
5422 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5424 DALI_TEST_EQUALS( actorScreenPosition.x , 480.0f , TEST_LOCATION );
5425 DALI_TEST_EQUALS( actorScreenPosition.y, 0.0f , TEST_LOCATION );
5431 int UtcDaliActorGetScreenPositionWithChildActors(void)
5433 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n" );
5435 TestApplication application;
5437 Stage stage( Stage::GetCurrent() );
5439 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5441 Actor actorA = Actor::New();
5442 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5443 actorA.SetParentOrigin( ParentOrigin::CENTER );
5444 Vector2 size1( 10.0f, 20.0f );
5445 actorA.SetSize( size1 );
5446 actorA.SetPosition( 0.f, 0.f );
5448 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5450 Actor parentActorA = Actor::New();
5451 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5452 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5453 Vector2 size2( 30.0f, 60.0f );
5454 parentActorA.SetSize( size2 );
5455 parentActorA.SetPosition( 0.f, 0.f );
5457 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5459 stage.Add( parentActorA );
5460 parentActorA.Add ( actorA );
5462 application.SendNotification();
5463 application.Render();
5465 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5466 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5468 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5469 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5471 DALI_TEST_EQUALS( actorScreenPosition.x, 255.0f , TEST_LOCATION );
5472 DALI_TEST_EQUALS( actorScreenPosition.y, 430.0f , TEST_LOCATION );
5474 tet_infoline( "Test 2\n");
5476 tet_infoline( "change parent anchor point and parent origin then check screen position \n" );
5478 parentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5479 parentActorA.SetParentOrigin( ParentOrigin::TOP_LEFT );
5481 application.SendNotification();
5482 application.Render();
5484 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5485 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5487 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y );
5488 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5490 DALI_TEST_EQUALS( actorScreenPosition.x, 15.0f , TEST_LOCATION );
5491 DALI_TEST_EQUALS( actorScreenPosition.y, -30.0f , TEST_LOCATION );
5496 int UtcDaliActorGetScreenPositionWithChildActors02(void)
5498 tet_infoline( "UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n" );
5500 TestApplication application;
5502 Stage stage( Stage::GetCurrent() );
5504 tet_infoline( "Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5506 Actor actorA = Actor::New();
5507 actorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5508 actorA.SetParentOrigin( ParentOrigin::CENTER );
5509 Vector2 size1( 10.0f, 20.0f );
5510 actorA.SetSize( size1 );
5511 actorA.SetPosition( 0.f, 0.f );
5513 tet_infoline( "Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5515 Actor parentActorA = Actor::New();
5516 parentActorA.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5517 parentActorA.SetParentOrigin( ParentOrigin::CENTER );
5518 Vector2 size2( 30.0f, 60.0f );
5519 parentActorA.SetSize( size2 );
5520 parentActorA.SetPosition( 0.f, 0.f );
5522 tet_infoline( "Create Grand Parent Actor 1 TOP_RIGHT Anchor Point, ParentOrigin::CENTER and 0,0 position \n" );
5524 Actor grandParentActorA = Actor::New();
5525 grandParentActorA.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
5526 grandParentActorA.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
5527 Vector2 size3( 60.0f, 120.0f );
5528 grandParentActorA.SetSize( size3 );
5529 grandParentActorA.SetPosition( 0.f, 0.f );
5531 tet_infoline( "Add Parent 1 to Grand Parent 1 \n" );
5533 stage.Add( grandParentActorA );
5534 grandParentActorA.Add ( parentActorA );
5536 tet_infoline( "Add child 1 to Parent 1 and check screen position \n" );
5538 parentActorA.Add ( actorA );
5540 application.SendNotification();
5541 application.Render();
5543 Vector3 actorWorldPosition = actorA.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
5544 Vector2 actorScreenPosition = actorA.GetProperty( DevelActor::Property::SCREEN_POSITION).Get< Vector2 >();
5546 tet_printf( "Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y );
5547 tet_printf( "Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y );
5549 DALI_TEST_EQUALS( actorScreenPosition.x, 45.0f , TEST_LOCATION );
5550 DALI_TEST_EQUALS( actorScreenPosition.y, 770.0f , TEST_LOCATION );
5555 int utcDaliActorPositionUsesAnchorPoint(void)
5557 TestApplication application;
5558 tet_infoline( "Check default behaviour\n" );
5560 Actor actor = Actor::New();
5561 actor.SetParentOrigin( ParentOrigin::CENTER );
5562 actor.SetAnchorPoint( AnchorPoint::CENTER );
5563 actor.SetSize( 100.0f, 100.0f );
5564 Stage::GetCurrent().Add( actor );
5566 application.SendNotification();
5567 application.Render();
5569 tet_infoline( "Check that the world position is in the center\n" );
5570 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5572 tet_infoline( "Set the position uses anchor point property to false\n" );
5573 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5575 application.SendNotification();
5576 application.Render();
5578 tet_infoline( "Check that the world position has changed appropriately\n" );
5579 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5584 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
5586 TestApplication application;
5587 tet_infoline( "Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5589 Actor actor = Actor::New();
5590 actor.SetParentOrigin( ParentOrigin::CENTER );
5591 actor.SetAnchorPoint( AnchorPoint::CENTER );
5592 actor.SetSize( 100.0f, 100.0f );
5593 actor.SetScale( 2.0f );
5594 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5595 Stage::GetCurrent().Add( actor );
5597 application.SendNotification();
5598 application.Render();
5600 tet_infoline( "Check the world position is the same as it would be without a scale\n" );
5601 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5603 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5604 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5605 application.SendNotification();
5606 application.Render();
5607 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5609 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5610 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5611 application.SendNotification();
5612 application.Render();
5613 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 0.0f, 0.0f, 0.0f ), TEST_LOCATION );
5618 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
5620 TestApplication application;
5621 tet_infoline( "Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5623 Actor actor = Actor::New();
5624 actor.SetParentOrigin( ParentOrigin::CENTER );
5625 actor.SetAnchorPoint( AnchorPoint::CENTER );
5626 actor.SetSize( 100.0f, 100.0f );
5627 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5628 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5629 Stage::GetCurrent().Add( actor );
5631 application.SendNotification();
5632 application.Render();
5634 tet_infoline( "Check the world position is the same as it would be without a rotation\n" );
5635 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5637 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5638 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5639 application.SendNotification();
5640 application.Render();
5641 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5643 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5644 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5645 application.SendNotification();
5646 application.Render();
5647 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 150.0f, 50.0f, 0.0f ), TEST_LOCATION );
5652 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
5654 TestApplication application;
5655 tet_infoline( "Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5657 Actor actor = Actor::New();
5658 actor.SetParentOrigin( ParentOrigin::CENTER );
5659 actor.SetAnchorPoint( AnchorPoint::CENTER );
5660 actor.SetSize( 100.0f, 100.0f );
5661 actor.SetOrientation( Degree( 90.0f), Vector3::ZAXIS );
5662 actor.SetScale( 2.0f );
5663 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5664 Stage::GetCurrent().Add( actor );
5666 application.SendNotification();
5667 application.Render();
5669 tet_infoline( "Check the world position is the same as it would be without a scale and rotation\n" );
5670 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 50.0f, 50.0f, 0.0f ), TEST_LOCATION );
5672 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly" );
5673 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5674 application.SendNotification();
5675 application.Render();
5676 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( -100.0f, 100.0f, 0.0f ), TEST_LOCATION );
5678 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly" );
5679 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5680 application.SendNotification();
5681 application.Render();
5682 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), Vector3( 200.0f, 0.0f, 0.0f ), TEST_LOCATION );
5687 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
5689 TestApplication application;
5690 tet_infoline( "Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n" );
5692 Actor parent = Actor::New();
5694 Stage::GetCurrent().Add( parent );
5695 Vector2 stageSize( Stage::GetCurrent().GetSize() );
5697 Actor actor = Actor::New();
5698 actor.SetParentOrigin( ParentOrigin::CENTER );
5699 actor.SetAnchorPoint( AnchorPoint::CENTER );
5700 actor.SetSize( 100.0f, 100.0f );
5701 actor.SetInheritScale( false );
5702 actor.SetInheritOrientation( false );
5703 actor.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false );
5704 parent.Add( actor );
5706 application.SendNotification();
5707 application.Render();
5709 const Vector3 expectedWorldPosition( -stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f );
5711 tet_infoline( "Check the world position is in the right place\n" );
5712 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5714 tet_infoline( "Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed" );
5715 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
5716 application.SendNotification();
5717 application.Render();
5718 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );
5720 tet_infoline( "Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed" );
5721 actor.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
5722 application.SendNotification();
5723 application.Render();
5724 DALI_TEST_EQUALS( actor.GetCurrentWorldPosition(), expectedWorldPosition, TEST_LOCATION );