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 );
983 int UtcDaliActorGetCurrentSize(void)
985 TestApplication application;
987 Actor actor = Actor::New();
988 Vector3 vector(100.0f, 100.0f, 20.0f);
990 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
992 actor.SetSize(vector);
994 // flush the queue and render once
995 application.SendNotification();
996 application.Render();
998 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1002 int UtcDaliActorGetNaturalSize(void)
1004 TestApplication application;
1006 Actor actor = Actor::New();
1007 Vector3 vector( 0.0f, 0.0f, 0.0f );
1009 DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
1014 int UtcDaliActorGetCurrentSizeImmediate(void)
1016 TestApplication application;
1018 Actor actor = Actor::New();
1019 Vector3 vector(100.0f, 100.0f, 20.0f);
1021 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1022 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1024 actor.SetSize(vector);
1026 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1027 DALI_TEST_CHECK(vector != actor.GetCurrentSize());
1029 // flush the queue and render once
1030 application.SendNotification();
1031 application.Render();
1033 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1034 DALI_TEST_CHECK(vector == actor.GetCurrentSize());
1037 // Build the animation
1038 const float durationSeconds = 2.0f;
1039 Animation animation = Animation::New( durationSeconds );
1040 const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
1041 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), targetValue );
1043 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1045 // Start the animation
1048 application.SendNotification();
1049 application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
1051 DALI_TEST_CHECK( actor.GetTargetSize() == targetValue );
1056 // SetPosition(float x, float y)
1057 int UtcDaliActorSetPosition01(void)
1059 TestApplication application;
1061 Actor actor = Actor::New();
1063 // Set to random to start off with
1064 actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f));
1066 Vector3 vector(100.0f, 100.0f, 0.0f);
1068 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1070 actor.SetPosition(vector.x, vector.y);
1071 // flush the queue and render once
1072 application.SendNotification();
1073 application.Render();
1074 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1076 Stage::GetCurrent().Add( actor );
1077 actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) );
1078 // flush the queue and render once
1079 application.SendNotification();
1080 application.Render();
1081 DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION );
1086 // flush the queue and render once
1087 application.SendNotification();
1088 application.Render();
1089 DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION );
1091 actor.TranslateBy( Vector3( 0.1f, 0.1f, 0.1f ) );
1092 // flush the queue and render once
1093 application.SendNotification();
1094 application.Render();
1095 DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION );
1097 Stage::GetCurrent().Remove( actor );
1101 // SetPosition(float x, float y, float z)
1102 int UtcDaliActorSetPosition02(void)
1104 TestApplication application;
1106 Actor actor = Actor::New();
1108 // Set to random to start off with
1109 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1111 Vector3 vector(100.0f, 100.0f, 100.0f);
1113 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1115 actor.SetPosition(vector.x, vector.y, vector.z);
1117 // flush the queue and render once
1118 application.SendNotification();
1119 application.Render();
1121 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1125 // SetPosition(Vector3 position)
1126 int UtcDaliActorSetPosition03(void)
1128 TestApplication application;
1130 Actor actor = Actor::New();
1132 // Set to random to start off with
1133 actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f));
1135 Vector3 vector(100.0f, 100.0f, 100.0f);
1137 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1139 actor.SetPosition(vector);
1141 // flush the queue and render once
1142 application.SendNotification();
1143 application.Render();
1145 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1149 int UtcDaliActorSetX(void)
1151 TestApplication application;
1153 Actor actor = Actor::New();
1155 Vector3 vector(100.0f, 0.0f, 0.0f);
1157 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1161 // flush the queue and render once
1162 application.SendNotification();
1163 application.Render();
1165 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1169 int UtcDaliActorSetY(void)
1171 TestApplication application;
1173 Actor actor = Actor::New();
1175 Vector3 vector(0.0f, 100.0f, 0.0f);
1177 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1181 // flush the queue and render once
1182 application.SendNotification();
1183 application.Render();
1185 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1189 int UtcDaliActorSetZ(void)
1191 TestApplication application;
1193 Actor actor = Actor::New();
1195 Vector3 vector(0.0f, 0.0f, 100.0f);
1197 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1201 // flush the queue and render once
1202 application.SendNotification();
1203 application.Render();
1205 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1209 int UtcDaliActorSetPositionProperties(void)
1211 TestApplication application;
1213 Actor actor = Actor::New();
1215 Vector3 vector(0.7f, 0.8f, 0.9f);
1216 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1218 actor.SetProperty( Actor::Property::POSITION_X, vector.x );
1220 // flush the queue and render once
1221 application.SendNotification();
1222 application.Render();
1224 DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION );
1226 actor.SetProperty( Actor::Property::POSITION_Y, vector.y );
1228 // flush the queue and render once
1229 application.SendNotification();
1230 application.Render();
1232 DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION );
1234 actor.SetProperty( Actor::Property::POSITION_Z, vector.z );
1236 // flush the queue and render once
1237 application.SendNotification();
1238 application.Render();
1240 DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION );
1245 int UtcDaliActorTranslateBy(void)
1247 TestApplication application;
1249 Actor actor = Actor::New();
1250 Vector3 vector(100.0f, 100.0f, 100.0f);
1252 DALI_TEST_CHECK(vector != actor.GetCurrentPosition());
1254 actor.SetPosition(vector);
1256 // flush the queue and render once
1257 application.SendNotification();
1258 application.Render();
1260 DALI_TEST_CHECK(vector == actor.GetCurrentPosition());
1262 actor.TranslateBy(vector);
1264 // flush the queue and render once
1265 application.SendNotification();
1266 application.Render();
1268 DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition());
1272 int UtcDaliActorGetCurrentPosition(void)
1274 TestApplication application;
1276 Actor actor = Actor::New();
1277 Vector3 setVector(100.0f, 100.0f, 0.0f);
1278 actor.SetPosition(setVector);
1280 // flush the queue and render once
1281 application.SendNotification();
1282 application.Render();
1284 DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector);
1288 int UtcDaliActorGetCurrentWorldPosition(void)
1290 TestApplication application;
1292 Actor parent = Actor::New();
1293 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1294 parent.SetPosition( parentPosition );
1295 parent.SetParentOrigin( ParentOrigin::CENTER );
1296 parent.SetAnchorPoint( AnchorPoint::CENTER );
1297 Stage::GetCurrent().Add( parent );
1299 Actor child = Actor::New();
1300 child.SetParentOrigin( ParentOrigin::CENTER );
1301 child.SetAnchorPoint( AnchorPoint::CENTER );
1302 Vector3 childPosition( 6.0f, 6.0f, 6.0f );
1303 child.SetPosition( childPosition );
1304 parent.Add( child );
1306 // The actors should not have a world position yet
1307 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1308 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1310 application.SendNotification();
1311 application.Render(0);
1313 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1314 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1316 // The actors should have a world position now
1317 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1318 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1322 int UtcDaliActorInheritPosition(void)
1324 tet_infoline("Testing Actor::SetPositionInheritanceMode");
1325 TestApplication application;
1327 Actor parent = Actor::New();
1328 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1329 parent.SetPosition( parentPosition );
1330 parent.SetParentOrigin( ParentOrigin::CENTER );
1331 parent.SetAnchorPoint( AnchorPoint::CENTER );
1332 Stage::GetCurrent().Add( parent );
1334 Actor child = Actor::New();
1335 child.SetParentOrigin( ParentOrigin::CENTER );
1336 child.SetAnchorPoint( AnchorPoint::CENTER );
1337 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1338 child.SetPosition( childPosition );
1339 parent.Add( child );
1341 // The actors should not have a world position yet
1342 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1343 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1345 // first test default, which is to inherit position
1346 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
1347 application.SendNotification();
1348 application.Render(0); // should only really call Update as Render is not required to update scene
1349 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1350 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1351 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1352 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1355 //Change child position
1356 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1357 child.SetPosition( childOffset );
1359 // Change inheritance mode to not inherit
1360 child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
1361 DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
1362 application.SendNotification();
1363 application.Render(0); // should only really call Update as Render is not required to update scene
1364 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1365 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1366 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1367 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1371 int UtcDaliActorSetInheritPosition(void)
1373 tet_infoline("Testing Actor::SetInheritPosition");
1374 TestApplication application;
1376 Actor parent = Actor::New();
1377 Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
1378 parent.SetPosition( parentPosition );
1379 parent.SetParentOrigin( ParentOrigin::CENTER );
1380 parent.SetAnchorPoint( AnchorPoint::CENTER );
1381 Stage::GetCurrent().Add( parent );
1383 Actor child = Actor::New();
1384 child.SetParentOrigin( ParentOrigin::CENTER );
1385 child.SetAnchorPoint( AnchorPoint::CENTER );
1386 Vector3 childPosition( 10.0f, 11.0f, 12.0f );
1387 child.SetPosition( childPosition );
1388 parent.Add( child );
1390 // The actors should not have a world position yet
1391 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1392 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
1394 // first test default, which is to inherit position
1395 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1396 application.SendNotification();
1397 application.Render(0); // should only really call Update as Render is not required to update scene
1398 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1399 DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
1400 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1401 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
1403 //Change child position
1404 Vector3 childOffset( -1.0f, 1.0f, 0.0f );
1405 child.SetPosition( childOffset );
1407 // Use local position as world postion
1408 child.SetInheritPosition( false );
1409 DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
1410 application.SendNotification();
1411 application.Render(0); // should only really call Update as Render is not required to update scene
1412 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1413 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1414 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1415 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
1417 //Change back to inherit position from parent
1418 child.SetInheritPosition( true );
1419 DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
1420 application.SendNotification();
1421 application.Render(0); // should only really call Update as Render is not required to update scene
1422 DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
1423 DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
1424 DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
1425 DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
1429 // SetOrientation(float angleRadians, Vector3 axis)
1430 int UtcDaliActorSetOrientation01(void)
1432 TestApplication application;
1434 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1435 Actor actor = Actor::New();
1437 actor.SetOrientation(rotation);
1439 // flush the queue and render once
1440 application.SendNotification();
1441 application.Render();
1443 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1447 int UtcDaliActorSetOrientation02(void)
1449 TestApplication application;
1451 Actor actor = Actor::New();
1453 Radian angle( 0.785f );
1454 Vector3 axis(1.0f, 1.0f, 0.0f);
1456 actor.SetOrientation( angle, axis);
1457 Quaternion rotation( angle, axis );
1458 // flush the queue and render once
1459 application.SendNotification();
1460 application.Render();
1461 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1463 Stage::GetCurrent().Add( actor );
1464 actor.RotateBy( Degree( 360 ), axis);
1465 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1467 actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1468 Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
1469 // flush the queue and render once
1470 application.SendNotification();
1471 application.Render();
1472 DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1474 actor.SetOrientation( angle, axis);
1475 // flush the queue and render once
1476 application.SendNotification();
1477 application.Render();
1478 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1480 Stage::GetCurrent().Remove( actor );
1484 // SetOrientation(float angleRadians, Vector3 axis)
1485 int UtcDaliActorSetOrientationProperty(void)
1487 TestApplication application;
1489 Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1490 Actor actor = Actor::New();
1492 actor.SetProperty( Actor::Property::ORIENTATION, rotation );
1494 // flush the queue and render once
1495 application.SendNotification();
1496 application.Render();
1498 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1502 // RotateBy(float angleRadians, Vector3 axis)
1503 int UtcDaliActorRotateBy01(void)
1505 TestApplication application;
1507 Actor actor = Actor::New();
1509 Radian angle( M_PI * 0.25f );
1510 actor.RotateBy(( angle ), Vector3::ZAXIS);
1511 // flush the queue and render once
1512 application.SendNotification();
1513 application.Render();
1514 DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1516 Stage::GetCurrent().Add( actor );
1518 actor.RotateBy( angle, Vector3::ZAXIS);
1519 // flush the queue and render once
1520 application.SendNotification();
1521 application.Render();
1522 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1524 Stage::GetCurrent().Remove( actor );
1528 // RotateBy(Quaternion relativeRotation)
1529 int UtcDaliActorRotateBy02(void)
1531 TestApplication application;
1533 Actor actor = Actor::New();
1535 Radian angle( M_PI * 0.25f );
1536 Quaternion rotation(angle, Vector3::ZAXIS);
1537 actor.RotateBy(rotation);
1538 // flush the queue and render once
1539 application.SendNotification();
1540 application.Render();
1541 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1543 actor.RotateBy(rotation);
1544 // flush the queue and render once
1545 application.SendNotification();
1546 application.Render();
1547 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1551 int UtcDaliActorGetCurrentOrientation(void)
1553 TestApplication application;
1554 Actor actor = Actor::New();
1556 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1557 actor.SetOrientation(rotation);
1558 // flush the queue and render once
1559 application.SendNotification();
1560 application.Render();
1561 DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
1565 int UtcDaliActorGetCurrentWorldOrientation(void)
1567 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1568 TestApplication application;
1570 Actor parent = Actor::New();
1571 Radian rotationAngle( Degree(90.0f) );
1572 Quaternion rotation( rotationAngle, Vector3::YAXIS );
1573 parent.SetOrientation( rotation );
1574 Stage::GetCurrent().Add( parent );
1576 Actor child = Actor::New();
1577 child.SetOrientation( rotation );
1578 parent.Add( child );
1580 // The actors should not have a world rotation yet
1581 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1582 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
1584 application.SendNotification();
1585 application.Render(0);
1587 DALI_TEST_EQUALS( parent.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1588 DALI_TEST_EQUALS( child.GetCurrentOrientation(), rotation, 0.001, TEST_LOCATION );
1590 // The actors should have a world rotation now
1591 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1592 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1594 // turn off child rotation inheritance
1595 child.SetInheritOrientation( false );
1596 DALI_TEST_EQUALS( child.IsOrientationInherited(), false, TEST_LOCATION );
1597 application.SendNotification();
1598 application.Render(0);
1600 // The actors should have a world rotation now
1601 DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION );
1602 DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), rotation, 0.001, TEST_LOCATION );
1606 // SetScale(float scale)
1607 int UtcDaliActorSetScale01(void)
1609 TestApplication application;
1611 Actor actor = Actor::New();
1613 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1614 actor.SetScale(0.25f);
1616 Vector3 scale(10.0f, 10.0f, 10.0f);
1617 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1619 actor.SetScale(scale.x);
1621 // flush the queue and render once
1622 application.SendNotification();
1623 application.Render();
1625 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1629 // SetScale(float scaleX, float scaleY, float scaleZ)
1630 int UtcDaliActorSetScale02(void)
1632 TestApplication application;
1633 Vector3 scale(10.0f, 10.0f, 10.0f);
1635 Actor actor = Actor::New();
1637 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1638 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1640 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1642 actor.SetScale(scale.x, scale.y, scale.z);
1643 // flush the queue and render once
1644 application.SendNotification();
1645 application.Render();
1646 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1648 // add to stage and test
1649 Stage::GetCurrent().Add( actor );
1650 actor.SetScale( 2.0f, 2.0f, 2.0f );
1651 // flush the queue and render once
1652 application.SendNotification();
1653 application.Render();
1654 DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION);
1656 Stage::GetCurrent().Remove( actor );
1661 // SetScale(Vector3 scale)
1662 int UtcDaliActorSetScale03(void)
1664 TestApplication application;
1665 Vector3 scale(10.0f, 10.0f, 10.0f);
1667 Actor actor = Actor::New();
1669 // Set to random value first - GetCurrentScale() asserts if called before SetScale()
1670 actor.SetScale(Vector3(12.0f, 1.0f, 2.0f));
1672 DALI_TEST_CHECK(actor.GetCurrentScale() != scale);
1674 actor.SetScale(scale);
1676 // flush the queue and render once
1677 application.SendNotification();
1678 application.Render();
1680 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1684 int UtcDaliActorSetScaleIndividual(void)
1686 TestApplication application;
1688 Actor actor = Actor::New();
1690 Vector3 vector(0.7f, 0.8f, 0.9f);
1691 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1693 actor.SetProperty( Actor::Property::SCALE_X, vector.x );
1695 // flush the queue and render once
1696 application.SendNotification();
1697 application.Render();
1699 DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION );
1701 actor.SetProperty( Actor::Property::SCALE_Y, vector.y );
1703 // flush the queue and render once
1704 application.SendNotification();
1705 application.Render();
1707 DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION );
1709 actor.SetProperty( Actor::Property::SCALE_Z, vector.z );
1711 // flush the queue and render once
1712 application.SendNotification();
1713 application.Render();
1715 DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION );
1720 int UtcDaliActorScaleBy(void)
1722 TestApplication application;
1723 Actor actor = Actor::New();
1724 Vector3 vector(100.0f, 100.0f, 100.0f);
1726 DALI_TEST_CHECK(vector != actor.GetCurrentScale());
1728 actor.SetScale(vector);
1730 // flush the queue and render once
1731 application.SendNotification();
1732 application.Render();
1734 DALI_TEST_CHECK(vector == actor.GetCurrentScale());
1736 actor.ScaleBy(vector);
1738 // flush the queue and render once
1739 application.SendNotification();
1740 application.Render();
1742 DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale());
1746 int UtcDaliActorGetCurrentScale(void)
1748 TestApplication application;
1749 Vector3 scale(12.0f, 1.0f, 2.0f);
1751 Actor actor = Actor::New();
1753 actor.SetScale(scale);
1755 // flush the queue and render once
1756 application.SendNotification();
1757 application.Render();
1759 DALI_TEST_CHECK(actor.GetCurrentScale() == scale);
1763 int UtcDaliActorGetCurrentWorldScale(void)
1765 TestApplication application;
1767 Actor parent = Actor::New();
1768 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1769 parent.SetScale( parentScale );
1770 Stage::GetCurrent().Add( parent );
1772 Actor child = Actor::New();
1773 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1774 child.SetScale( childScale );
1775 parent.Add( child );
1777 // The actors should not have a scale yet
1778 DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1779 DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
1781 // The actors should not have a world scale yet
1782 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1783 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION );
1785 application.SendNotification();
1786 application.Render(0);
1788 DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION );
1789 DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION );
1791 // The actors should have a world scale now
1792 DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION );
1793 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1797 int UtcDaliActorInheritScale(void)
1799 tet_infoline("Testing Actor::SetInheritScale");
1800 TestApplication application;
1802 Actor parent = Actor::New();
1803 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
1804 parent.SetScale( parentScale );
1805 Stage::GetCurrent().Add( parent );
1807 Actor child = Actor::New();
1808 Vector3 childScale( 2.0f, 2.0f, 2.0f );
1809 child.SetScale( childScale );
1810 parent.Add( child );
1812 application.SendNotification();
1813 application.Render(0);
1815 DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION );
1816 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION );
1818 child.SetInheritScale( false );
1819 DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION );
1821 application.SendNotification();
1822 application.Render(0);
1824 DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION );
1828 int UtcDaliActorSetVisible(void)
1830 TestApplication application;
1832 Actor actor = Actor::New();
1833 actor.SetVisible(false);
1834 // flush the queue and render once
1835 application.SendNotification();
1836 application.Render();
1837 DALI_TEST_CHECK(actor.IsVisible() == false);
1839 actor.SetVisible(true);
1840 // flush the queue and render once
1841 application.SendNotification();
1842 application.Render();
1843 DALI_TEST_CHECK(actor.IsVisible() == true);
1845 // put actor on stage
1846 Stage::GetCurrent().Add( actor );
1847 actor.SetVisible(false);
1848 // flush the queue and render once
1849 application.SendNotification();
1850 application.Render();
1851 DALI_TEST_CHECK(actor.IsVisible() == false);
1855 int UtcDaliActorIsVisible(void)
1857 TestApplication application;
1859 Actor actor = Actor::New();
1861 DALI_TEST_CHECK(actor.IsVisible() == true);
1865 int UtcDaliActorSetOpacity(void)
1867 TestApplication application;
1869 Actor actor = Actor::New();
1870 // initial opacity is 1
1871 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1873 actor.SetOpacity( 0.4f);
1874 // flush the queue and render once
1875 application.SendNotification();
1876 application.Render();
1877 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION );
1879 // change opacity, actor is on stage to change is not immediate
1880 actor.SetOpacity( actor.GetCurrentOpacity() + 0.1f );
1881 // flush the queue and render once
1882 application.SendNotification();
1883 application.Render();
1884 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1886 // put actor on stage
1887 Stage::GetCurrent().Add( actor );
1889 // change opacity, actor is on stage to change is not immediate
1890 actor.SetOpacity( 0.9f );
1891 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION );
1892 // flush the queue and render once
1893 application.SendNotification();
1894 application.Render();
1895 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION );
1897 // change opacity, actor is on stage to change is not immediate
1898 actor.SetOpacity( actor.GetCurrentOpacity() - 0.9f );
1899 // flush the queue and render once
1900 application.SendNotification();
1901 application.Render();
1902 DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1906 int UtcDaliActorGetCurrentOpacity(void)
1908 TestApplication application;
1910 Actor actor = Actor::New();
1911 DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f);
1913 actor.SetOpacity(0.5f);
1914 // flush the queue and render once
1915 application.SendNotification();
1916 application.Render();
1917 DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f);
1921 int UtcDaliActorSetSensitive(void)
1923 TestApplication application;
1924 Actor actor = Actor::New();
1926 bool sensitive = !actor.IsSensitive();
1928 actor.SetSensitive(sensitive);
1930 DALI_TEST_CHECK(sensitive == actor.IsSensitive());
1934 int UtcDaliActorIsSensitive(void)
1936 TestApplication application;
1937 Actor actor = Actor::New();
1938 actor.SetSensitive(false);
1940 DALI_TEST_CHECK(false == actor.IsSensitive());
1944 int UtcDaliActorSetColor(void)
1946 TestApplication application;
1947 Actor actor = Actor::New();
1948 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
1950 DALI_TEST_CHECK(color != actor.GetCurrentColor());
1952 actor.SetColor(color);
1953 // flush the queue and render once
1954 application.SendNotification();
1955 application.Render();
1956 DALI_TEST_CHECK(color == actor.GetCurrentColor());
1958 actor.SetColor( actor.GetCurrentColor() + Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) );
1959 // flush the queue and render once
1960 application.SendNotification();
1961 application.Render();
1962 DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION );
1964 Stage::GetCurrent().Add( actor );
1965 actor.SetColor( color );
1966 // flush the queue and render once
1967 application.SendNotification();
1968 application.Render();
1969 DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION );
1971 actor.SetColor( actor.GetCurrentColor() + Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) );
1972 // flush the queue and render once
1973 application.SendNotification();
1974 application.Render();
1975 // Actor color is not clamped
1976 DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION );
1977 // world color is clamped
1978 DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION );
1980 Stage::GetCurrent().Remove( actor );
1984 int UtcDaliActorSetColorIndividual(void)
1986 TestApplication application;
1988 Actor actor = Actor::New();
1990 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
1991 DALI_TEST_CHECK(vector != actor.GetCurrentColor());
1993 actor.SetProperty( Actor::Property::COLOR_RED, vector.r );
1995 // flush the queue and render once
1996 application.SendNotification();
1997 application.Render();
1999 DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION );
2001 actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g );
2003 // flush the queue and render once
2004 application.SendNotification();
2005 application.Render();
2007 DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION );
2009 actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b );
2011 // flush the queue and render once
2012 application.SendNotification();
2013 application.Render();
2015 DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION );
2017 actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a );
2019 // flush the queue and render once
2020 application.SendNotification();
2021 application.Render();
2023 DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION );
2025 actor.SetProperty( DevelActor::Property::OPACITY, 0.2f );
2027 // flush the queue and render once
2028 application.SendNotification();
2029 application.Render();
2031 DALI_TEST_EQUALS( 0.2f, actor.GetCurrentColor().a, TEST_LOCATION );
2037 int UtcDaliActorGetCurrentColor(void)
2039 TestApplication application;
2040 Actor actor = Actor::New();
2041 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2043 actor.SetColor(color);
2044 // flush the queue and render once
2045 application.SendNotification();
2046 application.Render();
2047 DALI_TEST_CHECK(color == actor.GetCurrentColor());
2051 int UtcDaliActorGetCurrentWorldColor(void)
2053 tet_infoline("Actor::GetCurrentWorldColor");
2054 TestApplication application;
2056 Actor parent = Actor::New();
2057 Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f );
2058 parent.SetColor( parentColor );
2059 Stage::GetCurrent().Add( parent );
2061 Actor child = Actor::New();
2062 Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f );
2063 child.SetColor( childColor );
2064 parent.Add( child );
2066 DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2067 DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
2069 // verify the default color mode
2070 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION );
2072 // The actors should not have a world color yet
2073 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2074 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION );
2076 application.SendNotification();
2077 application.Render(0);
2079 DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION );
2080 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2082 // The actors should have a world color now
2083 DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2084 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION );
2087 child.SetColorMode( USE_OWN_COLOR );
2088 application.SendNotification();
2089 application.Render(0);
2090 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION );
2093 child.SetColorMode( USE_PARENT_COLOR );
2094 application.SendNotification();
2095 application.Render(0);
2096 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2097 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION );
2100 child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2101 application.SendNotification();
2102 application.Render(0);
2103 Vector4 expectedColor( childColor );
2104 expectedColor.a *= parentColor.a;
2105 DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION );
2106 DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION );
2110 int UtcDaliActorSetColorMode(void)
2112 tet_infoline("Actor::SetColorMode");
2113 TestApplication application;
2114 Actor actor = Actor::New();
2115 Actor child = Actor::New();
2118 actor.SetColorMode( USE_OWN_COLOR );
2119 DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION );
2121 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
2122 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2124 actor.SetColorMode( USE_PARENT_COLOR );
2125 DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION );
2127 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
2128 DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION );
2132 int UtcDaliActorScreenToLocal(void)
2134 TestApplication application;
2135 Actor actor = Actor::New();
2136 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2137 actor.SetSize(100.0f, 100.0f);
2138 actor.SetPosition(10.0f, 10.0f);
2139 Stage::GetCurrent().Add(actor);
2141 // flush the queue and render once
2142 application.SendNotification();
2143 application.Render();
2148 application.SendNotification();
2149 application.Render();
2151 DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
2153 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2154 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2158 int UtcDaliActorSetLeaveRequired(void)
2160 TestApplication application;
2162 Actor actor = Actor::New();
2164 actor.SetLeaveRequired(false);
2165 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2167 actor.SetLeaveRequired(true);
2168 DALI_TEST_CHECK(actor.GetLeaveRequired() == true);
2172 int UtcDaliActorGetLeaveRequired(void)
2174 TestApplication application;
2176 Actor actor = Actor::New();
2178 DALI_TEST_CHECK(actor.GetLeaveRequired() == false);
2182 int UtcDaliActorSetKeyboardFocusable(void)
2184 TestApplication application;
2186 Actor actor = Actor::New();
2188 actor.SetKeyboardFocusable(true);
2189 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true);
2191 actor.SetKeyboardFocusable(false);
2192 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2196 int UtcDaliActorIsKeyboardFocusable(void)
2198 TestApplication application;
2200 Actor actor = Actor::New();
2202 DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false);
2206 int UtcDaliActorRemoveConstraints(void)
2208 tet_infoline(" UtcDaliActorRemoveConstraints");
2209 TestApplication application;
2211 gTestConstraintCalled = false;
2213 Actor actor = Actor::New();
2215 Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraint() );
2217 actor.RemoveConstraints();
2219 DALI_TEST_CHECK( gTestConstraintCalled == false );
2221 Stage::GetCurrent().Add( actor );
2224 // flush the queue and render once
2225 application.SendNotification();
2226 application.Render();
2228 actor.RemoveConstraints();
2230 DALI_TEST_CHECK( gTestConstraintCalled == true );
2234 int UtcDaliActorRemoveConstraintTag(void)
2236 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2237 TestApplication application;
2239 Actor actor = Actor::New();
2241 // 1. Apply Constraint1 and Constraint2, and test...
2242 unsigned int result1 = 0u;
2243 unsigned int result2 = 0u;
2245 unsigned constraint1Tag = 1u;
2246 Constraint constraint1 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1) );
2247 constraint1.SetTag( constraint1Tag );
2248 constraint1.Apply();
2250 unsigned constraint2Tag = 2u;
2251 Constraint constraint2 = Constraint::New<Vector4>( actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2) );
2252 constraint2.SetTag( constraint2Tag );
2253 constraint2.Apply();
2255 Stage::GetCurrent().Add( actor );
2256 // flush the queue and render once
2257 application.SendNotification();
2258 application.Render();
2260 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2261 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2263 // 2. Remove Constraint1 and test...
2266 actor.RemoveConstraints(constraint1Tag);
2267 // make color property dirty, which will trigger constraints to be reapplied.
2268 actor.SetColor( Color::WHITE );
2269 // flush the queue and render once
2270 application.SendNotification();
2271 application.Render();
2273 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2274 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2276 // 3. Re-Apply Constraint1 and test...
2279 constraint1.Apply();
2280 // make color property dirty, which will trigger constraints to be reapplied.
2281 actor.SetColor( Color::WHITE );
2282 // flush the queue and render once
2283 application.SendNotification();
2284 application.Render();
2286 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2287 DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
2289 // 2. Remove Constraint2 and test...
2292 actor.RemoveConstraints(constraint2Tag);
2293 // make color property dirty, which will trigger constraints to be reapplied.
2294 actor.SetColor( Color::WHITE );
2295 // flush the queue and render once
2296 application.SendNotification();
2297 application.Render();
2299 DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
2300 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2302 // 2. Remove Constraint1 as well and test...
2305 actor.RemoveConstraints(constraint1Tag);
2306 // make color property dirty, which will trigger constraints to be reapplied.
2307 actor.SetColor( Color::WHITE );
2308 // flush the queue and render once
2309 application.SendNotification();
2310 application.Render();
2312 DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
2313 DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
2317 int UtcDaliActorTouchedSignal(void)
2319 TestApplication application;
2321 ResetTouchCallbacks();
2323 // get the root layer
2324 Actor actor = Stage::GetCurrent().GetRootLayer();
2325 DALI_TEST_CHECK( gTouchCallBackCalled == false );
2327 application.SendNotification();
2328 application.Render();
2330 // connect to its touch signal
2331 actor.TouchedSignal().Connect( TestCallback );
2333 // simulate a touch event in the middle of the screen
2334 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2335 Dali::Integration::Point point;
2336 point.SetDeviceId( 1 );
2337 point.SetState( PointState::DOWN );
2338 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2339 Dali::Integration::TouchEvent event;
2340 event.AddPoint( point );
2341 application.ProcessEvent( event );
2343 DALI_TEST_CHECK( gTouchCallBackCalled == true );
2347 int UtcDaliActorHoveredSignal(void)
2349 TestApplication application;
2351 gHoverCallBackCalled = false;
2353 // get the root layer
2354 Actor actor = Stage::GetCurrent().GetRootLayer();
2355 DALI_TEST_CHECK( gHoverCallBackCalled == false );
2357 application.SendNotification();
2358 application.Render();
2360 // connect to its hover signal
2361 actor.HoveredSignal().Connect( TestCallback3 );
2363 // simulate a hover event in the middle of the screen
2364 Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 );
2365 Dali::Integration::Point point;
2366 point.SetDeviceId( 1 );
2367 point.SetState( PointState::MOTION );
2368 point.SetScreenPosition( Vector2( touchPoint.x, touchPoint.y ) );
2369 Dali::Integration::HoverEvent event;
2370 event.AddPoint( point );
2371 application.ProcessEvent( event );
2373 DALI_TEST_CHECK( gHoverCallBackCalled == true );
2377 int UtcDaliActorOnOffStageSignal(void)
2379 tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()");
2381 TestApplication application;
2384 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2385 gActorNamesOnOffStage.clear();
2387 Actor parent = Actor::New();
2388 parent.SetName( "parent" );
2389 parent.OnStageSignal().Connect( OnStageCallback );
2390 parent.OffStageSignal().Connect( OffStageCallback );
2392 DALI_TEST_CHECK( gOnStageCallBackCalled == 0 );
2393 DALI_TEST_CHECK( gOffStageCallBackCalled == 0 );
2395 // add parent to stage
2396 Stage::GetCurrent().Add( parent );
2397 // onstage emitted, offstage not
2398 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2399 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2400 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2402 // test adding a child, should get onstage emitted
2404 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2405 gActorNamesOnOffStage.clear();
2407 Actor child = Actor::New();
2408 child.SetName( "child" );
2409 child.OnStageSignal().Connect( OnStageCallback );
2410 child.OffStageSignal().Connect( OffStageCallback );
2411 parent.Add( child ); // add child
2412 // onstage emitted, offstage not
2413 DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION );
2414 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2415 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2417 // test removing parent from stage
2419 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2420 gActorNamesOnOffStage.clear();
2422 Stage::GetCurrent().Remove( parent );
2423 // onstage not emitted, offstage is
2424 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2425 DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION );
2426 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2427 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2429 // test adding parent back to stage
2431 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2432 gActorNamesOnOffStage.clear();
2434 Stage::GetCurrent().Add( parent );
2435 // onstage emitted, offstage not
2436 DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION );
2437 DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION );
2438 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2439 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION );
2441 // test removing child
2443 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2444 gActorNamesOnOffStage.clear();
2446 parent.Remove( child );
2447 // onstage not emitted, offstage is
2448 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2449 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2450 DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2452 // test removing parent
2454 gOnStageCallBackCalled = gOffStageCallBackCalled = 0;
2455 gActorNamesOnOffStage.clear();
2457 Stage::GetCurrent().Remove( parent );
2458 // onstage not emitted, offstage is
2459 DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION );
2460 DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION );
2461 DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION );
2465 int UtcDaliActorFindChildByName(void)
2467 tet_infoline("Testing Dali::Actor::FindChildByName()");
2468 TestApplication application;
2470 Actor parent = Actor::New();
2471 parent.SetName( "parent" );
2472 Actor first = Actor::New();
2473 first .SetName( "first" );
2474 Actor second = Actor::New();
2475 second.SetName( "second" );
2480 Actor found = parent.FindChildByName( "foo" );
2481 DALI_TEST_CHECK( !found );
2483 found = parent.FindChildByName( "parent" );
2484 DALI_TEST_CHECK( found == parent );
2486 found = parent.FindChildByName( "first" );
2487 DALI_TEST_CHECK( found == first );
2489 found = parent.FindChildByName( "second" );
2490 DALI_TEST_CHECK( found == second );
2494 int UtcDaliActorFindChildById(void)
2496 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2497 TestApplication application;
2499 Actor parent = Actor::New();
2500 Actor first = Actor::New();
2501 Actor second = Actor::New();
2506 Actor found = parent.FindChildById( 100000 );
2507 DALI_TEST_CHECK( !found );
2509 found = parent.FindChildById( parent.GetId() );
2510 DALI_TEST_CHECK( found == parent );
2512 found = parent.FindChildById( first.GetId() );
2513 DALI_TEST_CHECK( found == first );
2515 found = parent.FindChildById( second.GetId() );
2516 DALI_TEST_CHECK( found == second );
2520 int UtcDaliActorHitTest(void)
2525 HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result )
2527 mTouchPoint( touchPoint ),
2532 Vector2 mTouchPoint;
2536 TestApplication application;
2537 tet_infoline(" UtcDaliActorHitTest");
2539 // Fill a vector with different hit tests.
2540 struct HitTestData* hitTestData[] = {
2541 // scale touch point result
2542 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside)
2543 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside)
2544 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.
2545 new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside)
2546 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.
2550 // get the root layer
2551 Actor actor = Actor::New();
2552 actor.SetAnchorPoint( AnchorPoint::CENTER );
2553 actor.SetParentOrigin( ParentOrigin::CENTER );
2555 Stage::GetCurrent().Add( actor );
2557 ResetTouchCallbacks();
2559 unsigned int index = 0;
2560 while( NULL != hitTestData[index] )
2562 actor.SetSize( 1.f, 1.f );
2563 actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z );
2565 // flush the queue and render once
2566 application.SendNotification();
2567 application.Render();
2569 DALI_TEST_CHECK( !gTouchCallBackCalled );
2571 // connect to its touch signal
2572 actor.TouchedSignal().Connect(TestCallback);
2574 Dali::Integration::Point point;
2575 point.SetState( PointState::DOWN );
2576 point.SetScreenPosition( Vector2( hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ) );
2577 Dali::Integration::TouchEvent event;
2578 event.AddPoint( point );
2580 // flush the queue and render once
2581 application.SendNotification();
2582 application.Render();
2583 application.ProcessEvent( event );
2585 DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult );
2587 if( gTouchCallBackCalled != hitTestData[index]->mResult )
2588 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2589 hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z,
2590 hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y,
2591 hitTestData[index]->mResult );
2593 ResetTouchCallbacks();
2599 int UtcDaliActorSetDrawMode(void)
2601 TestApplication app;
2602 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2604 Actor a = Actor::New();
2606 Stage::GetCurrent().Add(a);
2607 app.SendNotification();
2609 app.SendNotification();
2612 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default
2614 a.SetDrawMode( DrawMode::OVERLAY_2D );
2615 app.SendNotification();
2618 DALI_TEST_CHECK( DrawMode::OVERLAY_2D == a.GetDrawMode() ); // Check Actor is overlay
2620 a.SetDrawMode( DrawMode::NORMAL );
2621 app.SendNotification();
2624 DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is normal
2628 int UtcDaliActorSetDrawModeOverlayRender(void)
2630 TestApplication app;
2631 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2633 app.SendNotification();
2636 std::vector<GLuint> ids;
2637 ids.push_back( 8 ); // first rendered actor
2638 ids.push_back( 9 ); // second rendered actor
2639 ids.push_back( 10 ); // third rendered actor
2640 app.GetGlAbstraction().SetNextTextureIds( ids );
2642 BufferImage imageA = BufferImage::New(16, 16);
2643 BufferImage imageB = BufferImage::New(16, 16);
2644 BufferImage imageC = BufferImage::New(16, 16);
2645 Actor a = CreateRenderableActor( imageA );
2646 Actor b = CreateRenderableActor( imageB );
2647 Actor c = CreateRenderableActor( imageC );
2649 app.SendNotification();
2652 //Textures are bound when first created. Clear bound textures vector
2653 app.GetGlAbstraction().ClearBoundTextures();
2655 // Render a,b,c as regular non-overlays. so order will be:
2659 Stage::GetCurrent().Add(a);
2660 Stage::GetCurrent().Add(b);
2661 Stage::GetCurrent().Add(c);
2663 app.SendNotification();
2666 // Should be 3 textures changes.
2667 const std::vector<GLuint>& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
2668 typedef std::vector<GLuint>::size_type TextureSize;
2669 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>( 3 ), TEST_LOCATION );
2670 if( boundTextures.size() == 3 )
2672 DALI_TEST_CHECK( boundTextures[0] == 8u );
2673 DALI_TEST_CHECK( boundTextures[1] == 9u );
2674 DALI_TEST_CHECK( boundTextures[2] == 10u );
2677 // Now texture ids have been set, we can monitor their render order.
2678 // render a as an overlay (last), so order will be:
2682 a.SetDrawMode( DrawMode::OVERLAY_2D );
2683 app.GetGlAbstraction().ClearBoundTextures();
2685 app.SendNotification();
2688 // Should be 3 texture changes.
2689 DALI_TEST_EQUALS( boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION );
2690 if( boundTextures.size() == 3 )
2692 DALI_TEST_CHECK( boundTextures[0] == 9u );
2693 DALI_TEST_CHECK( boundTextures[1] == 10u );
2694 DALI_TEST_CHECK( boundTextures[2] == 8u );
2699 int UtcDaliActorGetCurrentWorldMatrix(void)
2701 TestApplication app;
2702 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
2704 Actor parent = Actor::New();
2705 parent.SetParentOrigin(ParentOrigin::CENTER);
2706 parent.SetAnchorPoint(AnchorPoint::CENTER);
2707 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2708 Radian rotationAngle(Degree(85.0f));
2709 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2710 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2711 parent.SetPosition( parentPosition );
2712 parent.SetOrientation( parentRotation );
2713 parent.SetScale( parentScale );
2714 Stage::GetCurrent().Add( parent );
2716 Actor child = Actor::New();
2717 child.SetParentOrigin(ParentOrigin::CENTER);
2718 Vector3 childPosition( 0.0f, 0.0f, 100.0f );
2719 Radian childRotationAngle(Degree(23.0f));
2720 Quaternion childRotation( childRotationAngle, Vector3::YAXIS );
2721 Vector3 childScale( 2.0f, 2.0f, 2.0f );
2722 child.SetPosition( childPosition );
2723 child.SetOrientation( childRotation );
2724 child.SetScale( childScale );
2725 parent.Add( child );
2727 app.SendNotification();
2730 app.SendNotification();
2732 Matrix parentMatrix(false);
2733 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2735 Matrix childMatrix(false);
2736 childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
2738 //Child matrix should be the composition of child and parent
2739 Matrix childWorldMatrix(false);
2740 Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
2742 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2743 DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
2749 int UtcDaliActorConstrainedToWorldMatrix(void)
2751 TestApplication app;
2752 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
2754 Actor parent = Actor::New();
2755 parent.SetParentOrigin(ParentOrigin::CENTER);
2756 parent.SetAnchorPoint(AnchorPoint::CENTER);
2757 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2758 Radian rotationAngle(Degree(85.0f));
2759 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2760 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2761 parent.SetPosition( parentPosition );
2762 parent.SetOrientation( parentRotation );
2763 parent.SetScale( parentScale );
2764 Stage::GetCurrent().Add( parent );
2766 Actor child = Actor::New();
2767 child.SetParentOrigin(ParentOrigin::CENTER);
2768 Constraint posConstraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, PositionComponentConstraint() );
2769 posConstraint.AddSource( Source( parent, Actor::Property::WORLD_MATRIX ) );
2770 posConstraint.Apply();
2772 Stage::GetCurrent().Add( child );
2774 app.SendNotification();
2777 app.SendNotification();
2779 Matrix parentMatrix(false);
2780 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
2782 DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
2783 DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION );
2787 int UtcDaliActorConstrainedToOrientation(void)
2789 TestApplication app;
2790 tet_infoline(" UtcDaliActorConstrainedToOrientation");
2792 Actor parent = Actor::New();
2793 parent.SetParentOrigin(ParentOrigin::CENTER);
2794 parent.SetAnchorPoint(AnchorPoint::CENTER);
2795 Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
2796 Radian rotationAngle(Degree(85.0f));
2797 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
2798 Vector3 parentScale( 1.0f, 2.0f, 3.0f );
2799 parent.SetPosition( parentPosition );
2800 parent.SetOrientation( parentRotation );
2801 parent.SetScale( parentScale );
2802 Stage::GetCurrent().Add( parent );
2804 Actor child = Actor::New();
2805 child.SetParentOrigin(ParentOrigin::CENTER);
2806 Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
2807 posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
2808 posConstraint.Apply();
2810 Stage::GetCurrent().Add( child );
2812 app.SendNotification();
2815 app.SendNotification();
2817 DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
2821 int UtcDaliActorConstrainedToOpacity(void)
2823 TestApplication app;
2824 tet_infoline(" UtcDaliActorConstrainedToOpacity");
2826 Actor parent = Actor::New();
2827 parent.SetOpacity( 0.7f );
2828 Stage::GetCurrent().Add( parent );
2830 Actor child = Actor::New();
2831 Constraint opacityConstraint = Constraint::New<float>( child, DevelActor::Property::OPACITY, EqualToConstraint() );
2832 opacityConstraint.AddSource( Source( parent, DevelActor::Property::OPACITY ) );
2833 opacityConstraint.Apply();
2835 Stage::GetCurrent().Add( child );
2837 app.SendNotification();
2840 app.SendNotification();
2842 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2844 parent.SetOpacity( 0.3f );
2846 app.SendNotification();
2849 app.SendNotification();
2851 DALI_TEST_EQUALS( child.GetCurrentOpacity(), parent.GetCurrentOpacity(), 0.001f, TEST_LOCATION );
2856 int UtcDaliActorUnparent(void)
2858 TestApplication app;
2859 tet_infoline(" UtcDaliActorUnparent");
2861 Actor parent = Actor::New();
2862 Stage::GetCurrent().Add( parent );
2864 Actor child = Actor::New();
2866 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2867 DALI_TEST_CHECK( !child.GetParent() );
2869 // Test that calling Unparent with no parent is a NOOP
2872 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2873 DALI_TEST_CHECK( !child.GetParent() );
2875 // Test that Unparent works
2876 parent.Add( child );
2878 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2879 DALI_TEST_CHECK( parent == child.GetParent() );
2883 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2884 DALI_TEST_CHECK( !child.GetParent() );
2886 // Test that UnparentAndReset works
2887 parent.Add( child );
2889 DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
2890 DALI_TEST_CHECK( parent == child.GetParent() );
2892 UnparentAndReset( child );
2894 DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION );
2895 DALI_TEST_CHECK( !child );
2897 // Test that UnparentAndReset is a NOOP with empty handle
2898 UnparentAndReset( child );
2900 DALI_TEST_CHECK( !child );
2904 int UtcDaliActorGetChildAt(void)
2906 TestApplication app;
2907 tet_infoline(" UtcDaliActorGetChildAt");
2909 Actor parent = Actor::New();
2910 Stage::GetCurrent().Add( parent );
2912 Actor child0 = Actor::New();
2913 parent.Add( child0 );
2915 Actor child1 = Actor::New();
2916 parent.Add( child1 );
2918 Actor child2 = Actor::New();
2919 parent.Add( child2 );
2921 DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION );
2922 DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION );
2923 DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION );
2927 int UtcDaliActorSetGetOverlay(void)
2929 TestApplication app;
2930 tet_infoline(" UtcDaliActorSetGetOverlay");
2932 Actor parent = Actor::New();
2933 parent.SetDrawMode(DrawMode::OVERLAY_2D );
2934 DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY_2D );
2939 int UtcDaliActorCreateDestroy(void)
2941 Actor* actor = new Actor;
2942 DALI_TEST_CHECK( actor );
2949 struct PropertyStringIndex
2951 const char * const name;
2952 const Property::Index index;
2953 const Property::Type type;
2956 const PropertyStringIndex PROPERTY_TABLE[] =
2958 { "parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3 },
2959 { "parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT },
2960 { "parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT },
2961 { "parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT },
2962 { "anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3 },
2963 { "anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT },
2964 { "anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT },
2965 { "anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT },
2966 { "size", Actor::Property::SIZE, Property::VECTOR3 },
2967 { "sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT },
2968 { "sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT },
2969 { "sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT },
2970 { "position", Actor::Property::POSITION, Property::VECTOR3 },
2971 { "positionX", Actor::Property::POSITION_X, Property::FLOAT },
2972 { "positionY", Actor::Property::POSITION_Y, Property::FLOAT },
2973 { "positionZ", Actor::Property::POSITION_Z, Property::FLOAT },
2974 { "worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3 },
2975 { "worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT },
2976 { "worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT },
2977 { "worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT },
2978 { "orientation", Actor::Property::ORIENTATION, Property::ROTATION },
2979 { "worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION },
2980 { "scale", Actor::Property::SCALE, Property::VECTOR3 },
2981 { "scaleX", Actor::Property::SCALE_X, Property::FLOAT },
2982 { "scaleY", Actor::Property::SCALE_Y, Property::FLOAT },
2983 { "scaleZ", Actor::Property::SCALE_Z, Property::FLOAT },
2984 { "worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3 },
2985 { "visible", Actor::Property::VISIBLE, Property::BOOLEAN },
2986 { "color", Actor::Property::COLOR, Property::VECTOR4 },
2987 { "colorRed", Actor::Property::COLOR_RED, Property::FLOAT },
2988 { "colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT },
2989 { "colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT },
2990 { "colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT },
2991 { "worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4 },
2992 { "worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX },
2993 { "name", Actor::Property::NAME, Property::STRING },
2994 { "sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN },
2995 { "leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN },
2996 { "inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN },
2997 { "inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN },
2998 { "colorMode", Actor::Property::COLOR_MODE, Property::STRING },
2999 { "positionInheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
3000 { "drawMode", Actor::Property::DRAW_MODE, Property::STRING },
3001 { "sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
3002 { "widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
3003 { "heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
3004 { "sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
3005 { "widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN },
3006 { "heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN },
3007 { "padding", Actor::Property::PADDING, Property::VECTOR4 },
3008 { "minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 },
3009 { "maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 },
3010 { "inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN },
3011 { "clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING },
3012 { "opacity", DevelActor::Property::OPACITY, Property::FLOAT },
3014 const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
3015 } // unnamed namespace
3017 int UtcDaliActorProperties(void)
3019 TestApplication app;
3021 Actor actor = Actor::New();
3023 for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i )
3025 tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index );
3026 DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION );
3027 DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION );
3028 DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION );
3033 int UtcDaliRelayoutProperties_ResizePolicies(void)
3035 TestApplication app;
3037 Actor actor = Actor::New();
3040 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3041 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
3043 // Set resize policy for all dimensions
3044 actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
3045 for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3047 DALI_TEST_EQUALS( actor.GetResizePolicy( static_cast< Dimension::Type >( 1 << i ) ), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION );
3050 // Set individual dimensions
3051 const char* const widthPolicy = "FILL_TO_PARENT";
3052 const char* const heightPolicy = "FIXED";
3054 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy );
3055 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy );
3057 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), widthPolicy, TEST_LOCATION );
3058 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), heightPolicy, TEST_LOCATION );
3060 // Set individual dimensions using enums
3061 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3062 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3064 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum );
3065 actor.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum );
3067 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::WIDTH ) ), static_cast< int >( widthPolicyEnum ), TEST_LOCATION );
3068 DALI_TEST_EQUALS( static_cast< int >( actor.GetResizePolicy( Dimension::HEIGHT ) ), static_cast< int >( heightPolicyEnum ), TEST_LOCATION );
3073 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3075 TestApplication app;
3077 Actor actor = Actor::New();
3080 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), "USE_SIZE_SET", TEST_LOCATION );
3081 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION );
3083 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3084 actor.SetSizeScalePolicy( policy );
3085 DALI_TEST_EQUALS( actor.GetSizeScalePolicy(), policy, TEST_LOCATION );
3088 const char* const policy1 = "FIT_WITH_ASPECT_RATIO";
3089 const char* const policy2 = "FILL_WITH_ASPECT_RATIO";
3091 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy1 );
3092 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy1, TEST_LOCATION );
3094 actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy2 );
3095 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_SCALE_POLICY ).Get< std::string >(), policy2, TEST_LOCATION );
3100 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3102 TestApplication app;
3104 Actor actor = Actor::New();
3107 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3108 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), Vector3( 1.0f, 1.0f, 1.0f ), TEST_LOCATION );
3110 Vector3 sizeMode( 1.0f, 2.0f, 3.0f );
3111 actor.SetSizeModeFactor( sizeMode );
3112 DALI_TEST_EQUALS( actor.GetSizeModeFactor(), sizeMode, TEST_LOCATION );
3115 Vector3 sizeMode1( 2.0f, 3.0f, 4.0f );
3117 actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMode1 );
3118 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_MODE_FACTOR ).Get< Vector3 >(), sizeMode1, TEST_LOCATION );
3123 int UtcDaliRelayoutProperties_DimensionDependency(void)
3125 TestApplication app;
3127 Actor actor = Actor::New();
3130 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3131 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), false, TEST_LOCATION );
3134 actor.SetProperty( Actor::Property::WIDTH_FOR_HEIGHT, true );
3135 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), true, TEST_LOCATION );
3137 actor.SetProperty( Actor::Property::HEIGHT_FOR_WIDTH, true );
3138 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_FOR_WIDTH ).Get< bool >(), true, TEST_LOCATION );
3140 // Test setting another resize policy
3141 actor.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FIXED" );
3142 DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_FOR_HEIGHT ).Get< bool >(), false, TEST_LOCATION );
3147 int UtcDaliRelayoutProperties_Padding(void)
3149 TestApplication app;
3151 Actor actor = Actor::New();
3154 Vector4 padding( 1.0f, 2.0f, 3.0f, 4.0f );
3157 actor.SetProperty( Actor::Property::PADDING, padding );
3158 Vector4 paddingResult = actor.GetProperty( Actor::Property::PADDING ).Get< Vector4 >();
3160 DALI_TEST_EQUALS( paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3165 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3167 TestApplication app;
3169 Actor actor = Actor::New();
3172 Vector2 minSize( 1.0f, 2.0f );
3174 actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
3175 Vector2 resultMin = actor.GetProperty( Actor::Property::MINIMUM_SIZE ).Get< Vector2 >();
3177 DALI_TEST_EQUALS( resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3179 Vector2 maxSize( 3.0f, 4.0f );
3181 actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
3182 Vector2 resultMax = actor.GetProperty( Actor::Property::MAXIMUM_SIZE ).Get< Vector2 >();
3184 DALI_TEST_EQUALS( resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION );
3189 int UtcDaliActorGetHeightForWidth(void)
3191 TestApplication app;
3193 Actor actor = Actor::New();
3195 DALI_TEST_EQUALS( actor.GetHeightForWidth( 1.0f ), 1.0f, TEST_LOCATION );
3200 int UtcDaliActorGetWidthForHeight(void)
3202 TestApplication app;
3204 Actor actor = Actor::New();
3206 DALI_TEST_EQUALS( actor.GetWidthForHeight( 1.0f ), 1.0f, TEST_LOCATION );
3211 int UtcDaliActorGetRelayoutSize(void)
3213 TestApplication app;
3215 Actor actor = Actor::New();
3217 // Add actor to stage
3218 Stage::GetCurrent().Add( actor );
3220 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 0.0f, TEST_LOCATION );
3222 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
3223 actor.SetSize( Vector2( 1.0f, 0.0f ) );
3225 // Flush the queue and render once
3226 app.SendNotification();
3229 DALI_TEST_EQUALS( actor.GetRelayoutSize( Dimension::WIDTH ), 1.0f, TEST_LOCATION );
3234 int UtcDaliActorSetPadding(void)
3236 TestApplication app;
3238 Actor actor = Actor::New();
3241 actor.GetPadding( padding );
3243 DALI_TEST_EQUALS( padding.left, 0.0f, TEST_LOCATION );
3244 DALI_TEST_EQUALS( padding.right, 0.0f, TEST_LOCATION );
3245 DALI_TEST_EQUALS( padding.bottom, 0.0f, TEST_LOCATION );
3246 DALI_TEST_EQUALS( padding.top, 0.0f, TEST_LOCATION );
3248 Padding padding2( 1.0f, 2.0f, 3.0f, 4.0f );
3249 actor.SetPadding( padding2 );
3251 actor.GetPadding( padding );
3253 DALI_TEST_EQUALS( padding.left, padding2.left, TEST_LOCATION );
3254 DALI_TEST_EQUALS( padding.right, padding2.right, TEST_LOCATION );
3255 DALI_TEST_EQUALS( padding.bottom, padding2.bottom, TEST_LOCATION );
3256 DALI_TEST_EQUALS( padding.top, padding2.top, TEST_LOCATION );
3261 int UtcDaliActorSetMinimumSize(void)
3263 TestApplication app;
3265 Actor actor = Actor::New();
3267 Vector2 size = actor.GetMinimumSize();
3269 DALI_TEST_EQUALS( size.width, 0.0f, TEST_LOCATION );
3270 DALI_TEST_EQUALS( size.height, 0.0f, TEST_LOCATION );
3272 Vector2 size2( 1.0f, 2.0f );
3273 actor.SetMinimumSize( size2 );
3275 size = actor.GetMinimumSize();
3277 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3278 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3283 int UtcDaliActorSetMaximumSize(void)
3285 TestApplication app;
3287 Actor actor = Actor::New();
3289 Vector2 size = actor.GetMaximumSize();
3291 DALI_TEST_EQUALS( size.width, FLT_MAX, TEST_LOCATION );
3292 DALI_TEST_EQUALS( size.height, FLT_MAX, TEST_LOCATION );
3294 Vector2 size2( 1.0f, 2.0f );
3295 actor.SetMaximumSize( size2 );
3297 size = actor.GetMaximumSize();
3299 DALI_TEST_EQUALS( size.width, size2.width, TEST_LOCATION );
3300 DALI_TEST_EQUALS( size.height, size2.height, TEST_LOCATION );
3305 int UtcDaliActorOnRelayoutSignal(void)
3307 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3309 TestApplication application;
3312 gOnRelayoutCallBackCalled = false;
3313 gActorNamesRelayout.clear();
3315 Actor actor = Actor::New();
3316 actor.SetName( "actor" );
3317 actor.OnRelayoutSignal().Connect( OnRelayoutCallback );
3320 DALI_TEST_CHECK( ! gOnRelayoutCallBackCalled );
3322 // Add actor to stage
3323 Stage::GetCurrent().Add( actor );
3325 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3326 actor.SetSize( Vector2( 1.0f, 2.0 ) );
3328 // Flush the queue and render once
3329 application.SendNotification();
3330 application.Render();
3332 // OnRelayout emitted
3333 DALI_TEST_EQUALS( gOnRelayoutCallBackCalled, true, TEST_LOCATION );
3334 DALI_TEST_EQUALS( "actor", gActorNamesRelayout[ 0 ], TEST_LOCATION );
3339 int UtcDaliActorGetHierachyDepth(void)
3341 TestApplication application;
3342 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3345 /* Build tree of actors:
3355 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3357 Stage stage( Stage::GetCurrent() );
3359 Actor actorA = Actor::New();
3360 Actor actorB = Actor::New();
3361 Actor actorC = Actor::New();
3362 Actor actorD = Actor::New();
3363 Actor actorE = Actor::New();
3364 Actor actorF = Actor::New();
3366 //Test that root actor has depth equal 0
3367 DALI_TEST_EQUALS( 0, stage.GetRootLayer().GetHierarchyDepth(), TEST_LOCATION );
3369 //Test actors return depth -1 when not connected to the tree
3370 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3371 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3372 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3373 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3374 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3375 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3377 //Create the hierarchy
3378 stage.Add( actorA );
3379 actorA.Add( actorB );
3380 actorA.Add( actorC );
3381 actorB.Add( actorD );
3382 actorB.Add( actorE );
3383 actorC.Add( actorF );
3385 //Test actors return correct depth
3386 DALI_TEST_EQUALS( 1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3387 DALI_TEST_EQUALS( 2, actorB.GetHierarchyDepth(), TEST_LOCATION );
3388 DALI_TEST_EQUALS( 2, actorC.GetHierarchyDepth(), TEST_LOCATION );
3389 DALI_TEST_EQUALS( 3, actorD.GetHierarchyDepth(), TEST_LOCATION );
3390 DALI_TEST_EQUALS( 3, actorE.GetHierarchyDepth(), TEST_LOCATION );
3391 DALI_TEST_EQUALS( 3, actorF.GetHierarchyDepth(), TEST_LOCATION );
3393 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3394 actorA.Remove( actorB );
3396 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3397 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3398 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3400 //Removing actorA from the stage. All actors should have depth equal -1
3401 stage.Remove( actorA );
3403 DALI_TEST_EQUALS( -1, actorA.GetHierarchyDepth(), TEST_LOCATION );
3404 DALI_TEST_EQUALS( -1, actorB.GetHierarchyDepth(), TEST_LOCATION );
3405 DALI_TEST_EQUALS( -1, actorC.GetHierarchyDepth(), TEST_LOCATION );
3406 DALI_TEST_EQUALS( -1, actorD.GetHierarchyDepth(), TEST_LOCATION );
3407 DALI_TEST_EQUALS( -1, actorE.GetHierarchyDepth(), TEST_LOCATION );
3408 DALI_TEST_EQUALS( -1, actorF.GetHierarchyDepth(), TEST_LOCATION );
3413 int UtcDaliActorAnchorPointPropertyAsString(void)
3415 TestApplication application;
3417 Actor actor = Actor::New();
3419 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
3420 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3422 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
3423 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3425 actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
3426 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3428 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
3429 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3431 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
3432 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
3434 actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
3435 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3437 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
3438 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3440 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
3441 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3443 actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
3444 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3446 // Invalid should not change anything
3447 actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
3448 DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3453 int UtcDaliActorParentOriginPropertyAsString(void)
3455 TestApplication application;
3457 Actor actor = Actor::New();
3459 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
3460 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
3462 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
3463 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
3465 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
3466 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
3468 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
3469 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
3471 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
3472 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
3474 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
3475 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
3477 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
3478 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
3480 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
3481 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
3483 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
3484 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3486 // Invalid should not change anything
3487 actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
3488 DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
3493 int UtcDaliActorColorModePropertyAsString(void)
3495 TestApplication application;
3497 Actor actor = Actor::New();
3499 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
3500 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3502 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
3503 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3505 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
3506 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3508 actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
3509 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3511 // Invalid should not change anything
3512 actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
3513 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3518 int UtcDaliActorPositionInheritancePropertyAsString(void)
3520 TestApplication application;
3522 Actor actor = Actor::New();
3524 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
3525 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3527 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
3528 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3530 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
3531 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3533 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
3534 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3536 // Invalid should not change anything
3537 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
3538 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3543 int UtcDaliActorDrawModePropertyAsString(void)
3545 TestApplication application;
3547 Actor actor = Actor::New();
3549 actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
3550 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3552 actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
3553 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3555 actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
3556 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3558 // Invalid should not change anything
3559 actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
3560 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3565 int UtcDaliActorColorModePropertyAsEnum(void)
3567 TestApplication application;
3569 Actor actor = Actor::New();
3571 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR );
3572 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
3574 actor.SetProperty( Actor::Property::COLOR_MODE, USE_PARENT_COLOR );
3575 DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
3577 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );
3578 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
3580 actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA );
3581 DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
3586 int UtcDaliActorPositionInheritancePropertyAsEnum(void)
3588 TestApplication application;
3590 Actor actor = Actor::New();
3592 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, INHERIT_PARENT_POSITION );
3593 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
3595 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION );
3596 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
3598 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
3599 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
3601 actor.SetProperty( Actor::Property::POSITION_INHERITANCE, DONT_INHERIT_POSITION );
3602 DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
3607 int UtcDaliActorDrawModePropertyAsEnum(void)
3609 TestApplication application;
3611 Actor actor = Actor::New();
3613 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::NORMAL );
3614 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
3616 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
3617 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
3619 actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::STENCIL );
3620 DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
3625 int UtcDaliActorAddRendererP(void)
3627 tet_infoline("Testing Actor::AddRenderer");
3628 TestApplication application;
3630 Actor actor = Actor::New();
3632 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3634 Geometry geometry = CreateQuadGeometry();
3635 Shader shader = CreateShader();
3636 Renderer renderer = Renderer::New(geometry, shader);
3638 actor.AddRenderer( renderer );
3639 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3640 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3645 int UtcDaliActorAddRendererN(void)
3647 tet_infoline("Testing Actor::AddRenderer");
3648 TestApplication application;
3650 Actor actor = Actor::New();
3656 actor.AddRenderer( renderer );
3657 tet_printf("Assertion test failed - no Exception\n" );
3658 tet_result(TET_FAIL);
3660 catch(Dali::DaliException& e)
3662 DALI_TEST_PRINT_ASSERT( e );
3663 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3664 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3668 tet_printf("Assertion test failed - wrong Exception\n" );
3669 tet_result(TET_FAIL);
3675 int UtcDaliActorAddRendererOnStage(void)
3677 tet_infoline("Testing Actor::AddRenderer");
3678 TestApplication application;
3680 Actor actor = Actor::New();
3681 Stage::GetCurrent().Add(actor);
3683 application.SendNotification();
3684 application.Render(0);
3686 Geometry geometry = CreateQuadGeometry();
3687 Shader shader = CreateShader();
3688 Renderer renderer = Renderer::New(geometry, shader);
3690 application.SendNotification();
3691 application.Render(0);
3695 actor.AddRenderer( renderer );
3696 tet_result(TET_PASS);
3700 tet_result(TET_FAIL);
3706 int UtcDaliActorRemoveRendererP1(void)
3708 tet_infoline("Testing Actor::RemoveRenderer");
3709 TestApplication application;
3711 Actor actor = Actor::New();
3713 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3715 Geometry geometry = CreateQuadGeometry();
3716 Shader shader = CreateShader();
3717 Renderer renderer = Renderer::New(geometry, shader);
3719 actor.AddRenderer( renderer );
3720 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3721 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3723 actor.RemoveRenderer(renderer);
3724 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3730 int UtcDaliActorRemoveRendererP2(void)
3732 tet_infoline("Testing Actor::RemoveRenderer");
3733 TestApplication application;
3735 Actor actor = Actor::New();
3737 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3739 Geometry geometry = CreateQuadGeometry();
3740 Shader shader = CreateShader();
3741 Renderer renderer = Renderer::New(geometry, shader);
3743 actor.AddRenderer( renderer );
3744 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3745 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3747 actor.RemoveRenderer(0);
3748 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3755 int UtcDaliActorRemoveRendererN(void)
3757 tet_infoline("Testing Actor::RemoveRenderer");
3758 TestApplication application;
3760 Actor actor = Actor::New();
3762 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
3764 Geometry geometry = CreateQuadGeometry();
3765 Shader shader = CreateShader();
3766 Renderer renderer = Renderer::New(geometry, shader);
3768 actor.AddRenderer( renderer );
3769 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3770 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3772 actor.RemoveRenderer(10);
3773 DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
3774 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
3779 // Clipping test helper functions:
3780 Actor CreateActorWithContent()
3782 BufferImage image = BufferImage::New( 16u, 16u );
3783 Actor actor = CreateRenderableActor( image );
3785 // Setup dimensions and position so actor is not skipped by culling.
3786 actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3787 actor.SetSize( 16.0f, 16.0f );
3788 actor.SetParentOrigin( ParentOrigin::CENTER );
3789 actor.SetAnchorPoint( AnchorPoint::CENTER );
3794 void GenerateTrace( TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace )
3796 enabledDisableTrace.Reset();
3797 stencilTrace.Reset();
3798 enabledDisableTrace.Enable( true );
3799 stencilTrace.Enable( true );
3801 application.SendNotification();
3802 application.Render();
3804 enabledDisableTrace.Enable( false );
3805 stencilTrace.Enable( false );
3808 void CheckColorMask( TestGlAbstraction& glAbstraction, bool maskValue )
3810 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
3812 DALI_TEST_EQUALS<bool>( colorMaskParams.red, maskValue, TEST_LOCATION );
3813 DALI_TEST_EQUALS<bool>( colorMaskParams.green, maskValue, TEST_LOCATION );
3814 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, maskValue, TEST_LOCATION );
3815 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, maskValue, TEST_LOCATION );
3818 int UtcDaliActorPropertyClippingP(void)
3820 // This test checks the clippingMode property.
3821 tet_infoline( "Testing Actor::Property::CLIPPING_MODE P" );
3822 TestApplication application;
3824 Actor actor = Actor::New();
3826 // Check default clippingEnabled value.
3827 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3830 bool getValueResult = getValue.Get( value );
3831 DALI_TEST_CHECK( getValueResult );
3833 if( getValueResult )
3835 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3838 // Check setting the property.
3839 actor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3841 // Check the new value was set.
3842 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3843 getValueResult = getValue.Get( value );
3844 DALI_TEST_CHECK( getValueResult );
3846 if( getValueResult )
3848 DALI_TEST_EQUALS<int>( value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION );
3854 int UtcDaliActorPropertyClippingN(void)
3856 // Negative test case for Clipping.
3857 tet_infoline( "Testing Actor::Property::CLIPPING_MODE N" );
3858 TestApplication application;
3860 Actor actor = Actor::New();
3862 // Check default clippingEnabled value.
3863 Property::Value getValue( actor.GetProperty( Actor::Property::CLIPPING_MODE ) );
3866 bool getValueResult = getValue.Get( value );
3867 DALI_TEST_CHECK( getValueResult );
3869 if( getValueResult )
3871 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3874 // Check setting an invalid property value won't change the current property value.
3875 actor.SetProperty( Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY" );
3877 getValue = actor.GetProperty( Actor::Property::CLIPPING_MODE );
3878 getValueResult = getValue.Get( value );
3879 DALI_TEST_CHECK( getValueResult );
3881 if( getValueResult )
3883 DALI_TEST_EQUALS<int>( value, ClippingMode::DISABLED, TEST_LOCATION );
3889 int UtcDaliActorPropertyClippingActor(void)
3891 // This test checks that an actor is correctly setup for clipping.
3892 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor" );
3893 TestApplication application;
3895 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3896 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3897 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3898 size_t startIndex = 0u;
3900 // Create a clipping actor.
3901 Actor actorDepth1Clip = CreateActorWithContent();
3902 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3903 Stage::GetCurrent().Add( actorDepth1Clip );
3905 // Gather the call trace.
3906 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3908 // Check we are writing to the color buffer.
3909 CheckColorMask( glAbstraction, true );
3911 // Check the stencil buffer was enabled.
3912 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3914 // Check the stencil buffer was cleared.
3915 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3917 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3918 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3919 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3920 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3925 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
3927 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
3928 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" );
3929 TestApplication application;
3931 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3932 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3933 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3934 size_t startIndex = 0u;
3936 // Create a clipping actor.
3937 Actor actorDepth1Clip = CreateActorWithContent();
3938 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3939 Stage::GetCurrent().Add( actorDepth1Clip );
3941 // Gather the call trace.
3942 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3944 // Check we are writing to the color buffer.
3945 CheckColorMask( glAbstraction, true );
3947 // Check the stencil buffer was enabled.
3948 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3950 // Check the stencil buffer was cleared.
3951 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
3953 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
3954 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
3955 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) );
3956 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
3958 // Now disable the clipping
3959 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
3961 // Gather the call trace.
3962 GenerateTrace( application, enabledDisableTrace, stencilTrace );
3964 // Check the stencil buffer was disabled.
3965 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST
3967 // Ensure all values in stencil-mask are set to 1.
3969 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) );
3975 int UtcDaliActorPropertyClippingNestedChildren(void)
3977 // This test checks that a hierarchy of actors are clipped correctly by
3978 // writing to and reading from the correct bit-planes of the stencil buffer.
3979 tet_infoline( "Testing Actor::Property::CLIPPING_MODE nested children" );
3980 TestApplication application;
3981 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3982 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
3983 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
3985 // Create a clipping actor.
3986 Actor actorDepth1Clip = CreateActorWithContent();
3987 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3988 Stage::GetCurrent().Add( actorDepth1Clip );
3990 // Create a child actor.
3991 Actor childDepth2 = CreateActorWithContent();
3992 actorDepth1Clip.Add( childDepth2 );
3994 // Create another clipping actor.
3995 Actor childDepth2Clip = CreateActorWithContent();
3996 childDepth2Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
3997 childDepth2.Add( childDepth2Clip );
3999 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4000 // This tests the sort algorithm.
4001 Actor childDepth3 = CreateActorWithContent();
4002 childDepth2Clip.Add( childDepth3 );
4003 Actor childDepth4 = CreateActorWithContent();
4004 childDepth3.Add( childDepth4 );
4006 // Gather the call trace.
4007 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4009 // Check we are writing to the color buffer.
4010 CheckColorMask( glAbstraction, true );
4012 // Check the stencil buffer was enabled.
4013 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4015 // Perform the test twice, once for 2D layer, and once for 3D.
4016 for( unsigned int i = 0u ; i < 2u; ++i )
4018 size_t startIndex = 0u;
4020 // Check the stencil buffer was cleared.
4021 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) );
4023 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4024 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4025 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); // Write to the first bit-plane
4026 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4028 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4029 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 255", startIndex ) ); // 514 is GL_EQUAL
4030 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4032 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4033 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 1", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4034 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "3", startIndex ) ); // Write to second (and previous) bit-planes
4035 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE
4037 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4038 // (Both must be set to pass the check).
4039 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 3, 255", startIndex ) ); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4040 DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7680, 7680", startIndex ) ); // GL_KEEP, GL_KEEP, GL_KEEP
4042 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4045 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
4046 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4053 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4055 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4056 tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor with renderer override" );
4057 TestApplication application;
4059 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4060 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4061 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4063 // Create a clipping actor.
4064 Actor actorDepth1Clip = CreateActorWithContent();
4065 actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
4066 Stage::GetCurrent().Add( actorDepth1Clip );
4068 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4069 actorDepth1Clip.GetRendererAt( 0 ).SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
4071 // Gather the call trace.
4072 GenerateTrace( application, enabledDisableTrace, stencilTrace );
4074 // Check we are writing to the color buffer.
4075 CheckColorMask( glAbstraction, true );
4077 // Check the stencil buffer was not enabled.
4078 DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST
4080 // Check stencil functions are not called.
4081 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilFunc" ) );
4082 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilMask" ) );
4083 DALI_TEST_CHECK( !stencilTrace.FindMethod( "StencilOp" ) );
4088 int UtcDaliGetPropertyN(void)
4090 tet_infoline( "Testing Actor::GetProperty returns a non valid value if property index is out of range" );
4091 TestApplication app;
4093 Actor actor = Actor::New();
4095 unsigned int propertyCount = actor.GetPropertyCount();
4096 DALI_TEST_EQUALS( actor.GetProperty( Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION );
4100 int UtcDaliActorRaiseLower(void)
4102 tet_infoline( "UtcDaliActor Raise and Lower test\n" );
4104 TestApplication application;
4106 Stage stage( Stage::GetCurrent() );
4108 Actor actorA = Actor::New();
4109 Actor actorB = Actor::New();
4110 Actor actorC = Actor::New();
4112 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4113 actorA.SetParentOrigin( ParentOrigin::CENTER );
4115 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4116 actorB.SetParentOrigin( ParentOrigin::CENTER );
4118 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4119 actorC.SetParentOrigin( ParentOrigin::CENTER );
4121 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4122 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4124 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4125 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4127 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4128 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4130 stage.Add( actorA );
4131 stage.Add( actorB );
4132 stage.Add( actorC );
4134 ResetTouchCallbacks();
4136 application.SendNotification();
4137 application.Render();
4139 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4140 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4141 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4143 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4144 // Only top actor will get touched.
4145 actorA.TouchSignal().Connect( TestTouchCallback );
4146 actorB.TouchSignal().Connect( TestTouchCallback2 );
4147 actorC.TouchSignal().Connect( TestTouchCallback3 );
4149 Dali::Integration::Point point;
4150 point.SetDeviceId( 1 );
4151 point.SetState( PointState::DOWN );
4152 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4153 Dali::Integration::TouchEvent event;
4154 event.AddPoint( point );
4156 application.ProcessEvent( event );
4158 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4159 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4160 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4162 ResetTouchCallbacks();
4164 tet_printf( "Testing Raising of Actor\n" );
4166 int preActorOrder( 0 );
4167 int postActorOrder( 0 );
4169 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4170 value.Get( preActorOrder );
4172 DevelActor::Raise( actorB );
4174 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4175 value.Get( postActorOrder );
4177 tet_printf( "Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4179 application.ProcessEvent( event );
4181 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4182 DALI_TEST_EQUALS( gTouchCallBackCalled2, true , TEST_LOCATION );
4183 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4185 ResetTouchCallbacks();
4187 tet_printf( "Testing Lowering of Actor\n" );
4189 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4190 value.Get( preActorOrder );
4192 DevelActor::Lower( actorB );
4194 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4195 value.Get( postActorOrder );
4197 tet_printf( "Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder );
4199 application.ProcessEvent( event );
4201 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4202 DALI_TEST_EQUALS( gTouchCallBackCalled2, false , TEST_LOCATION );
4203 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
4205 ResetTouchCallbacks();
4210 int UtcDaliActorRaiseToTopLowerToBottom(void)
4212 tet_infoline( "UtcDaliActorRaiseToTop and LowerToBottom test \n" );
4214 TestApplication application;
4216 Stage stage( Stage::GetCurrent() );
4218 Actor actorA = Actor::New();
4219 Actor actorB = Actor::New();
4220 Actor actorC = Actor::New();
4222 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4223 // enables checking of which actor the uniform is assigned too
4224 Shader shaderA = CreateShader();
4225 shaderA.RegisterProperty( "uRendererColor",1.f);
4227 Shader shaderB = CreateShader();
4228 shaderB.RegisterProperty( "uRendererColor", 2.f );
4230 Shader shaderC = CreateShader();
4231 shaderC.RegisterProperty( "uRendererColor", 3.f );
4233 Geometry geometry = CreateQuadGeometry();
4235 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4236 Renderer rendererA = Renderer::New(geometry, shaderA);
4237 actorA.AddRenderer(rendererA);
4239 Renderer rendererB = Renderer::New(geometry, shaderB);
4240 actorB.AddRenderer(rendererB);
4242 Renderer rendererC = Renderer::New(geometry, shaderC);
4243 actorC.AddRenderer(rendererC);
4245 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4246 actorA.SetParentOrigin( ParentOrigin::CENTER );
4248 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4249 actorB.SetParentOrigin( ParentOrigin::CENTER );
4251 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4252 actorC.SetParentOrigin( ParentOrigin::CENTER );
4254 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4255 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4257 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4258 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4260 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4261 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4263 stage.Add( actorA );
4264 stage.Add( actorB );
4265 stage.Add( actorC );
4267 ResetTouchCallbacks();
4269 // Set up gl abstraction trace so can query the set uniform order
4270 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4271 glAbstraction.EnableSetUniformCallTrace(true);
4272 glAbstraction.ResetSetUniformCallStack();
4274 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4276 application.SendNotification();
4277 application.Render();
4279 tet_printf( "Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str() );
4282 // Test order of uniforms in stack
4283 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4284 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4285 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4287 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4289 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4291 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4292 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4293 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4295 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4296 // Only top actor will get touched.
4297 actorA.TouchSignal().Connect( TestTouchCallback );
4298 actorB.TouchSignal().Connect( TestTouchCallback2 );
4299 actorC.TouchSignal().Connect( TestTouchCallback3 );
4301 Dali::Integration::Point point;
4302 point.SetDeviceId( 1 );
4303 point.SetState( PointState::DOWN );
4304 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4305 Dali::Integration::TouchEvent event;
4306 event.AddPoint( point );
4308 application.ProcessEvent( event );
4310 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4311 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4312 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4314 ResetTouchCallbacks();
4316 tet_printf( "RaiseToTop ActorA\n" );
4318 DevelActor::RaiseToTop( actorA );
4320 application.ProcessEvent( event );
4322 glAbstraction.ResetSetUniformCallStack();
4323 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4325 application.SendNotification();
4326 application.Render();
4328 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4330 // Test order of uniforms in stack
4331 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4332 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4333 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4335 tet_infoline( "Testing A above C and B at bottom\n" );
4336 bool ACB = ( indexA > indexC) && ( indexC > indexB );
4338 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4340 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4341 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4342 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4344 ResetTouchCallbacks();
4346 tet_printf( "RaiseToTop ActorB\n" );
4348 DevelActor::RaiseToTop( actorB );
4350 application.ProcessEvent( event );
4352 glAbstraction.ResetSetUniformCallStack();
4353 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4355 application.SendNotification();
4356 application.Render();
4358 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4360 // Test order of uniforms in stack
4361 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4362 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4363 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4365 tet_infoline( "Testing B above A and C at bottom\n" );
4366 bool BAC = ( indexB > indexA ) && ( indexA > indexC );
4368 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4370 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4371 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4372 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4374 ResetTouchCallbacks();
4376 tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
4378 DevelActor::LowerToBottom( actorA );
4379 application.SendNotification();
4380 application.Render();
4382 DevelActor::LowerToBottom( actorB );
4383 application.SendNotification();
4384 application.Render();
4386 application.ProcessEvent( event );
4388 glAbstraction.ResetSetUniformCallStack();
4389 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4391 application.SendNotification();
4392 application.Render();
4394 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4396 // Test order of uniforms in stack
4397 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4398 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4399 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4401 tet_infoline( "Testing C above A and B at bottom\n" );
4402 bool CAB = ( indexC > indexA ) && ( indexA > indexB );
4404 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4406 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4407 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4408 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4410 ResetTouchCallbacks();
4415 int UtcDaliActorRaiseAbove(void)
4417 tet_infoline( "UtcDaliActor RaiseToAbove test \n" );
4419 TestApplication application;
4421 Stage stage( Stage::GetCurrent() );
4423 Actor actorA = Actor::New();
4424 Actor actorB = Actor::New();
4425 Actor actorC = Actor::New();
4427 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4428 actorA.SetParentOrigin( ParentOrigin::CENTER );
4430 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4431 actorB.SetParentOrigin( ParentOrigin::CENTER );
4433 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4434 actorC.SetParentOrigin( ParentOrigin::CENTER );
4436 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4437 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4439 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4440 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4442 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4443 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4445 stage.Add( actorA );
4446 stage.Add( actorB );
4447 stage.Add( actorC );
4449 ResetTouchCallbacks();
4451 application.SendNotification();
4452 application.Render();
4454 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4455 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4456 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4458 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4459 // Only top actor will get touched.
4460 actorA.TouchSignal().Connect( TestTouchCallback );
4461 actorB.TouchSignal().Connect( TestTouchCallback2 );
4462 actorC.TouchSignal().Connect( TestTouchCallback3 );
4464 Dali::Integration::Point point;
4465 point.SetDeviceId( 1 );
4466 point.SetState( PointState::DOWN );
4467 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4468 Dali::Integration::TouchEvent event;
4469 event.AddPoint( point );
4471 application.ProcessEvent( event );
4473 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4474 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4475 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4477 ResetTouchCallbacks();
4479 tet_printf( "Raise actor B Above Actor C\n" );
4481 DevelActor::RaiseAbove( actorB, actorC );
4483 application.ProcessEvent( event );
4485 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4486 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4487 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4489 ResetTouchCallbacks();
4491 tet_printf( "Raise actor A Above Actor B\n" );
4493 DevelActor::RaiseAbove( actorA, actorB );
4495 application.ProcessEvent( event );
4497 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4498 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4499 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4501 ResetTouchCallbacks();
4506 int UtcDaliActorLowerBelow(void)
4508 tet_infoline( "UtcDaliActor LowerBelow test \n" );
4510 TestApplication application;
4512 Stage stage( Stage::GetCurrent() );
4514 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4515 // enables checking of which actor the uniform is assigned too
4516 Shader shaderA = CreateShader();
4517 shaderA.RegisterProperty( "uRendererColor",1.f);
4519 Shader shaderB = CreateShader();
4520 shaderB.RegisterProperty( "uRendererColor", 2.f );
4522 Shader shaderC = CreateShader();
4523 shaderC.RegisterProperty( "uRendererColor", 3.f );
4525 Actor actorA = Actor::New();
4526 Actor actorB = Actor::New();
4527 Actor actorC = Actor::New();
4529 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4530 Geometry geometry = CreateQuadGeometry();
4532 Renderer rendererA = Renderer::New(geometry, shaderA);
4533 actorA.AddRenderer(rendererA);
4535 Renderer rendererB = Renderer::New(geometry, shaderB);
4536 actorB.AddRenderer(rendererB);
4538 Renderer rendererC = Renderer::New(geometry, shaderC);
4539 actorC.AddRenderer(rendererC);
4541 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4542 actorA.SetParentOrigin( ParentOrigin::CENTER );
4544 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4545 actorB.SetParentOrigin( ParentOrigin::CENTER );
4547 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4548 actorC.SetParentOrigin( ParentOrigin::CENTER );
4550 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4551 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4553 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4554 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4556 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4557 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4559 stage.Add( actorA );
4560 stage.Add( actorB );
4561 stage.Add( actorC );
4563 ResetTouchCallbacks();
4565 // Set up gl abstraction trace so can query the set uniform order
4566 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4567 glAbstraction.EnableSetUniformCallTrace(true);
4568 glAbstraction.ResetSetUniformCallStack();
4569 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
4571 glAbstraction.ResetSetUniformCallStack();
4573 application.SendNotification();
4574 application.Render();
4576 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4578 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4580 // Test order of uniforms in stack
4581 int indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4582 int indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4583 int indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4585 tet_infoline( "Testing C above B and A at bottom\n" );
4586 bool CBA = ( indexC > indexB) && ( indexB > indexA );
4588 DALI_TEST_EQUALS( CBA, true, TEST_LOCATION );
4590 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4591 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4592 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4594 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4595 // Only top actor will get touched.
4596 actorA.TouchSignal().Connect( TestTouchCallback );
4597 actorB.TouchSignal().Connect( TestTouchCallback2 );
4598 actorC.TouchSignal().Connect( TestTouchCallback3 );
4600 Dali::Integration::Point point;
4601 point.SetDeviceId( 1 );
4602 point.SetState( PointState::DOWN );
4603 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4604 Dali::Integration::TouchEvent event;
4605 event.AddPoint( point );
4607 tet_infoline( "UtcDaliActor Test Set up completed \n" );
4609 application.ProcessEvent( event );
4611 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4612 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4613 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4615 ResetTouchCallbacks();
4617 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" );
4619 DevelActor::LowerBelow( actorC, actorB );
4621 application.SendNotification();
4622 application.Render();
4624 application.ProcessEvent( event );
4626 glAbstraction.ResetSetUniformCallStack();
4627 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4629 application.SendNotification();
4630 application.Render();
4632 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4634 // Test order of uniforms in stack
4635 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4636 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4637 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4639 tet_infoline( "Testing B above A and C at bottom\n" );
4640 bool BAC = ( indexB > indexA) && ( indexA > indexC ); // B at TOP, then A then C at bottom
4642 DALI_TEST_EQUALS( BAC, true, TEST_LOCATION );
4644 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4645 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4646 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4648 ResetTouchCallbacks();
4650 tet_printf( "Lower actor B below Actor C leaving A on top\n" );
4652 DevelActor::LowerBelow( actorB, actorC );
4654 application.SendNotification();
4655 application.Render();
4657 application.ProcessEvent( event );
4659 glAbstraction.ResetSetUniformCallStack();
4660 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4662 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 bool ACB = ( indexA > indexC) && ( indexC > indexB ); // A on TOP, then C then B at bottom
4672 DALI_TEST_EQUALS( ACB, true, TEST_LOCATION );
4674 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4675 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4676 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4678 ResetTouchCallbacks();
4680 tet_printf( "Lower actor A below Actor C leaving C on top\n" );
4682 DevelActor::LowerBelow( actorA, actorC );
4684 application.SendNotification();
4685 application.Render();
4687 application.ProcessEvent( event );
4689 glAbstraction.ResetSetUniformCallStack();
4690 glSetUniformStack = glAbstraction.GetSetUniformTrace();
4692 application.Render();
4693 tet_printf( "Trace:%s \n", glSetUniformStack.GetTraceString().c_str() );
4695 // Test order of uniforms in stack
4696 indexC = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "3" );
4697 indexB = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "2" );
4698 indexA = glSetUniformStack.FindIndexFromMethodAndParams( "uRendererColor", "1" );
4700 bool CAB = ( indexC > indexA) && ( indexA > indexB );
4702 DALI_TEST_EQUALS( CAB, true, TEST_LOCATION );
4707 int UtcDaliActorMaxSiblingOrder(void)
4709 tet_infoline( "UtcDaliActor De-fragment of sibling order once max index reached\n" );
4711 TestApplication application;
4713 int testOrders[] = { 0,1,3,5,17,998, 999 };
4714 int resultingOrders[] = { 0,1,2,3,4,6,5 };
4716 const int TEST_ORDERS_COUNT = sizeof( testOrders ) / sizeof( testOrders[0] );
4718 Stage stage( Stage::GetCurrent() );
4720 Actor parent = Actor::New();
4722 for ( int index = 0; index < TEST_ORDERS_COUNT; index++ )
4724 Actor newActor = Actor::New();
4725 newActor.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, testOrders[index] );
4726 parent.Add( newActor );
4728 stage.Add( parent );
4730 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4731 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4733 Actor sibling = parent.GetChildAt( index );
4734 int siblingOrder = 0;
4735 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4736 value.Get( siblingOrder );
4737 tet_printf( "%d, ", siblingOrder );
4741 Actor sibling = parent.GetChildAt( 5 );
4742 DevelActor::RaiseToTop( sibling );
4744 application.SendNotification();
4745 application.Render();
4747 tet_printf( "Sibling Order %d children :", parent.GetChildCount() );
4748 for ( unsigned int index = 0; index < parent.GetChildCount(); index ++)
4750 Actor sibling = parent.GetChildAt( index );
4751 int siblingOrder = 0;
4752 Property::Value value = sibling.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
4753 value.Get( siblingOrder );
4754 tet_printf( "%d, ", siblingOrder );
4755 DALI_TEST_EQUALS( siblingOrder, resultingOrders[ index] , TEST_LOCATION );
4763 int UtcDaliActorRaiseAboveLowerBelowDifferentParentsN(void)
4765 tet_infoline( "UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n" );
4767 TestApplication application;
4769 Stage stage( Stage::GetCurrent() );
4771 Actor parentA = Actor::New();
4772 Actor parentB = Actor::New();
4773 parentA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4774 parentA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4775 parentB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4776 parentB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4778 parentA.SetAnchorPoint( AnchorPoint::CENTER );
4779 parentA.SetParentOrigin( ParentOrigin::CENTER );
4781 parentB.SetAnchorPoint( AnchorPoint::CENTER );
4782 parentB.SetParentOrigin( ParentOrigin::CENTER );
4784 stage.Add( parentA );
4785 stage.Add( parentB );
4787 Actor actorA = Actor::New();
4788 Actor actorB = Actor::New();
4789 Actor actorC = Actor::New();
4791 parentA.Add( actorA );
4792 parentA.Add( actorB );
4794 tet_printf( "Actor C added to different parent from A and B \n" );
4795 parentB.Add( actorC );
4797 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4798 actorA.SetParentOrigin( ParentOrigin::CENTER );
4800 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4801 actorB.SetParentOrigin( ParentOrigin::CENTER );
4803 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4804 actorC.SetParentOrigin( ParentOrigin::CENTER );
4806 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4807 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4809 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4810 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4812 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4813 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4815 ResetTouchCallbacks();
4817 application.SendNotification();
4818 application.Render();
4820 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4821 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4822 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4824 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4825 // Only top actor will get touched.
4826 actorA.TouchSignal().Connect( TestTouchCallback );
4827 actorB.TouchSignal().Connect( TestTouchCallback2 );
4828 actorC.TouchSignal().Connect( TestTouchCallback3 );
4830 Dali::Integration::Point point;
4831 point.SetDeviceId( 1 );
4832 point.SetState( PointState::DOWN );
4833 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4834 Dali::Integration::TouchEvent event;
4835 event.AddPoint( point );
4837 application.ProcessEvent( event );
4839 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4840 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4841 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4843 ResetTouchCallbacks();
4845 tet_printf( "Raise actor A Above Actor C which have different parents\n" );
4847 DevelActor::RaiseAbove( actorA, actorC );
4849 application.ProcessEvent( event );
4851 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4852 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4853 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
4855 ResetTouchCallbacks();
4860 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
4862 tet_infoline( "UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n" );
4864 TestApplication application;
4866 Stage stage( Stage::GetCurrent() );
4868 Actor actorA = Actor::New();
4869 Actor actorB = Actor::New();
4870 Actor actorC = Actor::New();
4872 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4873 actorA.SetParentOrigin( ParentOrigin::CENTER );
4875 actorB.SetAnchorPoint( AnchorPoint::CENTER );
4876 actorB.SetParentOrigin( ParentOrigin::CENTER );
4878 actorC.SetAnchorPoint( AnchorPoint::CENTER );
4879 actorC.SetParentOrigin( ParentOrigin::CENTER );
4881 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4882 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4884 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4885 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4887 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
4888 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
4890 ResetTouchCallbacks();
4892 application.SendNotification();
4893 application.Render();
4895 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4896 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4897 DALI_TEST_EQUALS( gTouchCallBackCalled3, false, TEST_LOCATION );
4899 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4900 // Only top actor will get touched.
4901 actorA.TouchSignal().Connect( TestTouchCallback );
4902 actorB.TouchSignal().Connect( TestTouchCallback2 );
4903 actorC.TouchSignal().Connect( TestTouchCallback3 );
4905 Dali::Integration::Point point;
4906 point.SetDeviceId( 1 );
4907 point.SetState( PointState::DOWN );
4908 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
4909 Dali::Integration::TouchEvent event;
4910 event.AddPoint( point );
4912 tet_printf( "Raise actor A Above Actor C which have no parents\n" );
4914 DevelActor::RaiseAbove( actorA, actorC );
4916 application.ProcessEvent( event );
4918 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
4920 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4921 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4922 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4924 ResetTouchCallbacks();
4926 stage.Add ( actorB );
4928 application.SendNotification();
4929 application.Render();
4931 tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
4932 DevelActor::LowerBelow( actorA, actorC );
4933 application.ProcessEvent( event );
4935 tet_printf( "Actor A not parented so LowerBelow should show no effect\n" );
4936 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
4937 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
4938 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4940 ResetTouchCallbacks();
4942 tet_printf( "Adding Actor A to stage, will be on top\n" );
4944 stage.Add ( actorA );
4945 application.SendNotification();
4946 application.Render();
4948 tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
4949 DevelActor::RaiseAbove( actorB, actorC );
4950 application.ProcessEvent( event );
4952 tet_printf( "C not parented so RaiseAbove should show no effect\n" );
4953 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4954 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4955 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4957 ResetTouchCallbacks();
4959 tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
4960 DevelActor::LowerBelow( actorA, actorC );
4961 application.ProcessEvent( event );
4963 tet_printf( "C not parented so LowerBelow should show no effect\n" );
4964 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4965 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4966 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4968 ResetTouchCallbacks();
4970 stage.Add ( actorC );
4972 application.SendNotification();
4973 application.Render();
4975 DevelActor::RaiseAbove( actorA, actorC );
4976 application.ProcessEvent( event );
4978 tet_printf( "Raise actor A Above Actor C, now both have same parent \n" );
4979 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
4980 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
4981 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
4986 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
4988 tet_infoline( "UtcDaliActor Test all raise/lower api when actor has no parent \n" );
4990 TestApplication application;
4992 Stage stage( Stage::GetCurrent() );
4994 Actor actorA = Actor::New();
4995 Actor actorB = Actor::New();
4996 Actor actorC = Actor::New();
4998 actorA.SetAnchorPoint( AnchorPoint::CENTER );
4999 actorA.SetParentOrigin( ParentOrigin::CENTER );
5001 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5002 actorB.SetParentOrigin( ParentOrigin::CENTER );
5004 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5005 actorC.SetParentOrigin( ParentOrigin::CENTER );
5007 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5008 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5010 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5011 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5013 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5014 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5016 ResetTouchCallbacks();
5018 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5019 // Only top actor will get touched.
5020 actorA.TouchSignal().Connect( TestTouchCallback );
5021 actorB.TouchSignal().Connect( TestTouchCallback2 );
5022 actorC.TouchSignal().Connect( TestTouchCallback3 );
5024 Dali::Integration::Point point;
5025 point.SetDeviceId( 1 );
5026 point.SetState( PointState::DOWN );
5027 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5028 Dali::Integration::TouchEvent event;
5029 event.AddPoint( point );
5031 stage.Add ( actorA );
5033 application.SendNotification();
5034 application.Render();
5036 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5038 DevelActor::Raise( actorB );
5040 application.ProcessEvent( event );
5042 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5044 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5045 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5046 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5048 tet_printf( "Raise actor B Above Actor C but B not parented\n" );
5049 ResetTouchCallbacks();
5051 DevelActor::Lower( actorC );
5053 application.ProcessEvent( event );
5055 tet_printf( "Not parented so RaiseAbove should show no effect\n" );
5057 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5058 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5059 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5060 ResetTouchCallbacks();
5062 tet_printf( "Lower actor C below B but C not parented\n" );
5064 DevelActor::Lower( actorB );
5066 application.ProcessEvent( event );
5068 tet_printf( "Not parented so Lower should show no effect\n" );
5070 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5071 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5072 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5073 ResetTouchCallbacks();
5075 tet_printf( "Raise actor B to top\n" );
5077 DevelActor::RaiseToTop( actorB );
5079 application.ProcessEvent( event );
5081 tet_printf( "Not parented so RaiseToTop should show no effect\n" );
5083 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5084 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5085 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5086 ResetTouchCallbacks();
5088 tet_printf( "Add ActorB to stage so only Actor C not parented\n" );
5090 stage.Add ( actorB );
5092 application.SendNotification();
5093 application.Render();
5095 tet_printf( "Lower actor C to Bottom, B stays at top\n" );
5097 DevelActor::LowerToBottom( actorC );
5099 application.ProcessEvent( event );
5101 tet_printf( "Not parented so LowerToBottom should show no effect\n" );
5103 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5104 DALI_TEST_EQUALS( gTouchCallBackCalled2, true, TEST_LOCATION );
5105 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );
5106 ResetTouchCallbacks();
5112 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5114 tet_infoline( "UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n" );
5116 TestApplication application;
5118 Stage stage( Stage::GetCurrent() );
5120 Actor actorA = Actor::New();
5121 Actor actorB = Actor::New();
5122 Actor actorC = Actor::New();
5124 actorA.SetAnchorPoint( AnchorPoint::CENTER );
5125 actorA.SetParentOrigin( ParentOrigin::CENTER );
5127 actorB.SetAnchorPoint( AnchorPoint::CENTER );
5128 actorB.SetParentOrigin( ParentOrigin::CENTER );
5130 actorC.SetAnchorPoint( AnchorPoint::CENTER );
5131 actorC.SetParentOrigin( ParentOrigin::CENTER );
5133 actorA.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5134 actorA.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5136 actorB.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5137 actorB.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5139 actorC.SetProperty( Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT" );
5140 actorC.SetProperty( Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT" );
5142 stage.Add( actorA );
5143 stage.Add( actorB );
5144 stage.Add( actorC );
5146 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5147 // Only top actor will get touched.
5148 actorA.TouchSignal().Connect( TestTouchCallback );
5149 actorB.TouchSignal().Connect( TestTouchCallback2 );
5150 actorC.TouchSignal().Connect( TestTouchCallback3 );
5152 ResetTouchCallbacks();
5154 application.SendNotification();
5155 application.Render();
5157 Dali::Integration::Point point;
5158 point.SetDeviceId( 1 );
5159 point.SetState( PointState::DOWN );
5160 point.SetScreenPosition( Vector2( 10.f, 10.f ) );
5161 Dali::Integration::TouchEvent event;
5162 event.AddPoint( point );
5164 application.ProcessEvent( event );
5166 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5167 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5168 DALI_TEST_EQUALS( gTouchCallBackCalled3, true, TEST_LOCATION );
5170 ResetTouchCallbacks();
5172 tet_printf( "Raise actor A Above Actor A which is the same actor!!\n" );
5174 DevelActor::RaiseAbove( actorA, actorA );
5176 application.ProcessEvent( event );
5178 tet_printf( "No target is source Actor so RaiseAbove should show no effect\n" );
5180 DALI_TEST_EQUALS( gTouchCallBackCalled, false, TEST_LOCATION );
5181 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5182 DALI_TEST_EQUALS( gTouchCallBackCalled3, true , TEST_LOCATION );
5184 ResetTouchCallbacks();
5186 DevelActor::RaiseAbove( actorA, actorC );
5187 application.ProcessEvent( event );
5189 tet_printf( "Raise actor A Above Actor C which will now be successful \n" );
5190 DALI_TEST_EQUALS( gTouchCallBackCalled, true, TEST_LOCATION );
5191 DALI_TEST_EQUALS( gTouchCallBackCalled2, false, TEST_LOCATION );
5192 DALI_TEST_EQUALS( gTouchCallBackCalled3, false , TEST_LOCATION );