2 * Copyright (c) 2020 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.
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
21 #include <dali-test-suite-utils.h>
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/public-api/dali-core.h>
27 #include <mesh-builder.h>
29 #include <cfloat> // For FLT_MAX
39 void utc_dali_actor_startup(void)
41 test_return_value = TET_UNDEF;
44 void utc_dali_actor_cleanup(void)
46 test_return_value = TET_PASS;
51 bool gTouchCallBackCalled = false;
52 bool gTouchCallBackCalled2 = false;
53 bool gTouchCallBackCalled3 = false;
55 bool gHoverCallBackCalled = false;
57 static bool gTestConstraintCalled;
59 LayoutDirection::Type gLayoutDirectionType;
63 void operator()(Vector4& color, const PropertyInputContainer& /* inputs */)
65 gTestConstraintCalled = true;
70 * TestConstraint reference.
71 * When constraint is called, the resultRef is updated
72 * with the value supplied.
75 struct TestConstraintRef
77 TestConstraintRef(unsigned int& resultRef, unsigned int value)
78 : mResultRef(resultRef),
83 void operator()(T& current, const PropertyInputContainer& /* inputs */)
88 unsigned int& mResultRef;
92 static bool TestTouchCallback(Actor, const TouchEvent&)
94 gTouchCallBackCalled = true;
99 static bool TestTouchCallback2(Actor, const TouchEvent&)
101 gTouchCallBackCalled2 = true;
106 static bool TestTouchCallback3(Actor, const TouchEvent&)
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> gActorNamesOnOffScene;
129 static int gOnSceneCallBackCalled;
130 void OnSceneCallback(Actor actor)
132 ++gOnSceneCallBackCalled;
133 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
134 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
136 static int gOffSceneCallBackCalled;
137 void OffSceneCallback(Actor actor)
139 ++gOffSceneCallBackCalled;
140 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
141 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
144 struct PositionComponentConstraint
146 PositionComponentConstraint()
150 void operator()(Vector3& pos, const PropertyInputContainer& inputs)
152 const Matrix& m = inputs[0]->GetMatrix();
155 m.GetTransformComponents(pos, rot, scale);
159 struct OrientationComponentConstraint
161 OrientationComponentConstraint()
165 void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
167 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
170 orientation = parentOrientation;
175 static bool gOnRelayoutCallBackCalled = false;
176 static std::vector<std::string> gActorNamesRelayout;
178 void OnRelayoutCallback(Actor actor)
180 gOnRelayoutCallBackCalled = true;
181 gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
184 struct VisibilityChangedFunctorData
186 VisibilityChangedFunctorData()
189 type(DevelActor::VisibilityChange::SELF),
198 type = DevelActor::VisibilityChange::SELF;
202 void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
204 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
205 DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
206 DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
207 DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
210 void Check(bool compareCalled, const std::string& location)
212 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
217 DevelActor::VisibilityChange::Type type;
221 struct VisibilityChangedFunctor
223 VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
228 void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
231 data.visible = visible;
236 VisibilityChangedFunctorData& data;
239 struct VisibilityChangedVoidFunctor
241 VisibilityChangedVoidFunctor(bool& signalCalled)
242 : mSignalCalled(signalCalled)
248 mSignalCalled = true;
254 struct ChildOrderChangedFunctor
256 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
257 : mSignalCalled(signalCalled),
262 void operator()(Actor actor)
264 mSignalCalled = true;
272 struct CulledPropertyNotificationFunctor
274 CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
275 : mSignalCalled(signalCalled),
276 mPropertyNotification(propertyNotification)
280 void operator()(PropertyNotification& source)
282 mSignalCalled = true;
283 mPropertyNotification = source;
287 PropertyNotification& mPropertyNotification;
290 } // anonymous namespace
292 //& purpose: Testing New API
293 int UtcDaliActorNew(void)
295 TestApplication application;
297 Actor actor = Actor::New();
299 DALI_TEST_CHECK(actor);
303 //& purpose: Testing Dali::Actor::DownCast()
304 int UtcDaliActorDownCastP(void)
306 TestApplication application;
307 tet_infoline("Testing Dali::Actor::DownCast()");
309 Actor actor = Actor::New();
310 BaseHandle object(actor);
311 Actor actor2 = Actor::DownCast(object);
312 DALI_TEST_CHECK(actor2);
316 //& purpose: Testing Dali::Actor::DownCast()
317 int UtcDaliActorDownCastN(void)
319 TestApplication application;
320 tet_infoline("Testing Dali::Actor::DownCast()");
322 BaseHandle unInitializedObject;
323 Actor actor = Actor::DownCast(unInitializedObject);
324 DALI_TEST_CHECK(!actor);
328 int UtcDaliActorMoveConstructor(void)
330 TestApplication application;
332 Actor actor = Actor::New();
333 DALI_TEST_CHECK(actor);
335 int id = actor.GetProperty<int>(Actor::Property::ID);
337 Actor moved = std::move(actor);
338 DALI_TEST_CHECK(moved);
339 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
340 DALI_TEST_CHECK(!actor);
345 int UtcDaliActorMoveAssignment(void)
347 TestApplication application;
349 Actor actor = Actor::New();
350 DALI_TEST_CHECK(actor);
352 int id = actor.GetProperty<int>(Actor::Property::ID);
355 moved = std::move(actor);
356 DALI_TEST_CHECK(moved);
357 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
358 DALI_TEST_CHECK(!actor);
363 //& purpose: Testing Dali::Actor::GetName()
364 int UtcDaliActorGetName(void)
366 TestApplication application;
368 Actor actor = Actor::New();
370 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
374 //& purpose: Testing Dali::Actor::SetName()
375 int UtcDaliActorSetName(void)
377 TestApplication application;
379 string str("ActorName");
380 Actor actor = Actor::New();
382 actor.SetProperty(Actor::Property::NAME, str);
383 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
387 int UtcDaliActorGetId(void)
389 tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
390 TestApplication application;
392 Actor first = Actor::New();
393 Actor second = Actor::New();
394 Actor third = Actor::New();
396 DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
397 DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
401 int UtcDaliActorIsRoot(void)
403 TestApplication application;
405 Actor actor = Actor::New();
406 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
408 // get the root layer
409 actor = application.GetScene().GetLayer(0);
410 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
414 int UtcDaliActorOnScene(void)
416 TestApplication application;
418 Actor actor = Actor::New();
419 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
421 // get the root layer
422 actor = application.GetScene().GetLayer(0);
423 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
427 int UtcDaliActorIsLayer(void)
429 TestApplication application;
431 Actor actor = Actor::New();
432 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
434 // get the root layer
435 actor = application.GetScene().GetLayer(0);
436 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
440 int UtcDaliActorGetLayer(void)
442 TestApplication application;
444 Actor actor = Actor::New();
445 application.GetScene().Add(actor);
446 Layer layer = actor.GetLayer();
448 DALI_TEST_CHECK(layer);
450 // get the root layers layer
451 actor = application.GetScene().GetLayer(0);
452 DALI_TEST_CHECK(actor.GetLayer());
456 int UtcDaliActorAddP(void)
458 tet_infoline("Testing Actor::Add");
459 TestApplication application;
461 Actor parent = Actor::New();
462 Actor child = Actor::New();
464 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
468 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
470 Actor parent2 = Actor::New();
473 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
474 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
476 // try Adding to same parent again, works
478 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
480 // try reparenting an orphaned child
482 Actor temporaryParent = Actor::New();
483 temporaryParent.Add(child);
484 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
486 // temporaryParent has now died, reparent the orphaned child
488 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
493 int UtcDaliActorAddN(void)
495 tet_infoline("Testing Actor::Add");
496 TestApplication application;
498 Actor child = Actor::New();
500 Actor parent2 = Actor::New();
506 parent2.Add(parent2);
507 tet_printf("Assertion test failed - no Exception\n");
508 tet_result(TET_FAIL);
510 catch(Dali::DaliException& e)
512 DALI_TEST_PRINT_ASSERT(e);
513 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
514 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
518 tet_printf("Assertion test failed - wrong Exception\n");
519 tet_result(TET_FAIL);
522 // try reparenting root
525 parent2.Add(application.GetScene().GetLayer(0));
526 tet_printf("Assertion test failed - no Exception\n");
527 tet_result(TET_FAIL);
529 catch(Dali::DaliException& e)
531 DALI_TEST_PRINT_ASSERT(e);
532 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
533 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
537 tet_printf("Assertion test failed - wrong Exception\n");
538 tet_result(TET_FAIL);
546 tet_printf("Assertion test failed - no Exception\n");
547 tet_result(TET_FAIL);
549 catch(Dali::DaliException& e)
551 DALI_TEST_PRINT_ASSERT(e);
552 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
553 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
557 tet_printf("Assertion test failed - wrong Exception\n");
558 tet_result(TET_FAIL);
564 int UtcDaliActorRemoveN(void)
566 tet_infoline("Testing Actor::Remove");
567 TestApplication application;
569 Actor parent = Actor::New();
570 Actor child = Actor::New();
571 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
574 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
576 parent.Remove(child);
577 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
579 // remove again, no problem
580 parent.Remove(child);
581 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
585 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
586 // try Remove self, its a no-op
587 parent.Remove(parent);
588 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
594 parent.Remove(empty);
595 tet_printf("Assertion test failed - no Exception\n");
596 tet_result(TET_FAIL);
598 catch(Dali::DaliException& e)
600 DALI_TEST_PRINT_ASSERT(e);
601 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
602 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
606 tet_printf("Assertion test failed - wrong Exception\n");
607 tet_result(TET_FAIL);
612 int UtcDaliActorRemoveP(void)
614 TestApplication application;
616 Actor parent = Actor::New();
617 Actor child = Actor::New();
618 Actor random = Actor::New();
620 application.GetScene().Add(parent);
622 DALI_TEST_CHECK(parent.GetChildCount() == 0);
626 DALI_TEST_CHECK(parent.GetChildCount() == 1);
628 parent.Remove(random);
630 DALI_TEST_CHECK(parent.GetChildCount() == 1);
632 application.GetScene().Remove(parent);
634 DALI_TEST_CHECK(parent.GetChildCount() == 1);
638 int UtcDaliActorGetChildCount(void)
640 TestApplication application;
642 Actor parent = Actor::New();
643 Actor child = Actor::New();
645 DALI_TEST_CHECK(parent.GetChildCount() == 0);
649 DALI_TEST_CHECK(parent.GetChildCount() == 1);
653 int UtcDaliActorGetChildren01(void)
655 TestApplication application;
657 Actor parent = Actor::New();
658 Actor first = Actor::New();
659 Actor second = Actor::New();
660 Actor third = Actor::New();
666 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
667 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
668 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
672 int UtcDaliActorGetChildren02(void)
674 TestApplication application;
676 Actor parent = Actor::New();
677 Actor first = Actor::New();
678 Actor second = Actor::New();
679 Actor third = Actor::New();
685 const Actor& constParent = parent;
687 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
688 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
689 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
693 int UtcDaliActorGetParent01(void)
695 TestApplication application;
697 Actor parent = Actor::New();
698 Actor child = Actor::New();
702 DALI_TEST_CHECK(child.GetParent() == parent);
706 int UtcDaliActorGetParent02(void)
708 TestApplication application;
710 Actor actor = Actor::New();
712 DALI_TEST_CHECK(!actor.GetParent());
716 int UtcDaliActorCustomProperty(void)
718 TestApplication application;
720 Actor actor = Actor::New();
721 application.GetScene().Add(actor);
723 float startValue(1.0f);
724 Property::Index index = actor.RegisterProperty("testProperty", startValue);
725 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
727 application.SendNotification();
728 application.Render(0);
729 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
731 actor.SetProperty(index, 5.0f);
733 application.SendNotification();
734 application.Render(0);
735 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
739 int UtcDaliActorCustomPropertyIntToFloat(void)
741 TestApplication application;
743 Actor actor = Actor::New();
744 application.GetScene().Add(actor);
746 float startValue(5.0f);
747 Property::Index index = actor.RegisterProperty("testProperty", startValue);
748 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
750 application.SendNotification();
751 application.Render(0);
752 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
754 actor.SetProperty(index, int(1));
756 application.SendNotification();
757 application.Render(0);
758 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
762 int UtcDaliActorCustomPropertyFloatToInt(void)
764 TestApplication application;
766 Actor actor = Actor::New();
767 application.GetScene().Add(actor);
770 Property::Index index = actor.RegisterProperty("testProperty", startValue);
771 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
773 application.SendNotification();
774 application.Render(0);
775 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
777 actor.SetProperty(index, float(1.5));
779 application.SendNotification();
780 application.Render(0);
781 DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
785 int UtcDaliActorSetParentOrigin(void)
787 TestApplication application;
789 Actor actor = Actor::New();
791 Vector3 vector(0.7f, 0.8f, 0.9f);
792 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
794 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
796 // flush the queue and render once
797 application.SendNotification();
798 application.Render();
800 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
802 application.GetScene().Add(actor);
804 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
806 // flush the queue and render once
807 application.SendNotification();
808 application.Render();
810 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
812 application.GetScene().Remove(actor);
816 int UtcDaliActorSetParentOriginIndividual(void)
818 TestApplication application;
820 Actor actor = Actor::New();
822 Vector3 vector(0.7f, 0.8f, 0.9f);
823 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
825 actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
827 // flush the queue and render once
828 application.SendNotification();
829 application.Render();
831 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
833 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
835 // flush the queue and render once
836 application.SendNotification();
837 application.Render();
839 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
841 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
843 // flush the queue and render once
844 application.SendNotification();
845 application.Render();
847 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
852 int UtcDaliActorGetCurrentParentOrigin(void)
854 TestApplication application;
856 Actor actor = Actor::New();
858 Vector3 vector(0.7f, 0.8f, 0.9f);
859 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
861 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
863 // flush the queue and render once
864 application.SendNotification();
865 application.Render();
867 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
871 int UtcDaliActorSetAnchorPoint(void)
873 TestApplication application;
875 Actor actor = Actor::New();
877 Vector3 vector(0.7f, 0.8f, 0.9f);
878 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
880 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
882 // flush the queue and render once
883 application.SendNotification();
884 application.Render();
886 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
888 application.GetScene().Add(actor);
890 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
891 // flush the queue and render once
892 application.SendNotification();
893 application.Render();
895 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
897 application.GetScene().Remove(actor);
901 int UtcDaliActorSetAnchorPointIndividual(void)
903 TestApplication application;
905 Actor actor = Actor::New();
907 Vector3 vector(0.7f, 0.8f, 0.9f);
908 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
910 actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
912 // flush the queue and render once
913 application.SendNotification();
914 application.Render();
916 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
918 actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
920 // flush the queue and render once
921 application.SendNotification();
922 application.Render();
924 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
926 actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
928 // flush the queue and render once
929 application.SendNotification();
930 application.Render();
932 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
937 int UtcDaliActorGetCurrentAnchorPoint(void)
939 TestApplication application;
941 Actor actor = Actor::New();
943 Vector3 vector(0.7f, 0.8f, 0.9f);
944 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
946 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
948 // flush the queue and render once
949 application.SendNotification();
950 application.Render();
952 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
956 int UtcDaliActorSetSize01(void)
958 TestApplication application;
960 Actor actor = Actor::New();
961 Vector3 vector(100.0f, 100.0f, 0.0f);
963 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
965 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
967 // Immediately retrieve the size after setting
968 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
969 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
970 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
971 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
972 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
974 // Flush the queue and render once
975 application.SendNotification();
976 application.Render();
978 // Check the size in the new frame
979 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
981 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
982 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
983 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
984 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
985 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
987 // Check async behaviour
988 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
989 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
990 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
991 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
992 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
994 // Change the resize policy and check whether the size stays the same
995 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
997 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
998 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1000 // Set a new size after resize policy is changed and check the new size
1001 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1003 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1004 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1006 // Change the resize policy again and check whether the new size stays the same
1007 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1009 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1010 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1012 // Set another new size after resize policy is changed and check the new size
1013 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1015 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1016 DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1021 int UtcDaliActorSetSize02(void)
1023 TestApplication application;
1025 Actor actor = Actor::New();
1026 Vector3 vector(100.0f, 100.0f, 100.0f);
1028 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1030 actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1032 // Immediately check the size after setting
1033 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1034 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1036 // flush the queue and render once
1037 application.SendNotification();
1038 application.Render();
1040 // Check the size in the new frame
1041 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1043 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1044 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1049 // SetSize(Vector2 size)
1050 int UtcDaliActorSetSize03(void)
1052 TestApplication application;
1054 Actor actor = Actor::New();
1055 Vector3 vector(100.0f, 100.0f, 0.0f);
1057 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1059 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1061 // Immediately check the size after setting
1062 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1063 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1065 // flush the queue and render once
1066 application.SendNotification();
1067 application.Render();
1069 // Check the size in the new frame
1070 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1072 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1073 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1078 // SetSize(Vector3 size)
1079 int UtcDaliActorSetSize04(void)
1081 TestApplication application;
1083 Actor actor = Actor::New();
1084 Vector3 vector(100.0f, 100.0f, 100.0f);
1086 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1088 actor.SetProperty(Actor::Property::SIZE, vector);
1090 // Immediately check the size after setting
1091 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1092 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1094 // flush the queue and render once
1095 application.SendNotification();
1096 application.Render();
1098 // Check the size in the new frame
1099 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1101 application.GetScene().Add(actor);
1102 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1104 // Immediately check the size after setting
1105 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1106 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1108 // flush the queue and render once
1109 application.SendNotification();
1110 application.Render();
1112 // Check the size in the new frame
1113 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1115 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1116 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1118 application.GetScene().Remove(actor);
1122 int UtcDaliActorSetSizeIndividual(void)
1124 TestApplication application;
1126 Actor actor = Actor::New();
1128 Vector3 vector(0.7f, 0.8f, 0.9f);
1129 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1131 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1133 // Immediately check the width after setting
1134 float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1135 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1137 // flush the queue and render once
1138 application.SendNotification();
1139 application.Render();
1141 // Check the width in the new frame
1142 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1144 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1145 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1147 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1149 // Immediately check the height after setting
1150 float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1151 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1153 // flush the queue and render once
1154 application.SendNotification();
1155 application.Render();
1157 // Check the height in the new frame
1158 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1160 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1161 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1163 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1165 // Immediately check the depth after setting
1166 float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1167 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1169 // flush the queue and render once
1170 application.SendNotification();
1171 application.Render();
1173 // Check the depth in the new frame
1174 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1176 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1177 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1179 // Change the resize policy and check whether the size stays the same
1180 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1182 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1183 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1185 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1186 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1188 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1189 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1191 // Change the resize policy again and check whether the size stays the same
1192 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1194 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1195 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1197 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1198 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1200 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1201 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1206 int UtcDaliActorSetSizeIndividual02(void)
1208 TestApplication application;
1210 Actor actor = Actor::New();
1211 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1212 application.GetScene().Add(actor);
1214 Vector3 vector(100.0f, 200.0f, 400.0f);
1215 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1217 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1218 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1220 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1221 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1223 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1224 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1226 // flush the queue and render once
1227 application.SendNotification();
1228 application.Render();
1230 // Check the width in the new frame
1231 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1232 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1237 int UtcDaliActorGetCurrentSize(void)
1239 TestApplication application;
1241 Actor actor = Actor::New();
1242 Vector3 vector(100.0f, 100.0f, 20.0f);
1244 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1246 actor.SetProperty(Actor::Property::SIZE, vector);
1248 // flush the queue and render once
1249 application.SendNotification();
1250 application.Render();
1252 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1256 int UtcDaliActorGetNaturalSize(void)
1258 TestApplication application;
1260 Actor actor = Actor::New();
1261 Vector3 vector(0.0f, 0.0f, 0.0f);
1263 DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1268 int UtcDaliActorGetCurrentSizeImmediate(void)
1270 TestApplication application;
1272 Actor actor = Actor::New();
1273 Vector3 vector(100.0f, 100.0f, 20.0f);
1275 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1276 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1278 actor.SetProperty(Actor::Property::SIZE, vector);
1280 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1281 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1283 // flush the queue and render once
1284 application.SendNotification();
1285 application.Render();
1287 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1288 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1291 // Build the animation
1292 const float durationSeconds = 2.0f;
1293 Animation animation = Animation::New(durationSeconds);
1294 const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1295 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1297 DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1299 // Start the animation
1302 application.SendNotification();
1303 application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1305 DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1310 int UtcDaliActorCalculateScreenExtents(void)
1312 TestApplication application;
1314 Actor actor = Actor::New();
1316 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1317 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1319 application.SendNotification();
1320 application.Render();
1322 auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f};
1323 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1324 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1325 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1326 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1327 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1329 application.GetScene().Remove(actor);
1333 // SetPosition(float x, float y)
1334 int UtcDaliActorSetPosition01(void)
1336 TestApplication application;
1338 Actor actor = Actor::New();
1340 // Set to random to start off with
1341 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1343 Vector3 vector(100.0f, 100.0f, 0.0f);
1345 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1347 actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1348 // flush the queue and render once
1349 application.SendNotification();
1350 application.Render();
1351 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1353 application.GetScene().Add(actor);
1354 actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1355 // flush the queue and render once
1356 application.SendNotification();
1357 application.Render();
1358 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1360 actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1361 actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1362 actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1363 // flush the queue and render once
1364 application.SendNotification();
1365 application.Render();
1366 DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1368 actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1369 // flush the queue and render once
1370 application.SendNotification();
1371 application.Render();
1372 DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1374 application.GetScene().Remove(actor);
1378 // SetPosition(float x, float y, float z)
1379 int UtcDaliActorSetPosition02(void)
1381 TestApplication application;
1383 Actor actor = Actor::New();
1385 // Set to random to start off with
1386 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1388 Vector3 vector(100.0f, 100.0f, 100.0f);
1390 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1392 actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1394 // flush the queue and render once
1395 application.SendNotification();
1396 application.Render();
1398 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1402 // SetPosition(Vector3 position)
1403 int UtcDaliActorSetPosition03(void)
1405 TestApplication application;
1407 Actor actor = Actor::New();
1409 // Set to random to start off with
1410 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1412 Vector3 vector(100.0f, 100.0f, 100.0f);
1414 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1416 actor.SetProperty(Actor::Property::POSITION, vector);
1418 // flush the queue and render once
1419 application.SendNotification();
1420 application.Render();
1422 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1426 int UtcDaliActorSetX(void)
1428 TestApplication application;
1430 Actor actor = Actor::New();
1432 Vector3 vector(100.0f, 0.0f, 0.0f);
1434 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1436 actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1438 // flush the queue and render once
1439 application.SendNotification();
1440 application.Render();
1442 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1446 int UtcDaliActorSetY(void)
1448 TestApplication application;
1450 Actor actor = Actor::New();
1452 Vector3 vector(0.0f, 100.0f, 0.0f);
1454 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1456 actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1458 // flush the queue and render once
1459 application.SendNotification();
1460 application.Render();
1462 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1466 int UtcDaliActorSetZ(void)
1468 TestApplication application;
1470 Actor actor = Actor::New();
1472 Vector3 vector(0.0f, 0.0f, 100.0f);
1474 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1476 actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1478 // flush the queue and render once
1479 application.SendNotification();
1480 application.Render();
1482 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1486 int UtcDaliActorSetPositionProperties(void)
1488 TestApplication application;
1490 Actor actor = Actor::New();
1492 Vector3 vector(0.7f, 0.8f, 0.9f);
1493 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1495 actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1496 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1497 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1499 // flush the queue and render once
1500 application.SendNotification();
1501 application.Render();
1503 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1504 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1505 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1506 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1507 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1509 actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1510 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1511 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1513 // flush the queue and render once
1514 application.SendNotification();
1515 application.Render();
1517 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1518 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1519 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1520 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1521 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1523 actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1524 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1525 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1527 // flush the queue and render once
1528 application.SendNotification();
1529 application.Render();
1531 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1532 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1533 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1534 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1535 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1540 int UtcDaliActorTranslateBy(void)
1542 TestApplication application;
1544 Actor actor = Actor::New();
1545 Vector3 vector(100.0f, 100.0f, 100.0f);
1547 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1549 actor.SetProperty(Actor::Property::POSITION, vector);
1551 // flush the queue and render once
1552 application.SendNotification();
1553 application.Render();
1555 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1557 actor.TranslateBy(vector);
1559 // flush the queue and render once
1560 application.SendNotification();
1561 application.Render();
1563 DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1567 int UtcDaliActorGetCurrentPosition(void)
1569 TestApplication application;
1571 Actor actor = Actor::New();
1572 Vector3 setVector(100.0f, 100.0f, 0.0f);
1573 actor.SetProperty(Actor::Property::POSITION, setVector);
1575 // flush the queue and render once
1576 application.SendNotification();
1577 application.Render();
1579 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1583 int UtcDaliActorGetCurrentWorldPosition(void)
1585 TestApplication application;
1587 Actor parent = Actor::New();
1588 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1589 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1590 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1591 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1592 application.GetScene().Add(parent);
1594 Actor child = Actor::New();
1595 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1596 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1597 Vector3 childPosition(6.0f, 6.0f, 6.0f);
1598 child.SetProperty(Actor::Property::POSITION, childPosition);
1601 // The actors should not have a world position yet
1602 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1603 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1605 application.SendNotification();
1606 application.Render(0);
1608 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1609 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1611 // The actors should have a world position now
1612 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1613 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1617 int UtcDaliActorSetInheritPosition(void)
1619 tet_infoline("Testing Actor::SetInheritPosition");
1620 TestApplication application;
1622 Actor parent = Actor::New();
1623 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1624 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1625 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1626 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1627 application.GetScene().Add(parent);
1629 Actor child = Actor::New();
1630 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1631 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1632 Vector3 childPosition(10.0f, 11.0f, 12.0f);
1633 child.SetProperty(Actor::Property::POSITION, childPosition);
1636 // The actors should not have a world position yet
1637 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1638 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1640 // first test default, which is to inherit position
1641 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1642 application.SendNotification();
1643 application.Render(0); // should only really call Update as Render is not required to update scene
1644 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1645 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1646 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1647 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1649 //Change child position
1650 Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1651 child.SetProperty(Actor::Property::POSITION, childOffset);
1653 // Use local position as world postion
1654 child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1655 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1656 application.SendNotification();
1657 application.Render(0); // should only really call Update as Render is not required to update scene
1658 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1659 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1660 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1661 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1663 //Change back to inherit position from parent
1664 child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1665 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1666 application.SendNotification();
1667 application.Render(0); // should only really call Update as Render is not required to update scene
1668 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1669 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1670 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1671 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1675 int UtcDaliActorInheritOpacity(void)
1677 tet_infoline("Testing Actor::Inherit Opacity");
1678 TestApplication application;
1680 Actor parent = Actor::New();
1681 Actor child = Actor::New();
1683 application.GetScene().Add(parent);
1685 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1686 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1688 // flush the queue and render once
1689 application.SendNotification();
1690 application.Render();
1692 parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1694 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1695 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1697 application.SendNotification();
1698 application.Render();
1700 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1701 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1702 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1703 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1704 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1705 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1710 // SetOrientation(float angleRadians, Vector3 axis)
1711 int UtcDaliActorSetOrientation01(void)
1713 TestApplication application;
1715 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1716 Actor actor = Actor::New();
1718 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1720 // flush the queue and render once
1721 application.SendNotification();
1722 application.Render();
1724 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1728 int UtcDaliActorSetOrientation02(void)
1730 TestApplication application;
1732 Actor actor = Actor::New();
1734 Radian angle(0.785f);
1735 Vector3 axis(1.0f, 1.0f, 0.0f);
1737 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1738 Quaternion rotation(angle, axis);
1739 // flush the queue and render once
1740 application.SendNotification();
1741 application.Render();
1742 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1744 application.GetScene().Add(actor);
1745 actor.RotateBy(Degree(360), axis);
1746 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1748 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
1749 Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
1750 // flush the queue and render once
1751 application.SendNotification();
1752 application.Render();
1753 DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1755 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1756 // flush the queue and render once
1757 application.SendNotification();
1758 application.Render();
1759 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1761 application.GetScene().Remove(actor);
1765 // SetOrientation(float angleRadians, Vector3 axis)
1766 int UtcDaliActorSetOrientationProperty(void)
1768 TestApplication application;
1770 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1771 Actor actor = Actor::New();
1773 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1774 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1776 // flush the queue and render once
1777 application.SendNotification();
1778 application.Render();
1780 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1781 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1782 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1786 // RotateBy(float angleRadians, Vector3 axis)
1787 int UtcDaliActorRotateBy01(void)
1789 TestApplication application;
1791 Actor actor = Actor::New();
1793 Radian angle(M_PI * 0.25f);
1794 actor.RotateBy((angle), Vector3::ZAXIS);
1795 // flush the queue and render once
1796 application.SendNotification();
1797 application.Render();
1798 DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1800 application.GetScene().Add(actor);
1802 actor.RotateBy(angle, Vector3::ZAXIS);
1803 // flush the queue and render once
1804 application.SendNotification();
1805 application.Render();
1806 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1808 application.GetScene().Remove(actor);
1812 // RotateBy(Quaternion relativeRotation)
1813 int UtcDaliActorRotateBy02(void)
1815 TestApplication application;
1817 Actor actor = Actor::New();
1819 Radian angle(M_PI * 0.25f);
1820 Quaternion rotation(angle, Vector3::ZAXIS);
1821 actor.RotateBy(rotation);
1822 // flush the queue and render once
1823 application.SendNotification();
1824 application.Render();
1825 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1827 actor.RotateBy(rotation);
1828 // flush the queue and render once
1829 application.SendNotification();
1830 application.Render();
1831 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1835 int UtcDaliActorGetCurrentOrientation(void)
1837 TestApplication application;
1838 Actor actor = Actor::New();
1840 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1841 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1842 // flush the queue and render once
1843 application.SendNotification();
1844 application.Render();
1845 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1849 int UtcDaliActorGetCurrentWorldOrientation(void)
1851 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1852 TestApplication application;
1854 Actor parent = Actor::New();
1855 Radian rotationAngle(Degree(90.0f));
1856 Quaternion rotation(rotationAngle, Vector3::YAXIS);
1857 parent.SetProperty(Actor::Property::ORIENTATION, rotation);
1858 application.GetScene().Add(parent);
1860 Actor child = Actor::New();
1861 child.SetProperty(Actor::Property::ORIENTATION, rotation);
1864 // The actors should not have a world rotation yet
1865 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1866 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1868 application.SendNotification();
1869 application.Render(0);
1871 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1872 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1874 // The actors should have a world rotation now
1875 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1876 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
1878 // turn off child rotation inheritance
1879 child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
1880 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
1881 application.SendNotification();
1882 application.Render(0);
1884 // The actors should have a world rotation now
1885 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1886 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
1890 // SetScale(float scale)
1891 int UtcDaliActorSetScale01(void)
1893 TestApplication application;
1895 Actor actor = Actor::New();
1897 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1898 actor.SetProperty(Actor::Property::SCALE, 0.25f);
1900 Vector3 scale(10.0f, 10.0f, 10.0f);
1901 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1903 actor.SetProperty(Actor::Property::SCALE, scale.x);
1905 // flush the queue and render once
1906 application.SendNotification();
1907 application.Render();
1909 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1913 // SetScale(float scaleX, float scaleY, float scaleZ)
1914 int UtcDaliActorSetScale02(void)
1916 TestApplication application;
1917 Vector3 scale(10.0f, 10.0f, 10.0f);
1919 Actor actor = Actor::New();
1921 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1922 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1924 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1926 actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
1927 // flush the queue and render once
1928 application.SendNotification();
1929 application.Render();
1930 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1932 // add to stage and test
1933 application.GetScene().Add(actor);
1934 actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
1935 // flush the queue and render once
1936 application.SendNotification();
1937 application.Render();
1938 DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
1940 application.GetScene().Remove(actor);
1945 // SetScale(Vector3 scale)
1946 int UtcDaliActorSetScale03(void)
1948 TestApplication application;
1949 Vector3 scale(10.0f, 10.0f, 10.0f);
1951 Actor actor = Actor::New();
1953 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1954 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1956 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1958 actor.SetProperty(Actor::Property::SCALE, scale);
1960 // flush the queue and render once
1961 application.SendNotification();
1962 application.Render();
1964 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1968 int UtcDaliActorSetScaleIndividual(void)
1970 TestApplication application;
1972 Actor actor = Actor::New();
1974 Vector3 vector(0.7f, 0.8f, 0.9f);
1975 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
1977 actor.SetProperty(Actor::Property::SCALE_X, vector.x);
1978 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1980 // flush the queue and render once
1981 application.SendNotification();
1982 application.Render();
1984 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
1985 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1986 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1988 actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
1989 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
1991 // flush the queue and render once
1992 application.SendNotification();
1993 application.Render();
1995 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
1996 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
1997 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
1999 actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2000 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2002 // flush the queue and render once
2003 application.SendNotification();
2004 application.Render();
2006 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2007 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2008 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2010 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2011 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2016 int UtcDaliActorScaleBy(void)
2018 TestApplication application;
2019 Actor actor = Actor::New();
2020 Vector3 vector(100.0f, 100.0f, 100.0f);
2022 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2024 actor.SetProperty(Actor::Property::SCALE, vector);
2026 // flush the queue and render once
2027 application.SendNotification();
2028 application.Render();
2030 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2032 actor.ScaleBy(vector);
2034 // flush the queue and render once
2035 application.SendNotification();
2036 application.Render();
2038 DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2042 int UtcDaliActorGetCurrentScale(void)
2044 TestApplication application;
2045 Vector3 scale(12.0f, 1.0f, 2.0f);
2047 Actor actor = Actor::New();
2049 actor.SetProperty(Actor::Property::SCALE, scale);
2051 // flush the queue and render once
2052 application.SendNotification();
2053 application.Render();
2055 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2059 int UtcDaliActorGetCurrentWorldScale(void)
2061 TestApplication application;
2063 Actor parent = Actor::New();
2064 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2065 parent.SetProperty(Actor::Property::SCALE, parentScale);
2066 application.GetScene().Add(parent);
2068 Actor child = Actor::New();
2069 Vector3 childScale(2.0f, 2.0f, 2.0f);
2070 child.SetProperty(Actor::Property::SCALE, childScale);
2073 // The actors should not have a scale yet
2074 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2075 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2077 // The actors should not have a world scale yet
2078 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2079 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2081 application.SendNotification();
2082 application.Render(0);
2084 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2085 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2087 // The actors should have a world scale now
2088 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2089 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2093 int UtcDaliActorInheritScale(void)
2095 tet_infoline("Testing Actor::SetInheritScale");
2096 TestApplication application;
2098 Actor parent = Actor::New();
2099 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2100 parent.SetProperty(Actor::Property::SCALE, parentScale);
2101 application.GetScene().Add(parent);
2103 Actor child = Actor::New();
2104 Vector3 childScale(2.0f, 2.0f, 2.0f);
2105 child.SetProperty(Actor::Property::SCALE, childScale);
2108 application.SendNotification();
2109 application.Render(0);
2111 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2112 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2114 child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2115 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2117 application.SendNotification();
2118 application.Render(0);
2120 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2124 int UtcDaliActorSetVisible(void)
2126 TestApplication application;
2128 Actor actor = Actor::New();
2129 actor.SetProperty(Actor::Property::VISIBLE, false);
2130 // flush the queue and render once
2131 application.SendNotification();
2132 application.Render();
2133 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2135 actor.SetProperty(Actor::Property::VISIBLE, true);
2136 // flush the queue and render once
2137 application.SendNotification();
2138 application.Render();
2139 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2141 // put actor on stage
2142 application.GetScene().Add(actor);
2143 actor.SetProperty(Actor::Property::VISIBLE, false);
2144 // flush the queue and render once
2145 application.SendNotification();
2146 application.Render();
2147 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2151 int UtcDaliActorIsVisible(void)
2153 TestApplication application;
2155 Actor actor = Actor::New();
2157 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2161 int UtcDaliActorSetOpacity(void)
2163 TestApplication application;
2165 Actor actor = Actor::New();
2166 // initial opacity is 1
2167 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2169 actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2170 // flush the queue and render once
2171 application.SendNotification();
2172 application.Render();
2173 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2175 // change opacity, actor is on stage to change is not immediate
2176 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2177 // flush the queue and render once
2178 application.SendNotification();
2179 application.Render();
2180 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2182 // put actor on stage
2183 application.GetScene().Add(actor);
2185 // change opacity, actor is on stage to change is not immediate
2186 actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2187 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2188 // flush the queue and render once
2189 application.SendNotification();
2190 application.Render();
2191 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2193 // change opacity, actor is on stage to change is not immediate
2194 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2195 // flush the queue and render once
2196 application.SendNotification();
2197 application.Render();
2198 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2202 int UtcDaliActorGetCurrentOpacity(void)
2204 TestApplication application;
2206 Actor actor = Actor::New();
2207 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2209 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2210 // flush the queue and render once
2211 application.SendNotification();
2212 application.Render();
2213 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2217 int UtcDaliActorSetSensitive(void)
2219 TestApplication application;
2220 Actor actor = Actor::New();
2222 bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2224 actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2226 DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2230 int UtcDaliActorIsSensitive(void)
2232 TestApplication application;
2233 Actor actor = Actor::New();
2234 actor.SetProperty(Actor::Property::SENSITIVE, false);
2236 DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2240 int UtcDaliActorSetColor(void)
2242 TestApplication application;
2243 Actor actor = Actor::New();
2244 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2246 DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2248 actor.SetProperty(Actor::Property::COLOR, color);
2249 // flush the queue and render once
2250 application.SendNotification();
2251 application.Render();
2252 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2254 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2255 // flush the queue and render once
2256 application.SendNotification();
2257 application.Render();
2258 DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2260 application.GetScene().Add(actor);
2261 actor.SetProperty(Actor::Property::COLOR, color);
2262 // flush the queue and render once
2263 application.SendNotification();
2264 application.Render();
2265 DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2267 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2268 // flush the queue and render once
2269 application.SendNotification();
2270 application.Render();
2271 // Actor color is not clamped
2272 DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2273 // world color is clamped
2274 DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2276 actor.SetProperty(Actor::Property::COLOR, color);
2277 DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2279 Vector3 newColor(1.0f, 0.0f, 0.0f);
2280 actor.SetProperty(Actor::Property::COLOR, newColor);
2281 DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2283 application.GetScene().Remove(actor);
2287 int UtcDaliActorSetColorIndividual(void)
2289 TestApplication application;
2291 Actor actor = Actor::New();
2293 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2294 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2296 actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2297 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2299 // flush the queue and render once
2300 application.SendNotification();
2301 application.Render();
2303 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2304 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2305 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2307 actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2308 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2310 // flush the queue and render once
2311 application.SendNotification();
2312 application.Render();
2314 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2315 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2316 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2318 actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2319 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2321 // flush the queue and render once
2322 application.SendNotification();
2323 application.Render();
2325 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2326 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2327 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2329 actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2330 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2332 // flush the queue and render once
2333 application.SendNotification();
2334 application.Render();
2336 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2337 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2338 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2340 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2341 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2343 actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2345 // flush the queue and render once
2346 application.SendNotification();
2347 application.Render();
2349 DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2354 int UtcDaliActorGetCurrentColor(void)
2356 TestApplication application;
2357 Actor actor = Actor::New();
2358 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2360 actor.SetProperty(Actor::Property::COLOR, color);
2361 // flush the queue and render once
2362 application.SendNotification();
2363 application.Render();
2364 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2368 int UtcDaliActorGetCurrentWorldColor(void)
2370 tet_infoline("Actor::GetCurrentWorldColor");
2371 TestApplication application;
2373 Actor parent = Actor::New();
2374 Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2375 parent.SetProperty(Actor::Property::COLOR, parentColor);
2376 application.GetScene().Add(parent);
2378 Actor child = Actor::New();
2379 Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2380 child.SetProperty(Actor::Property::COLOR, childColor);
2383 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2384 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2386 // verify the default color mode
2387 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2389 // The actors should not have a world color yet
2390 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2391 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2393 application.SendNotification();
2394 application.Render(0);
2396 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2397 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2399 // The actors should have a world color now
2400 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2401 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2404 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2405 application.SendNotification();
2406 application.Render(0);
2407 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2410 child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2411 application.SendNotification();
2412 application.Render(0);
2413 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2414 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2417 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2418 application.SendNotification();
2419 application.Render(0);
2420 Vector4 expectedColor(childColor);
2421 expectedColor.a *= parentColor.a;
2422 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2423 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2427 int UtcDaliActorSetColorMode(void)
2429 tet_infoline("Actor::SetColorMode");
2430 TestApplication application;
2431 Actor actor = Actor::New();
2432 Actor child = Actor::New();
2435 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2436 DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2438 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2439 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2441 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2442 DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2444 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2445 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2449 int UtcDaliActorScreenToLocal(void)
2451 TestApplication application;
2452 Actor actor = Actor::New();
2453 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2454 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2455 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2456 application.GetScene().Add(actor);
2458 // flush the queue and render once
2459 application.SendNotification();
2460 application.Render();
2465 application.SendNotification();
2466 application.Render();
2468 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2470 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2471 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2475 int UtcDaliActorSetLeaveRequired(void)
2477 TestApplication application;
2479 Actor actor = Actor::New();
2481 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2482 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2484 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2485 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2489 int UtcDaliActorGetLeaveRequired(void)
2491 TestApplication application;
2493 Actor actor = Actor::New();
2495 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2499 int UtcDaliActorSetKeyboardFocusable(void)
2501 TestApplication application;
2503 Actor actor = Actor::New();
2505 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2506 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2508 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2509 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2513 int UtcDaliActorIsKeyboardFocusable(void)
2515 TestApplication application;
2517 Actor actor = Actor::New();
2519 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2523 int UtcDaliActorRemoveConstraints(void)
2525 tet_infoline(" UtcDaliActorRemoveConstraints");
2526 TestApplication application;
2528 gTestConstraintCalled = false;
2530 Actor actor = Actor::New();
2532 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2534 actor.RemoveConstraints();
2536 DALI_TEST_CHECK(gTestConstraintCalled == false);
2538 application.GetScene().Add(actor);
2541 // flush the queue and render once
2542 application.SendNotification();
2543 application.Render();
2545 actor.RemoveConstraints();
2547 DALI_TEST_CHECK(gTestConstraintCalled == true);
2551 int UtcDaliActorRemoveConstraintTag(void)
2553 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2554 TestApplication application;
2556 Actor actor = Actor::New();
2558 // 1. Apply Constraint1 and Constraint2, and test...
2559 unsigned int result1 = 0u;
2560 unsigned int result2 = 0u;
2562 unsigned constraint1Tag = 1u;
2563 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2564 constraint1.SetTag(constraint1Tag);
2565 constraint1.Apply();
2567 unsigned constraint2Tag = 2u;
2568 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2569 constraint2.SetTag(constraint2Tag);
2570 constraint2.Apply();
2572 application.GetScene().Add(actor);
2573 // flush the queue and render once
2574 application.SendNotification();
2575 application.Render();
2577 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2578 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2580 // 2. Remove Constraint1 and test...
2583 actor.RemoveConstraints(constraint1Tag);
2584 // make color property dirty, which will trigger constraints to be reapplied.
2585 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2586 // flush the queue and render once
2587 application.SendNotification();
2588 application.Render();
2590 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2591 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2593 // 3. Re-Apply Constraint1 and test...
2596 constraint1.Apply();
2597 // make color property dirty, which will trigger constraints to be reapplied.
2598 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2599 // flush the queue and render once
2600 application.SendNotification();
2601 application.Render();
2603 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2604 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2606 // 2. Remove Constraint2 and test...
2609 actor.RemoveConstraints(constraint2Tag);
2610 // make color property dirty, which will trigger constraints to be reapplied.
2611 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2612 // flush the queue and render once
2613 application.SendNotification();
2614 application.Render();
2616 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2617 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2619 // 2. Remove Constraint1 as well and test...
2622 actor.RemoveConstraints(constraint1Tag);
2623 // make color property dirty, which will trigger constraints to be reapplied.
2624 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2625 // flush the queue and render once
2626 application.SendNotification();
2627 application.Render();
2629 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2630 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2634 int UtcDaliActorTouchedSignal(void)
2636 TestApplication application;
2638 ResetTouchCallbacks();
2640 // get the root layer
2641 Actor actor = application.GetScene().GetRootLayer();
2642 DALI_TEST_CHECK(gTouchCallBackCalled == false);
2644 application.SendNotification();
2645 application.Render();
2647 // connect to its touch signal
2648 actor.TouchedSignal().Connect(TestTouchCallback);
2650 // simulate a touch event in the middle of the screen
2651 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2652 Dali::Integration::Point point;
2653 point.SetDeviceId(1);
2654 point.SetState(PointState::DOWN);
2655 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2656 Dali::Integration::TouchEvent touchEvent;
2657 touchEvent.AddPoint(point);
2658 application.ProcessEvent(touchEvent);
2660 DALI_TEST_CHECK(gTouchCallBackCalled == true);
2664 int UtcDaliActorHoveredSignal(void)
2666 TestApplication application;
2668 gHoverCallBackCalled = false;
2670 // get the root layer
2671 Actor actor = application.GetScene().GetRootLayer();
2672 DALI_TEST_CHECK(gHoverCallBackCalled == false);
2674 application.SendNotification();
2675 application.Render();
2677 // connect to its hover signal
2678 actor.HoveredSignal().Connect(TestCallback3);
2680 // simulate a hover event in the middle of the screen
2681 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2682 Dali::Integration::Point point;
2683 point.SetDeviceId(1);
2684 point.SetState(PointState::MOTION);
2685 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2686 Dali::Integration::HoverEvent hoverEvent;
2687 hoverEvent.AddPoint(point);
2688 application.ProcessEvent(hoverEvent);
2690 DALI_TEST_CHECK(gHoverCallBackCalled == true);
2694 int UtcDaliActorOnOffSceneSignal(void)
2696 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2698 TestApplication application;
2701 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2702 gActorNamesOnOffScene.clear();
2704 Actor parent = Actor::New();
2705 parent.SetProperty(Actor::Property::NAME, "parent");
2706 parent.OnSceneSignal().Connect(OnSceneCallback);
2707 parent.OffSceneSignal().Connect(OffSceneCallback);
2709 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2710 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2712 // add parent to the scene
2713 application.GetScene().Add(parent);
2714 // onstage emitted, offstage not
2715 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2716 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2717 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2719 // test adding a child, should get onstage emitted
2721 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2722 gActorNamesOnOffScene.clear();
2724 Actor child = Actor::New();
2725 child.SetProperty(Actor::Property::NAME, "child");
2726 child.OnSceneSignal().Connect(OnSceneCallback);
2727 child.OffSceneSignal().Connect(OffSceneCallback);
2728 parent.Add(child); // add child
2729 // onscene emitted, offscene not
2730 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2731 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2732 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2734 // test removing parent from the scene
2736 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2737 gActorNamesOnOffScene.clear();
2739 application.GetScene().Remove(parent);
2740 // onscene not emitted, offscene is
2741 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2742 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2743 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2744 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2746 // test adding parent back to the scene
2748 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2749 gActorNamesOnOffScene.clear();
2751 application.GetScene().Add(parent);
2752 // onscene emitted, offscene not
2753 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2754 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2755 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2756 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2758 // test removing child
2760 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2761 gActorNamesOnOffScene.clear();
2763 parent.Remove(child);
2764 // onscene not emitted, offscene is
2765 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2766 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2767 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2769 // test removing parent
2771 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2772 gActorNamesOnOffScene.clear();
2774 application.GetScene().Remove(parent);
2775 // onscene not emitted, offscene is
2776 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2777 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2778 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2782 int UtcDaliActorFindChildByName(void)
2784 tet_infoline("Testing Dali::Actor::FindChildByName()");
2785 TestApplication application;
2787 Actor parent = Actor::New();
2788 parent.SetProperty(Actor::Property::NAME, "parent");
2789 Actor first = Actor::New();
2790 first.SetProperty(Actor::Property::NAME, "first");
2791 Actor second = Actor::New();
2792 second.SetProperty(Actor::Property::NAME, "second");
2797 Actor found = parent.FindChildByName("foo");
2798 DALI_TEST_CHECK(!found);
2800 found = parent.FindChildByName("parent");
2801 DALI_TEST_CHECK(found == parent);
2803 found = parent.FindChildByName("first");
2804 DALI_TEST_CHECK(found == first);
2806 found = parent.FindChildByName("second");
2807 DALI_TEST_CHECK(found == second);
2811 int UtcDaliActorFindChildById(void)
2813 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2814 TestApplication application;
2816 Actor parent = Actor::New();
2817 Actor first = Actor::New();
2818 Actor second = Actor::New();
2823 Actor found = parent.FindChildById(100000);
2824 DALI_TEST_CHECK(!found);
2826 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2827 DALI_TEST_CHECK(found == parent);
2829 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2830 DALI_TEST_CHECK(found == first);
2832 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2833 DALI_TEST_CHECK(found == second);
2837 int UtcDaliActorHitTest(void)
2842 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2844 mTouchPoint(touchPoint),
2850 Vector2 mTouchPoint;
2854 TestApplication application;
2855 tet_infoline(" UtcDaliActorHitTest");
2857 // Fill a vector with different hit tests.
2858 struct HitTestData* hitTestData[] = {
2859 // scale touch point result
2860 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
2861 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2862 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.
2863 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2864 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.
2868 // get the root layer
2869 Actor actor = Actor::New();
2870 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2871 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2873 application.GetScene().Add(actor);
2875 ResetTouchCallbacks();
2877 unsigned int index = 0;
2878 while(NULL != hitTestData[index])
2880 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2881 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2883 // flush the queue and render once
2884 application.SendNotification();
2885 application.Render();
2887 DALI_TEST_CHECK(!gTouchCallBackCalled);
2889 // connect to its touch signal
2890 actor.TouchedSignal().Connect(TestTouchCallback);
2892 Dali::Integration::Point point;
2893 point.SetState(PointState::DOWN);
2894 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2895 Dali::Integration::TouchEvent event;
2896 event.AddPoint(point);
2898 // flush the queue and render once
2899 application.SendNotification();
2900 application.Render();
2901 application.ProcessEvent(event);
2903 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
2905 if(gTouchCallBackCalled != hitTestData[index]->mResult)
2906 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2907 hitTestData[index]->mScale.x,
2908 hitTestData[index]->mScale.y,
2909 hitTestData[index]->mScale.z,
2910 hitTestData[index]->mTouchPoint.x,
2911 hitTestData[index]->mTouchPoint.y,
2912 hitTestData[index]->mResult);
2914 ResetTouchCallbacks();
2920 int UtcDaliActorSetDrawMode(void)
2922 TestApplication application;
2923 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2925 Actor a = Actor::New();
2927 application.GetScene().Add(a);
2928 application.SendNotification();
2929 application.Render(0);
2930 application.SendNotification();
2931 application.Render(1);
2933 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
2935 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2936 application.SendNotification();
2937 application.Render(1);
2939 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
2941 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
2942 application.SendNotification();
2943 application.Render(1);
2945 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
2949 int UtcDaliActorSetDrawModeOverlayRender(void)
2951 TestApplication application;
2952 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2954 application.SendNotification();
2955 application.Render(1);
2957 std::vector<GLuint> ids;
2958 ids.push_back(8); // first rendered actor
2959 ids.push_back(9); // second rendered actor
2960 ids.push_back(10); // third rendered actor
2961 application.GetGlAbstraction().SetNextTextureIds(ids);
2963 Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2964 Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2965 Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2966 Actor a = CreateRenderableActor(imageA);
2967 Actor b = CreateRenderableActor(imageB);
2968 Actor c = CreateRenderableActor(imageC);
2970 application.SendNotification();
2971 application.Render(1);
2973 //Textures are bound when first created. Clear bound textures vector
2974 application.GetGlAbstraction().ClearBoundTextures();
2976 // Render a,b,c as regular non-overlays. so order will be:
2980 application.GetScene().Add(a);
2981 application.GetScene().Add(b);
2982 application.GetScene().Add(c);
2984 application.SendNotification();
2985 application.Render(1);
2987 // Should be 3 textures changes.
2988 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
2989 typedef std::vector<GLuint>::size_type TextureSize;
2990 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
2991 if(boundTextures.size() == 3)
2993 DALI_TEST_CHECK(boundTextures[0] == 8u);
2994 DALI_TEST_CHECK(boundTextures[1] == 9u);
2995 DALI_TEST_CHECK(boundTextures[2] == 10u);
2998 // Now texture ids have been set, we can monitor their render order.
2999 // render a as an overlay (last), so order will be:
3003 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3004 application.GetGlAbstraction().ClearBoundTextures();
3006 application.SendNotification();
3007 application.Render(1);
3009 // Should be 3 texture changes.
3010 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3011 if(boundTextures.size() == 3)
3013 DALI_TEST_CHECK(boundTextures[0] == 9u);
3014 DALI_TEST_CHECK(boundTextures[1] == 10u);
3015 DALI_TEST_CHECK(boundTextures[2] == 8u);
3020 int UtcDaliActorGetCurrentWorldMatrix(void)
3022 TestApplication application;
3023 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3025 Actor parent = Actor::New();
3026 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3027 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3028 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3029 Radian rotationAngle(Degree(85.0f));
3030 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3031 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3032 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3033 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3034 parent.SetProperty(Actor::Property::SCALE, parentScale);
3035 application.GetScene().Add(parent);
3037 Actor child = Actor::New();
3038 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3039 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3040 Radian childRotationAngle(Degree(23.0f));
3041 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3042 Vector3 childScale(2.0f, 2.0f, 2.0f);
3043 child.SetProperty(Actor::Property::POSITION, childPosition);
3044 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3045 child.SetProperty(Actor::Property::SCALE, childScale);
3048 application.SendNotification();
3049 application.Render(0);
3050 application.Render();
3051 application.SendNotification();
3053 Matrix parentMatrix(false);
3054 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3056 Matrix childMatrix(false);
3057 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3059 //Child matrix should be the composition of child and parent
3060 Matrix childWorldMatrix(false);
3061 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3063 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3064 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3068 int UtcDaliActorConstrainedToWorldMatrix(void)
3070 TestApplication application;
3071 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3073 Actor parent = Actor::New();
3074 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3075 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3076 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3077 Radian rotationAngle(Degree(85.0f));
3078 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3079 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3080 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3081 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3082 parent.SetProperty(Actor::Property::SCALE, parentScale);
3083 application.GetScene().Add(parent);
3085 Actor child = Actor::New();
3086 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3087 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3088 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3089 posConstraint.Apply();
3091 application.GetScene().Add(child);
3093 application.SendNotification();
3094 application.Render(0);
3095 application.Render();
3096 application.SendNotification();
3098 Matrix parentMatrix(false);
3099 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3101 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3102 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3106 int UtcDaliActorConstrainedToOrientation(void)
3108 TestApplication application;
3109 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3111 Actor parent = Actor::New();
3112 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3113 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3114 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3115 Radian rotationAngle(Degree(85.0f));
3116 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3117 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3118 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3119 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3120 parent.SetProperty(Actor::Property::SCALE, parentScale);
3121 application.GetScene().Add(parent);
3123 Actor child = Actor::New();
3124 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3125 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3126 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3127 posConstraint.Apply();
3129 application.GetScene().Add(child);
3131 application.SendNotification();
3132 application.Render(0);
3133 application.Render();
3134 application.SendNotification();
3136 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3140 int UtcDaliActorConstrainedToOpacity(void)
3142 TestApplication application;
3143 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3145 Actor parent = Actor::New();
3146 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3147 application.GetScene().Add(parent);
3149 Actor child = Actor::New();
3150 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3151 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3152 opacityConstraint.Apply();
3154 application.GetScene().Add(child);
3156 application.SendNotification();
3157 application.Render(0);
3158 application.Render();
3159 application.SendNotification();
3161 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3163 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3165 application.SendNotification();
3166 application.Render(0);
3167 application.Render();
3168 application.SendNotification();
3170 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3175 int UtcDaliActorUnparent(void)
3177 TestApplication application;
3178 tet_infoline(" UtcDaliActorUnparent");
3180 Actor parent = Actor::New();
3181 application.GetScene().Add(parent);
3183 Actor child = Actor::New();
3185 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3186 DALI_TEST_CHECK(!child.GetParent());
3188 // Test that calling Unparent with no parent is a NOOP
3191 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3192 DALI_TEST_CHECK(!child.GetParent());
3194 // Test that Unparent works
3197 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3198 DALI_TEST_CHECK(parent == child.GetParent());
3202 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3203 DALI_TEST_CHECK(!child.GetParent());
3205 // Test that UnparentAndReset works
3208 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3209 DALI_TEST_CHECK(parent == child.GetParent());
3211 UnparentAndReset(child);
3213 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3214 DALI_TEST_CHECK(!child);
3216 // Test that UnparentAndReset is a NOOP with empty handle
3217 UnparentAndReset(child);
3219 DALI_TEST_CHECK(!child);
3223 int UtcDaliActorGetChildAt(void)
3225 TestApplication application;
3226 tet_infoline(" UtcDaliActorGetChildAt");
3228 Actor parent = Actor::New();
3229 application.GetScene().Add(parent);
3231 Actor child0 = Actor::New();
3234 Actor child1 = Actor::New();
3237 Actor child2 = Actor::New();
3240 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3241 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3242 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3246 int UtcDaliActorSetGetOverlay(void)
3248 TestApplication application;
3249 tet_infoline(" UtcDaliActorSetGetOverlay");
3251 Actor parent = Actor::New();
3252 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3253 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3257 int UtcDaliActorCreateDestroy(void)
3259 Actor* actor = new Actor;
3260 DALI_TEST_CHECK(actor);
3267 struct PropertyStringIndex
3269 const char* const name;
3270 const Property::Index index;
3271 const Property::Type type;
3274 const PropertyStringIndex PROPERTY_TABLE[] =
3276 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3277 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3278 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3279 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3280 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3281 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3282 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3283 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3284 {"size", Actor::Property::SIZE, Property::VECTOR3},
3285 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3286 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3287 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3288 {"position", Actor::Property::POSITION, Property::VECTOR3},
3289 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3290 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3291 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3292 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3293 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3294 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3295 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3296 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3297 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3298 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3299 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3300 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3301 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3302 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3303 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3304 {"color", Actor::Property::COLOR, Property::VECTOR4},
3305 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3306 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3307 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3308 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3309 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3310 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3311 {"name", Actor::Property::NAME, Property::STRING},
3312 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3313 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3314 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3315 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3316 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3317 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3318 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3319 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3320 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3321 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3322 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3323 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3324 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3325 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3326 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3327 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3328 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3329 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3331 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3332 } // unnamed namespace
3334 int UtcDaliActorProperties(void)
3336 TestApplication application;
3338 Actor actor = Actor::New();
3340 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3342 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3343 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3344 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3345 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3350 int UtcDaliRelayoutProperties_ResizePolicies(void)
3352 TestApplication application;
3354 Actor actor = Actor::New();
3357 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3358 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3360 // Set resize policy for all dimensions
3361 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3362 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3364 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3367 // Set individual dimensions
3368 const char* const widthPolicy = "FILL_TO_PARENT";
3369 const char* const heightPolicy = "FIXED";
3371 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3372 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3374 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3375 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3377 // Set individual dimensions using enums
3378 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3379 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3381 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3382 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3384 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3385 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3390 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3392 TestApplication application;
3394 Actor actor = Actor::New();
3397 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3399 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3400 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3401 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3404 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3405 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3407 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3408 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3410 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3411 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3416 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3418 TestApplication application;
3420 Actor actor = Actor::New();
3423 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3424 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3426 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3427 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3428 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3431 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3433 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3434 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3439 int UtcDaliRelayoutProperties_DimensionDependency(void)
3441 TestApplication application;
3443 Actor actor = Actor::New();
3446 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3447 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3450 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3451 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3453 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3454 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3456 // Test setting another resize policy
3457 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3458 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3463 int UtcDaliRelayoutProperties_Padding(void)
3465 TestApplication application;
3467 Actor actor = Actor::New();
3470 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3473 actor.SetProperty(Actor::Property::PADDING, padding);
3474 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3476 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3481 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3483 TestApplication application;
3485 Actor actor = Actor::New();
3488 Vector2 minSize(1.0f, 2.0f);
3490 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3491 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3493 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3495 Vector2 maxSize(3.0f, 4.0f);
3497 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3498 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3500 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3505 int UtcDaliActorGetHeightForWidth(void)
3507 TestApplication application;
3509 Actor actor = Actor::New();
3511 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3516 int UtcDaliActorGetWidthForHeight(void)
3518 TestApplication application;
3520 Actor actor = Actor::New();
3522 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3527 int UtcDaliActorGetRelayoutSize(void)
3529 TestApplication application;
3531 Actor actor = Actor::New();
3533 // Add actor to stage
3534 application.GetScene().Add(actor);
3536 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3538 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3539 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3541 // Flush the queue and render once
3542 application.SendNotification();
3543 application.Render();
3545 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3550 int UtcDaliActorSetPadding(void)
3552 TestApplication application;
3554 Actor actor = Actor::New();
3557 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3559 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3560 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3561 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3562 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3564 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3565 actor.SetProperty(Actor::Property::PADDING, padding2);
3567 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3569 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3570 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3571 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3572 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3577 int UtcDaliActorSetMinimumSize(void)
3579 TestApplication application;
3581 Actor actor = Actor::New();
3583 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3585 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3586 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3588 Vector2 size2(1.0f, 2.0f);
3589 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3591 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3593 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3594 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3599 int UtcDaliActorSetMaximumSize(void)
3601 TestApplication application;
3603 Actor actor = Actor::New();
3605 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3607 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3608 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3610 Vector2 size2(1.0f, 2.0f);
3611 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3613 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3615 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3616 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3621 int UtcDaliActorOnRelayoutSignal(void)
3623 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3625 TestApplication application;
3628 gOnRelayoutCallBackCalled = false;
3629 gActorNamesRelayout.clear();
3631 Actor actor = Actor::New();
3632 actor.SetProperty(Actor::Property::NAME, "actor");
3633 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3636 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3638 // Add actor to stage
3639 application.GetScene().Add(actor);
3641 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3642 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3644 // Flush the queue and render once
3645 application.SendNotification();
3646 application.Render();
3648 // OnRelayout emitted
3649 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3650 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3655 int UtcDaliActorGetHierachyDepth(void)
3657 TestApplication application;
3658 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3660 /* Build tree of actors:
3670 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3672 Integration::Scene stage(application.GetScene());
3674 Actor actorA = Actor::New();
3675 Actor actorB = Actor::New();
3676 Actor actorC = Actor::New();
3677 Actor actorD = Actor::New();
3678 Actor actorE = Actor::New();
3679 Actor actorF = Actor::New();
3681 //Test that root actor has depth equal 0
3682 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3684 //Test actors return depth -1 when not connected to the tree
3685 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3686 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3687 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3688 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3689 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3690 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3692 //Create the hierarchy
3700 //Test actors return correct depth
3701 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3702 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3703 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3704 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3705 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3706 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3708 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3709 actorA.Remove(actorB);
3711 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3712 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3713 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3715 //Removing actorA from the stage. All actors should have depth equal -1
3716 stage.Remove(actorA);
3718 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3719 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3720 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3721 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3722 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3723 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3728 int UtcDaliActorAnchorPointPropertyAsString(void)
3730 TestApplication application;
3732 Actor actor = Actor::New();
3734 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3735 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3737 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3738 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3740 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3741 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3743 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3744 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3746 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3747 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3749 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3750 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3752 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3753 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3755 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3756 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3758 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3759 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3761 // Invalid should not change anything
3762 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3763 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3768 int UtcDaliActorParentOriginPropertyAsString(void)
3770 TestApplication application;
3772 Actor actor = Actor::New();
3774 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3775 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3777 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3778 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3780 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3781 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3783 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3784 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3786 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3787 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3789 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3790 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3792 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3793 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3795 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3796 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3798 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3799 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3801 // Invalid should not change anything
3802 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3803 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3808 int UtcDaliActorColorModePropertyAsString(void)
3810 TestApplication application;
3812 Actor actor = Actor::New();
3814 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3815 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3817 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3818 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3820 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3821 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3823 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3824 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3826 // Invalid should not change anything
3827 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3828 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3833 int UtcDaliActorDrawModePropertyAsString(void)
3835 TestApplication application;
3837 Actor actor = Actor::New();
3839 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3840 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3842 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3843 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3845 // Invalid should not change anything
3846 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3847 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3852 int UtcDaliActorColorModePropertyAsEnum(void)
3854 TestApplication application;
3856 Actor actor = Actor::New();
3858 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3859 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3861 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3862 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3864 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3865 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3867 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3868 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3873 int UtcDaliActorDrawModePropertyAsEnum(void)
3875 TestApplication application;
3877 Actor actor = Actor::New();
3879 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3880 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3882 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3883 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3888 int UtcDaliActorAddRendererP(void)
3890 tet_infoline("Testing Actor::AddRenderer");
3891 TestApplication application;
3893 Actor actor = Actor::New();
3895 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3897 Geometry geometry = CreateQuadGeometry();
3898 Shader shader = CreateShader();
3899 Renderer renderer = Renderer::New(geometry, shader);
3901 actor.AddRenderer(renderer);
3902 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3903 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
3908 int UtcDaliActorAddRendererN01(void)
3910 tet_infoline("Testing Actor::AddRenderer");
3911 TestApplication application;
3913 Actor actor = Actor::New();
3919 actor.AddRenderer(renderer);
3920 tet_printf("Assertion test failed - no Exception\n");
3921 tet_result(TET_FAIL);
3923 catch(Dali::DaliException& e)
3925 DALI_TEST_PRINT_ASSERT(e);
3926 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3927 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3931 tet_printf("Assertion test failed - wrong Exception\n");
3932 tet_result(TET_FAIL);
3938 int UtcDaliActorAddRendererN02(void)
3940 tet_infoline("UtcDaliActorAddRendererN02");
3946 TestApplication application;
3948 Geometry geometry = CreateQuadGeometry();
3949 Shader shader = CreateShader();
3950 renderer = Renderer::New(geometry, shader);
3952 actor = Actor::New();
3955 // try illegal AddRenderer
3958 actor.AddRenderer(renderer);
3959 tet_printf("Assertion test failed - no Exception\n");
3960 tet_result(TET_FAIL);
3962 catch(Dali::DaliException& e)
3964 DALI_TEST_PRINT_ASSERT(e);
3965 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
3969 tet_printf("Assertion test failed - wrong Exception\n");
3970 tet_result(TET_FAIL);
3976 int UtcDaliActorAddRendererOnScene(void)
3978 tet_infoline("Testing Actor::AddRenderer");
3979 TestApplication application;
3981 Actor actor = Actor::New();
3982 application.GetScene().Add(actor);
3984 application.SendNotification();
3985 application.Render(0);
3987 Geometry geometry = CreateQuadGeometry();
3988 Shader shader = CreateShader();
3989 Renderer renderer = Renderer::New(geometry, shader);
3991 application.SendNotification();
3992 application.Render(0);
3996 actor.AddRenderer(renderer);
3997 tet_result(TET_PASS);
4001 tet_result(TET_FAIL);
4007 int UtcDaliActorRemoveRendererP1(void)
4009 tet_infoline("Testing Actor::RemoveRenderer");
4010 TestApplication application;
4012 Actor actor = Actor::New();
4014 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4017 Geometry geometry = CreateQuadGeometry();
4018 Shader shader = CreateShader();
4019 Renderer renderer = Renderer::New(geometry, shader);
4021 actor.AddRenderer(renderer);
4022 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4023 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4025 application.SendNotification();
4026 application.Render();
4030 Renderer renderer = actor.GetRendererAt(0);
4031 actor.RemoveRenderer(renderer);
4032 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4034 application.SendNotification();
4035 application.Render();
4038 // Call one final time to ensure that the renderer is actually removed after
4039 // the handle goes out of scope, and excercises the deletion code path in
4040 // scene graph and render.
4041 application.SendNotification();
4042 application.Render();
4047 int UtcDaliActorRemoveRendererP2(void)
4049 tet_infoline("Testing Actor::RemoveRenderer");
4050 TestApplication application;
4052 Actor actor = Actor::New();
4054 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4056 Geometry geometry = CreateQuadGeometry();
4057 Shader shader = CreateShader();
4058 Renderer renderer = Renderer::New(geometry, shader);
4060 actor.AddRenderer(renderer);
4061 application.SendNotification();
4062 application.Render();
4064 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4065 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4067 actor.RemoveRenderer(0);
4068 application.SendNotification();
4069 application.Render();
4071 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4073 // Shut down whilst holding onto the renderer handle.
4077 int UtcDaliActorRemoveRendererN(void)
4079 tet_infoline("Testing Actor::RemoveRenderer");
4080 TestApplication application;
4082 Actor actor = Actor::New();
4084 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4086 Geometry geometry = CreateQuadGeometry();
4087 Shader shader = CreateShader();
4088 Renderer renderer = Renderer::New(geometry, shader);
4090 actor.AddRenderer(renderer);
4091 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4092 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4094 actor.RemoveRenderer(10);
4095 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4096 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4101 // Clipping test helper functions:
4102 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4104 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4105 Actor actor = CreateRenderableActor(image);
4107 // Setup dimensions and position so actor is not skipped by culling.
4108 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4109 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4110 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4111 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4116 Actor CreateActorWithContent16x16()
4118 return CreateActorWithContent(16, 16);
4121 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4123 enabledDisableTrace.Reset();
4124 stencilTrace.Reset();
4125 enabledDisableTrace.Enable(true);
4126 stencilTrace.Enable(true);
4128 application.SendNotification();
4129 application.Render();
4131 enabledDisableTrace.Enable(false);
4132 stencilTrace.Enable(false);
4135 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4137 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4139 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4140 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4141 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4142 DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4145 int UtcDaliActorPropertyClippingP(void)
4147 // This test checks the clippingMode property.
4148 tet_infoline("Testing Actor::Property::ClippingMode: P");
4149 TestApplication application;
4151 Actor actor = Actor::New();
4153 // Check default clippingEnabled value.
4154 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4157 bool getValueResult = getValue.Get(value);
4158 DALI_TEST_CHECK(getValueResult);
4162 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4165 // Check setting the property to the stencil mode.
4166 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4168 // Check the new value was set.
4169 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4170 getValueResult = getValue.Get(value);
4171 DALI_TEST_CHECK(getValueResult);
4175 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4178 // Check setting the property to the scissor mode.
4179 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4181 // Check the new value was set.
4182 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4183 getValueResult = getValue.Get(value);
4184 DALI_TEST_CHECK(getValueResult);
4188 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4193 int UtcDaliActorPropertyClippingN(void)
4195 // Negative test case for Clipping.
4196 tet_infoline("Testing Actor::Property::ClippingMode: N");
4197 TestApplication application;
4199 Actor actor = Actor::New();
4201 // Check default clippingEnabled value.
4202 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4205 bool getValueResult = getValue.Get(value);
4206 DALI_TEST_CHECK(getValueResult);
4210 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4213 // Check setting an invalid property value won't change the current property value.
4214 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4216 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4217 getValueResult = getValue.Get(value);
4218 DALI_TEST_CHECK(getValueResult);
4222 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4228 int UtcDaliActorPropertyClippingActor(void)
4230 // This test checks that an actor is correctly setup for clipping.
4231 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4232 TestApplication application;
4234 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4235 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4236 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4237 size_t startIndex = 0u;
4239 // Create a clipping actor.
4240 Actor actorDepth1Clip = CreateActorWithContent16x16();
4241 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4242 application.GetScene().Add(actorDepth1Clip);
4244 // Gather the call trace.
4245 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4247 // Check we are writing to the color buffer.
4248 CheckColorMask(glAbstraction, true);
4250 // Check the stencil buffer was enabled.
4251 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4253 // Check the stencil buffer was cleared.
4254 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4256 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4257 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4258 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4259 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4264 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4266 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4267 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4268 TestApplication application;
4270 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4271 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4272 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4273 size_t startIndex = 0u;
4275 // Create a clipping actor.
4276 Actor actorDepth1Clip = CreateActorWithContent16x16();
4277 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4278 application.GetScene().Add(actorDepth1Clip);
4280 // Gather the call trace.
4281 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4283 // Check we are writing to the color buffer.
4284 CheckColorMask(glAbstraction, true);
4286 // Check the stencil buffer was enabled.
4287 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4289 // Check the stencil buffer was cleared.
4290 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4292 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4293 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4294 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4295 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4297 // Now disable the clipping
4298 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4300 // Gather the call trace.
4301 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4303 // Check the stencil buffer was disabled.
4304 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", "2960")); // 2960 is GL_STENCIL_TEST
4306 // Ensure all values in stencil-mask are set to 1.
4308 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4313 int UtcDaliActorPropertyClippingNestedChildren(void)
4315 // This test checks that a hierarchy of actors are clipped correctly by
4316 // writing to and reading from the correct bit-planes of the stencil buffer.
4317 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4318 TestApplication application;
4319 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4320 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4321 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4323 // Create a clipping actor.
4324 Actor actorDepth1Clip = CreateActorWithContent16x16();
4325 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4326 application.GetScene().Add(actorDepth1Clip);
4328 // Create a child actor.
4329 Actor childDepth2 = CreateActorWithContent16x16();
4330 actorDepth1Clip.Add(childDepth2);
4332 // Create another clipping actor.
4333 Actor childDepth2Clip = CreateActorWithContent16x16();
4334 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4335 childDepth2.Add(childDepth2Clip);
4337 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4338 // This tests the sort algorithm.
4339 Actor childDepth3 = CreateActorWithContent16x16();
4340 childDepth2Clip.Add(childDepth3);
4341 Actor childDepth4 = CreateActorWithContent16x16();
4342 childDepth3.Add(childDepth4);
4344 // Gather the call trace.
4345 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4347 // Check we are writing to the color buffer.
4348 CheckColorMask(glAbstraction, true);
4350 // Check the stencil buffer was enabled.
4351 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4353 // Perform the test twice, once for 2D layer, and once for 3D.
4354 for(unsigned int i = 0u; i < 2u; ++i)
4356 size_t startIndex = 0u;
4358 // Check the stencil buffer was cleared.
4359 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4361 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4362 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4363 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4364 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4366 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4367 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 255", startIndex)); // 514 is GL_EQUAL
4368 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4370 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4371 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4372 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4373 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4375 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4376 // (Both must be set to pass the check).
4377 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 255", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4378 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4380 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4383 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4384 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4391 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4393 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4394 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4395 TestApplication application;
4396 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4397 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4399 /* We create a small tree of actors as follows:
4403 Clipping enabled -> B D
4407 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4410 for(int i = 0; i < 5; ++i)
4412 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4413 Actor actor = CreateRenderableActor(image);
4415 // Setup dimensions and position so actor is not skipped by culling.
4416 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4417 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4421 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4425 float b = i > 2 ? 1.0f : -1.0f;
4426 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4432 // Enable clipping on the actor at the top of the left branch.
4433 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4435 // Build the scene graph.
4436 application.GetScene().Add(actors[0]);
4439 actors[0].Add(actors[1]);
4440 actors[1].Add(actors[2]);
4443 actors[0].Add(actors[3]);
4444 actors[3].Add(actors[4]);
4446 // Gather the call trace.
4447 enabledDisableTrace.Reset();
4448 enabledDisableTrace.Enable(true);
4449 application.SendNotification();
4450 application.Render();
4451 enabledDisableTrace.Enable(false);
4453 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4455 Note: Correct enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
4456 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4458 size_t startIndex = 0u;
4459 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "3042", startIndex));
4460 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); // 2960 is GL_STENCIL_TEST
4461 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
4463 // Swap the clipping actor from top of left branch to top of right branch.
4464 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4465 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4467 // Gather the call trace.
4468 enabledDisableTrace.Reset();
4469 enabledDisableTrace.Enable(true);
4470 application.SendNotification();
4471 application.Render();
4472 enabledDisableTrace.Enable(false);
4474 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4475 // This proves the draw order has remained the same.
4477 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex));
4478 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
4483 int UtcDaliActorPropertyScissorClippingActor(void)
4485 // This test checks that an actor is correctly setup for clipping.
4486 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4487 TestApplication application;
4489 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4490 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4491 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4493 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4494 const Vector2 imageSize(16.0f, 16.0f);
4496 // Create a clipping actor.
4497 Actor clippingActorA = CreateActorWithContent16x16();
4498 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4499 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4500 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4501 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4502 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4503 application.GetScene().Add(clippingActorA);
4505 // Gather the call trace.
4506 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4508 // Check we are writing to the color buffer.
4509 CheckColorMask(glAbstraction, true);
4511 // Check scissor test was enabled.
4512 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4514 // Check the scissor was set, and the coordinates are correct.
4515 std::stringstream compareParametersString;
4516 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4517 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4519 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4520 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4522 // Gather the call trace.
4523 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4525 // Check the scissor was set, and the coordinates are correct.
4526 compareParametersString.str(std::string());
4527 compareParametersString.clear();
4528 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4529 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4534 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4536 // This test checks that an actor is correctly setup for clipping.
4537 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4538 TestApplication application;
4540 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4541 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4542 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4544 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4545 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4546 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4548 // Create a clipping actors.
4549 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4550 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4552 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4553 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4554 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4556 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4557 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4558 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4560 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4561 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4563 application.GetScene().Add(clippingActorA);
4564 application.GetScene().Add(clippingActorB);
4566 // Gather the call trace.
4567 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4569 // Check we are writing to the color buffer.
4570 CheckColorMask(glAbstraction, true);
4572 // Check scissor test was enabled.
4573 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4575 // Check the scissor was set, and the coordinates are correct.
4576 std::stringstream compareParametersString;
4578 std::string clipA("0, 500, 480, 200");
4579 std::string clipB("0, 380, 480, 40");
4581 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4582 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4587 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4589 // This test checks that an actor is correctly setup for clipping.
4590 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4591 TestApplication application;
4593 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4594 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4595 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4597 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4598 const Vector2 imageSize(16.0f, 16.0f);
4600 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4602 A is drawn first - with scissor clipping on
4603 B is drawn second - also with scissor clipping on
4604 C is the generated clipping region, the intersection ( A ∩ B )
4608 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4609 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4610 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4614 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4617 // Create a clipping actor.
4618 Actor clippingActorA = CreateActorWithContent16x16();
4619 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4620 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4621 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4622 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4623 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4624 application.GetScene().Add(clippingActorA);
4626 // Create a child clipping actor.
4627 Actor clippingActorB = CreateActorWithContent16x16();
4628 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4629 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4630 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4631 clippingActorA.Add(clippingActorB);
4633 // positionModifiers is an array of positions to position B around.
4634 // expect is an array of expected scissor clip coordinate results.
4635 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4636 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4638 // Loop through each overlap combination.
4639 for(unsigned int test = 0u; test < 4u; ++test)
4641 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4642 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4643 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4645 // Gather the call trace.
4646 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4648 // Check we are writing to the color buffer.
4649 CheckColorMask(glAbstraction, true);
4651 // Check scissor test was enabled.
4652 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4654 // Check the scissor was set, and the coordinates are correct.
4655 const Vector4& expectResults(expect[test]);
4656 std::stringstream compareParametersString;
4657 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4658 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4664 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4666 // This test checks that an actor is correctly setup for clipping.
4667 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4668 TestApplication application;
4670 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4671 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4672 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4674 /* Create a nest of 2 scissors and siblings of the parent.
4684 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4685 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4686 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4687 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4688 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4689 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4691 // Create a clipping actors.
4692 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4693 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4694 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4695 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4696 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4698 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4699 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4700 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4702 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4703 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4704 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4706 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4707 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4708 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4710 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4711 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4712 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4714 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4715 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4717 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4718 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4719 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4720 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4721 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4723 application.GetScene().Add(clippingActorA);
4724 clippingActorA.Add(clippingActorB);
4725 application.GetScene().Add(clippingActorC);
4726 application.GetScene().Add(clippingActorD);
4727 clippingActorD.Add(clippingActorE);
4729 // Gather the call trace.
4730 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4732 // Check we are writing to the color buffer.
4733 CheckColorMask(glAbstraction, true);
4735 // Check scissor test was enabled.
4736 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4738 // Check the scissor was set, and the coordinates are correct.
4739 std::string clipA("0, 500, 480, 200");
4740 std::string clipB("0, 580, 480, 40");
4741 std::string clipC("0, 200, 480, 200");
4742 std::string clipD("0, 300, 480, 200");
4744 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4745 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4746 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4747 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4748 DALI_TEST_CHECK(scissorTrace.CountMethod("Scissor") == 4); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4753 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4755 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4756 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4757 TestApplication application;
4759 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4760 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4761 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4763 // Create a clipping actor.
4764 Actor actorDepth1Clip = CreateActorWithContent16x16();
4765 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4766 application.GetScene().Add(actorDepth1Clip);
4768 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4769 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4771 // Gather the call trace.
4772 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4774 // Check we are writing to the color buffer.
4775 CheckColorMask(glAbstraction, true);
4777 // Check the stencil buffer was not enabled.
4778 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4780 // Check stencil functions are not called.
4781 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4782 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask"));
4783 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4785 // Check that scissor clipping is overriden by the renderer properties.
4786 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4788 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4790 // Gather the call trace.
4791 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4793 // Check the stencil buffer was not enabled.
4794 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4796 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4801 int UtcDaliGetPropertyN(void)
4803 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
4804 TestApplication application;
4806 Actor actor = Actor::New();
4808 unsigned int propertyCount = actor.GetPropertyCount();
4809 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
4813 int UtcDaliActorRaiseLower(void)
4815 tet_infoline("UtcDaliActor Raise and Lower test\n");
4817 TestApplication application;
4819 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
4821 Integration::Scene stage(application.GetScene());
4823 Actor actorA = Actor::New();
4824 Actor actorB = Actor::New();
4825 Actor actorC = Actor::New();
4827 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4828 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4830 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4831 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4833 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4834 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4836 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4837 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4839 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4840 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4842 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4843 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4849 ResetTouchCallbacks();
4851 application.SendNotification();
4852 application.Render();
4854 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4855 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4856 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4858 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4859 // Only top actor will get touched.
4860 actorA.TouchedSignal().Connect(TestTouchCallback);
4861 actorB.TouchedSignal().Connect(TestTouchCallback2);
4862 actorC.TouchedSignal().Connect(TestTouchCallback3);
4864 // Connect ChildOrderChangedSignal
4865 bool orderChangedSignal(false);
4866 Actor orderChangedActor;
4867 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
4868 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
4870 Dali::Integration::Point point;
4871 point.SetDeviceId(1);
4872 point.SetState(PointState::DOWN);
4873 point.SetScreenPosition(Vector2(10.f, 10.f));
4874 Dali::Integration::TouchEvent touchEvent;
4875 touchEvent.AddPoint(point);
4877 application.ProcessEvent(touchEvent);
4879 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4880 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4881 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4883 ResetTouchCallbacks();
4885 tet_printf("Testing Raising of Actor\n");
4887 int preActorOrder(0);
4888 int postActorOrder(0);
4890 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4891 value.Get(preActorOrder);
4893 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4895 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4896 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4898 // Ensure sort order is calculated before next touch event
4899 application.SendNotification();
4901 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4902 value.Get(postActorOrder);
4904 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4906 application.ProcessEvent(touchEvent);
4908 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4909 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
4910 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4912 ResetTouchCallbacks();
4914 tet_printf("Testing Lowering of Actor\n");
4916 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4917 value.Get(preActorOrder);
4919 orderChangedSignal = false;
4921 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4923 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4924 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4926 application.SendNotification(); // ensure sort order calculated before next touch event
4928 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4929 value.Get(postActorOrder);
4931 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4933 application.ProcessEvent(touchEvent);
4935 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4936 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4937 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4939 ResetTouchCallbacks();
4941 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
4946 int UtcDaliActorRaiseToTopLowerToBottom(void)
4948 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
4950 TestApplication application;
4952 Integration::Scene stage(application.GetScene());
4954 Actor actorA = Actor::New();
4955 Actor actorB = Actor::New();
4956 Actor actorC = Actor::New();
4958 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4959 // enables checking of which actor the uniform is assigned too
4960 Shader shaderA = CreateShader();
4961 shaderA.RegisterProperty("uRendererColor", 1.f);
4963 Shader shaderB = CreateShader();
4964 shaderB.RegisterProperty("uRendererColor", 2.f);
4966 Shader shaderC = CreateShader();
4967 shaderC.RegisterProperty("uRendererColor", 3.f);
4969 Geometry geometry = CreateQuadGeometry();
4971 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4972 Renderer rendererA = Renderer::New(geometry, shaderA);
4973 actorA.AddRenderer(rendererA);
4975 Renderer rendererB = Renderer::New(geometry, shaderB);
4976 actorB.AddRenderer(rendererB);
4978 Renderer rendererC = Renderer::New(geometry, shaderC);
4979 actorC.AddRenderer(rendererC);
4981 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4982 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4984 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4985 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4987 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4988 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4990 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4991 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4993 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4994 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4996 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4997 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5003 ResetTouchCallbacks();
5005 // Connect ChildOrderChangedSignal
5006 bool orderChangedSignal(false);
5007 Actor orderChangedActor;
5008 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5009 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5011 // Set up gl abstraction trace so can query the set uniform order
5012 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5013 glAbstraction.EnableSetUniformCallTrace(true);
5014 glAbstraction.ResetSetUniformCallStack();
5016 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5018 application.SendNotification();
5019 application.Render();
5021 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5023 // Test order of uniforms in stack
5024 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5025 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5026 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5028 bool CBA = (indexC > indexB) && (indexB > indexA);
5030 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5032 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5033 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5034 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5036 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5037 // Only top actor will get touched.
5038 actorA.TouchedSignal().Connect(TestTouchCallback);
5039 actorB.TouchedSignal().Connect(TestTouchCallback2);
5040 actorC.TouchedSignal().Connect(TestTouchCallback3);
5042 Dali::Integration::Point point;
5043 point.SetDeviceId(1);
5044 point.SetState(PointState::DOWN);
5045 point.SetScreenPosition(Vector2(10.f, 10.f));
5046 Dali::Integration::TouchEvent touchEvent;
5047 touchEvent.AddPoint(point);
5049 application.ProcessEvent(touchEvent);
5051 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5052 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5053 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5055 ResetTouchCallbacks();
5057 tet_printf("RaiseToTop ActorA\n");
5059 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5060 actorA.RaiseToTop();
5061 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5062 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5064 application.SendNotification(); // ensure sorting order is calculated before next touch event
5066 application.ProcessEvent(touchEvent);
5068 glAbstraction.ResetSetUniformCallStack();
5069 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5071 application.SendNotification();
5072 application.Render();
5074 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5076 // Test order of uniforms in stack
5077 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5078 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5079 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5081 tet_infoline("Testing A above C and B at bottom\n");
5082 bool ACB = (indexA > indexC) && (indexC > indexB);
5084 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5086 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5087 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5088 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5090 ResetTouchCallbacks();
5092 tet_printf("RaiseToTop ActorB\n");
5094 orderChangedSignal = false;
5096 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5097 actorB.RaiseToTop();
5098 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5099 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5101 application.SendNotification(); // Ensure sort order is calculated before next touch event
5103 application.ProcessEvent(touchEvent);
5105 glAbstraction.ResetSetUniformCallStack();
5106 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5108 application.SendNotification();
5109 application.Render();
5111 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5113 // Test order of uniforms in stack
5114 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5115 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5116 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5118 tet_infoline("Testing B above A and C at bottom\n");
5119 bool BAC = (indexB > indexA) && (indexA > indexC);
5121 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5123 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5124 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5125 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5127 ResetTouchCallbacks();
5129 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5131 orderChangedSignal = false;
5133 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5134 actorA.LowerToBottom();
5135 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5136 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5138 application.SendNotification();
5139 application.Render();
5141 orderChangedSignal = false;
5143 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5144 actorB.LowerToBottom();
5145 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5146 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5148 application.SendNotification();
5149 application.Render();
5151 application.ProcessEvent(touchEvent);
5153 glAbstraction.ResetSetUniformCallStack();
5154 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5156 application.SendNotification();
5157 application.Render();
5159 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5161 // Test order of uniforms in stack
5162 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5163 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5164 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5166 tet_infoline("Testing C above A and B at bottom\n");
5167 bool CAB = (indexC > indexA) && (indexA > indexB);
5169 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5171 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5172 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5173 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5175 ResetTouchCallbacks();
5180 int UtcDaliActorRaiseAbove(void)
5182 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5184 TestApplication application;
5186 Integration::Scene stage(application.GetScene());
5188 Actor actorA = Actor::New();
5189 Actor actorB = Actor::New();
5190 Actor actorC = Actor::New();
5192 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5193 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5195 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5196 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5198 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5199 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5201 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5202 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5204 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5205 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5207 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5208 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5214 ResetTouchCallbacks();
5216 application.SendNotification();
5217 application.Render();
5219 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5220 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5221 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5223 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5224 // Only top actor will get touched.
5225 actorA.TouchedSignal().Connect(TestTouchCallback);
5226 actorB.TouchedSignal().Connect(TestTouchCallback2);
5227 actorC.TouchedSignal().Connect(TestTouchCallback3);
5229 bool orderChangedSignal(false);
5230 Actor orderChangedActor;
5231 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5232 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5234 Dali::Integration::Point point;
5235 point.SetDeviceId(1);
5236 point.SetState(PointState::DOWN);
5237 point.SetScreenPosition(Vector2(10.f, 10.f));
5238 Dali::Integration::TouchEvent touchEvent;
5239 touchEvent.AddPoint(point);
5241 application.ProcessEvent(touchEvent);
5243 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5244 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5245 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5247 ResetTouchCallbacks();
5249 tet_printf("Raise actor B Above Actor C\n");
5251 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5252 actorB.RaiseAbove(actorC);
5253 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5254 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5256 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5257 application.SendNotification();
5258 application.ProcessEvent(touchEvent);
5260 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5261 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5262 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5264 ResetTouchCallbacks();
5266 tet_printf("Raise actor A Above Actor B\n");
5268 orderChangedSignal = false;
5270 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5271 actorA.RaiseAbove(actorB);
5272 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5273 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5275 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5276 application.SendNotification();
5278 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5280 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5281 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5282 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5284 ResetTouchCallbacks();
5289 int UtcDaliActorLowerBelow(void)
5291 tet_infoline("UtcDaliActor LowerBelow test \n");
5293 TestApplication application;
5295 Integration::Scene stage(application.GetScene());
5297 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5298 // enables checking of which actor the uniform is assigned too
5299 Shader shaderA = CreateShader();
5300 shaderA.RegisterProperty("uRendererColor", 1.f);
5302 Shader shaderB = CreateShader();
5303 shaderB.RegisterProperty("uRendererColor", 2.f);
5305 Shader shaderC = CreateShader();
5306 shaderC.RegisterProperty("uRendererColor", 3.f);
5308 Actor actorA = Actor::New();
5309 Actor actorB = Actor::New();
5310 Actor actorC = Actor::New();
5312 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5313 Geometry geometry = CreateQuadGeometry();
5315 Renderer rendererA = Renderer::New(geometry, shaderA);
5316 actorA.AddRenderer(rendererA);
5318 Renderer rendererB = Renderer::New(geometry, shaderB);
5319 actorB.AddRenderer(rendererB);
5321 Renderer rendererC = Renderer::New(geometry, shaderC);
5322 actorC.AddRenderer(rendererC);
5324 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5325 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5327 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5328 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5330 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5331 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5333 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5334 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5336 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5337 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5339 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5340 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5342 Actor container = Actor::New();
5343 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5344 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5345 stage.Add(container);
5347 container.Add(actorA);
5348 container.Add(actorB);
5349 container.Add(actorC);
5351 ResetTouchCallbacks();
5353 // Connect ChildOrderChangedSignal
5354 bool orderChangedSignal(false);
5355 Actor orderChangedActor;
5356 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5357 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5359 // Set up gl abstraction trace so can query the set uniform order
5360 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5361 glAbstraction.EnableSetUniformCallTrace(true);
5362 glAbstraction.ResetSetUniformCallStack();
5363 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5365 glAbstraction.ResetSetUniformCallStack();
5367 application.SendNotification();
5368 application.Render();
5370 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5372 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5374 // Test order of uniforms in stack
5375 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5376 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5377 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5379 tet_infoline("Testing C above B and A at bottom\n");
5380 bool CBA = (indexC > indexB) && (indexB > indexA);
5382 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5384 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5385 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5386 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5388 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5389 // Only top actor will get touched.
5390 actorA.TouchedSignal().Connect(TestTouchCallback);
5391 actorB.TouchedSignal().Connect(TestTouchCallback2);
5392 actorC.TouchedSignal().Connect(TestTouchCallback3);
5394 Dali::Integration::Point point;
5395 point.SetDeviceId(1);
5396 point.SetState(PointState::DOWN);
5397 point.SetScreenPosition(Vector2(10.f, 10.f));
5398 Dali::Integration::TouchEvent touchEvent;
5399 touchEvent.AddPoint(point);
5401 tet_infoline("UtcDaliActor Test Set up completed \n");
5403 application.ProcessEvent(touchEvent);
5405 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5406 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5407 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5409 ResetTouchCallbacks();
5411 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");
5413 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5414 actorC.LowerBelow(actorB);
5415 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5416 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5418 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5419 application.SendNotification();
5420 application.Render();
5422 application.ProcessEvent(touchEvent); // touch event
5424 glAbstraction.ResetSetUniformCallStack();
5425 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5427 application.SendNotification();
5428 application.Render();
5430 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5432 // Test order of uniforms in stack
5433 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5434 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5435 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5437 tet_infoline("Testing render order is A, C, B");
5438 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5439 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5441 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5442 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5443 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5445 ResetTouchCallbacks();
5447 tet_printf("Lower actor C below Actor A leaving B on top\n");
5449 orderChangedSignal = false;
5451 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5452 actorC.LowerBelow(actorA);
5453 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5454 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5456 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5457 application.SendNotification();
5458 application.Render();
5460 application.ProcessEvent(touchEvent);
5462 glAbstraction.ResetSetUniformCallStack();
5463 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5465 application.Render();
5466 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5468 // Test order of uniforms in stack
5469 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5470 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5471 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5473 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5474 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5476 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5477 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5478 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5480 ResetTouchCallbacks();
5482 tet_printf("Lower actor B below Actor C leaving A on top\n");
5484 orderChangedSignal = false;
5486 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5487 actorB.LowerBelow(actorC);
5488 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5489 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5491 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5492 application.SendNotification();
5493 application.Render();
5495 application.ProcessEvent(touchEvent);
5497 glAbstraction.ResetSetUniformCallStack();
5498 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5500 application.Render();
5501 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5503 // Test order of uniforms in stack
5504 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5505 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5506 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5508 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5509 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5514 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5516 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
5518 TestApplication application;
5520 Integration::Scene stage(application.GetScene());
5522 Actor parentA = Actor::New();
5523 Actor parentB = Actor::New();
5524 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5525 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5526 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5527 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5529 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5530 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5532 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5533 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5538 Actor actorA = Actor::New();
5539 Actor actorB = Actor::New();
5540 Actor actorC = Actor::New();
5542 parentA.Add(actorA);
5543 parentA.Add(actorB);
5545 tet_printf("Actor C added to different parent from A and B \n");
5546 parentB.Add(actorC);
5548 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5549 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5551 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5552 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5554 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5555 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5557 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5558 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5560 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5561 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5563 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5564 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5566 ResetTouchCallbacks();
5568 // Connect ChildOrderChangedSignal
5569 bool orderChangedSignal(false);
5570 Actor orderChangedActor;
5571 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5572 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5574 application.SendNotification();
5575 application.Render();
5577 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5578 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5579 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5581 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5582 // Only top actor will get touched.
5583 actorA.TouchedSignal().Connect(TestTouchCallback);
5584 actorB.TouchedSignal().Connect(TestTouchCallback2);
5585 actorC.TouchedSignal().Connect(TestTouchCallback3);
5587 Dali::Integration::Point point;
5588 point.SetDeviceId(1);
5589 point.SetState(PointState::DOWN);
5590 point.SetScreenPosition(Vector2(10.f, 10.f));
5591 Dali::Integration::TouchEvent touchEvent;
5592 touchEvent.AddPoint(point);
5594 application.ProcessEvent(touchEvent);
5596 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5597 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5598 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5600 ResetTouchCallbacks();
5602 tet_printf("Raise actor A Above Actor C which have different parents\n");
5604 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5605 actorA.RaiseAbove(actorC);
5606 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5608 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5609 application.SendNotification();
5611 application.ProcessEvent(touchEvent); // touch event
5613 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5614 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5615 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5617 ResetTouchCallbacks();
5622 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5624 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
5626 TestApplication application;
5628 Integration::Scene stage(application.GetScene());
5630 Actor actorA = Actor::New();
5631 Actor actorB = Actor::New();
5632 Actor actorC = Actor::New();
5634 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5635 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5637 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5638 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5640 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5641 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5643 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5644 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5646 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5647 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5649 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5650 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5652 ResetTouchCallbacks();
5654 // Connect ChildOrderChangedSignal
5655 bool orderChangedSignal(false);
5656 Actor orderChangedActor;
5657 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5658 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5660 application.SendNotification();
5661 application.Render();
5663 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5664 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5665 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5667 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5668 // Only top actor will get touched.
5669 actorA.TouchedSignal().Connect(TestTouchCallback);
5670 actorB.TouchedSignal().Connect(TestTouchCallback2);
5671 actorC.TouchedSignal().Connect(TestTouchCallback3);
5673 Dali::Integration::Point point;
5674 point.SetDeviceId(1);
5675 point.SetState(PointState::DOWN);
5676 point.SetScreenPosition(Vector2(10.f, 10.f));
5677 Dali::Integration::TouchEvent touchEvent;
5678 touchEvent.AddPoint(point);
5680 tet_printf("Raise actor A Above Actor C which have no parents\n");
5682 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5683 actorA.RaiseAbove(actorC);
5684 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5686 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5687 application.SendNotification();
5689 application.ProcessEvent(touchEvent);
5691 tet_printf("Not parented so RaiseAbove should show no effect\n");
5693 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5694 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5695 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5697 ResetTouchCallbacks();
5699 orderChangedSignal = false;
5702 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
5704 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5705 actorA.LowerBelow(actorC);
5706 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5708 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5709 application.SendNotification();
5710 application.Render();
5712 application.ProcessEvent(touchEvent);
5714 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
5715 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5716 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5717 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5719 ResetTouchCallbacks();
5721 orderChangedSignal = false;
5723 tet_printf("Adding Actor A to stage, will be on top\n");
5726 application.SendNotification();
5727 application.Render();
5729 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
5731 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5732 actorB.RaiseAbove(actorC);
5733 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5735 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5736 application.SendNotification();
5738 application.ProcessEvent(touchEvent);
5740 tet_printf("C not parented so RaiseAbove should show no effect\n");
5741 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5742 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5743 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5745 ResetTouchCallbacks();
5747 orderChangedSignal = false;
5749 tet_printf("Lower actor A below Actor C when only A has a parent\n");
5751 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5752 actorA.LowerBelow(actorC);
5753 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5755 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5756 application.SendNotification();
5758 application.ProcessEvent(touchEvent);
5760 tet_printf("C not parented so LowerBelow should show no effect\n");
5761 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5762 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5763 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5765 ResetTouchCallbacks();
5767 orderChangedSignal = false;
5771 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5772 actorA.RaiseAbove(actorC);
5773 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5774 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5776 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5777 application.SendNotification();
5778 application.Render();
5780 application.ProcessEvent(touchEvent);
5782 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
5783 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5784 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5785 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5790 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5792 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
5794 TestApplication application;
5796 Integration::Scene stage(application.GetScene());
5798 Actor actorA = Actor::New();
5799 Actor actorB = Actor::New();
5800 Actor actorC = Actor::New();
5802 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5803 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5805 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5806 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5808 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5809 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5811 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5812 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5814 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5815 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5817 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5818 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5820 ResetTouchCallbacks();
5822 // Connect ChildOrderChangedSignal
5823 bool orderChangedSignal(false);
5824 Actor orderChangedActor;
5825 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5826 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5828 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5829 // Only top actor will get touched.
5830 actorA.TouchedSignal().Connect(TestTouchCallback);
5831 actorB.TouchedSignal().Connect(TestTouchCallback2);
5832 actorC.TouchedSignal().Connect(TestTouchCallback3);
5834 Dali::Integration::Point point;
5835 point.SetDeviceId(1);
5836 point.SetState(PointState::DOWN);
5837 point.SetScreenPosition(Vector2(10.f, 10.f));
5838 Dali::Integration::TouchEvent touchEvent;
5839 touchEvent.AddPoint(point);
5842 tet_printf("Raise actor B Above Actor C but B not parented\n");
5844 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5846 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5848 application.SendNotification();
5849 application.Render();
5851 application.ProcessEvent(touchEvent);
5853 tet_printf("Not parented so RaiseAbove should show no effect\n");
5855 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5856 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5857 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5859 tet_printf("Raise actor B Above Actor C but B not parented\n");
5860 ResetTouchCallbacks();
5862 orderChangedSignal = false;
5864 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5866 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5868 // Sort actor tree before next touch event
5869 application.SendNotification();
5870 application.Render();
5872 application.ProcessEvent(touchEvent);
5874 tet_printf("Not parented so RaiseAbove should show no effect\n");
5876 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5877 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5878 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5879 ResetTouchCallbacks();
5881 orderChangedSignal = false;
5883 tet_printf("Lower actor C below B but C not parented\n");
5885 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5887 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5889 // Sort actor tree before next touch event
5890 application.SendNotification();
5891 application.Render();
5893 application.ProcessEvent(touchEvent);
5895 tet_printf("Not parented so Lower should show no effect\n");
5897 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5898 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5899 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5900 ResetTouchCallbacks();
5902 orderChangedSignal = false;
5904 tet_printf("Raise actor B to top\n");
5906 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5907 actorB.RaiseToTop();
5908 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5910 // Sort actor tree before next touch event
5911 application.SendNotification();
5912 application.Render();
5914 application.ProcessEvent(touchEvent);
5916 tet_printf("Not parented so RaiseToTop should show no effect\n");
5918 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5919 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5920 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5921 ResetTouchCallbacks();
5923 orderChangedSignal = false;
5925 tet_printf("Add ActorB to stage so only Actor C not parented\n");
5929 tet_printf("Lower actor C to Bottom, B stays at top\n");
5931 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5932 actorC.LowerToBottom();
5933 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5935 application.SendNotification();
5936 application.Render();
5938 application.ProcessEvent(touchEvent);
5940 tet_printf("Not parented so LowerToBottom should show no effect\n");
5942 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5943 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5944 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5945 ResetTouchCallbacks();
5950 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5952 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
5954 TestApplication application;
5956 Integration::Scene stage(application.GetScene());
5958 Actor actorA = Actor::New();
5959 Actor actorB = Actor::New();
5960 Actor actorC = Actor::New();
5962 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5963 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5965 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5966 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5968 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5969 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5971 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5972 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5974 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5975 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5977 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5978 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5984 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5985 // Only top actor will get touched.
5986 actorA.TouchedSignal().Connect(TestTouchCallback);
5987 actorB.TouchedSignal().Connect(TestTouchCallback2);
5988 actorC.TouchedSignal().Connect(TestTouchCallback3);
5990 ResetTouchCallbacks();
5992 // Connect ChildOrderChangedSignal
5993 bool orderChangedSignal(false);
5994 Actor orderChangedActor;
5995 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5996 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5998 application.SendNotification();
5999 application.Render();
6001 Dali::Integration::Point point;
6002 point.SetDeviceId(1);
6003 point.SetState(PointState::DOWN);
6004 point.SetScreenPosition(Vector2(10.f, 10.f));
6005 Dali::Integration::TouchEvent touchEvent;
6006 touchEvent.AddPoint(point);
6008 application.ProcessEvent(touchEvent);
6010 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6011 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6012 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6014 ResetTouchCallbacks();
6016 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6018 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6019 actorA.RaiseAbove(actorA);
6020 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6021 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6023 application.SendNotification();
6024 application.Render();
6026 application.ProcessEvent(touchEvent);
6028 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6030 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6031 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6032 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6034 ResetTouchCallbacks();
6036 orderChangedSignal = false;
6038 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6039 actorA.RaiseAbove(actorC);
6040 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6041 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6043 application.SendNotification();
6044 application.Render();
6046 application.ProcessEvent(touchEvent);
6048 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6049 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6050 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6051 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6056 int UtcDaliActorGetScreenPosition(void)
6058 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6060 TestApplication application;
6062 Integration::Scene stage(application.GetScene());
6064 Actor actorA = Actor::New();
6065 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6067 Vector2 size2(10.0f, 20.0f);
6068 actorA.SetProperty(Actor::Property::SIZE, size2);
6070 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6072 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6076 application.SendNotification();
6077 application.Render();
6079 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6080 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6082 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6083 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6085 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6086 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6088 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6090 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6092 application.SendNotification();
6093 application.Render();
6095 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6096 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6098 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6099 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6101 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6102 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6104 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6106 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6108 application.SendNotification();
6109 application.Render();
6111 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6112 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6114 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6115 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6117 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6118 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6120 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6122 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6124 application.SendNotification();
6125 application.Render();
6127 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6128 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6130 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6131 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6133 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6134 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6136 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6138 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6140 application.SendNotification();
6141 application.Render();
6143 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6144 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6146 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6147 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6149 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6150 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6152 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6154 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6155 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6157 Actor actorB = Actor::New();
6158 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6159 actorB.SetProperty(Actor::Property::SIZE, size2);
6160 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6163 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6165 application.SendNotification();
6166 application.Render();
6168 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6170 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6171 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6176 int UtcDaliActorGetScreenPositionAfterScaling(void)
6178 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6180 TestApplication application;
6182 Integration::Scene stage(application.GetScene());
6184 Actor actorA = Actor::New();
6185 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6187 Vector2 size2(10.0f, 20.0f);
6188 actorA.SetProperty(Actor::Property::SIZE, size2);
6189 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6190 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6192 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6196 application.SendNotification();
6197 application.Render();
6199 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6200 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6202 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6203 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6205 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6206 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6208 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6210 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6212 application.SendNotification();
6213 application.Render();
6215 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6216 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6218 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6219 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6221 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6222 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6227 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6229 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6231 TestApplication application;
6233 Integration::Scene stage(application.GetScene());
6235 Actor actorA = Actor::New();
6236 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6237 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6238 Vector2 size2(10.0f, 20.0f);
6239 actorA.SetProperty(Actor::Property::SIZE, size2);
6240 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6242 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6246 application.SendNotification();
6247 application.Render();
6249 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6250 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6252 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6253 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6255 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6256 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6258 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6260 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6261 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6263 application.SendNotification();
6264 application.Render();
6266 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6267 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6269 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6270 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6272 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6273 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6279 int UtcDaliActorGetScreenPositionWithChildActors(void)
6281 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6283 TestApplication application;
6285 Integration::Scene stage(application.GetScene());
6287 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6289 Actor actorA = Actor::New();
6290 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6291 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6292 Vector2 size1(10.0f, 20.0f);
6293 actorA.SetProperty(Actor::Property::SIZE, size1);
6294 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6296 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6298 Actor parentActorA = Actor::New();
6299 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6300 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6301 Vector2 size2(30.0f, 60.0f);
6302 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6303 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6305 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6307 stage.Add(parentActorA);
6308 parentActorA.Add(actorA);
6310 application.SendNotification();
6311 application.Render();
6313 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6314 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6316 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6317 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6319 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6320 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6322 tet_infoline("Test 2\n");
6324 tet_infoline("change parent anchor point and parent origin then check screen position \n");
6326 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6327 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6329 application.SendNotification();
6330 application.Render();
6332 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6333 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6335 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6336 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6338 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6339 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6344 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6346 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6348 TestApplication application;
6350 Integration::Scene stage(application.GetScene());
6352 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6354 Actor actorA = Actor::New();
6355 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6356 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6357 Vector2 size1(10.0f, 20.0f);
6358 actorA.SetProperty(Actor::Property::SIZE, size1);
6359 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6361 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6363 Actor parentActorA = Actor::New();
6364 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6365 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6366 Vector2 size2(30.0f, 60.0f);
6367 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6368 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6370 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6372 Actor grandParentActorA = Actor::New();
6373 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6374 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6375 Vector2 size3(60.0f, 120.0f);
6376 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6377 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6379 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6381 stage.Add(grandParentActorA);
6382 grandParentActorA.Add(parentActorA);
6384 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6386 parentActorA.Add(actorA);
6388 application.SendNotification();
6389 application.Render();
6391 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6392 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6394 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6395 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6397 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6398 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6403 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6405 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6407 TestApplication application;
6409 Integration::Scene stage(application.GetScene());
6411 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6413 Actor actorA = Actor::New();
6414 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6415 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6416 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6417 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6420 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6422 Actor actorB = Actor::New();
6423 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6424 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6425 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6426 Vector2 actorBSize(30.0f, 60.0f);
6427 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6430 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6432 Actor actorC = Actor::New();
6433 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6434 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6435 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6436 Vector2 actorCSize(60.0f, 120.0f);
6437 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6440 application.SendNotification();
6441 application.Render();
6443 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
6445 Vector2 center(stage.GetSize() * 0.5f);
6447 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6448 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6449 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6451 tet_infoline("Add scale to all actors");
6453 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6454 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
6455 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
6457 application.SendNotification();
6458 application.Render();
6460 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
6461 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
6462 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
6467 int utcDaliActorPositionUsesAnchorPoint(void)
6469 TestApplication application;
6470 tet_infoline("Check default behaviour\n");
6472 Actor actor = Actor::New();
6473 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6474 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6475 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6476 application.GetScene().Add(actor);
6478 application.SendNotification();
6479 application.Render();
6481 tet_infoline("Check that the world position is in the center\n");
6482 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6484 tet_infoline("Set the position uses anchor point property to false\n");
6485 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6487 application.SendNotification();
6488 application.Render();
6490 tet_infoline("Check that the world position has changed appropriately\n");
6491 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6496 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6498 TestApplication application;
6499 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6501 Actor actor = Actor::New();
6502 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6503 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6504 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6505 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6506 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6507 application.GetScene().Add(actor);
6509 application.SendNotification();
6510 application.Render();
6512 tet_infoline("Check the world position is the same as it would be without a scale\n");
6513 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6515 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6516 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6517 application.SendNotification();
6518 application.Render();
6519 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
6521 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6522 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6523 application.SendNotification();
6524 application.Render();
6525 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6530 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6532 TestApplication application;
6533 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6535 Actor actor = Actor::New();
6536 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6537 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6538 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6539 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6540 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6541 application.GetScene().Add(actor);
6543 application.SendNotification();
6544 application.Render();
6546 tet_infoline("Check the world position is the same as it would be without a rotation\n");
6547 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6549 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6550 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6551 application.SendNotification();
6552 application.Render();
6553 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
6555 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6556 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6557 application.SendNotification();
6558 application.Render();
6559 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
6564 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6566 TestApplication application;
6567 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6569 Actor actor = Actor::New();
6570 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6571 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6572 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6573 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6574 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6575 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6576 application.GetScene().Add(actor);
6578 application.SendNotification();
6579 application.Render();
6581 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
6582 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6584 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6585 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6586 application.SendNotification();
6587 application.Render();
6588 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
6590 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6591 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6592 application.SendNotification();
6593 application.Render();
6594 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
6599 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6601 TestApplication application;
6602 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6604 Actor parent = Actor::New();
6606 application.GetScene().Add(parent);
6607 Vector2 stageSize(application.GetScene().GetSize());
6609 Actor actor = Actor::New();
6610 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6611 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6612 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6613 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
6614 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
6615 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6618 application.SendNotification();
6619 application.Render();
6621 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
6623 tet_infoline("Check the world position is in the right place\n");
6624 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6626 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
6627 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6628 application.SendNotification();
6629 application.Render();
6630 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6632 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
6633 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6634 application.SendNotification();
6635 application.Render();
6636 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6641 int utcDaliActorVisibilityChangeSignalSelf(void)
6643 TestApplication application;
6644 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
6646 Actor actor = Actor::New();
6648 VisibilityChangedFunctorData data;
6649 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
6651 actor.SetProperty(Actor::Property::VISIBLE, false);
6653 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6655 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
6658 actor.SetProperty(Actor::Property::VISIBLE, false);
6659 data.Check(false /* not called */, TEST_LOCATION);
6661 tet_infoline("Change the visibility using properties, ensure called");
6664 actor.SetProperty(Actor::Property::VISIBLE, true);
6665 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6667 tet_infoline("Set the visibility to current using properties, ensure not called");
6670 actor.SetProperty(Actor::Property::VISIBLE, true);
6671 data.Check(false /* not called */, TEST_LOCATION);
6676 int utcDaliActorVisibilityChangeSignalChildren(void)
6678 TestApplication application;
6679 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
6681 Actor parent = Actor::New();
6682 Actor child = Actor::New();
6685 Actor grandChild = Actor::New();
6686 child.Add(grandChild);
6688 VisibilityChangedFunctorData parentData;
6689 VisibilityChangedFunctorData childData;
6690 VisibilityChangedFunctorData grandChildData;
6692 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
6693 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
6694 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
6696 parent.SetProperty(Actor::Property::VISIBLE, false);
6697 parentData.Check(false /* not called */, TEST_LOCATION);
6698 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6699 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6701 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
6704 grandChildData.Reset();
6706 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
6708 parent.SetProperty(Actor::Property::VISIBLE, true);
6709 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6710 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6711 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6713 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
6716 grandChildData.Reset();
6718 parent.SetProperty(Actor::Property::VISIBLE, true);
6719 parentData.Check(false /* not called */, TEST_LOCATION);
6720 childData.Check(false /* not called */, TEST_LOCATION);
6721 grandChildData.Check(false /* not called */, TEST_LOCATION);
6726 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6728 TestApplication application;
6729 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
6731 Actor actor = Actor::New();
6732 application.GetScene().Add(actor);
6734 application.SendNotification();
6735 application.Render();
6737 VisibilityChangedFunctorData data;
6738 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
6740 Animation animation = Animation::New(1.0f);
6741 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
6743 data.Check(false, TEST_LOCATION);
6744 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
6745 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
6747 tet_infoline("Play the animation and check the property value");
6750 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6751 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
6753 tet_infoline("Animation not currently finished, so the current visibility should still be true");
6754 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
6756 application.SendNotification();
6757 application.Render(1100); // After the animation
6759 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
6764 int utcDaliActorVisibilityChangeSignalByName(void)
6766 TestApplication application;
6767 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
6769 Actor actor = Actor::New();
6771 bool signalCalled = false;
6772 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
6773 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6774 actor.SetProperty(Actor::Property::VISIBLE, false);
6775 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
6777 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
6778 signalCalled = false;
6779 actor.SetProperty(Actor::Property::VISIBLE, false);
6780 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6782 tet_infoline("Change the visibility using properties, ensure called");
6783 actor.SetProperty(Actor::Property::VISIBLE, true);
6784 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
6786 tet_infoline("Set the visibility to current using properties, ensure not called");
6787 signalCalled = false;
6789 actor.SetProperty(Actor::Property::VISIBLE, true);
6790 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6795 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
6797 gLayoutDirectionType = type;
6800 int UtcDaliActorLayoutDirectionProperty(void)
6802 TestApplication application;
6803 tet_infoline("Check layout direction property");
6805 Actor actor0 = Actor::New();
6806 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6807 application.GetScene().Add(actor0);
6809 application.SendNotification();
6810 application.Render();
6812 Actor actor1 = Actor::New();
6813 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6814 Actor actor2 = Actor::New();
6815 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6816 Actor actor3 = Actor::New();
6817 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6818 Actor actor4 = Actor::New();
6819 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6820 Actor actor5 = Actor::New();
6821 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6822 Actor actor6 = Actor::New();
6823 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6824 Actor actor7 = Actor::New();
6825 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6826 Actor actor8 = Actor::New();
6827 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6828 Actor actor9 = Actor::New();
6829 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6832 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6833 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
6835 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
6836 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
6837 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
6839 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6840 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6841 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
6843 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
6845 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6846 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6848 application.GetScene().Add(actor3);
6855 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
6856 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
6858 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
6859 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
6860 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
6862 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
6864 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6865 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6866 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6867 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6868 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6869 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6870 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6872 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
6873 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6874 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6876 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
6877 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6878 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6879 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6881 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
6882 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6883 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6888 struct LayoutDirectionFunctor
6890 LayoutDirectionFunctor(bool& signalCalled)
6891 : mSignalCalled(signalCalled)
6895 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6896 : mSignalCalled(rhs.mSignalCalled)
6902 mSignalCalled = true;
6905 bool& mSignalCalled;
6908 int UtcDaliActorLayoutDirectionSignal(void)
6910 TestApplication application;
6911 tet_infoline("Check changing layout direction property sends a signal");
6913 Actor actor = Actor::New();
6914 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6915 application.GetScene().Add(actor);
6916 bool signalCalled = false;
6917 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6919 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
6920 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6922 // Test that writing the same value doesn't send a signal
6923 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
6924 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6926 // Test that writing a different value sends the signal
6927 signalCalled = false;
6928 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
6929 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
6931 signalCalled = false;
6932 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
6933 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6938 struct ChildAddedSignalCheck
6940 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
6941 : mSignalReceived(signalReceived),
6942 mChildHandle(childHandle)
6946 void operator()(Actor childHandle)
6948 mSignalReceived = true;
6949 mChildHandle = childHandle;
6953 mSignalReceived = true;
6954 mChildHandle = Actor();
6957 bool& mSignalReceived;
6958 Actor& mChildHandle;
6961 int UtcDaliChildAddedSignalP1(void)
6963 TestApplication application;
6964 auto stage = application.GetScene();
6966 bool signalReceived = false;
6969 ChildAddedSignalCheck signal(signalReceived, childActor);
6970 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
6971 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
6973 auto actorA = Actor::New();
6975 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
6976 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
6977 signalReceived = false;
6979 auto actorB = Actor::New();
6981 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
6982 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
6987 int UtcDaliChildAddedSignalP2(void)
6989 TestApplication application;
6990 auto stage = application.GetScene();
6992 bool signalReceived = false;
6995 ChildAddedSignalCheck signal(signalReceived, childActor);
6996 tet_infoline("Connect to childAdded signal by name");
6998 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
6999 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7001 auto actorA = Actor::New();
7003 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7005 // Can't test which actor was added; signal signature is void() when connecting via name.
7006 signalReceived = false;
7008 auto actorB = Actor::New();
7010 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7015 int UtcDaliChildAddedSignalN(void)
7017 TestApplication application;
7018 auto stage = application.GetScene();
7020 bool signalReceived = false;
7023 ChildAddedSignalCheck signal(signalReceived, childActor);
7024 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7025 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7027 auto actorA = Actor::New();
7029 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7030 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7031 signalReceived = false;
7033 auto actorB = Actor::New();
7035 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7039 struct ChildRemovedSignalCheck
7041 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7042 : mSignalReceived(signalReceived),
7043 mChildHandle(childHandle)
7047 void operator()(Actor childHandle)
7049 mSignalReceived = true;
7050 mChildHandle = childHandle;
7055 mSignalReceived = true;
7058 bool& mSignalReceived;
7059 Actor& mChildHandle;
7062 int UtcDaliChildRemovedSignalP1(void)
7064 TestApplication application;
7065 auto stage = application.GetScene();
7067 bool signalReceived = false;
7070 ChildRemovedSignalCheck signal(signalReceived, childActor);
7071 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7072 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7074 auto actorA = Actor::New();
7076 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7077 DALI_TEST_CHECK(!childActor);
7079 stage.Remove(actorA);
7080 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7081 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7083 signalReceived = false;
7084 auto actorB = Actor::New();
7086 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7088 stage.Remove(actorB);
7089 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7090 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7095 int UtcDaliChildRemovedSignalP2(void)
7097 TestApplication application;
7098 auto stage = application.GetScene();
7100 bool signalReceived = false;
7103 ChildAddedSignalCheck signal(signalReceived, childActor);
7104 tet_infoline("Connect to childRemoved signal by name");
7106 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7107 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7109 auto actorA = Actor::New();
7111 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7113 stage.Remove(actorA);
7114 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7116 signalReceived = false;
7117 auto actorB = Actor::New();
7119 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7121 stage.Remove(actorB);
7122 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7127 int UtcDaliChildRemovedSignalN(void)
7129 TestApplication application;
7130 auto stage = application.GetScene();
7132 bool signalReceived = false;
7135 ChildRemovedSignalCheck signal(signalReceived, childActor);
7136 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7137 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7139 auto actorA = Actor::New();
7142 auto actorB = Actor::New();
7145 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7146 DALI_TEST_CHECK(!childActor);
7148 actorA.Remove(actorB);
7149 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7153 int UtcDaliChildMovedSignalP(void)
7155 TestApplication application;
7156 auto stage = application.GetScene();
7158 bool addedASignalReceived = false;
7159 bool removedASignalReceived = false;
7160 bool addedBSignalReceived = false;
7161 bool removedBSignalReceived = false;
7164 auto actorA = Actor::New();
7165 auto actorB = Actor::New();
7169 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
7170 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7171 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
7172 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7174 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7175 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7176 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7177 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7179 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7180 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7181 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7182 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7184 // Create a child of A
7186 auto child = Actor::New();
7189 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7190 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7191 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7192 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7193 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7196 addedASignalReceived = false;
7197 addedBSignalReceived = false;
7198 removedASignalReceived = false;
7199 removedBSignalReceived = false;
7201 actorB.Add(child); // Expect this child to be re-parented
7202 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7203 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7204 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7205 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7207 // Move child back to A:
7208 addedASignalReceived = false;
7209 addedBSignalReceived = false;
7210 removedASignalReceived = false;
7211 removedBSignalReceived = false;
7213 actorA.Add(child); // Expect this child to be re-parented
7214 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7215 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7216 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7217 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7222 int utcDaliActorCulled(void)
7224 TestApplication application;
7225 auto stage = application.GetScene();
7227 tet_infoline("Check that the actor is culled if the actor is out of the screen");
7229 Actor actor = Actor::New();
7230 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7232 Geometry geometry = CreateQuadGeometry();
7233 Shader shader = CreateShader();
7234 Renderer renderer = Renderer::New(geometry, shader);
7235 actor.AddRenderer(renderer);
7239 application.SendNotification();
7240 application.Render(0);
7242 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7244 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7245 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7247 // Connect NotifySignal
7248 bool propertyNotificationSignal(false);
7249 PropertyNotification source;
7250 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7251 notification.NotifySignal().Connect(&application, f);
7253 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7255 application.SendNotification();
7256 application.Render();
7258 application.SendNotification();
7260 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7262 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7263 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7264 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7269 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7271 TestApplication application;
7272 auto stage = application.GetScene();
7274 tet_infoline("Ensure we clear the screen when the last actor is removed");
7276 Actor actor = CreateRenderableActor();
7277 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7280 application.SendNotification();
7281 application.Render();
7283 auto& glAbstraction = application.GetGlAbstraction();
7284 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7288 application.SendNotification();
7289 application.Render();
7291 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7296 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7298 TestApplication application;
7299 auto stage = application.GetScene();
7301 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7303 Actor actor = CreateRenderableActor();
7304 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7307 application.SendNotification();
7308 application.Render();
7310 auto& glAbstraction = application.GetGlAbstraction();
7311 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7313 actor.SetProperty(Actor::Property::VISIBLE, false);
7315 application.SendNotification();
7316 application.Render();
7318 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7323 int utcDaliActorGetSizeAfterAnimation(void)
7325 TestApplication application;
7326 tet_infoline("Check the actor size before / after an animation is finished");
7328 Vector3 actorSize(100.0f, 100.0f, 0.0f);
7330 Actor actor = Actor::New();
7331 actor.SetProperty(Actor::Property::SIZE, actorSize);
7332 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7333 application.GetScene().Add(actor);
7335 // Size should be updated without rendering.
7336 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7337 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7339 application.SendNotification();
7340 application.Render();
7342 // Size and current size should be updated.
7343 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7344 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7345 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7346 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7347 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7349 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7350 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7351 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7352 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7353 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7356 actorSize = Vector3(200.0f, 200.0f, 0.0f);
7357 actor.SetProperty(Actor::Property::SIZE, actorSize);
7359 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7360 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7362 Vector3 targetValue(10.0f, 20.0f, 0.0f);
7364 Animation animation = Animation::New(1.0f);
7365 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7368 // Size should be updated without rendering.
7369 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7370 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7372 application.SendNotification();
7373 application.Render(1100); // After the animation
7375 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7376 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7377 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7378 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7379 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7381 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7382 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7383 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7384 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7385 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7387 targetValue.width = 50.0f;
7390 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
7393 application.SendNotification();
7394 application.Render(1100); // After the animation
7396 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7397 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7398 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7399 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7400 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7402 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7403 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7404 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7405 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7406 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7408 targetValue.height = 70.0f;
7411 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
7414 application.SendNotification();
7415 application.Render(1100); // After the animation
7417 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7418 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7419 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7420 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7421 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7423 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7424 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7425 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7426 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7427 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7429 Vector3 offset(10.0f, 20.0f, 0.0f);
7432 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
7435 application.SendNotification();
7436 application.Render(1100); // After the animation
7438 targetValue += offset;
7440 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7441 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7442 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7443 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7444 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7446 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7447 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7448 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7449 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7450 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7452 offset.width = 20.0f;
7455 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
7458 application.SendNotification();
7459 application.Render(1100); // After the animation
7461 targetValue.width += offset.width;
7463 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7464 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7465 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7466 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7467 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7469 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7470 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7471 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7472 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7473 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7475 offset.height = 10.0f;
7478 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
7481 application.SendNotification();
7482 application.Render(1100); // After the animation
7484 targetValue.height += offset.height;
7486 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7487 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7488 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7489 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7490 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7492 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7493 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7494 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7495 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7496 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7499 actorSize = Vector3(300.0f, 300.0f, 0.0f);
7501 actor.SetProperty(Actor::Property::SIZE, actorSize);
7503 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7504 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7506 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7507 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7509 application.SendNotification();
7510 application.Render();
7512 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7513 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7515 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7516 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7521 int utcDaliActorPartialUpdate(void)
7523 TestApplication application(
7524 TestApplication::DEFAULT_SURFACE_WIDTH,
7525 TestApplication::DEFAULT_SURFACE_HEIGHT,
7526 TestApplication::DEFAULT_HORIZONTAL_DPI,
7527 TestApplication::DEFAULT_VERTICAL_DPI,
7531 tet_infoline("Check the damaged area");
7533 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7535 std::vector<Rect<int>> damagedRects;
7536 Rect<int> clippingRect;
7537 application.SendNotification();
7538 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7540 // First render pass, nothing to render, adaptor would just do swap buffer.
7541 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7542 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7544 Actor actor = CreateRenderableActor();
7545 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7546 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7547 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7548 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7549 application.GetScene().Add(actor);
7551 application.SendNotification();
7553 // 1. Actor added, damaged rect is added size of actor
7554 damagedRects.clear();
7555 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7556 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7559 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7560 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7561 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7562 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7563 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7564 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7565 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7568 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7569 application.SendNotification();
7571 damagedRects.clear();
7572 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7573 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7576 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7577 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7578 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7579 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7580 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7581 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7582 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7584 // 3. Set new position
7585 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7586 application.SendNotification();
7588 damagedRects.clear();
7589 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7590 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7593 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7594 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7595 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7596 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7597 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7598 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7599 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7601 application.GetScene().Remove(actor);
7602 application.SendNotification();
7604 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7605 damagedRects.clear();
7606 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7607 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7609 clippingRect = damagedRects[0];
7610 clippingRect.Merge(damagedRects[1]);
7611 clippingRect.Merge(damagedRects[2]);
7613 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7614 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7615 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7617 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7618 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7619 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7620 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7621 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7626 int utcDaliActorPartialUpdateSetColor(void)
7628 TestApplication application(
7629 TestApplication::DEFAULT_SURFACE_WIDTH,
7630 TestApplication::DEFAULT_SURFACE_HEIGHT,
7631 TestApplication::DEFAULT_HORIZONTAL_DPI,
7632 TestApplication::DEFAULT_VERTICAL_DPI,
7636 tet_infoline("Check uniform update");
7638 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7640 std::vector<Rect<int>> damagedRects;
7641 Rect<int> clippingRect;
7642 application.SendNotification();
7643 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7645 // First render pass, nothing to render, adaptor would just do swap buffer.
7646 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7647 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7649 Actor actor = CreateRenderableActor();
7650 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7651 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7652 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7653 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7654 application.GetScene().Add(actor);
7656 application.SendNotification();
7658 // 1. Actor added, damaged rect is added size of actor
7659 damagedRects.clear();
7660 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7661 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7664 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7665 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7666 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7667 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7668 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7669 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7670 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7672 damagedRects.clear();
7673 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7675 damagedRects.clear();
7676 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7679 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
7680 application.SendNotification();
7682 damagedRects.clear();
7683 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7684 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7687 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7688 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7689 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7690 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7691 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7692 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7693 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7698 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
7699 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
7700 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
7701 const char* const RENDER_SHADOW_VERTEX_SOURCE =
7702 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
7703 " uniform mediump mat4 uLightCameraViewMatrix;\n"
7707 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
7708 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
7709 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
7712 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
7713 "uniform lowp vec4 uShadowColor;\n"
7716 " lowp float alpha;\n"
7717 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
7718 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
7721 int utcDaliActorPartialUpdateSetProperty(void)
7723 TestApplication application(
7724 TestApplication::DEFAULT_SURFACE_WIDTH,
7725 TestApplication::DEFAULT_SURFACE_HEIGHT,
7726 TestApplication::DEFAULT_HORIZONTAL_DPI,
7727 TestApplication::DEFAULT_VERTICAL_DPI,
7731 tet_infoline("Set/Update property with partial update");
7733 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7735 std::vector<Rect<int>> damagedRects;
7736 Rect<int> clippingRect;
7737 application.SendNotification();
7738 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7740 // First render pass, nothing to render, adaptor would just do swap buffer.
7741 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7742 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7744 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
7745 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
7746 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7747 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7748 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7749 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7750 application.GetScene().Add(actor);
7752 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
7754 damagedRects.clear();
7755 application.SendNotification();
7756 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7757 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7760 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7761 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7762 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7763 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7764 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7765 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7766 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7768 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
7769 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
7771 damagedRects.clear();
7772 application.SendNotification();
7773 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7774 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7776 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7777 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7778 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7779 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7780 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7781 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7783 damagedRects.clear();
7784 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7785 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7787 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7788 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7789 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7790 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7791 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7792 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7794 damagedRects.clear();
7795 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7796 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7801 int utcDaliActorPartialUpdateTwoActors(void)
7803 TestApplication application(
7804 TestApplication::DEFAULT_SURFACE_WIDTH,
7805 TestApplication::DEFAULT_SURFACE_HEIGHT,
7806 TestApplication::DEFAULT_HORIZONTAL_DPI,
7807 TestApplication::DEFAULT_VERTICAL_DPI,
7811 tet_infoline("Check the damaged rects with partial update and two actors");
7813 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7815 Actor actor = CreateRenderableActor();
7816 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
7817 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
7818 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7819 application.GetScene().Add(actor);
7821 Actor actor2 = CreateRenderableActor();
7822 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
7823 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
7824 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7825 application.GetScene().Add(actor2);
7827 application.SendNotification();
7828 std::vector<Rect<int>> damagedRects;
7829 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7831 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
7832 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
7833 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
7835 // in screen coordinates, adaptor would calculate it using previous frames information
7836 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
7837 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7839 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7840 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7841 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7842 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7847 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
7849 TestApplication application(
7850 TestApplication::DEFAULT_SURFACE_WIDTH,
7851 TestApplication::DEFAULT_SURFACE_HEIGHT,
7852 TestApplication::DEFAULT_HORIZONTAL_DPI,
7853 TestApplication::DEFAULT_VERTICAL_DPI,
7857 tet_infoline("Check the damaged rect with partial update and actor size hint");
7859 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7861 Actor actor = CreateRenderableActor();
7862 actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f));
7863 actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f));
7864 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0));
7865 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7866 application.GetScene().Add(actor);
7868 application.SendNotification();
7869 std::vector<Rect<int>> damagedRects;
7870 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7872 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7874 Rect<int> clippingRect = Rect<int>(0, 496, 160, 320);
7875 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7877 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7879 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7880 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7881 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7882 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7887 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
7889 TestApplication application;
7891 Actor actor = Actor::New();
7892 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
7893 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
7894 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
7895 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
7896 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
7897 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7898 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7899 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
7903 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
7905 TestApplication application;
7907 Actor actor = Actor::New();
7909 // Make sure setting invalid types does not cause a crash
7912 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
7913 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
7914 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
7915 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
7916 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
7917 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
7918 tet_result(TET_PASS);
7922 tet_result(TET_FAIL);
7927 int UtcDaliActorLowerBelowNegative(void)
7929 TestApplication application;
7930 Dali::Actor instance;
7934 instance.LowerBelow(arg1);
7935 DALI_TEST_CHECK(false); // Should not get here
7939 DALI_TEST_CHECK(true); // We expect an assert
7944 int UtcDaliActorRaiseAboveNegative(void)
7946 TestApplication application;
7947 Dali::Actor instance;
7951 instance.RaiseAbove(arg1);
7952 DALI_TEST_CHECK(false); // Should not get here
7956 DALI_TEST_CHECK(true); // We expect an assert
7961 int UtcDaliActorRaiseToTopNegative(void)
7963 TestApplication application;
7964 Dali::Actor instance;
7967 instance.RaiseToTop();
7968 DALI_TEST_CHECK(false); // Should not get here
7972 DALI_TEST_CHECK(true); // We expect an assert
7977 int UtcDaliActorAddRendererNegative(void)
7979 TestApplication application;
7980 Dali::Actor instance;
7983 Dali::Renderer arg1;
7984 instance.AddRenderer(arg1);
7985 DALI_TEST_CHECK(false); // Should not get here
7989 DALI_TEST_CHECK(true); // We expect an assert
7994 int UtcDaliActorTouchedSignalNegative(void)
7996 TestApplication application;
7997 Dali::Actor instance;
8000 instance.TouchedSignal();
8001 DALI_TEST_CHECK(false); // Should not get here
8005 DALI_TEST_CHECK(true); // We expect an assert
8010 int UtcDaliActorTranslateByNegative(void)
8012 TestApplication application;
8013 Dali::Actor instance;
8017 instance.TranslateBy(arg1);
8018 DALI_TEST_CHECK(false); // Should not get here
8022 DALI_TEST_CHECK(true); // We expect an assert
8027 int UtcDaliActorFindChildByIdNegative(void)
8029 TestApplication application;
8030 Dali::Actor instance;
8033 unsigned int arg1 = 0u;
8034 instance.FindChildById(arg1);
8035 DALI_TEST_CHECK(false); // Should not get here
8039 DALI_TEST_CHECK(true); // We expect an assert
8044 int UtcDaliActorGetRendererAtNegative(void)
8046 TestApplication application;
8047 Dali::Actor instance;
8050 unsigned int arg1 = 0u;
8051 instance.GetRendererAt(arg1);
8052 DALI_TEST_CHECK(false); // Should not get here
8056 DALI_TEST_CHECK(true); // We expect an assert
8061 int UtcDaliActorHoveredSignalNegative(void)
8063 TestApplication application;
8064 Dali::Actor instance;
8067 instance.HoveredSignal();
8068 DALI_TEST_CHECK(false); // Should not get here
8072 DALI_TEST_CHECK(true); // We expect an assert
8077 int UtcDaliActorLowerToBottomNegative(void)
8079 TestApplication application;
8080 Dali::Actor instance;
8083 instance.LowerToBottom();
8084 DALI_TEST_CHECK(false); // Should not get here
8088 DALI_TEST_CHECK(true); // We expect an assert
8093 int UtcDaliActorOnSceneSignalNegative(void)
8095 TestApplication application;
8096 Dali::Actor instance;
8099 instance.OnSceneSignal();
8100 DALI_TEST_CHECK(false); // Should not get here
8104 DALI_TEST_CHECK(true); // We expect an assert
8109 int UtcDaliActorOffSceneSignalNegative(void)
8111 TestApplication application;
8112 Dali::Actor instance;
8115 instance.OffSceneSignal();
8116 DALI_TEST_CHECK(false); // Should not get here
8120 DALI_TEST_CHECK(true); // We expect an assert
8125 int UtcDaliActorRemoveRendererNegative01(void)
8127 TestApplication application;
8128 Dali::Actor instance;
8131 unsigned int arg1 = 0u;
8132 instance.RemoveRenderer(arg1);
8133 DALI_TEST_CHECK(false); // Should not get here
8137 DALI_TEST_CHECK(true); // We expect an assert
8142 int UtcDaliActorRemoveRendererNegative02(void)
8144 TestApplication application;
8145 Dali::Actor instance;
8148 Dali::Renderer arg1;
8149 instance.RemoveRenderer(arg1);
8150 DALI_TEST_CHECK(false); // Should not get here
8154 DALI_TEST_CHECK(true); // We expect an assert
8159 int UtcDaliActorFindChildByNameNegative(void)
8161 TestApplication application;
8162 Dali::Actor instance;
8166 instance.FindChildByName(arg1);
8167 DALI_TEST_CHECK(false); // Should not get here
8171 DALI_TEST_CHECK(true); // We expect an assert
8176 int UtcDaliActorSetResizePolicyNegative(void)
8178 TestApplication application;
8179 Dali::Actor instance;
8182 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
8183 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
8184 instance.SetResizePolicy(arg1, arg2);
8185 DALI_TEST_CHECK(false); // Should not get here
8189 DALI_TEST_CHECK(true); // We expect an assert
8194 int UtcDaliActorOnRelayoutSignalNegative(void)
8196 TestApplication application;
8197 Dali::Actor instance;
8200 instance.OnRelayoutSignal();
8201 DALI_TEST_CHECK(false); // Should not get here
8205 DALI_TEST_CHECK(true); // We expect an assert
8210 int UtcDaliActorWheelEventSignalNegative(void)
8212 TestApplication application;
8213 Dali::Actor instance;
8216 instance.WheelEventSignal();
8217 DALI_TEST_CHECK(false); // Should not get here
8221 DALI_TEST_CHECK(true); // We expect an assert
8226 int UtcDaliActorGetHeightForWidthNegative(void)
8228 TestApplication application;
8229 Dali::Actor instance;
8233 instance.GetHeightForWidth(arg1);
8234 DALI_TEST_CHECK(false); // Should not get here
8238 DALI_TEST_CHECK(true); // We expect an assert
8243 int UtcDaliActorGetWidthForHeightNegative(void)
8245 TestApplication application;
8246 Dali::Actor instance;
8250 instance.GetWidthForHeight(arg1);
8251 DALI_TEST_CHECK(false); // Should not get here
8255 DALI_TEST_CHECK(true); // We expect an assert
8260 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
8262 TestApplication application;
8263 Dali::Actor instance;
8266 instance.LayoutDirectionChangedSignal();
8267 DALI_TEST_CHECK(false); // Should not get here
8271 DALI_TEST_CHECK(true); // We expect an assert
8276 int UtcDaliActorAddNegative(void)
8278 TestApplication application;
8279 Dali::Actor instance;
8284 DALI_TEST_CHECK(false); // Should not get here
8288 DALI_TEST_CHECK(true); // We expect an assert
8293 int UtcDaliActorLowerNegative(void)
8295 TestApplication application;
8296 Dali::Actor instance;
8300 DALI_TEST_CHECK(false); // Should not get here
8304 DALI_TEST_CHECK(true); // We expect an assert
8309 int UtcDaliActorRaiseNegative(void)
8311 TestApplication application;
8312 Dali::Actor instance;
8316 DALI_TEST_CHECK(false); // Should not get here
8320 DALI_TEST_CHECK(true); // We expect an assert
8325 int UtcDaliActorRemoveNegative(void)
8327 TestApplication application;
8328 Dali::Actor instance;
8332 instance.Remove(arg1);
8333 DALI_TEST_CHECK(false); // Should not get here
8337 DALI_TEST_CHECK(true); // We expect an assert
8342 int UtcDaliActorScaleByNegative(void)
8344 TestApplication application;
8345 Dali::Actor instance;
8349 instance.ScaleBy(arg1);
8350 DALI_TEST_CHECK(false); // Should not get here
8354 DALI_TEST_CHECK(true); // We expect an assert
8359 int UtcDaliActorGetLayerNegative(void)
8361 TestApplication application;
8362 Dali::Actor instance;
8365 instance.GetLayer();
8366 DALI_TEST_CHECK(false); // Should not get here
8370 DALI_TEST_CHECK(true); // We expect an assert
8375 int UtcDaliActorRotateByNegative01(void)
8377 TestApplication application;
8378 Dali::Actor instance;
8381 Dali::Quaternion arg1;
8382 instance.RotateBy(arg1);
8383 DALI_TEST_CHECK(false); // Should not get here
8387 DALI_TEST_CHECK(true); // We expect an assert
8392 int UtcDaliActorRotateByNegative02(void)
8394 TestApplication application;
8395 Dali::Actor instance;
8400 instance.RotateBy(arg1, arg2);
8401 DALI_TEST_CHECK(false); // Should not get here
8405 DALI_TEST_CHECK(true); // We expect an assert
8410 int UtcDaliActorUnparentNegative(void)
8412 TestApplication application;
8413 Dali::Actor instance;
8416 instance.Unparent();
8417 DALI_TEST_CHECK(false); // Should not get here
8421 DALI_TEST_CHECK(true); // We expect an assert
8426 int UtcDaliActorGetChildAtNegative(void)
8428 TestApplication application;
8429 Dali::Actor instance;
8432 unsigned int arg1 = 0u;
8433 instance.GetChildAt(arg1);
8434 DALI_TEST_CHECK(false); // Should not get here
8438 DALI_TEST_CHECK(true); // We expect an assert
8443 int UtcDaliActorGetChildCountNegative(void)
8445 TestApplication application;
8446 Dali::Actor instance;
8449 instance.GetChildCount();
8450 DALI_TEST_CHECK(false); // Should not get here
8454 DALI_TEST_CHECK(true); // We expect an assert
8459 int UtcDaliActorGetTargetSizeNegative(void)
8461 TestApplication application;
8462 Dali::Actor instance;
8465 instance.GetTargetSize();
8466 DALI_TEST_CHECK(false); // Should not get here
8470 DALI_TEST_CHECK(true); // We expect an assert
8475 int UtcDaliActorScreenToLocalNegative(void)
8477 TestApplication application;
8478 Dali::Actor instance;
8485 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
8486 DALI_TEST_CHECK(false); // Should not get here
8490 DALI_TEST_CHECK(true); // We expect an assert
8495 int UtcDaliActorGetNaturalSizeNegative(void)
8497 TestApplication application;
8498 Dali::Actor instance;
8501 instance.GetNaturalSize();
8502 DALI_TEST_CHECK(false); // Should not get here
8506 DALI_TEST_CHECK(true); // We expect an assert
8511 int UtcDaliActorGetRelayoutSizeNegative(void)
8513 TestApplication application;
8514 Dali::Actor instance;
8517 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
8518 instance.GetRelayoutSize(arg1);
8519 DALI_TEST_CHECK(false); // Should not get here
8523 DALI_TEST_CHECK(true); // We expect an assert
8528 int UtcDaliActorGetResizePolicyNegative(void)
8530 TestApplication application;
8531 Dali::Actor instance;
8534 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
8535 instance.GetResizePolicy(arg1);
8536 DALI_TEST_CHECK(false); // Should not get here
8540 DALI_TEST_CHECK(true); // We expect an assert
8545 int UtcDaliActorGetRendererCountNegative(void)
8547 TestApplication application;
8548 Dali::Actor instance;
8551 instance.GetRendererCount();
8552 DALI_TEST_CHECK(false); // Should not get here
8556 DALI_TEST_CHECK(true); // We expect an assert
8561 int UtcDaliActorGetParentNegative(void)
8563 TestApplication application;
8564 Dali::Actor instance;
8567 instance.GetParent();
8568 DALI_TEST_CHECK(false); // Should not get here
8572 DALI_TEST_CHECK(true); // We expect an assert