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 application.GetScene().Add(actor);
1301 // Start the animation
1304 application.SendNotification();
1305 application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1307 DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1312 int UtcDaliActorCalculateScreenExtents(void)
1314 TestApplication application;
1316 Actor actor = Actor::New();
1318 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1319 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1321 application.SendNotification();
1322 application.Render();
1324 auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f};
1325 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1326 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1327 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1328 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1329 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1331 application.GetScene().Remove(actor);
1335 // SetPosition(float x, float y)
1336 int UtcDaliActorSetPosition01(void)
1338 TestApplication application;
1340 Actor actor = Actor::New();
1342 // Set to random to start off with
1343 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1345 Vector3 vector(100.0f, 100.0f, 0.0f);
1347 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1349 actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1350 // flush the queue and render once
1351 application.SendNotification();
1352 application.Render();
1353 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1355 application.GetScene().Add(actor);
1356 actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1357 // flush the queue and render once
1358 application.SendNotification();
1359 application.Render();
1360 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1362 actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1363 actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1364 actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1365 // flush the queue and render once
1366 application.SendNotification();
1367 application.Render();
1368 DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1370 actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1371 // flush the queue and render once
1372 application.SendNotification();
1373 application.Render();
1374 DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1376 application.GetScene().Remove(actor);
1380 // SetPosition(float x, float y, float z)
1381 int UtcDaliActorSetPosition02(void)
1383 TestApplication application;
1385 Actor actor = Actor::New();
1387 // Set to random to start off with
1388 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1390 Vector3 vector(100.0f, 100.0f, 100.0f);
1392 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1394 actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1396 // flush the queue and render once
1397 application.SendNotification();
1398 application.Render();
1400 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1404 // SetPosition(Vector3 position)
1405 int UtcDaliActorSetPosition03(void)
1407 TestApplication application;
1409 Actor actor = Actor::New();
1411 // Set to random to start off with
1412 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1414 Vector3 vector(100.0f, 100.0f, 100.0f);
1416 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1418 actor.SetProperty(Actor::Property::POSITION, vector);
1420 // flush the queue and render once
1421 application.SendNotification();
1422 application.Render();
1424 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1428 int UtcDaliActorSetX(void)
1430 TestApplication application;
1432 Actor actor = Actor::New();
1434 Vector3 vector(100.0f, 0.0f, 0.0f);
1436 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1438 actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1440 // flush the queue and render once
1441 application.SendNotification();
1442 application.Render();
1444 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1448 int UtcDaliActorSetY(void)
1450 TestApplication application;
1452 Actor actor = Actor::New();
1454 Vector3 vector(0.0f, 100.0f, 0.0f);
1456 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1458 actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1460 // flush the queue and render once
1461 application.SendNotification();
1462 application.Render();
1464 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1468 int UtcDaliActorSetZ(void)
1470 TestApplication application;
1472 Actor actor = Actor::New();
1474 Vector3 vector(0.0f, 0.0f, 100.0f);
1476 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1478 actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1480 // flush the queue and render once
1481 application.SendNotification();
1482 application.Render();
1484 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1488 int UtcDaliActorSetPositionProperties(void)
1490 TestApplication application;
1492 Actor actor = Actor::New();
1494 Vector3 vector(0.7f, 0.8f, 0.9f);
1495 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1497 actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1498 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1499 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1501 // flush the queue and render once
1502 application.SendNotification();
1503 application.Render();
1505 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1506 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1507 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1508 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1509 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1511 actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1512 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1513 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1515 // flush the queue and render once
1516 application.SendNotification();
1517 application.Render();
1519 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1520 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1521 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1522 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1523 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1525 actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1526 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1527 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1529 // flush the queue and render once
1530 application.SendNotification();
1531 application.Render();
1533 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1534 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1535 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1536 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1537 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1542 int UtcDaliActorTranslateBy(void)
1544 TestApplication application;
1546 Actor actor = Actor::New();
1547 Vector3 vector(100.0f, 100.0f, 100.0f);
1549 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1551 actor.SetProperty(Actor::Property::POSITION, vector);
1553 // flush the queue and render once
1554 application.SendNotification();
1555 application.Render();
1557 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1559 actor.TranslateBy(vector);
1561 // flush the queue and render once
1562 application.SendNotification();
1563 application.Render();
1565 DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1569 int UtcDaliActorGetCurrentPosition(void)
1571 TestApplication application;
1573 Actor actor = Actor::New();
1574 Vector3 setVector(100.0f, 100.0f, 0.0f);
1575 actor.SetProperty(Actor::Property::POSITION, setVector);
1577 // flush the queue and render once
1578 application.SendNotification();
1579 application.Render();
1581 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1585 int UtcDaliActorGetCurrentWorldPosition(void)
1587 TestApplication application;
1589 Actor parent = Actor::New();
1590 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1591 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1592 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1593 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1594 application.GetScene().Add(parent);
1596 Actor child = Actor::New();
1597 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1598 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1599 Vector3 childPosition(6.0f, 6.0f, 6.0f);
1600 child.SetProperty(Actor::Property::POSITION, childPosition);
1603 // The actors should not have a world position yet
1604 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1605 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1607 application.SendNotification();
1608 application.Render(0);
1610 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1611 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1613 // The actors should have a world position now
1614 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1615 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1619 int UtcDaliActorSetInheritPosition(void)
1621 tet_infoline("Testing Actor::SetInheritPosition");
1622 TestApplication application;
1624 Actor parent = Actor::New();
1625 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1626 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1627 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1628 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1629 application.GetScene().Add(parent);
1631 Actor child = Actor::New();
1632 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1633 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1634 Vector3 childPosition(10.0f, 11.0f, 12.0f);
1635 child.SetProperty(Actor::Property::POSITION, childPosition);
1638 // The actors should not have a world position yet
1639 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1640 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1642 // first test default, which is to inherit position
1643 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1644 application.SendNotification();
1645 application.Render(0); // should only really call Update as Render is not required to update scene
1646 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1647 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1648 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1649 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1651 //Change child position
1652 Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1653 child.SetProperty(Actor::Property::POSITION, childOffset);
1655 // Use local position as world postion
1656 child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1657 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1658 application.SendNotification();
1659 application.Render(0); // should only really call Update as Render is not required to update scene
1660 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1661 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1662 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1663 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1665 //Change back to inherit position from parent
1666 child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1667 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1668 application.SendNotification();
1669 application.Render(0); // should only really call Update as Render is not required to update scene
1670 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1671 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1672 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1673 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1677 int UtcDaliActorInheritOpacity(void)
1679 tet_infoline("Testing Actor::Inherit Opacity");
1680 TestApplication application;
1682 Actor parent = Actor::New();
1683 Actor child = Actor::New();
1685 application.GetScene().Add(parent);
1687 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1688 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1690 // flush the queue and render once
1691 application.SendNotification();
1692 application.Render();
1694 parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1696 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1697 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1699 application.SendNotification();
1700 application.Render();
1702 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1703 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1704 DALI_TEST_EQUALS(parent.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.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1706 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1707 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1712 // SetOrientation(float angleRadians, Vector3 axis)
1713 int UtcDaliActorSetOrientation01(void)
1715 TestApplication application;
1717 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1718 Actor actor = Actor::New();
1720 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1722 // flush the queue and render once
1723 application.SendNotification();
1724 application.Render();
1726 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1730 int UtcDaliActorSetOrientation02(void)
1732 TestApplication application;
1734 Actor actor = Actor::New();
1736 Radian angle(0.785f);
1737 Vector3 axis(1.0f, 1.0f, 0.0f);
1739 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1740 Quaternion rotation(angle, axis);
1741 // flush the queue and render once
1742 application.SendNotification();
1743 application.Render();
1744 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1746 application.GetScene().Add(actor);
1747 actor.RotateBy(Degree(360), axis);
1748 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1750 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
1751 Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
1752 // flush the queue and render once
1753 application.SendNotification();
1754 application.Render();
1755 DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1757 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1758 // flush the queue and render once
1759 application.SendNotification();
1760 application.Render();
1761 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1763 application.GetScene().Remove(actor);
1767 // SetOrientation(float angleRadians, Vector3 axis)
1768 int UtcDaliActorSetOrientationProperty(void)
1770 TestApplication application;
1772 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1773 Actor actor = Actor::New();
1775 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1776 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1778 // flush the queue and render once
1779 application.SendNotification();
1780 application.Render();
1782 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1783 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1784 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1788 // RotateBy(float angleRadians, Vector3 axis)
1789 int UtcDaliActorRotateBy01(void)
1791 TestApplication application;
1793 Actor actor = Actor::New();
1795 Radian angle(M_PI * 0.25f);
1796 actor.RotateBy((angle), Vector3::ZAXIS);
1797 // flush the queue and render once
1798 application.SendNotification();
1799 application.Render();
1800 DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1802 application.GetScene().Add(actor);
1804 actor.RotateBy(angle, Vector3::ZAXIS);
1805 // flush the queue and render once
1806 application.SendNotification();
1807 application.Render();
1808 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1810 application.GetScene().Remove(actor);
1814 // RotateBy(Quaternion relativeRotation)
1815 int UtcDaliActorRotateBy02(void)
1817 TestApplication application;
1819 Actor actor = Actor::New();
1821 Radian angle(M_PI * 0.25f);
1822 Quaternion rotation(angle, Vector3::ZAXIS);
1823 actor.RotateBy(rotation);
1824 // flush the queue and render once
1825 application.SendNotification();
1826 application.Render();
1827 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1829 actor.RotateBy(rotation);
1830 // flush the queue and render once
1831 application.SendNotification();
1832 application.Render();
1833 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1837 int UtcDaliActorGetCurrentOrientation(void)
1839 TestApplication application;
1840 Actor actor = Actor::New();
1842 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1843 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1844 // flush the queue and render once
1845 application.SendNotification();
1846 application.Render();
1847 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1851 int UtcDaliActorGetCurrentWorldOrientation(void)
1853 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1854 TestApplication application;
1856 Actor parent = Actor::New();
1857 Radian rotationAngle(Degree(90.0f));
1858 Quaternion rotation(rotationAngle, Vector3::YAXIS);
1859 parent.SetProperty(Actor::Property::ORIENTATION, rotation);
1860 application.GetScene().Add(parent);
1862 Actor child = Actor::New();
1863 child.SetProperty(Actor::Property::ORIENTATION, rotation);
1866 // The actors should not have a world rotation yet
1867 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1868 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1870 application.SendNotification();
1871 application.Render(0);
1873 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1874 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1876 // The actors should have a world rotation now
1877 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1878 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
1880 // turn off child rotation inheritance
1881 child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
1882 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
1883 application.SendNotification();
1884 application.Render(0);
1886 // The actors should have a world rotation now
1887 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1888 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
1892 // SetScale(float scale)
1893 int UtcDaliActorSetScale01(void)
1895 TestApplication application;
1897 Actor actor = Actor::New();
1899 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1900 actor.SetProperty(Actor::Property::SCALE, 0.25f);
1902 Vector3 scale(10.0f, 10.0f, 10.0f);
1903 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1905 actor.SetProperty(Actor::Property::SCALE, scale.x);
1907 // flush the queue and render once
1908 application.SendNotification();
1909 application.Render();
1911 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1915 // SetScale(float scaleX, float scaleY, float scaleZ)
1916 int UtcDaliActorSetScale02(void)
1918 TestApplication application;
1919 Vector3 scale(10.0f, 10.0f, 10.0f);
1921 Actor actor = Actor::New();
1923 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1924 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1926 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1928 actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
1929 // flush the queue and render once
1930 application.SendNotification();
1931 application.Render();
1932 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1934 // add to stage and test
1935 application.GetScene().Add(actor);
1936 actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
1937 // flush the queue and render once
1938 application.SendNotification();
1939 application.Render();
1940 DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
1942 application.GetScene().Remove(actor);
1947 // SetScale(Vector3 scale)
1948 int UtcDaliActorSetScale03(void)
1950 TestApplication application;
1951 Vector3 scale(10.0f, 10.0f, 10.0f);
1953 Actor actor = Actor::New();
1955 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1956 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1958 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1960 actor.SetProperty(Actor::Property::SCALE, scale);
1962 // flush the queue and render once
1963 application.SendNotification();
1964 application.Render();
1966 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1970 int UtcDaliActorSetScaleIndividual(void)
1972 TestApplication application;
1974 Actor actor = Actor::New();
1976 Vector3 vector(0.7f, 0.8f, 0.9f);
1977 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
1979 actor.SetProperty(Actor::Property::SCALE_X, vector.x);
1980 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1982 // flush the queue and render once
1983 application.SendNotification();
1984 application.Render();
1986 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
1987 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1988 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1990 actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
1991 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
1993 // flush the queue and render once
1994 application.SendNotification();
1995 application.Render();
1997 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
1998 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
1999 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2001 actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2002 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2004 // flush the queue and render once
2005 application.SendNotification();
2006 application.Render();
2008 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2009 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2010 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2012 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2013 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2018 int UtcDaliActorScaleBy(void)
2020 TestApplication application;
2021 Actor actor = Actor::New();
2022 Vector3 vector(100.0f, 100.0f, 100.0f);
2024 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2026 actor.SetProperty(Actor::Property::SCALE, vector);
2028 // flush the queue and render once
2029 application.SendNotification();
2030 application.Render();
2032 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2034 actor.ScaleBy(vector);
2036 // flush the queue and render once
2037 application.SendNotification();
2038 application.Render();
2040 DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2044 int UtcDaliActorGetCurrentScale(void)
2046 TestApplication application;
2047 Vector3 scale(12.0f, 1.0f, 2.0f);
2049 Actor actor = Actor::New();
2051 actor.SetProperty(Actor::Property::SCALE, scale);
2053 // flush the queue and render once
2054 application.SendNotification();
2055 application.Render();
2057 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2061 int UtcDaliActorGetCurrentWorldScale(void)
2063 TestApplication application;
2065 Actor parent = Actor::New();
2066 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2067 parent.SetProperty(Actor::Property::SCALE, parentScale);
2068 application.GetScene().Add(parent);
2070 Actor child = Actor::New();
2071 Vector3 childScale(2.0f, 2.0f, 2.0f);
2072 child.SetProperty(Actor::Property::SCALE, childScale);
2075 // The actors should not have a scale yet
2076 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2077 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2079 // The actors should not have a world scale yet
2080 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2081 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2083 application.SendNotification();
2084 application.Render(0);
2086 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2087 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2089 // The actors should have a world scale now
2090 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2091 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2095 int UtcDaliActorInheritScale(void)
2097 tet_infoline("Testing Actor::SetInheritScale");
2098 TestApplication application;
2100 Actor parent = Actor::New();
2101 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2102 parent.SetProperty(Actor::Property::SCALE, parentScale);
2103 application.GetScene().Add(parent);
2105 Actor child = Actor::New();
2106 Vector3 childScale(2.0f, 2.0f, 2.0f);
2107 child.SetProperty(Actor::Property::SCALE, childScale);
2110 application.SendNotification();
2111 application.Render(0);
2113 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2114 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2116 child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2117 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2119 application.SendNotification();
2120 application.Render(0);
2122 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2126 int UtcDaliActorSetVisible(void)
2128 TestApplication application;
2130 Actor actor = Actor::New();
2131 actor.SetProperty(Actor::Property::VISIBLE, false);
2132 // flush the queue and render once
2133 application.SendNotification();
2134 application.Render();
2135 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2137 actor.SetProperty(Actor::Property::VISIBLE, true);
2138 // flush the queue and render once
2139 application.SendNotification();
2140 application.Render();
2141 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2143 // put actor on stage
2144 application.GetScene().Add(actor);
2145 actor.SetProperty(Actor::Property::VISIBLE, false);
2146 // flush the queue and render once
2147 application.SendNotification();
2148 application.Render();
2149 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2153 int UtcDaliActorIsVisible(void)
2155 TestApplication application;
2157 Actor actor = Actor::New();
2159 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2163 int UtcDaliActorSetOpacity(void)
2165 TestApplication application;
2167 Actor actor = Actor::New();
2168 // initial opacity is 1
2169 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2171 actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2172 // flush the queue and render once
2173 application.SendNotification();
2174 application.Render();
2175 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2177 // change opacity, actor is on stage to change is not immediate
2178 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2179 // flush the queue and render once
2180 application.SendNotification();
2181 application.Render();
2182 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2184 // put actor on stage
2185 application.GetScene().Add(actor);
2187 // change opacity, actor is on stage to change is not immediate
2188 actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2189 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2190 // flush the queue and render once
2191 application.SendNotification();
2192 application.Render();
2193 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2195 // change opacity, actor is on stage to change is not immediate
2196 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2197 // flush the queue and render once
2198 application.SendNotification();
2199 application.Render();
2200 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2204 int UtcDaliActorGetCurrentOpacity(void)
2206 TestApplication application;
2208 Actor actor = Actor::New();
2209 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2211 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2212 // flush the queue and render once
2213 application.SendNotification();
2214 application.Render();
2215 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2219 int UtcDaliActorSetSensitive(void)
2221 TestApplication application;
2222 Actor actor = Actor::New();
2224 bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2226 actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2228 DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2232 int UtcDaliActorIsSensitive(void)
2234 TestApplication application;
2235 Actor actor = Actor::New();
2236 actor.SetProperty(Actor::Property::SENSITIVE, false);
2238 DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2242 int UtcDaliActorSetColor(void)
2244 TestApplication application;
2245 Actor actor = Actor::New();
2246 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2248 DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2250 actor.SetProperty(Actor::Property::COLOR, color);
2251 // flush the queue and render once
2252 application.SendNotification();
2253 application.Render();
2254 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2256 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2257 // flush the queue and render once
2258 application.SendNotification();
2259 application.Render();
2260 DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2262 application.GetScene().Add(actor);
2263 actor.SetProperty(Actor::Property::COLOR, color);
2264 // flush the queue and render once
2265 application.SendNotification();
2266 application.Render();
2267 DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2269 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2270 // flush the queue and render once
2271 application.SendNotification();
2272 application.Render();
2273 // Actor color is not clamped
2274 DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2275 // world color is clamped
2276 DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2278 actor.SetProperty(Actor::Property::COLOR, color);
2279 DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2281 Vector3 newColor(1.0f, 0.0f, 0.0f);
2282 actor.SetProperty(Actor::Property::COLOR, newColor);
2283 DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2285 application.GetScene().Remove(actor);
2289 int UtcDaliActorSetColorIndividual(void)
2291 TestApplication application;
2293 Actor actor = Actor::New();
2295 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2296 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2298 actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2299 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2301 // flush the queue and render once
2302 application.SendNotification();
2303 application.Render();
2305 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2306 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2307 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2309 actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2310 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2312 // flush the queue and render once
2313 application.SendNotification();
2314 application.Render();
2316 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2317 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2318 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2320 actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2321 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2323 // flush the queue and render once
2324 application.SendNotification();
2325 application.Render();
2327 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2328 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2329 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2331 actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2332 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2334 // flush the queue and render once
2335 application.SendNotification();
2336 application.Render();
2338 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2339 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2340 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2342 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2343 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2345 actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2347 // flush the queue and render once
2348 application.SendNotification();
2349 application.Render();
2351 DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2356 int UtcDaliActorGetCurrentColor(void)
2358 TestApplication application;
2359 Actor actor = Actor::New();
2360 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2362 actor.SetProperty(Actor::Property::COLOR, color);
2363 // flush the queue and render once
2364 application.SendNotification();
2365 application.Render();
2366 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2370 int UtcDaliActorGetCurrentWorldColor(void)
2372 tet_infoline("Actor::GetCurrentWorldColor");
2373 TestApplication application;
2375 Actor parent = Actor::New();
2376 Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2377 parent.SetProperty(Actor::Property::COLOR, parentColor);
2378 application.GetScene().Add(parent);
2380 Actor child = Actor::New();
2381 Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2382 child.SetProperty(Actor::Property::COLOR, childColor);
2385 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2386 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2388 // verify the default color mode
2389 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2391 // The actors should not have a world color yet
2392 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2393 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2395 application.SendNotification();
2396 application.Render(0);
2398 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2399 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2401 // The actors should have a world color now
2402 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2403 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2406 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2407 application.SendNotification();
2408 application.Render(0);
2409 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2412 child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2413 application.SendNotification();
2414 application.Render(0);
2415 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2416 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2419 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2420 application.SendNotification();
2421 application.Render(0);
2422 Vector4 expectedColor(childColor);
2423 expectedColor.a *= parentColor.a;
2424 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2425 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2429 int UtcDaliActorSetColorMode(void)
2431 tet_infoline("Actor::SetColorMode");
2432 TestApplication application;
2433 Actor actor = Actor::New();
2434 Actor child = Actor::New();
2437 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2438 DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2440 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2441 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2443 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2444 DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2446 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2447 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2451 int UtcDaliActorScreenToLocal(void)
2453 TestApplication application;
2454 Actor actor = Actor::New();
2455 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2456 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2457 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2458 application.GetScene().Add(actor);
2460 // flush the queue and render once
2461 application.SendNotification();
2462 application.Render();
2467 application.SendNotification();
2468 application.Render();
2470 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2472 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2473 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2477 int UtcDaliActorSetLeaveRequired(void)
2479 TestApplication application;
2481 Actor actor = Actor::New();
2483 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2484 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2486 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2487 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2491 int UtcDaliActorGetLeaveRequired(void)
2493 TestApplication application;
2495 Actor actor = Actor::New();
2497 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2501 int UtcDaliActorSetKeyboardFocusable(void)
2503 TestApplication application;
2505 Actor actor = Actor::New();
2507 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2508 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2510 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2511 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2515 int UtcDaliActorIsKeyboardFocusable(void)
2517 TestApplication application;
2519 Actor actor = Actor::New();
2521 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2525 int UtcDaliActorRemoveConstraints(void)
2527 tet_infoline(" UtcDaliActorRemoveConstraints");
2528 TestApplication application;
2530 gTestConstraintCalled = false;
2532 Actor actor = Actor::New();
2534 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2536 actor.RemoveConstraints();
2538 DALI_TEST_CHECK(gTestConstraintCalled == false);
2540 application.GetScene().Add(actor);
2543 // flush the queue and render once
2544 application.SendNotification();
2545 application.Render();
2547 actor.RemoveConstraints();
2549 DALI_TEST_CHECK(gTestConstraintCalled == true);
2553 int UtcDaliActorRemoveConstraintTag(void)
2555 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2556 TestApplication application;
2558 Actor actor = Actor::New();
2560 // 1. Apply Constraint1 and Constraint2, and test...
2561 unsigned int result1 = 0u;
2562 unsigned int result2 = 0u;
2564 unsigned constraint1Tag = 1u;
2565 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2566 constraint1.SetTag(constraint1Tag);
2567 constraint1.Apply();
2569 unsigned constraint2Tag = 2u;
2570 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2571 constraint2.SetTag(constraint2Tag);
2572 constraint2.Apply();
2574 application.GetScene().Add(actor);
2575 // flush the queue and render once
2576 application.SendNotification();
2577 application.Render();
2579 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2580 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2582 // 2. Remove Constraint1 and test...
2585 actor.RemoveConstraints(constraint1Tag);
2586 // make color property dirty, which will trigger constraints to be reapplied.
2587 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2588 // flush the queue and render once
2589 application.SendNotification();
2590 application.Render();
2592 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2593 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2595 // 3. Re-Apply Constraint1 and test...
2598 constraint1.Apply();
2599 // make color property dirty, which will trigger constraints to be reapplied.
2600 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2601 // flush the queue and render once
2602 application.SendNotification();
2603 application.Render();
2605 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2606 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2608 // 2. Remove Constraint2 and test...
2611 actor.RemoveConstraints(constraint2Tag);
2612 // make color property dirty, which will trigger constraints to be reapplied.
2613 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2614 // flush the queue and render once
2615 application.SendNotification();
2616 application.Render();
2618 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2619 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2621 // 2. Remove Constraint1 as well and test...
2624 actor.RemoveConstraints(constraint1Tag);
2625 // make color property dirty, which will trigger constraints to be reapplied.
2626 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2627 // flush the queue and render once
2628 application.SendNotification();
2629 application.Render();
2631 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2632 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2636 int UtcDaliActorTouchedSignal(void)
2638 TestApplication application;
2640 ResetTouchCallbacks();
2642 // get the root layer
2643 Actor actor = application.GetScene().GetRootLayer();
2644 DALI_TEST_CHECK(gTouchCallBackCalled == false);
2646 application.SendNotification();
2647 application.Render();
2649 // connect to its touch signal
2650 actor.TouchedSignal().Connect(TestTouchCallback);
2652 // simulate a touch event in the middle of the screen
2653 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2654 Dali::Integration::Point point;
2655 point.SetDeviceId(1);
2656 point.SetState(PointState::DOWN);
2657 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2658 Dali::Integration::TouchEvent touchEvent;
2659 touchEvent.AddPoint(point);
2660 application.ProcessEvent(touchEvent);
2662 DALI_TEST_CHECK(gTouchCallBackCalled == true);
2666 int UtcDaliActorHoveredSignal(void)
2668 TestApplication application;
2670 gHoverCallBackCalled = false;
2672 // get the root layer
2673 Actor actor = application.GetScene().GetRootLayer();
2674 DALI_TEST_CHECK(gHoverCallBackCalled == false);
2676 application.SendNotification();
2677 application.Render();
2679 // connect to its hover signal
2680 actor.HoveredSignal().Connect(TestCallback3);
2682 // simulate a hover event in the middle of the screen
2683 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2684 Dali::Integration::Point point;
2685 point.SetDeviceId(1);
2686 point.SetState(PointState::MOTION);
2687 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2688 Dali::Integration::HoverEvent hoverEvent;
2689 hoverEvent.AddPoint(point);
2690 application.ProcessEvent(hoverEvent);
2692 DALI_TEST_CHECK(gHoverCallBackCalled == true);
2696 int UtcDaliActorOnOffSceneSignal(void)
2698 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2700 TestApplication application;
2703 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2704 gActorNamesOnOffScene.clear();
2706 Actor parent = Actor::New();
2707 parent.SetProperty(Actor::Property::NAME, "parent");
2708 parent.OnSceneSignal().Connect(OnSceneCallback);
2709 parent.OffSceneSignal().Connect(OffSceneCallback);
2711 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2712 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2714 // add parent to the scene
2715 application.GetScene().Add(parent);
2716 // onstage emitted, offstage not
2717 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2718 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2719 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2721 // test adding a child, should get onstage emitted
2723 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2724 gActorNamesOnOffScene.clear();
2726 Actor child = Actor::New();
2727 child.SetProperty(Actor::Property::NAME, "child");
2728 child.OnSceneSignal().Connect(OnSceneCallback);
2729 child.OffSceneSignal().Connect(OffSceneCallback);
2730 parent.Add(child); // add child
2731 // onscene emitted, offscene not
2732 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2733 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2734 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2736 // test removing parent from the scene
2738 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2739 gActorNamesOnOffScene.clear();
2741 application.GetScene().Remove(parent);
2742 // onscene not emitted, offscene is
2743 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2744 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2745 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2746 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2748 // test adding parent back to the scene
2750 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2751 gActorNamesOnOffScene.clear();
2753 application.GetScene().Add(parent);
2754 // onscene emitted, offscene not
2755 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2756 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2757 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2758 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2760 // test removing child
2762 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2763 gActorNamesOnOffScene.clear();
2765 parent.Remove(child);
2766 // onscene not emitted, offscene is
2767 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2768 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2769 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2771 // test removing parent
2773 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2774 gActorNamesOnOffScene.clear();
2776 application.GetScene().Remove(parent);
2777 // onscene not emitted, offscene is
2778 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2779 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2780 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2784 int UtcDaliActorFindChildByName(void)
2786 tet_infoline("Testing Dali::Actor::FindChildByName()");
2787 TestApplication application;
2789 Actor parent = Actor::New();
2790 parent.SetProperty(Actor::Property::NAME, "parent");
2791 Actor first = Actor::New();
2792 first.SetProperty(Actor::Property::NAME, "first");
2793 Actor second = Actor::New();
2794 second.SetProperty(Actor::Property::NAME, "second");
2799 Actor found = parent.FindChildByName("foo");
2800 DALI_TEST_CHECK(!found);
2802 found = parent.FindChildByName("parent");
2803 DALI_TEST_CHECK(found == parent);
2805 found = parent.FindChildByName("first");
2806 DALI_TEST_CHECK(found == first);
2808 found = parent.FindChildByName("second");
2809 DALI_TEST_CHECK(found == second);
2813 int UtcDaliActorFindChildById(void)
2815 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2816 TestApplication application;
2818 Actor parent = Actor::New();
2819 Actor first = Actor::New();
2820 Actor second = Actor::New();
2825 Actor found = parent.FindChildById(100000);
2826 DALI_TEST_CHECK(!found);
2828 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2829 DALI_TEST_CHECK(found == parent);
2831 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2832 DALI_TEST_CHECK(found == first);
2834 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2835 DALI_TEST_CHECK(found == second);
2839 int UtcDaliActorHitTest(void)
2844 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2846 mTouchPoint(touchPoint),
2852 Vector2 mTouchPoint;
2856 TestApplication application;
2857 tet_infoline(" UtcDaliActorHitTest");
2859 // Fill a vector with different hit tests.
2860 struct HitTestData* hitTestData[] = {
2861 // scale touch point result
2862 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
2863 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2864 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.
2865 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2866 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.
2870 // get the root layer
2871 Actor actor = Actor::New();
2872 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2873 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2875 application.GetScene().Add(actor);
2877 ResetTouchCallbacks();
2879 unsigned int index = 0;
2880 while(NULL != hitTestData[index])
2882 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2883 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2885 // flush the queue and render once
2886 application.SendNotification();
2887 application.Render();
2889 DALI_TEST_CHECK(!gTouchCallBackCalled);
2891 // connect to its touch signal
2892 actor.TouchedSignal().Connect(TestTouchCallback);
2894 Dali::Integration::Point point;
2895 point.SetState(PointState::DOWN);
2896 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2897 Dali::Integration::TouchEvent event;
2898 event.AddPoint(point);
2900 // flush the queue and render once
2901 application.SendNotification();
2902 application.Render();
2903 application.ProcessEvent(event);
2905 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
2907 if(gTouchCallBackCalled != hitTestData[index]->mResult)
2908 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2909 hitTestData[index]->mScale.x,
2910 hitTestData[index]->mScale.y,
2911 hitTestData[index]->mScale.z,
2912 hitTestData[index]->mTouchPoint.x,
2913 hitTestData[index]->mTouchPoint.y,
2914 hitTestData[index]->mResult);
2916 ResetTouchCallbacks();
2922 int UtcDaliActorSetDrawMode(void)
2924 TestApplication application;
2925 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2927 Actor a = Actor::New();
2929 application.GetScene().Add(a);
2930 application.SendNotification();
2931 application.Render(0);
2932 application.SendNotification();
2933 application.Render(1);
2935 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
2937 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2938 application.SendNotification();
2939 application.Render(1);
2941 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
2943 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
2944 application.SendNotification();
2945 application.Render(1);
2947 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
2951 int UtcDaliActorSetDrawModeOverlayRender(void)
2953 TestApplication application;
2954 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2956 application.SendNotification();
2957 application.Render(1);
2959 std::vector<GLuint> ids;
2960 ids.push_back(8); // first rendered actor
2961 ids.push_back(9); // second rendered actor
2962 ids.push_back(10); // third rendered actor
2963 application.GetGlAbstraction().SetNextTextureIds(ids);
2965 Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2966 Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2967 Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2968 Actor a = CreateRenderableActor(imageA);
2969 Actor b = CreateRenderableActor(imageB);
2970 Actor c = CreateRenderableActor(imageC);
2972 application.SendNotification();
2973 application.Render(1);
2975 //Textures are bound when first created. Clear bound textures vector
2976 application.GetGlAbstraction().ClearBoundTextures();
2978 // Render a,b,c as regular non-overlays. so order will be:
2982 application.GetScene().Add(a);
2983 application.GetScene().Add(b);
2984 application.GetScene().Add(c);
2986 application.SendNotification();
2987 application.Render(1);
2989 // Should be 3 textures changes.
2990 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
2991 typedef std::vector<GLuint>::size_type TextureSize;
2992 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
2993 if(boundTextures.size() == 3)
2995 DALI_TEST_CHECK(boundTextures[0] == 8u);
2996 DALI_TEST_CHECK(boundTextures[1] == 9u);
2997 DALI_TEST_CHECK(boundTextures[2] == 10u);
3000 // Now texture ids have been set, we can monitor their render order.
3001 // render a as an overlay (last), so order will be:
3005 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3006 application.GetGlAbstraction().ClearBoundTextures();
3008 application.SendNotification();
3009 application.Render(1);
3011 // Should be 3 texture changes.
3012 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3013 if(boundTextures.size() == 3)
3015 DALI_TEST_CHECK(boundTextures[0] == 9u);
3016 DALI_TEST_CHECK(boundTextures[1] == 10u);
3017 DALI_TEST_CHECK(boundTextures[2] == 8u);
3022 int UtcDaliActorGetCurrentWorldMatrix(void)
3024 TestApplication application;
3025 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3027 Actor parent = Actor::New();
3028 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3029 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3030 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3031 Radian rotationAngle(Degree(85.0f));
3032 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3033 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3034 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3035 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3036 parent.SetProperty(Actor::Property::SCALE, parentScale);
3037 application.GetScene().Add(parent);
3039 Actor child = Actor::New();
3040 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3041 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3042 Radian childRotationAngle(Degree(23.0f));
3043 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3044 Vector3 childScale(2.0f, 2.0f, 2.0f);
3045 child.SetProperty(Actor::Property::POSITION, childPosition);
3046 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3047 child.SetProperty(Actor::Property::SCALE, childScale);
3050 application.SendNotification();
3051 application.Render(0);
3052 application.Render();
3053 application.SendNotification();
3055 Matrix parentMatrix(false);
3056 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3058 Matrix childMatrix(false);
3059 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3061 //Child matrix should be the composition of child and parent
3062 Matrix childWorldMatrix(false);
3063 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3065 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3066 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3070 int UtcDaliActorConstrainedToWorldMatrix(void)
3072 TestApplication application;
3073 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3075 Actor parent = Actor::New();
3076 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3077 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3078 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3079 Radian rotationAngle(Degree(85.0f));
3080 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3081 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3082 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3083 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3084 parent.SetProperty(Actor::Property::SCALE, parentScale);
3085 application.GetScene().Add(parent);
3087 Actor child = Actor::New();
3088 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3089 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3090 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3091 posConstraint.Apply();
3093 application.GetScene().Add(child);
3095 application.SendNotification();
3096 application.Render(0);
3097 application.Render();
3098 application.SendNotification();
3100 Matrix parentMatrix(false);
3101 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3103 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3104 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3108 int UtcDaliActorConstrainedToOrientation(void)
3110 TestApplication application;
3111 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3113 Actor parent = Actor::New();
3114 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3115 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3116 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3117 Radian rotationAngle(Degree(85.0f));
3118 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3119 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3120 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3121 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3122 parent.SetProperty(Actor::Property::SCALE, parentScale);
3123 application.GetScene().Add(parent);
3125 Actor child = Actor::New();
3126 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3127 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3128 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3129 posConstraint.Apply();
3131 application.GetScene().Add(child);
3133 application.SendNotification();
3134 application.Render(0);
3135 application.Render();
3136 application.SendNotification();
3138 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3142 int UtcDaliActorConstrainedToOpacity(void)
3144 TestApplication application;
3145 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3147 Actor parent = Actor::New();
3148 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3149 application.GetScene().Add(parent);
3151 Actor child = Actor::New();
3152 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3153 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3154 opacityConstraint.Apply();
3156 application.GetScene().Add(child);
3158 application.SendNotification();
3159 application.Render(0);
3160 application.Render();
3161 application.SendNotification();
3163 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3165 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3167 application.SendNotification();
3168 application.Render(0);
3169 application.Render();
3170 application.SendNotification();
3172 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3177 int UtcDaliActorUnparent(void)
3179 TestApplication application;
3180 tet_infoline(" UtcDaliActorUnparent");
3182 Actor parent = Actor::New();
3183 application.GetScene().Add(parent);
3185 Actor child = Actor::New();
3187 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3188 DALI_TEST_CHECK(!child.GetParent());
3190 // Test that calling Unparent with no parent is a NOOP
3193 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3194 DALI_TEST_CHECK(!child.GetParent());
3196 // Test that Unparent works
3199 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3200 DALI_TEST_CHECK(parent == child.GetParent());
3204 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3205 DALI_TEST_CHECK(!child.GetParent());
3207 // Test that UnparentAndReset works
3210 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3211 DALI_TEST_CHECK(parent == child.GetParent());
3213 UnparentAndReset(child);
3215 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3216 DALI_TEST_CHECK(!child);
3218 // Test that UnparentAndReset is a NOOP with empty handle
3219 UnparentAndReset(child);
3221 DALI_TEST_CHECK(!child);
3225 int UtcDaliActorGetChildAt(void)
3227 TestApplication application;
3228 tet_infoline(" UtcDaliActorGetChildAt");
3230 Actor parent = Actor::New();
3231 application.GetScene().Add(parent);
3233 Actor child0 = Actor::New();
3236 Actor child1 = Actor::New();
3239 Actor child2 = Actor::New();
3242 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3243 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3244 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3248 int UtcDaliActorSetGetOverlay(void)
3250 TestApplication application;
3251 tet_infoline(" UtcDaliActorSetGetOverlay");
3253 Actor parent = Actor::New();
3254 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3255 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3259 int UtcDaliActorCreateDestroy(void)
3261 Actor* actor = new Actor;
3262 DALI_TEST_CHECK(actor);
3269 struct PropertyStringIndex
3271 const char* const name;
3272 const Property::Index index;
3273 const Property::Type type;
3276 const PropertyStringIndex PROPERTY_TABLE[] =
3278 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3279 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3280 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3281 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3282 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3283 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3284 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3285 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3286 {"size", Actor::Property::SIZE, Property::VECTOR3},
3287 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3288 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3289 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3290 {"position", Actor::Property::POSITION, Property::VECTOR3},
3291 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3292 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3293 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3294 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3295 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3296 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3297 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3298 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3299 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3300 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3301 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3302 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3303 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3304 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3305 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3306 {"color", Actor::Property::COLOR, Property::VECTOR4},
3307 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3308 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3309 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3310 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3311 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3312 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3313 {"name", Actor::Property::NAME, Property::STRING},
3314 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3315 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3316 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3317 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3318 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3319 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3320 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3321 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3322 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3323 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3324 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3325 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3326 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3327 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3328 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3329 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3330 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3331 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3333 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3334 } // unnamed namespace
3336 int UtcDaliActorProperties(void)
3338 TestApplication application;
3340 Actor actor = Actor::New();
3342 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3344 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3345 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3346 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3347 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3352 int UtcDaliRelayoutProperties_ResizePolicies(void)
3354 TestApplication application;
3356 Actor actor = Actor::New();
3359 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3360 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3362 // Set resize policy for all dimensions
3363 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3364 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3366 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3369 // Set individual dimensions
3370 const char* const widthPolicy = "FILL_TO_PARENT";
3371 const char* const heightPolicy = "FIXED";
3373 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3374 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3376 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3377 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3379 // Set individual dimensions using enums
3380 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3381 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3383 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3384 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3386 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3387 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3392 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3394 TestApplication application;
3396 Actor actor = Actor::New();
3399 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3401 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3402 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3403 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3406 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3407 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3409 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3410 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3412 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3413 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3418 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3420 TestApplication application;
3422 Actor actor = Actor::New();
3425 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3426 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3428 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3429 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3430 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3433 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3435 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3436 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3441 int UtcDaliRelayoutProperties_DimensionDependency(void)
3443 TestApplication application;
3445 Actor actor = Actor::New();
3448 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3449 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3452 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3453 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3455 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3456 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3458 // Test setting another resize policy
3459 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3460 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3465 int UtcDaliRelayoutProperties_Padding(void)
3467 TestApplication application;
3469 Actor actor = Actor::New();
3472 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3475 actor.SetProperty(Actor::Property::PADDING, padding);
3476 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3478 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3483 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3485 TestApplication application;
3487 Actor actor = Actor::New();
3490 Vector2 minSize(1.0f, 2.0f);
3492 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3493 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3495 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3497 Vector2 maxSize(3.0f, 4.0f);
3499 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3500 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3502 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3507 int UtcDaliActorGetHeightForWidth(void)
3509 TestApplication application;
3511 Actor actor = Actor::New();
3513 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3518 int UtcDaliActorGetWidthForHeight(void)
3520 TestApplication application;
3522 Actor actor = Actor::New();
3524 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3529 int UtcDaliActorGetRelayoutSize(void)
3531 TestApplication application;
3533 Actor actor = Actor::New();
3535 // Add actor to stage
3536 application.GetScene().Add(actor);
3538 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3540 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3541 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3543 // Flush the queue and render once
3544 application.SendNotification();
3545 application.Render();
3547 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3552 int UtcDaliActorSetPadding(void)
3554 TestApplication application;
3556 Actor actor = Actor::New();
3559 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3561 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3562 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3563 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3564 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3566 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3567 actor.SetProperty(Actor::Property::PADDING, padding2);
3569 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3571 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3572 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3573 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3574 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3579 int UtcDaliActorSetMinimumSize(void)
3581 TestApplication application;
3583 Actor actor = Actor::New();
3585 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3587 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3588 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3590 Vector2 size2(1.0f, 2.0f);
3591 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3593 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3595 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3596 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3601 int UtcDaliActorSetMaximumSize(void)
3603 TestApplication application;
3605 Actor actor = Actor::New();
3607 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3609 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3610 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3612 Vector2 size2(1.0f, 2.0f);
3613 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3615 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3617 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3618 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3623 int UtcDaliActorOnRelayoutSignal(void)
3625 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3627 TestApplication application;
3630 gOnRelayoutCallBackCalled = false;
3631 gActorNamesRelayout.clear();
3633 Actor actor = Actor::New();
3634 actor.SetProperty(Actor::Property::NAME, "actor");
3635 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3638 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3640 // Add actor to stage
3641 application.GetScene().Add(actor);
3643 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3644 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3646 // Flush the queue and render once
3647 application.SendNotification();
3648 application.Render();
3650 // OnRelayout emitted
3651 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3652 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3657 int UtcDaliActorGetHierachyDepth(void)
3659 TestApplication application;
3660 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3662 /* Build tree of actors:
3672 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3674 Integration::Scene stage(application.GetScene());
3676 Actor actorA = Actor::New();
3677 Actor actorB = Actor::New();
3678 Actor actorC = Actor::New();
3679 Actor actorD = Actor::New();
3680 Actor actorE = Actor::New();
3681 Actor actorF = Actor::New();
3683 //Test that root actor has depth equal 0
3684 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3686 //Test actors return depth -1 when not connected to the tree
3687 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3688 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3689 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3690 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3691 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3692 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3694 //Create the hierarchy
3702 //Test actors return correct depth
3703 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3704 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3705 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3706 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3707 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3708 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3710 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3711 actorA.Remove(actorB);
3713 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3714 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3715 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3717 //Removing actorA from the stage. All actors should have depth equal -1
3718 stage.Remove(actorA);
3720 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3721 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3722 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3723 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3724 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3725 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3730 int UtcDaliActorAnchorPointPropertyAsString(void)
3732 TestApplication application;
3734 Actor actor = Actor::New();
3736 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3737 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3739 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3740 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3742 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3743 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3745 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3746 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3748 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3749 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3751 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3752 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3754 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3755 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3757 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3758 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3760 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3761 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3763 // Invalid should not change anything
3764 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3765 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3770 int UtcDaliActorParentOriginPropertyAsString(void)
3772 TestApplication application;
3774 Actor actor = Actor::New();
3776 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3777 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3779 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3780 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3782 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3783 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3785 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3786 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3788 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3789 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3791 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3792 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3794 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3795 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3797 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3798 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3800 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3801 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3803 // Invalid should not change anything
3804 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3805 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3810 int UtcDaliActorColorModePropertyAsString(void)
3812 TestApplication application;
3814 Actor actor = Actor::New();
3816 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3817 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3819 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3820 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3822 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3823 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3825 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3826 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3828 // Invalid should not change anything
3829 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3830 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3835 int UtcDaliActorDrawModePropertyAsString(void)
3837 TestApplication application;
3839 Actor actor = Actor::New();
3841 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3842 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3844 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3845 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3847 // Invalid should not change anything
3848 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3849 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3854 int UtcDaliActorColorModePropertyAsEnum(void)
3856 TestApplication application;
3858 Actor actor = Actor::New();
3860 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3861 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3863 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3864 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3866 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3867 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3869 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3870 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3875 int UtcDaliActorDrawModePropertyAsEnum(void)
3877 TestApplication application;
3879 Actor actor = Actor::New();
3881 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3882 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3884 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3885 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3890 int UtcDaliActorAddRendererP(void)
3892 tet_infoline("Testing Actor::AddRenderer");
3893 TestApplication application;
3895 Actor actor = Actor::New();
3897 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3899 Geometry geometry = CreateQuadGeometry();
3900 Shader shader = CreateShader();
3901 Renderer renderer = Renderer::New(geometry, shader);
3903 actor.AddRenderer(renderer);
3904 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3905 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
3910 int UtcDaliActorAddRendererN01(void)
3912 tet_infoline("Testing Actor::AddRenderer");
3913 TestApplication application;
3915 Actor actor = Actor::New();
3921 actor.AddRenderer(renderer);
3922 tet_printf("Assertion test failed - no Exception\n");
3923 tet_result(TET_FAIL);
3925 catch(Dali::DaliException& e)
3927 DALI_TEST_PRINT_ASSERT(e);
3928 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3929 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3933 tet_printf("Assertion test failed - wrong Exception\n");
3934 tet_result(TET_FAIL);
3940 int UtcDaliActorAddRendererN02(void)
3942 tet_infoline("UtcDaliActorAddRendererN02");
3948 TestApplication application;
3950 Geometry geometry = CreateQuadGeometry();
3951 Shader shader = CreateShader();
3952 renderer = Renderer::New(geometry, shader);
3954 actor = Actor::New();
3957 // try illegal AddRenderer
3960 actor.AddRenderer(renderer);
3961 tet_printf("Assertion test failed - no Exception\n");
3962 tet_result(TET_FAIL);
3964 catch(Dali::DaliException& e)
3966 DALI_TEST_PRINT_ASSERT(e);
3967 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
3971 tet_printf("Assertion test failed - wrong Exception\n");
3972 tet_result(TET_FAIL);
3978 int UtcDaliActorAddRendererOnScene(void)
3980 tet_infoline("Testing Actor::AddRenderer");
3981 TestApplication application;
3983 Actor actor = Actor::New();
3984 application.GetScene().Add(actor);
3986 application.SendNotification();
3987 application.Render(0);
3989 Geometry geometry = CreateQuadGeometry();
3990 Shader shader = CreateShader();
3991 Renderer renderer = Renderer::New(geometry, shader);
3993 application.SendNotification();
3994 application.Render(0);
3998 actor.AddRenderer(renderer);
3999 tet_result(TET_PASS);
4003 tet_result(TET_FAIL);
4009 int UtcDaliActorRemoveRendererP1(void)
4011 tet_infoline("Testing Actor::RemoveRenderer");
4012 TestApplication application;
4014 Actor actor = Actor::New();
4016 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4019 Geometry geometry = CreateQuadGeometry();
4020 Shader shader = CreateShader();
4021 Renderer renderer = Renderer::New(geometry, shader);
4023 actor.AddRenderer(renderer);
4024 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4025 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4027 application.SendNotification();
4028 application.Render();
4032 Renderer renderer = actor.GetRendererAt(0);
4033 actor.RemoveRenderer(renderer);
4034 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4036 application.SendNotification();
4037 application.Render();
4040 // Call one final time to ensure that the renderer is actually removed after
4041 // the handle goes out of scope, and excercises the deletion code path in
4042 // scene graph and render.
4043 application.SendNotification();
4044 application.Render();
4049 int UtcDaliActorRemoveRendererP2(void)
4051 tet_infoline("Testing Actor::RemoveRenderer");
4052 TestApplication application;
4054 Actor actor = Actor::New();
4056 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4058 Geometry geometry = CreateQuadGeometry();
4059 Shader shader = CreateShader();
4060 Renderer renderer = Renderer::New(geometry, shader);
4062 actor.AddRenderer(renderer);
4063 application.SendNotification();
4064 application.Render();
4066 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4067 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4069 actor.RemoveRenderer(0);
4070 application.SendNotification();
4071 application.Render();
4073 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4075 // Shut down whilst holding onto the renderer handle.
4079 int UtcDaliActorRemoveRendererN(void)
4081 tet_infoline("Testing Actor::RemoveRenderer");
4082 TestApplication application;
4084 Actor actor = Actor::New();
4086 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4088 Geometry geometry = CreateQuadGeometry();
4089 Shader shader = CreateShader();
4090 Renderer renderer = Renderer::New(geometry, shader);
4092 actor.AddRenderer(renderer);
4093 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4094 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4096 actor.RemoveRenderer(10);
4097 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4098 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4103 // Clipping test helper functions:
4104 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4106 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4107 Actor actor = CreateRenderableActor(image);
4109 // Setup dimensions and position so actor is not skipped by culling.
4110 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4111 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4112 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4113 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4118 Actor CreateActorWithContent16x16()
4120 return CreateActorWithContent(16, 16);
4123 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4125 enabledDisableTrace.Reset();
4126 stencilTrace.Reset();
4127 enabledDisableTrace.Enable(true);
4128 stencilTrace.Enable(true);
4130 application.SendNotification();
4131 application.Render();
4133 enabledDisableTrace.Enable(false);
4134 stencilTrace.Enable(false);
4137 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4139 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4141 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4142 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4143 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4144 DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4147 int UtcDaliActorPropertyClippingP(void)
4149 // This test checks the clippingMode property.
4150 tet_infoline("Testing Actor::Property::ClippingMode: P");
4151 TestApplication application;
4153 Actor actor = Actor::New();
4155 // Check default clippingEnabled value.
4156 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4159 bool getValueResult = getValue.Get(value);
4160 DALI_TEST_CHECK(getValueResult);
4164 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4167 // Check setting the property to the stencil mode.
4168 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4170 // Check the new value was set.
4171 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4172 getValueResult = getValue.Get(value);
4173 DALI_TEST_CHECK(getValueResult);
4177 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4180 // Check setting the property to the scissor mode.
4181 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4183 // Check the new value was set.
4184 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4185 getValueResult = getValue.Get(value);
4186 DALI_TEST_CHECK(getValueResult);
4190 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4195 int UtcDaliActorPropertyClippingN(void)
4197 // Negative test case for Clipping.
4198 tet_infoline("Testing Actor::Property::ClippingMode: N");
4199 TestApplication application;
4201 Actor actor = Actor::New();
4203 // Check default clippingEnabled value.
4204 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4207 bool getValueResult = getValue.Get(value);
4208 DALI_TEST_CHECK(getValueResult);
4212 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4215 // Check setting an invalid property value won't change the current property value.
4216 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4218 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4219 getValueResult = getValue.Get(value);
4220 DALI_TEST_CHECK(getValueResult);
4224 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4230 int UtcDaliActorPropertyClippingActor(void)
4232 // This test checks that an actor is correctly setup for clipping.
4233 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4234 TestApplication application;
4236 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4237 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4238 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4239 size_t startIndex = 0u;
4241 // Create a clipping actor.
4242 Actor actorDepth1Clip = CreateActorWithContent16x16();
4243 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4244 application.GetScene().Add(actorDepth1Clip);
4246 // Gather the call trace.
4247 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4249 // Check we are writing to the color buffer.
4250 CheckColorMask(glAbstraction, true);
4252 // Check the stencil buffer was enabled.
4253 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4255 // Check the stencil buffer was cleared.
4256 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4258 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4259 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4260 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4261 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4266 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4268 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4269 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4270 TestApplication application;
4272 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4273 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4274 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4275 size_t startIndex = 0u;
4277 // Create a clipping actor.
4278 Actor actorDepth1Clip = CreateActorWithContent16x16();
4279 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4280 application.GetScene().Add(actorDepth1Clip);
4282 // Gather the call trace.
4283 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4285 // Check we are writing to the color buffer.
4286 CheckColorMask(glAbstraction, true);
4288 // Check the stencil buffer was enabled.
4289 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4291 // Check the stencil buffer was cleared.
4292 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4294 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4295 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4296 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4297 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4299 // Now disable the clipping
4300 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4302 // Gather the call trace.
4303 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4305 // Check the stencil buffer was disabled.
4306 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", "2960")); // 2960 is GL_STENCIL_TEST
4308 // Ensure all values in stencil-mask are set to 1.
4310 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4315 int UtcDaliActorPropertyClippingNestedChildren(void)
4317 // This test checks that a hierarchy of actors are clipped correctly by
4318 // writing to and reading from the correct bit-planes of the stencil buffer.
4319 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4320 TestApplication application;
4321 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4322 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4323 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4325 // Create a clipping actor.
4326 Actor actorDepth1Clip = CreateActorWithContent16x16();
4327 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4328 application.GetScene().Add(actorDepth1Clip);
4330 // Create a child actor.
4331 Actor childDepth2 = CreateActorWithContent16x16();
4332 actorDepth1Clip.Add(childDepth2);
4334 // Create another clipping actor.
4335 Actor childDepth2Clip = CreateActorWithContent16x16();
4336 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4337 childDepth2.Add(childDepth2Clip);
4339 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4340 // This tests the sort algorithm.
4341 Actor childDepth3 = CreateActorWithContent16x16();
4342 childDepth2Clip.Add(childDepth3);
4343 Actor childDepth4 = CreateActorWithContent16x16();
4344 childDepth3.Add(childDepth4);
4346 // Gather the call trace.
4347 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4349 // Check we are writing to the color buffer.
4350 CheckColorMask(glAbstraction, true);
4352 // Check the stencil buffer was enabled.
4353 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4355 // Perform the test twice, once for 2D layer, and once for 3D.
4356 for(unsigned int i = 0u; i < 2u; ++i)
4358 size_t startIndex = 0u;
4360 // Check the stencil buffer was cleared.
4361 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4363 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4364 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4365 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4366 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4368 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4369 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 255", startIndex)); // 514 is GL_EQUAL
4370 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4372 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4373 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4374 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4375 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4377 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4378 // (Both must be set to pass the check).
4379 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 255", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4380 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4382 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4385 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4386 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4393 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4395 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4396 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4397 TestApplication application;
4398 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4399 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4401 /* We create a small tree of actors as follows:
4405 Clipping enabled -> B D
4409 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4412 for(int i = 0; i < 5; ++i)
4414 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4415 Actor actor = CreateRenderableActor(image);
4417 // Setup dimensions and position so actor is not skipped by culling.
4418 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4419 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4423 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4427 float b = i > 2 ? 1.0f : -1.0f;
4428 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4434 // Enable clipping on the actor at the top of the left branch.
4435 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4437 // Build the scene graph.
4438 application.GetScene().Add(actors[0]);
4441 actors[0].Add(actors[1]);
4442 actors[1].Add(actors[2]);
4445 actors[0].Add(actors[3]);
4446 actors[3].Add(actors[4]);
4448 // Gather the call trace.
4449 enabledDisableTrace.Reset();
4450 enabledDisableTrace.Enable(true);
4451 application.SendNotification();
4452 application.Render();
4453 enabledDisableTrace.Enable(false);
4455 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4457 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
4458 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4460 size_t startIndex = 0u;
4461 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "3042", startIndex));
4462 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); // 2960 is GL_STENCIL_TEST
4463 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
4465 // Swap the clipping actor from top of left branch to top of right branch.
4466 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4467 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4469 // Gather the call trace.
4470 enabledDisableTrace.Reset();
4471 enabledDisableTrace.Enable(true);
4472 application.SendNotification();
4473 application.Render();
4474 enabledDisableTrace.Enable(false);
4476 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4477 // This proves the draw order has remained the same.
4479 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex));
4480 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
4485 int UtcDaliActorPropertyScissorClippingActor(void)
4487 // This test checks that an actor is correctly setup for clipping.
4488 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4489 TestApplication application;
4491 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4492 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4493 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4495 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4496 const Vector2 imageSize(16.0f, 16.0f);
4498 // Create a clipping actor.
4499 Actor clippingActorA = CreateActorWithContent16x16();
4500 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4501 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4502 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4503 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4504 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4505 application.GetScene().Add(clippingActorA);
4507 // Gather the call trace.
4508 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4510 // Check we are writing to the color buffer.
4511 CheckColorMask(glAbstraction, true);
4513 // Check scissor test was enabled.
4514 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4516 // Check the scissor was set, and the coordinates are correct.
4517 std::stringstream compareParametersString;
4518 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4519 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4521 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4522 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4524 // Gather the call trace.
4525 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4527 // Check the scissor was set, and the coordinates are correct.
4528 compareParametersString.str(std::string());
4529 compareParametersString.clear();
4530 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4531 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4536 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4538 // This test checks that an actor is correctly setup for clipping.
4539 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4540 TestApplication application;
4542 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4543 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4544 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4546 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4547 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4548 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4550 // Create a clipping actors.
4551 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4552 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4554 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4555 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4556 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4558 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4559 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4560 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4562 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4563 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4565 application.GetScene().Add(clippingActorA);
4566 application.GetScene().Add(clippingActorB);
4568 // Gather the call trace.
4569 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4571 // Check we are writing to the color buffer.
4572 CheckColorMask(glAbstraction, true);
4574 // Check scissor test was enabled.
4575 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4577 // Check the scissor was set, and the coordinates are correct.
4578 std::stringstream compareParametersString;
4580 std::string clipA("0, 500, 480, 200");
4581 std::string clipB("0, 380, 480, 40");
4583 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4584 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4589 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4591 // This test checks that an actor is correctly setup for clipping.
4592 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4593 TestApplication application;
4595 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4596 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4597 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4599 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4600 const Vector2 imageSize(16.0f, 16.0f);
4602 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4604 A is drawn first - with scissor clipping on
4605 B is drawn second - also with scissor clipping on
4606 C is the generated clipping region, the intersection ( A ∩ B )
4610 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4611 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4612 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4616 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4619 // Create a clipping actor.
4620 Actor clippingActorA = CreateActorWithContent16x16();
4621 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4622 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4623 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4624 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4625 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4626 application.GetScene().Add(clippingActorA);
4628 // Create a child clipping actor.
4629 Actor clippingActorB = CreateActorWithContent16x16();
4630 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4631 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4632 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4633 clippingActorA.Add(clippingActorB);
4635 // positionModifiers is an array of positions to position B around.
4636 // expect is an array of expected scissor clip coordinate results.
4637 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4638 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4640 // Loop through each overlap combination.
4641 for(unsigned int test = 0u; test < 4u; ++test)
4643 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4644 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4645 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4647 // Gather the call trace.
4648 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4650 // Check we are writing to the color buffer.
4651 CheckColorMask(glAbstraction, true);
4653 // Check scissor test was enabled.
4654 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4656 // Check the scissor was set, and the coordinates are correct.
4657 const Vector4& expectResults(expect[test]);
4658 std::stringstream compareParametersString;
4659 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4660 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4666 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4668 // This test checks that an actor is correctly setup for clipping.
4669 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4670 TestApplication application;
4672 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4673 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4674 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4676 /* Create a nest of 2 scissors and siblings of the parent.
4686 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4687 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4688 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4689 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4690 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4691 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4693 // Create a clipping actors.
4694 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4695 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4696 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4697 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4698 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4700 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4701 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4702 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4704 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4705 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4706 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4708 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4709 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4710 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4712 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4713 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4714 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4716 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4717 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4719 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4720 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4721 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4722 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4723 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4725 application.GetScene().Add(clippingActorA);
4726 clippingActorA.Add(clippingActorB);
4727 application.GetScene().Add(clippingActorC);
4728 application.GetScene().Add(clippingActorD);
4729 clippingActorD.Add(clippingActorE);
4731 // Gather the call trace.
4732 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4734 // Check we are writing to the color buffer.
4735 CheckColorMask(glAbstraction, true);
4737 // Check scissor test was enabled.
4738 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4740 // Check the scissor was set, and the coordinates are correct.
4741 std::string clipA("0, 500, 480, 200");
4742 std::string clipB("0, 580, 480, 40");
4743 std::string clipC("0, 200, 480, 200");
4744 std::string clipD("0, 300, 480, 200");
4746 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4747 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4748 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4749 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4750 DALI_TEST_CHECK(scissorTrace.CountMethod("Scissor") == 4); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4755 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4757 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4758 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4759 TestApplication application;
4761 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4762 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4763 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4765 // Create a clipping actor.
4766 Actor actorDepth1Clip = CreateActorWithContent16x16();
4767 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4768 application.GetScene().Add(actorDepth1Clip);
4770 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4771 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4773 // Gather the call trace.
4774 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4776 // Check we are writing to the color buffer.
4777 CheckColorMask(glAbstraction, true);
4779 // Check the stencil buffer was not enabled.
4780 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4782 // Check stencil functions are not called.
4783 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4784 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask"));
4785 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4787 // Check that scissor clipping is overriden by the renderer properties.
4788 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4790 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4792 // Gather the call trace.
4793 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4795 // Check the stencil buffer was not enabled.
4796 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4798 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4803 int UtcDaliGetPropertyN(void)
4805 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
4806 TestApplication application;
4808 Actor actor = Actor::New();
4810 unsigned int propertyCount = actor.GetPropertyCount();
4811 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
4815 int UtcDaliActorRaiseLower(void)
4817 tet_infoline("UtcDaliActor Raise and Lower test\n");
4819 TestApplication application;
4821 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
4823 Integration::Scene stage(application.GetScene());
4825 Actor actorA = Actor::New();
4826 Actor actorB = Actor::New();
4827 Actor actorC = Actor::New();
4829 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4830 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4832 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4833 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4835 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4836 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4838 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4839 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4841 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4842 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4844 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4845 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4851 ResetTouchCallbacks();
4853 application.SendNotification();
4854 application.Render();
4856 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4857 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4858 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4860 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4861 // Only top actor will get touched.
4862 actorA.TouchedSignal().Connect(TestTouchCallback);
4863 actorB.TouchedSignal().Connect(TestTouchCallback2);
4864 actorC.TouchedSignal().Connect(TestTouchCallback3);
4866 // Connect ChildOrderChangedSignal
4867 bool orderChangedSignal(false);
4868 Actor orderChangedActor;
4869 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
4870 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
4872 Dali::Integration::Point point;
4873 point.SetDeviceId(1);
4874 point.SetState(PointState::DOWN);
4875 point.SetScreenPosition(Vector2(10.f, 10.f));
4876 Dali::Integration::TouchEvent touchEvent;
4877 touchEvent.AddPoint(point);
4879 application.ProcessEvent(touchEvent);
4881 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4882 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4883 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4885 ResetTouchCallbacks();
4887 tet_printf("Testing Raising of Actor\n");
4889 int preActorOrder(0);
4890 int postActorOrder(0);
4892 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4893 value.Get(preActorOrder);
4895 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4897 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4898 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4900 // Ensure sort order is calculated before next touch event
4901 application.SendNotification();
4903 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4904 value.Get(postActorOrder);
4906 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4908 application.ProcessEvent(touchEvent);
4910 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4911 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
4912 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4914 ResetTouchCallbacks();
4916 tet_printf("Testing Lowering of Actor\n");
4918 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4919 value.Get(preActorOrder);
4921 orderChangedSignal = false;
4923 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4925 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4926 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4928 application.SendNotification(); // ensure sort order calculated before next touch event
4930 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4931 value.Get(postActorOrder);
4933 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4935 application.ProcessEvent(touchEvent);
4937 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4938 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4939 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4941 ResetTouchCallbacks();
4943 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
4948 int UtcDaliActorRaiseToTopLowerToBottom(void)
4950 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
4952 TestApplication application;
4954 Integration::Scene stage(application.GetScene());
4956 Actor actorA = Actor::New();
4957 Actor actorB = Actor::New();
4958 Actor actorC = Actor::New();
4960 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4961 // enables checking of which actor the uniform is assigned too
4962 Shader shaderA = CreateShader();
4963 shaderA.RegisterProperty("uRendererColor", 1.f);
4965 Shader shaderB = CreateShader();
4966 shaderB.RegisterProperty("uRendererColor", 2.f);
4968 Shader shaderC = CreateShader();
4969 shaderC.RegisterProperty("uRendererColor", 3.f);
4971 Geometry geometry = CreateQuadGeometry();
4973 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4974 Renderer rendererA = Renderer::New(geometry, shaderA);
4975 actorA.AddRenderer(rendererA);
4977 Renderer rendererB = Renderer::New(geometry, shaderB);
4978 actorB.AddRenderer(rendererB);
4980 Renderer rendererC = Renderer::New(geometry, shaderC);
4981 actorC.AddRenderer(rendererC);
4983 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4984 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4986 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4987 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4989 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4990 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4992 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4993 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4995 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4996 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4998 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4999 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5005 ResetTouchCallbacks();
5007 // Connect ChildOrderChangedSignal
5008 bool orderChangedSignal(false);
5009 Actor orderChangedActor;
5010 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5011 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5013 // Set up gl abstraction trace so can query the set uniform order
5014 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5015 glAbstraction.EnableSetUniformCallTrace(true);
5016 glAbstraction.ResetSetUniformCallStack();
5018 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5020 application.SendNotification();
5021 application.Render();
5023 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5025 // Test order of uniforms in stack
5026 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5027 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5028 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5030 bool CBA = (indexC > indexB) && (indexB > indexA);
5032 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5034 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5035 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5036 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5038 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5039 // Only top actor will get touched.
5040 actorA.TouchedSignal().Connect(TestTouchCallback);
5041 actorB.TouchedSignal().Connect(TestTouchCallback2);
5042 actorC.TouchedSignal().Connect(TestTouchCallback3);
5044 Dali::Integration::Point point;
5045 point.SetDeviceId(1);
5046 point.SetState(PointState::DOWN);
5047 point.SetScreenPosition(Vector2(10.f, 10.f));
5048 Dali::Integration::TouchEvent touchEvent;
5049 touchEvent.AddPoint(point);
5051 application.ProcessEvent(touchEvent);
5053 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5054 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5055 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5057 ResetTouchCallbacks();
5059 tet_printf("RaiseToTop ActorA\n");
5061 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5062 actorA.RaiseToTop();
5063 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5064 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5066 application.SendNotification(); // ensure sorting order is calculated before next touch event
5068 application.ProcessEvent(touchEvent);
5070 glAbstraction.ResetSetUniformCallStack();
5071 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5073 application.SendNotification();
5074 application.Render();
5076 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5078 // Test order of uniforms in stack
5079 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5080 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5081 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5083 tet_infoline("Testing A above C and B at bottom\n");
5084 bool ACB = (indexA > indexC) && (indexC > indexB);
5086 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5088 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5089 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5090 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5092 ResetTouchCallbacks();
5094 tet_printf("RaiseToTop ActorB\n");
5096 orderChangedSignal = false;
5098 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5099 actorB.RaiseToTop();
5100 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5101 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5103 application.SendNotification(); // Ensure sort order is calculated before next touch event
5105 application.ProcessEvent(touchEvent);
5107 glAbstraction.ResetSetUniformCallStack();
5108 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5110 application.SendNotification();
5111 application.Render();
5113 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5115 // Test order of uniforms in stack
5116 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5117 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5118 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5120 tet_infoline("Testing B above A and C at bottom\n");
5121 bool BAC = (indexB > indexA) && (indexA > indexC);
5123 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5125 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5126 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5127 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5129 ResetTouchCallbacks();
5131 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5133 orderChangedSignal = false;
5135 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5136 actorA.LowerToBottom();
5137 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5138 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5140 application.SendNotification();
5141 application.Render();
5143 orderChangedSignal = false;
5145 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5146 actorB.LowerToBottom();
5147 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5148 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5150 application.SendNotification();
5151 application.Render();
5153 application.ProcessEvent(touchEvent);
5155 glAbstraction.ResetSetUniformCallStack();
5156 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5158 application.SendNotification();
5159 application.Render();
5161 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5163 // Test order of uniforms in stack
5164 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5165 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5166 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5168 tet_infoline("Testing C above A and B at bottom\n");
5169 bool CAB = (indexC > indexA) && (indexA > indexB);
5171 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5173 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5174 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5175 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5177 ResetTouchCallbacks();
5182 int UtcDaliActorRaiseAbove(void)
5184 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5186 TestApplication application;
5188 Integration::Scene stage(application.GetScene());
5190 Actor actorA = Actor::New();
5191 Actor actorB = Actor::New();
5192 Actor actorC = Actor::New();
5194 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5195 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5197 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5198 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5200 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5201 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5203 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5204 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5206 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5207 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5209 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5210 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5216 ResetTouchCallbacks();
5218 application.SendNotification();
5219 application.Render();
5221 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5222 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5223 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5225 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5226 // Only top actor will get touched.
5227 actorA.TouchedSignal().Connect(TestTouchCallback);
5228 actorB.TouchedSignal().Connect(TestTouchCallback2);
5229 actorC.TouchedSignal().Connect(TestTouchCallback3);
5231 bool orderChangedSignal(false);
5232 Actor orderChangedActor;
5233 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5234 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5236 Dali::Integration::Point point;
5237 point.SetDeviceId(1);
5238 point.SetState(PointState::DOWN);
5239 point.SetScreenPosition(Vector2(10.f, 10.f));
5240 Dali::Integration::TouchEvent touchEvent;
5241 touchEvent.AddPoint(point);
5243 application.ProcessEvent(touchEvent);
5245 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5246 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5247 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5249 ResetTouchCallbacks();
5251 tet_printf("Raise actor B Above Actor C\n");
5253 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5254 actorB.RaiseAbove(actorC);
5255 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5256 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5258 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5259 application.SendNotification();
5260 application.ProcessEvent(touchEvent);
5262 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5263 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5264 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5266 ResetTouchCallbacks();
5268 tet_printf("Raise actor A Above Actor B\n");
5270 orderChangedSignal = false;
5272 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5273 actorA.RaiseAbove(actorB);
5274 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5275 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5277 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5278 application.SendNotification();
5280 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5282 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5283 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5284 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5286 ResetTouchCallbacks();
5291 int UtcDaliActorLowerBelow(void)
5293 tet_infoline("UtcDaliActor LowerBelow test \n");
5295 TestApplication application;
5297 Integration::Scene stage(application.GetScene());
5299 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5300 // enables checking of which actor the uniform is assigned too
5301 Shader shaderA = CreateShader();
5302 shaderA.RegisterProperty("uRendererColor", 1.f);
5304 Shader shaderB = CreateShader();
5305 shaderB.RegisterProperty("uRendererColor", 2.f);
5307 Shader shaderC = CreateShader();
5308 shaderC.RegisterProperty("uRendererColor", 3.f);
5310 Actor actorA = Actor::New();
5311 Actor actorB = Actor::New();
5312 Actor actorC = Actor::New();
5314 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5315 Geometry geometry = CreateQuadGeometry();
5317 Renderer rendererA = Renderer::New(geometry, shaderA);
5318 actorA.AddRenderer(rendererA);
5320 Renderer rendererB = Renderer::New(geometry, shaderB);
5321 actorB.AddRenderer(rendererB);
5323 Renderer rendererC = Renderer::New(geometry, shaderC);
5324 actorC.AddRenderer(rendererC);
5326 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5327 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5329 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5330 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5332 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5333 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5335 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5336 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5338 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5339 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5341 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5342 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5344 Actor container = Actor::New();
5345 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5346 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5347 stage.Add(container);
5349 container.Add(actorA);
5350 container.Add(actorB);
5351 container.Add(actorC);
5353 ResetTouchCallbacks();
5355 // Connect ChildOrderChangedSignal
5356 bool orderChangedSignal(false);
5357 Actor orderChangedActor;
5358 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5359 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5361 // Set up gl abstraction trace so can query the set uniform order
5362 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5363 glAbstraction.EnableSetUniformCallTrace(true);
5364 glAbstraction.ResetSetUniformCallStack();
5365 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5367 glAbstraction.ResetSetUniformCallStack();
5369 application.SendNotification();
5370 application.Render();
5372 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5374 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5376 // Test order of uniforms in stack
5377 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5378 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5379 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5381 tet_infoline("Testing C above B and A at bottom\n");
5382 bool CBA = (indexC > indexB) && (indexB > indexA);
5384 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5386 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5387 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5388 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5390 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5391 // Only top actor will get touched.
5392 actorA.TouchedSignal().Connect(TestTouchCallback);
5393 actorB.TouchedSignal().Connect(TestTouchCallback2);
5394 actorC.TouchedSignal().Connect(TestTouchCallback3);
5396 Dali::Integration::Point point;
5397 point.SetDeviceId(1);
5398 point.SetState(PointState::DOWN);
5399 point.SetScreenPosition(Vector2(10.f, 10.f));
5400 Dali::Integration::TouchEvent touchEvent;
5401 touchEvent.AddPoint(point);
5403 tet_infoline("UtcDaliActor Test Set up completed \n");
5405 application.ProcessEvent(touchEvent);
5407 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5408 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5409 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5411 ResetTouchCallbacks();
5413 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");
5415 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5416 actorC.LowerBelow(actorB);
5417 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5418 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5420 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5421 application.SendNotification();
5422 application.Render();
5424 application.ProcessEvent(touchEvent); // touch event
5426 glAbstraction.ResetSetUniformCallStack();
5427 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5429 application.SendNotification();
5430 application.Render();
5432 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5434 // Test order of uniforms in stack
5435 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5436 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5437 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5439 tet_infoline("Testing render order is A, C, B");
5440 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5441 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5443 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5444 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5445 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5447 ResetTouchCallbacks();
5449 tet_printf("Lower actor C below Actor A leaving B on top\n");
5451 orderChangedSignal = false;
5453 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5454 actorC.LowerBelow(actorA);
5455 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5456 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5458 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5459 application.SendNotification();
5460 application.Render();
5462 application.ProcessEvent(touchEvent);
5464 glAbstraction.ResetSetUniformCallStack();
5465 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5467 application.Render();
5468 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5470 // Test order of uniforms in stack
5471 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5472 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5473 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5475 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5476 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5478 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5479 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5480 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5482 ResetTouchCallbacks();
5484 tet_printf("Lower actor B below Actor C leaving A on top\n");
5486 orderChangedSignal = false;
5488 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5489 actorB.LowerBelow(actorC);
5490 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5491 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5493 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5494 application.SendNotification();
5495 application.Render();
5497 application.ProcessEvent(touchEvent);
5499 glAbstraction.ResetSetUniformCallStack();
5500 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5502 application.Render();
5503 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5505 // Test order of uniforms in stack
5506 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5507 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5508 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5510 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5511 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5516 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5518 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
5520 TestApplication application;
5522 Integration::Scene stage(application.GetScene());
5524 Actor parentA = Actor::New();
5525 Actor parentB = Actor::New();
5526 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5527 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5528 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5529 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5531 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5532 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5534 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5535 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5540 Actor actorA = Actor::New();
5541 Actor actorB = Actor::New();
5542 Actor actorC = Actor::New();
5544 parentA.Add(actorA);
5545 parentA.Add(actorB);
5547 tet_printf("Actor C added to different parent from A and B \n");
5548 parentB.Add(actorC);
5550 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5551 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5553 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5554 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5556 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5557 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5559 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5560 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5562 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5563 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5565 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5566 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5568 ResetTouchCallbacks();
5570 // Connect ChildOrderChangedSignal
5571 bool orderChangedSignal(false);
5572 Actor orderChangedActor;
5573 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5574 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5576 application.SendNotification();
5577 application.Render();
5579 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5580 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5581 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5583 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5584 // Only top actor will get touched.
5585 actorA.TouchedSignal().Connect(TestTouchCallback);
5586 actorB.TouchedSignal().Connect(TestTouchCallback2);
5587 actorC.TouchedSignal().Connect(TestTouchCallback3);
5589 Dali::Integration::Point point;
5590 point.SetDeviceId(1);
5591 point.SetState(PointState::DOWN);
5592 point.SetScreenPosition(Vector2(10.f, 10.f));
5593 Dali::Integration::TouchEvent touchEvent;
5594 touchEvent.AddPoint(point);
5596 application.ProcessEvent(touchEvent);
5598 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5599 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5600 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5602 ResetTouchCallbacks();
5604 tet_printf("Raise actor A Above Actor C which have different parents\n");
5606 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5607 actorA.RaiseAbove(actorC);
5608 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5610 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5611 application.SendNotification();
5613 application.ProcessEvent(touchEvent); // touch event
5615 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5616 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5617 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5619 ResetTouchCallbacks();
5624 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5626 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
5628 TestApplication application;
5630 Integration::Scene stage(application.GetScene());
5632 Actor actorA = Actor::New();
5633 Actor actorB = Actor::New();
5634 Actor actorC = Actor::New();
5636 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5637 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5639 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5640 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5642 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5643 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5645 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5646 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5648 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5649 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5651 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5652 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5654 ResetTouchCallbacks();
5656 // Connect ChildOrderChangedSignal
5657 bool orderChangedSignal(false);
5658 Actor orderChangedActor;
5659 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5660 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5662 application.SendNotification();
5663 application.Render();
5665 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5666 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5667 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5669 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5670 // Only top actor will get touched.
5671 actorA.TouchedSignal().Connect(TestTouchCallback);
5672 actorB.TouchedSignal().Connect(TestTouchCallback2);
5673 actorC.TouchedSignal().Connect(TestTouchCallback3);
5675 Dali::Integration::Point point;
5676 point.SetDeviceId(1);
5677 point.SetState(PointState::DOWN);
5678 point.SetScreenPosition(Vector2(10.f, 10.f));
5679 Dali::Integration::TouchEvent touchEvent;
5680 touchEvent.AddPoint(point);
5682 tet_printf("Raise actor A Above Actor C which have no parents\n");
5684 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5685 actorA.RaiseAbove(actorC);
5686 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5688 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5689 application.SendNotification();
5691 application.ProcessEvent(touchEvent);
5693 tet_printf("Not parented so RaiseAbove should show no effect\n");
5695 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5696 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5697 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5699 ResetTouchCallbacks();
5701 orderChangedSignal = false;
5704 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
5706 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5707 actorA.LowerBelow(actorC);
5708 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5710 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5711 application.SendNotification();
5712 application.Render();
5714 application.ProcessEvent(touchEvent);
5716 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
5717 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5718 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5719 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5721 ResetTouchCallbacks();
5723 orderChangedSignal = false;
5725 tet_printf("Adding Actor A to stage, will be on top\n");
5728 application.SendNotification();
5729 application.Render();
5731 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
5733 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5734 actorB.RaiseAbove(actorC);
5735 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5737 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5738 application.SendNotification();
5740 application.ProcessEvent(touchEvent);
5742 tet_printf("C not parented so RaiseAbove should show no effect\n");
5743 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5744 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5745 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5747 ResetTouchCallbacks();
5749 orderChangedSignal = false;
5751 tet_printf("Lower actor A below Actor C when only A has a parent\n");
5753 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5754 actorA.LowerBelow(actorC);
5755 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5757 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5758 application.SendNotification();
5760 application.ProcessEvent(touchEvent);
5762 tet_printf("C not parented so LowerBelow should show no effect\n");
5763 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5764 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5765 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5767 ResetTouchCallbacks();
5769 orderChangedSignal = false;
5773 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5774 actorA.RaiseAbove(actorC);
5775 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5776 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5778 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5779 application.SendNotification();
5780 application.Render();
5782 application.ProcessEvent(touchEvent);
5784 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
5785 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5786 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5787 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5792 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5794 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
5796 TestApplication application;
5798 Integration::Scene stage(application.GetScene());
5800 Actor actorA = Actor::New();
5801 Actor actorB = Actor::New();
5802 Actor actorC = Actor::New();
5804 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5805 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5807 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5808 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5810 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5811 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5813 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5814 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5816 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5817 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5819 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5820 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5822 ResetTouchCallbacks();
5824 // Connect ChildOrderChangedSignal
5825 bool orderChangedSignal(false);
5826 Actor orderChangedActor;
5827 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5828 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5830 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5831 // Only top actor will get touched.
5832 actorA.TouchedSignal().Connect(TestTouchCallback);
5833 actorB.TouchedSignal().Connect(TestTouchCallback2);
5834 actorC.TouchedSignal().Connect(TestTouchCallback3);
5836 Dali::Integration::Point point;
5837 point.SetDeviceId(1);
5838 point.SetState(PointState::DOWN);
5839 point.SetScreenPosition(Vector2(10.f, 10.f));
5840 Dali::Integration::TouchEvent touchEvent;
5841 touchEvent.AddPoint(point);
5844 tet_printf("Raise actor B Above Actor C but B not parented\n");
5846 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5848 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5850 application.SendNotification();
5851 application.Render();
5853 application.ProcessEvent(touchEvent);
5855 tet_printf("Not parented so RaiseAbove should show no effect\n");
5857 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5858 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5859 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5861 tet_printf("Raise actor B Above Actor C but B not parented\n");
5862 ResetTouchCallbacks();
5864 orderChangedSignal = false;
5866 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5868 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5870 // Sort actor tree before next touch event
5871 application.SendNotification();
5872 application.Render();
5874 application.ProcessEvent(touchEvent);
5876 tet_printf("Not parented so RaiseAbove should show no effect\n");
5878 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5879 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5880 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5881 ResetTouchCallbacks();
5883 orderChangedSignal = false;
5885 tet_printf("Lower actor C below B but C not parented\n");
5887 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5889 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5891 // Sort actor tree before next touch event
5892 application.SendNotification();
5893 application.Render();
5895 application.ProcessEvent(touchEvent);
5897 tet_printf("Not parented so Lower should show no effect\n");
5899 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5900 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5901 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5902 ResetTouchCallbacks();
5904 orderChangedSignal = false;
5906 tet_printf("Raise actor B to top\n");
5908 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5909 actorB.RaiseToTop();
5910 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5912 // Sort actor tree before next touch event
5913 application.SendNotification();
5914 application.Render();
5916 application.ProcessEvent(touchEvent);
5918 tet_printf("Not parented so RaiseToTop should show no effect\n");
5920 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5921 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5922 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5923 ResetTouchCallbacks();
5925 orderChangedSignal = false;
5927 tet_printf("Add ActorB to stage so only Actor C not parented\n");
5931 tet_printf("Lower actor C to Bottom, B stays at top\n");
5933 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5934 actorC.LowerToBottom();
5935 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5937 application.SendNotification();
5938 application.Render();
5940 application.ProcessEvent(touchEvent);
5942 tet_printf("Not parented so LowerToBottom should show no effect\n");
5944 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5945 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5946 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5947 ResetTouchCallbacks();
5952 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5954 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
5956 TestApplication application;
5958 Integration::Scene stage(application.GetScene());
5960 Actor actorA = Actor::New();
5961 Actor actorB = Actor::New();
5962 Actor actorC = Actor::New();
5964 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5965 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5967 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5968 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5970 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5971 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5973 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5974 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5976 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5977 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5979 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5980 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5986 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5987 // Only top actor will get touched.
5988 actorA.TouchedSignal().Connect(TestTouchCallback);
5989 actorB.TouchedSignal().Connect(TestTouchCallback2);
5990 actorC.TouchedSignal().Connect(TestTouchCallback3);
5992 ResetTouchCallbacks();
5994 // Connect ChildOrderChangedSignal
5995 bool orderChangedSignal(false);
5996 Actor orderChangedActor;
5997 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5998 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6000 application.SendNotification();
6001 application.Render();
6003 Dali::Integration::Point point;
6004 point.SetDeviceId(1);
6005 point.SetState(PointState::DOWN);
6006 point.SetScreenPosition(Vector2(10.f, 10.f));
6007 Dali::Integration::TouchEvent touchEvent;
6008 touchEvent.AddPoint(point);
6010 application.ProcessEvent(touchEvent);
6012 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6013 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6014 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6016 ResetTouchCallbacks();
6018 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6020 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6021 actorA.RaiseAbove(actorA);
6022 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6023 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6025 application.SendNotification();
6026 application.Render();
6028 application.ProcessEvent(touchEvent);
6030 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6032 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6033 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6034 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6036 ResetTouchCallbacks();
6038 orderChangedSignal = false;
6040 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6041 actorA.RaiseAbove(actorC);
6042 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6043 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6045 application.SendNotification();
6046 application.Render();
6048 application.ProcessEvent(touchEvent);
6050 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6051 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6052 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6053 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6058 int UtcDaliActorGetScreenPosition(void)
6060 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6062 TestApplication application;
6064 Integration::Scene stage(application.GetScene());
6066 Actor actorA = Actor::New();
6067 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6069 Vector2 size2(10.0f, 20.0f);
6070 actorA.SetProperty(Actor::Property::SIZE, size2);
6072 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6074 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6078 application.SendNotification();
6079 application.Render();
6081 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6082 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6084 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6085 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6087 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6088 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6090 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6092 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6094 application.SendNotification();
6095 application.Render();
6097 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6098 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6100 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6101 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6103 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6104 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6106 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6108 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6110 application.SendNotification();
6111 application.Render();
6113 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6114 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6116 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6117 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6119 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6120 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6122 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6124 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6126 application.SendNotification();
6127 application.Render();
6129 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6130 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6132 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6133 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6135 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6136 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6138 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6140 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6142 application.SendNotification();
6143 application.Render();
6145 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6146 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6148 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6149 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6151 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6152 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6154 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6156 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6157 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6159 Actor actorB = Actor::New();
6160 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6161 actorB.SetProperty(Actor::Property::SIZE, size2);
6162 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6165 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6167 application.SendNotification();
6168 application.Render();
6170 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6172 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6173 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6178 int UtcDaliActorGetScreenPositionAfterScaling(void)
6180 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6182 TestApplication application;
6184 Integration::Scene stage(application.GetScene());
6186 Actor actorA = Actor::New();
6187 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6189 Vector2 size2(10.0f, 20.0f);
6190 actorA.SetProperty(Actor::Property::SIZE, size2);
6191 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6192 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6194 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6198 application.SendNotification();
6199 application.Render();
6201 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6202 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6204 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6205 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6207 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6208 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6210 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6212 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6214 application.SendNotification();
6215 application.Render();
6217 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6218 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6220 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6221 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6223 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6224 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6229 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6231 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6233 TestApplication application;
6235 Integration::Scene stage(application.GetScene());
6237 Actor actorA = Actor::New();
6238 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6239 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6240 Vector2 size2(10.0f, 20.0f);
6241 actorA.SetProperty(Actor::Property::SIZE, size2);
6242 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6244 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6248 application.SendNotification();
6249 application.Render();
6251 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6252 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6254 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6255 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6257 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6258 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6260 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6262 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6263 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6265 application.SendNotification();
6266 application.Render();
6268 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6269 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6271 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6272 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6274 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6275 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6281 int UtcDaliActorGetScreenPositionWithChildActors(void)
6283 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6285 TestApplication application;
6287 Integration::Scene stage(application.GetScene());
6289 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6291 Actor actorA = Actor::New();
6292 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6293 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6294 Vector2 size1(10.0f, 20.0f);
6295 actorA.SetProperty(Actor::Property::SIZE, size1);
6296 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6298 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6300 Actor parentActorA = Actor::New();
6301 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6302 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6303 Vector2 size2(30.0f, 60.0f);
6304 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6305 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6307 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6309 stage.Add(parentActorA);
6310 parentActorA.Add(actorA);
6312 application.SendNotification();
6313 application.Render();
6315 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6316 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6318 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6319 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6321 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6322 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6324 tet_infoline("Test 2\n");
6326 tet_infoline("change parent anchor point and parent origin then check screen position \n");
6328 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6329 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6331 application.SendNotification();
6332 application.Render();
6334 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6335 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6337 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6338 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6340 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6341 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6346 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6348 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6350 TestApplication application;
6352 Integration::Scene stage(application.GetScene());
6354 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6356 Actor actorA = Actor::New();
6357 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6358 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6359 Vector2 size1(10.0f, 20.0f);
6360 actorA.SetProperty(Actor::Property::SIZE, size1);
6361 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6363 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6365 Actor parentActorA = Actor::New();
6366 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6367 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6368 Vector2 size2(30.0f, 60.0f);
6369 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6370 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6372 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6374 Actor grandParentActorA = Actor::New();
6375 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6376 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6377 Vector2 size3(60.0f, 120.0f);
6378 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6379 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6381 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6383 stage.Add(grandParentActorA);
6384 grandParentActorA.Add(parentActorA);
6386 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6388 parentActorA.Add(actorA);
6390 application.SendNotification();
6391 application.Render();
6393 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6394 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6396 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6397 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6399 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6400 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6405 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6407 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6409 TestApplication application;
6411 Integration::Scene stage(application.GetScene());
6413 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6415 Actor actorA = Actor::New();
6416 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6417 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6418 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6419 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6422 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6424 Actor actorB = Actor::New();
6425 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6426 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6427 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6428 Vector2 actorBSize(30.0f, 60.0f);
6429 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6432 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6434 Actor actorC = Actor::New();
6435 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6436 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6437 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6438 Vector2 actorCSize(60.0f, 120.0f);
6439 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6442 application.SendNotification();
6443 application.Render();
6445 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
6447 Vector2 center(stage.GetSize() * 0.5f);
6449 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6450 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6451 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6453 tet_infoline("Add scale to all actors");
6455 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6456 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
6457 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
6459 application.SendNotification();
6460 application.Render();
6462 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
6463 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
6464 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
6469 int utcDaliActorPositionUsesAnchorPoint(void)
6471 TestApplication application;
6472 tet_infoline("Check default behaviour\n");
6474 Actor actor = Actor::New();
6475 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6476 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6477 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6478 application.GetScene().Add(actor);
6480 application.SendNotification();
6481 application.Render();
6483 tet_infoline("Check that the world position is in the center\n");
6484 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6486 tet_infoline("Set the position uses anchor point property to false\n");
6487 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6489 application.SendNotification();
6490 application.Render();
6492 tet_infoline("Check that the world position has changed appropriately\n");
6493 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6498 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6500 TestApplication application;
6501 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6503 Actor actor = Actor::New();
6504 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6505 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6506 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6507 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6508 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6509 application.GetScene().Add(actor);
6511 application.SendNotification();
6512 application.Render();
6514 tet_infoline("Check the world position is the same as it would be without a scale\n");
6515 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6517 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6518 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6519 application.SendNotification();
6520 application.Render();
6521 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
6523 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6524 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6525 application.SendNotification();
6526 application.Render();
6527 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6532 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6534 TestApplication application;
6535 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6537 Actor actor = Actor::New();
6538 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6539 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6540 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6541 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6542 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6543 application.GetScene().Add(actor);
6545 application.SendNotification();
6546 application.Render();
6548 tet_infoline("Check the world position is the same as it would be without a rotation\n");
6549 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6551 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6552 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6553 application.SendNotification();
6554 application.Render();
6555 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
6557 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6558 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6559 application.SendNotification();
6560 application.Render();
6561 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
6566 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6568 TestApplication application;
6569 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6571 Actor actor = Actor::New();
6572 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6573 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6574 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6575 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6576 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6577 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6578 application.GetScene().Add(actor);
6580 application.SendNotification();
6581 application.Render();
6583 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
6584 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6586 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6587 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6588 application.SendNotification();
6589 application.Render();
6590 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
6592 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6593 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6594 application.SendNotification();
6595 application.Render();
6596 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
6601 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6603 TestApplication application;
6604 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6606 Actor parent = Actor::New();
6608 application.GetScene().Add(parent);
6609 Vector2 stageSize(application.GetScene().GetSize());
6611 Actor actor = Actor::New();
6612 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6613 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6614 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6615 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
6616 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
6617 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6620 application.SendNotification();
6621 application.Render();
6623 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
6625 tet_infoline("Check the world position is in the right place\n");
6626 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6628 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
6629 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6630 application.SendNotification();
6631 application.Render();
6632 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6634 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
6635 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6636 application.SendNotification();
6637 application.Render();
6638 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6643 int utcDaliActorVisibilityChangeSignalSelf(void)
6645 TestApplication application;
6646 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
6648 Actor actor = Actor::New();
6650 VisibilityChangedFunctorData data;
6651 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
6653 actor.SetProperty(Actor::Property::VISIBLE, false);
6655 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6657 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
6660 actor.SetProperty(Actor::Property::VISIBLE, false);
6661 data.Check(false /* not called */, TEST_LOCATION);
6663 tet_infoline("Change the visibility using properties, ensure called");
6666 actor.SetProperty(Actor::Property::VISIBLE, true);
6667 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6669 tet_infoline("Set the visibility to current using properties, ensure not called");
6672 actor.SetProperty(Actor::Property::VISIBLE, true);
6673 data.Check(false /* not called */, TEST_LOCATION);
6678 int utcDaliActorVisibilityChangeSignalChildren(void)
6680 TestApplication application;
6681 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
6683 Actor parent = Actor::New();
6684 Actor child = Actor::New();
6687 Actor grandChild = Actor::New();
6688 child.Add(grandChild);
6690 VisibilityChangedFunctorData parentData;
6691 VisibilityChangedFunctorData childData;
6692 VisibilityChangedFunctorData grandChildData;
6694 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
6695 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
6696 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
6698 parent.SetProperty(Actor::Property::VISIBLE, false);
6699 parentData.Check(false /* not called */, TEST_LOCATION);
6700 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6701 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6703 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
6706 grandChildData.Reset();
6708 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
6710 parent.SetProperty(Actor::Property::VISIBLE, true);
6711 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6712 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6713 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6715 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
6718 grandChildData.Reset();
6720 parent.SetProperty(Actor::Property::VISIBLE, true);
6721 parentData.Check(false /* not called */, TEST_LOCATION);
6722 childData.Check(false /* not called */, TEST_LOCATION);
6723 grandChildData.Check(false /* not called */, TEST_LOCATION);
6728 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6730 TestApplication application;
6731 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
6733 Actor actor = Actor::New();
6734 application.GetScene().Add(actor);
6736 application.SendNotification();
6737 application.Render();
6739 VisibilityChangedFunctorData data;
6740 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
6742 Animation animation = Animation::New(1.0f);
6743 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
6745 data.Check(false, TEST_LOCATION);
6746 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
6747 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
6749 tet_infoline("Play the animation and check the property value");
6752 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6753 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
6755 tet_infoline("Animation not currently finished, so the current visibility should still be true");
6756 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
6758 application.SendNotification();
6759 application.Render(1100); // After the animation
6761 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
6766 int utcDaliActorVisibilityChangeSignalByName(void)
6768 TestApplication application;
6769 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
6771 Actor actor = Actor::New();
6773 bool signalCalled = false;
6774 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
6775 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6776 actor.SetProperty(Actor::Property::VISIBLE, false);
6777 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
6779 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
6780 signalCalled = false;
6781 actor.SetProperty(Actor::Property::VISIBLE, false);
6782 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6784 tet_infoline("Change the visibility using properties, ensure called");
6785 actor.SetProperty(Actor::Property::VISIBLE, true);
6786 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
6788 tet_infoline("Set the visibility to current using properties, ensure not called");
6789 signalCalled = false;
6791 actor.SetProperty(Actor::Property::VISIBLE, true);
6792 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6797 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
6799 gLayoutDirectionType = type;
6802 int UtcDaliActorLayoutDirectionProperty(void)
6804 TestApplication application;
6805 tet_infoline("Check layout direction property");
6807 Actor actor0 = Actor::New();
6808 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6809 application.GetScene().Add(actor0);
6811 application.SendNotification();
6812 application.Render();
6814 Actor actor1 = Actor::New();
6815 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6816 Actor actor2 = Actor::New();
6817 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6818 Actor actor3 = Actor::New();
6819 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6820 Actor actor4 = Actor::New();
6821 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6822 Actor actor5 = Actor::New();
6823 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6824 Actor actor6 = Actor::New();
6825 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6826 Actor actor7 = Actor::New();
6827 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6828 Actor actor8 = Actor::New();
6829 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6830 Actor actor9 = Actor::New();
6831 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6834 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6835 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
6837 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
6838 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
6839 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
6841 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6842 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6843 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
6845 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
6847 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6848 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6850 application.GetScene().Add(actor3);
6857 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
6858 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
6860 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
6861 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
6862 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
6864 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
6866 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6867 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6868 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6869 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6870 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6871 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6872 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6874 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
6875 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6876 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6878 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
6879 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6880 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6881 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6883 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
6884 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6885 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6890 struct LayoutDirectionFunctor
6892 LayoutDirectionFunctor(bool& signalCalled)
6893 : mSignalCalled(signalCalled)
6897 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6898 : mSignalCalled(rhs.mSignalCalled)
6904 mSignalCalled = true;
6907 bool& mSignalCalled;
6910 int UtcDaliActorLayoutDirectionSignal(void)
6912 TestApplication application;
6913 tet_infoline("Check changing layout direction property sends a signal");
6915 Actor actor = Actor::New();
6916 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6917 application.GetScene().Add(actor);
6918 bool signalCalled = false;
6919 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6921 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
6922 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6924 // Test that writing the same value doesn't send a signal
6925 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
6926 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6928 // Test that writing a different value sends the signal
6929 signalCalled = false;
6930 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
6931 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
6933 signalCalled = false;
6934 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
6935 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6940 struct ChildAddedSignalCheck
6942 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
6943 : mSignalReceived(signalReceived),
6944 mChildHandle(childHandle)
6948 void operator()(Actor childHandle)
6950 mSignalReceived = true;
6951 mChildHandle = childHandle;
6955 mSignalReceived = true;
6956 mChildHandle = Actor();
6959 bool& mSignalReceived;
6960 Actor& mChildHandle;
6963 int UtcDaliChildAddedSignalP1(void)
6965 TestApplication application;
6966 auto stage = application.GetScene();
6968 bool signalReceived = false;
6971 ChildAddedSignalCheck signal(signalReceived, childActor);
6972 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
6973 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
6975 auto actorA = Actor::New();
6977 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
6978 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
6979 signalReceived = false;
6981 auto actorB = Actor::New();
6983 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
6984 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
6989 int UtcDaliChildAddedSignalP2(void)
6991 TestApplication application;
6992 auto stage = application.GetScene();
6994 bool signalReceived = false;
6997 ChildAddedSignalCheck signal(signalReceived, childActor);
6998 tet_infoline("Connect to childAdded signal by name");
7000 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7001 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7003 auto actorA = Actor::New();
7005 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7007 // Can't test which actor was added; signal signature is void() when connecting via name.
7008 signalReceived = false;
7010 auto actorB = Actor::New();
7012 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7017 int UtcDaliChildAddedSignalN(void)
7019 TestApplication application;
7020 auto stage = application.GetScene();
7022 bool signalReceived = false;
7025 ChildAddedSignalCheck signal(signalReceived, childActor);
7026 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7027 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7029 auto actorA = Actor::New();
7031 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7032 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7033 signalReceived = false;
7035 auto actorB = Actor::New();
7037 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7041 struct ChildRemovedSignalCheck
7043 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7044 : mSignalReceived(signalReceived),
7045 mChildHandle(childHandle)
7049 void operator()(Actor childHandle)
7051 mSignalReceived = true;
7052 mChildHandle = childHandle;
7057 mSignalReceived = true;
7060 bool& mSignalReceived;
7061 Actor& mChildHandle;
7064 int UtcDaliChildRemovedSignalP1(void)
7066 TestApplication application;
7067 auto stage = application.GetScene();
7069 bool signalReceived = false;
7072 ChildRemovedSignalCheck signal(signalReceived, childActor);
7073 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7074 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7076 auto actorA = Actor::New();
7078 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7079 DALI_TEST_CHECK(!childActor);
7081 stage.Remove(actorA);
7082 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7083 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7085 signalReceived = false;
7086 auto actorB = Actor::New();
7088 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7090 stage.Remove(actorB);
7091 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7092 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7097 int UtcDaliChildRemovedSignalP2(void)
7099 TestApplication application;
7100 auto stage = application.GetScene();
7102 bool signalReceived = false;
7105 ChildAddedSignalCheck signal(signalReceived, childActor);
7106 tet_infoline("Connect to childRemoved signal by name");
7108 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7109 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7111 auto actorA = Actor::New();
7113 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7115 stage.Remove(actorA);
7116 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7118 signalReceived = false;
7119 auto actorB = Actor::New();
7121 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7123 stage.Remove(actorB);
7124 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7129 int UtcDaliChildRemovedSignalN(void)
7131 TestApplication application;
7132 auto stage = application.GetScene();
7134 bool signalReceived = false;
7137 ChildRemovedSignalCheck signal(signalReceived, childActor);
7138 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7139 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7141 auto actorA = Actor::New();
7144 auto actorB = Actor::New();
7147 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7148 DALI_TEST_CHECK(!childActor);
7150 actorA.Remove(actorB);
7151 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7155 int UtcDaliChildMovedSignalP(void)
7157 TestApplication application;
7158 auto stage = application.GetScene();
7160 bool addedASignalReceived = false;
7161 bool removedASignalReceived = false;
7162 bool addedBSignalReceived = false;
7163 bool removedBSignalReceived = false;
7166 auto actorA = Actor::New();
7167 auto actorB = Actor::New();
7171 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
7172 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7173 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
7174 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7176 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7177 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7178 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7179 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7181 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7182 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7183 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7184 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7186 // Create a child of A
7188 auto child = Actor::New();
7191 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7192 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7193 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7194 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7195 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7198 addedASignalReceived = false;
7199 addedBSignalReceived = false;
7200 removedASignalReceived = false;
7201 removedBSignalReceived = false;
7203 actorB.Add(child); // Expect this child to be re-parented
7204 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7205 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7206 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7207 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7209 // Move child back to A:
7210 addedASignalReceived = false;
7211 addedBSignalReceived = false;
7212 removedASignalReceived = false;
7213 removedBSignalReceived = false;
7215 actorA.Add(child); // Expect this child to be re-parented
7216 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7217 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7218 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7219 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7224 int utcDaliActorCulled(void)
7226 TestApplication application;
7227 auto stage = application.GetScene();
7229 tet_infoline("Check that the actor is culled if the actor is out of the screen");
7231 Actor actor = Actor::New();
7232 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7234 Geometry geometry = CreateQuadGeometry();
7235 Shader shader = CreateShader();
7236 Renderer renderer = Renderer::New(geometry, shader);
7237 actor.AddRenderer(renderer);
7241 application.SendNotification();
7242 application.Render(0);
7244 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7246 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7247 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7249 // Connect NotifySignal
7250 bool propertyNotificationSignal(false);
7251 PropertyNotification source;
7252 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7253 notification.NotifySignal().Connect(&application, f);
7255 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7257 application.SendNotification();
7258 application.Render();
7260 application.SendNotification();
7262 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7264 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7265 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7266 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7271 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7273 TestApplication application;
7274 auto stage = application.GetScene();
7276 tet_infoline("Ensure we clear the screen when the last actor is removed");
7278 Actor actor = CreateRenderableActor();
7279 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7282 application.SendNotification();
7283 application.Render();
7285 auto& glAbstraction = application.GetGlAbstraction();
7286 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7290 application.SendNotification();
7291 application.Render();
7293 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7298 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7300 TestApplication application;
7301 auto stage = application.GetScene();
7303 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7305 Actor actor = CreateRenderableActor();
7306 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7309 application.SendNotification();
7310 application.Render();
7312 auto& glAbstraction = application.GetGlAbstraction();
7313 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7315 actor.SetProperty(Actor::Property::VISIBLE, false);
7317 application.SendNotification();
7318 application.Render();
7320 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7325 int utcDaliActorGetSizeAfterAnimation(void)
7327 TestApplication application;
7328 tet_infoline("Check the actor size before / after an animation is finished");
7330 Vector3 actorSize(100.0f, 100.0f, 0.0f);
7332 Actor actor = Actor::New();
7333 actor.SetProperty(Actor::Property::SIZE, actorSize);
7334 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7335 application.GetScene().Add(actor);
7337 // Size should be updated without rendering.
7338 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7339 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7341 application.SendNotification();
7342 application.Render();
7344 // Size and current size should be updated.
7345 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7346 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7347 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7348 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7349 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7351 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7352 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7353 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7354 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7355 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7358 actorSize = Vector3(200.0f, 200.0f, 0.0f);
7359 actor.SetProperty(Actor::Property::SIZE, actorSize);
7361 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7362 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7364 Vector3 targetValue(10.0f, 20.0f, 0.0f);
7366 Animation animation = Animation::New(1.0f);
7367 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7370 // Size should be updated without rendering.
7371 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7372 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7374 application.SendNotification();
7375 application.Render(1100); // After the animation
7377 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7378 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7379 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7380 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7381 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7383 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7384 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7385 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7386 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7387 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7389 targetValue.width = 50.0f;
7392 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
7395 application.SendNotification();
7396 application.Render(1100); // After the animation
7398 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7399 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7400 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7401 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7402 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7404 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7405 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7406 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7407 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7408 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7410 targetValue.height = 70.0f;
7413 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
7416 application.SendNotification();
7417 application.Render(1100); // After the animation
7419 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7420 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7421 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7422 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7423 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7425 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7426 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7427 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7428 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7429 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7431 Vector3 offset(10.0f, 20.0f, 0.0f);
7434 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
7437 application.SendNotification();
7438 application.Render(1100); // After the animation
7440 targetValue += offset;
7442 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7443 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7444 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7445 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7446 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7448 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7449 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7450 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7451 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7452 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7454 offset.width = 20.0f;
7457 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
7460 application.SendNotification();
7461 application.Render(1100); // After the animation
7463 targetValue.width += offset.width;
7465 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7466 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7467 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7468 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7469 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7471 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7472 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7473 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7474 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7475 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7477 offset.height = 10.0f;
7480 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
7483 application.SendNotification();
7484 application.Render(1100); // After the animation
7486 targetValue.height += offset.height;
7488 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7489 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7490 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7491 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7492 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7494 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7495 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7496 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7497 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7498 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7501 actorSize = Vector3(300.0f, 300.0f, 0.0f);
7503 actor.SetProperty(Actor::Property::SIZE, actorSize);
7505 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7506 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7508 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7509 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7511 application.SendNotification();
7512 application.Render();
7514 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7515 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7517 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7518 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7523 int utcDaliActorPartialUpdate(void)
7525 TestApplication application(
7526 TestApplication::DEFAULT_SURFACE_WIDTH,
7527 TestApplication::DEFAULT_SURFACE_HEIGHT,
7528 TestApplication::DEFAULT_HORIZONTAL_DPI,
7529 TestApplication::DEFAULT_VERTICAL_DPI,
7533 tet_infoline("Check the damaged area");
7535 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7537 std::vector<Rect<int>> damagedRects;
7538 Rect<int> clippingRect;
7539 application.SendNotification();
7540 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7542 // First render pass, nothing to render, adaptor would just do swap buffer.
7543 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7544 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7546 Actor actor = CreateRenderableActor();
7547 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7548 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7549 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7550 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7551 application.GetScene().Add(actor);
7553 application.SendNotification();
7555 // 1. Actor added, damaged rect is added size of actor
7556 damagedRects.clear();
7557 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7558 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7561 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7562 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7563 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7564 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7565 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7566 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7567 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7570 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7571 application.SendNotification();
7573 damagedRects.clear();
7574 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7575 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7578 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7579 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7580 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7581 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7582 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7583 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7584 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7586 // 3. Set new position
7587 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7588 application.SendNotification();
7590 damagedRects.clear();
7591 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7592 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7595 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7596 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7597 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7598 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7599 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7600 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7601 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7603 application.GetScene().Remove(actor);
7604 application.SendNotification();
7606 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7607 damagedRects.clear();
7608 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7609 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7611 clippingRect = damagedRects[0];
7612 clippingRect.Merge(damagedRects[1]);
7613 clippingRect.Merge(damagedRects[2]);
7615 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7616 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7617 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7619 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7620 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7621 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7622 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7623 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7628 int utcDaliActorPartialUpdateSetColor(void)
7630 TestApplication application(
7631 TestApplication::DEFAULT_SURFACE_WIDTH,
7632 TestApplication::DEFAULT_SURFACE_HEIGHT,
7633 TestApplication::DEFAULT_HORIZONTAL_DPI,
7634 TestApplication::DEFAULT_VERTICAL_DPI,
7638 tet_infoline("Check uniform update");
7640 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7642 std::vector<Rect<int>> damagedRects;
7643 Rect<int> clippingRect;
7644 application.SendNotification();
7645 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7647 // First render pass, nothing to render, adaptor would just do swap buffer.
7648 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7649 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7651 Actor actor = CreateRenderableActor();
7652 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7653 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7654 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7655 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7656 application.GetScene().Add(actor);
7658 application.SendNotification();
7660 // 1. Actor added, damaged rect is added size of actor
7661 damagedRects.clear();
7662 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7663 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7666 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7667 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7668 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7669 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7670 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7671 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7672 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7674 damagedRects.clear();
7675 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7677 damagedRects.clear();
7678 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7681 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
7682 application.SendNotification();
7684 damagedRects.clear();
7685 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7686 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7689 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7690 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7691 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7692 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7693 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7694 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7695 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7700 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
7701 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
7702 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
7703 const char* const RENDER_SHADOW_VERTEX_SOURCE =
7704 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
7705 " uniform mediump mat4 uLightCameraViewMatrix;\n"
7709 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
7710 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
7711 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
7714 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
7715 "uniform lowp vec4 uShadowColor;\n"
7718 " lowp float alpha;\n"
7719 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
7720 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
7723 int utcDaliActorPartialUpdateSetProperty(void)
7725 TestApplication application(
7726 TestApplication::DEFAULT_SURFACE_WIDTH,
7727 TestApplication::DEFAULT_SURFACE_HEIGHT,
7728 TestApplication::DEFAULT_HORIZONTAL_DPI,
7729 TestApplication::DEFAULT_VERTICAL_DPI,
7733 tet_infoline("Set/Update property with partial update");
7735 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7737 std::vector<Rect<int>> damagedRects;
7738 Rect<int> clippingRect;
7739 application.SendNotification();
7740 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7742 // First render pass, nothing to render, adaptor would just do swap buffer.
7743 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7744 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7746 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
7747 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
7748 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7749 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7750 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7751 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7752 application.GetScene().Add(actor);
7754 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
7756 damagedRects.clear();
7757 application.SendNotification();
7758 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7759 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7762 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7763 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7764 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7765 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7766 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7767 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7768 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7770 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
7771 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
7773 damagedRects.clear();
7774 application.SendNotification();
7775 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7776 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7778 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7779 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7780 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7781 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7782 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7783 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7785 damagedRects.clear();
7786 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7787 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7789 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7790 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7791 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7792 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7793 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7794 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7796 damagedRects.clear();
7797 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7798 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7803 int utcDaliActorPartialUpdateTwoActors(void)
7805 TestApplication application(
7806 TestApplication::DEFAULT_SURFACE_WIDTH,
7807 TestApplication::DEFAULT_SURFACE_HEIGHT,
7808 TestApplication::DEFAULT_HORIZONTAL_DPI,
7809 TestApplication::DEFAULT_VERTICAL_DPI,
7813 tet_infoline("Check the damaged rects with partial update and two actors");
7815 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7817 Actor actor = CreateRenderableActor();
7818 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
7819 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
7820 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7821 application.GetScene().Add(actor);
7823 Actor actor2 = CreateRenderableActor();
7824 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
7825 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
7826 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7827 application.GetScene().Add(actor2);
7829 application.SendNotification();
7830 std::vector<Rect<int>> damagedRects;
7831 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7833 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
7834 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
7835 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
7837 // in screen coordinates, adaptor would calculate it using previous frames information
7838 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
7839 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7841 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7842 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7843 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7844 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7849 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
7851 TestApplication application(
7852 TestApplication::DEFAULT_SURFACE_WIDTH,
7853 TestApplication::DEFAULT_SURFACE_HEIGHT,
7854 TestApplication::DEFAULT_HORIZONTAL_DPI,
7855 TestApplication::DEFAULT_VERTICAL_DPI,
7859 tet_infoline("Check the damaged rect with partial update and actor size hint");
7861 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7863 Actor actor = CreateRenderableActor();
7864 actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f));
7865 actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f));
7866 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0));
7867 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7868 application.GetScene().Add(actor);
7870 application.SendNotification();
7871 std::vector<Rect<int>> damagedRects;
7872 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7874 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7876 Rect<int> clippingRect = Rect<int>(0, 496, 160, 320);
7877 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7879 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7881 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7882 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7883 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7884 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7889 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
7891 TestApplication application;
7893 Actor actor = Actor::New();
7894 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
7895 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
7896 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
7897 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
7898 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
7899 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7900 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7901 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
7905 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
7907 TestApplication application;
7909 Actor actor = Actor::New();
7911 // Make sure setting invalid types does not cause a crash
7914 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
7915 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
7916 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
7917 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
7918 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
7919 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
7920 tet_result(TET_PASS);
7924 tet_result(TET_FAIL);
7929 int UtcDaliActorTouchAreaPropertyP(void)
7931 TestApplication application;
7933 Actor actor = Actor::New();
7934 Vector2 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
7935 DALI_TEST_EQUALS(touchArea, Vector2::ZERO, TEST_LOCATION);
7936 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(10.f, 10.f));
7937 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
7938 DALI_TEST_EQUALS(touchArea, Vector2(10.f, 10.f), TEST_LOCATION);
7942 int UtcDaliActorTouchAreaPropertyN(void)
7944 TestApplication application;
7946 Actor actor = Actor::New();
7948 // Make sure setting invalid types does not cause a crash
7951 actor.SetProperty(DevelActor::Property::TOUCH_AREA, 1.0f);
7952 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2::ONE);
7953 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector3::ONE);
7954 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector4::ONE);
7955 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Map());
7956 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Array());
7957 tet_result(TET_PASS);
7961 tet_result(TET_FAIL);
7966 int UtcDaliActorLowerBelowNegative(void)
7968 TestApplication application;
7969 Dali::Actor instance;
7973 instance.LowerBelow(arg1);
7974 DALI_TEST_CHECK(false); // Should not get here
7978 DALI_TEST_CHECK(true); // We expect an assert
7983 int UtcDaliActorRaiseAboveNegative(void)
7985 TestApplication application;
7986 Dali::Actor instance;
7990 instance.RaiseAbove(arg1);
7991 DALI_TEST_CHECK(false); // Should not get here
7995 DALI_TEST_CHECK(true); // We expect an assert
8000 int UtcDaliActorRaiseToTopNegative(void)
8002 TestApplication application;
8003 Dali::Actor instance;
8006 instance.RaiseToTop();
8007 DALI_TEST_CHECK(false); // Should not get here
8011 DALI_TEST_CHECK(true); // We expect an assert
8016 int UtcDaliActorAddRendererNegative(void)
8018 TestApplication application;
8019 Dali::Actor instance;
8022 Dali::Renderer arg1;
8023 instance.AddRenderer(arg1);
8024 DALI_TEST_CHECK(false); // Should not get here
8028 DALI_TEST_CHECK(true); // We expect an assert
8033 int UtcDaliActorTouchedSignalNegative(void)
8035 TestApplication application;
8036 Dali::Actor instance;
8039 instance.TouchedSignal();
8040 DALI_TEST_CHECK(false); // Should not get here
8044 DALI_TEST_CHECK(true); // We expect an assert
8049 int UtcDaliActorTranslateByNegative(void)
8051 TestApplication application;
8052 Dali::Actor instance;
8056 instance.TranslateBy(arg1);
8057 DALI_TEST_CHECK(false); // Should not get here
8061 DALI_TEST_CHECK(true); // We expect an assert
8066 int UtcDaliActorFindChildByIdNegative(void)
8068 TestApplication application;
8069 Dali::Actor instance;
8072 unsigned int arg1 = 0u;
8073 instance.FindChildById(arg1);
8074 DALI_TEST_CHECK(false); // Should not get here
8078 DALI_TEST_CHECK(true); // We expect an assert
8083 int UtcDaliActorGetRendererAtNegative(void)
8085 TestApplication application;
8086 Dali::Actor instance;
8089 unsigned int arg1 = 0u;
8090 instance.GetRendererAt(arg1);
8091 DALI_TEST_CHECK(false); // Should not get here
8095 DALI_TEST_CHECK(true); // We expect an assert
8100 int UtcDaliActorHoveredSignalNegative(void)
8102 TestApplication application;
8103 Dali::Actor instance;
8106 instance.HoveredSignal();
8107 DALI_TEST_CHECK(false); // Should not get here
8111 DALI_TEST_CHECK(true); // We expect an assert
8116 int UtcDaliActorLowerToBottomNegative(void)
8118 TestApplication application;
8119 Dali::Actor instance;
8122 instance.LowerToBottom();
8123 DALI_TEST_CHECK(false); // Should not get here
8127 DALI_TEST_CHECK(true); // We expect an assert
8132 int UtcDaliActorOnSceneSignalNegative(void)
8134 TestApplication application;
8135 Dali::Actor instance;
8138 instance.OnSceneSignal();
8139 DALI_TEST_CHECK(false); // Should not get here
8143 DALI_TEST_CHECK(true); // We expect an assert
8148 int UtcDaliActorOffSceneSignalNegative(void)
8150 TestApplication application;
8151 Dali::Actor instance;
8154 instance.OffSceneSignal();
8155 DALI_TEST_CHECK(false); // Should not get here
8159 DALI_TEST_CHECK(true); // We expect an assert
8164 int UtcDaliActorRemoveRendererNegative01(void)
8166 TestApplication application;
8167 Dali::Actor instance;
8170 unsigned int arg1 = 0u;
8171 instance.RemoveRenderer(arg1);
8172 DALI_TEST_CHECK(false); // Should not get here
8176 DALI_TEST_CHECK(true); // We expect an assert
8181 int UtcDaliActorRemoveRendererNegative02(void)
8183 TestApplication application;
8184 Dali::Actor instance;
8187 Dali::Renderer arg1;
8188 instance.RemoveRenderer(arg1);
8189 DALI_TEST_CHECK(false); // Should not get here
8193 DALI_TEST_CHECK(true); // We expect an assert
8198 int UtcDaliActorFindChildByNameNegative(void)
8200 TestApplication application;
8201 Dali::Actor instance;
8205 instance.FindChildByName(arg1);
8206 DALI_TEST_CHECK(false); // Should not get here
8210 DALI_TEST_CHECK(true); // We expect an assert
8215 int UtcDaliActorSetResizePolicyNegative(void)
8217 TestApplication application;
8218 Dali::Actor instance;
8221 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
8222 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
8223 instance.SetResizePolicy(arg1, arg2);
8224 DALI_TEST_CHECK(false); // Should not get here
8228 DALI_TEST_CHECK(true); // We expect an assert
8233 int UtcDaliActorOnRelayoutSignalNegative(void)
8235 TestApplication application;
8236 Dali::Actor instance;
8239 instance.OnRelayoutSignal();
8240 DALI_TEST_CHECK(false); // Should not get here
8244 DALI_TEST_CHECK(true); // We expect an assert
8249 int UtcDaliActorWheelEventSignalNegative(void)
8251 TestApplication application;
8252 Dali::Actor instance;
8255 instance.WheelEventSignal();
8256 DALI_TEST_CHECK(false); // Should not get here
8260 DALI_TEST_CHECK(true); // We expect an assert
8265 int UtcDaliActorGetHeightForWidthNegative(void)
8267 TestApplication application;
8268 Dali::Actor instance;
8272 instance.GetHeightForWidth(arg1);
8273 DALI_TEST_CHECK(false); // Should not get here
8277 DALI_TEST_CHECK(true); // We expect an assert
8282 int UtcDaliActorGetWidthForHeightNegative(void)
8284 TestApplication application;
8285 Dali::Actor instance;
8289 instance.GetWidthForHeight(arg1);
8290 DALI_TEST_CHECK(false); // Should not get here
8294 DALI_TEST_CHECK(true); // We expect an assert
8299 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
8301 TestApplication application;
8302 Dali::Actor instance;
8305 instance.LayoutDirectionChangedSignal();
8306 DALI_TEST_CHECK(false); // Should not get here
8310 DALI_TEST_CHECK(true); // We expect an assert
8315 int UtcDaliActorAddNegative(void)
8317 TestApplication application;
8318 Dali::Actor instance;
8323 DALI_TEST_CHECK(false); // Should not get here
8327 DALI_TEST_CHECK(true); // We expect an assert
8332 int UtcDaliActorLowerNegative(void)
8334 TestApplication application;
8335 Dali::Actor instance;
8339 DALI_TEST_CHECK(false); // Should not get here
8343 DALI_TEST_CHECK(true); // We expect an assert
8348 int UtcDaliActorRaiseNegative(void)
8350 TestApplication application;
8351 Dali::Actor instance;
8355 DALI_TEST_CHECK(false); // Should not get here
8359 DALI_TEST_CHECK(true); // We expect an assert
8364 int UtcDaliActorRemoveNegative(void)
8366 TestApplication application;
8367 Dali::Actor instance;
8371 instance.Remove(arg1);
8372 DALI_TEST_CHECK(false); // Should not get here
8376 DALI_TEST_CHECK(true); // We expect an assert
8381 int UtcDaliActorScaleByNegative(void)
8383 TestApplication application;
8384 Dali::Actor instance;
8388 instance.ScaleBy(arg1);
8389 DALI_TEST_CHECK(false); // Should not get here
8393 DALI_TEST_CHECK(true); // We expect an assert
8398 int UtcDaliActorGetLayerNegative(void)
8400 TestApplication application;
8401 Dali::Actor instance;
8404 instance.GetLayer();
8405 DALI_TEST_CHECK(false); // Should not get here
8409 DALI_TEST_CHECK(true); // We expect an assert
8414 int UtcDaliActorRotateByNegative01(void)
8416 TestApplication application;
8417 Dali::Actor instance;
8420 Dali::Quaternion arg1;
8421 instance.RotateBy(arg1);
8422 DALI_TEST_CHECK(false); // Should not get here
8426 DALI_TEST_CHECK(true); // We expect an assert
8431 int UtcDaliActorRotateByNegative02(void)
8433 TestApplication application;
8434 Dali::Actor instance;
8439 instance.RotateBy(arg1, arg2);
8440 DALI_TEST_CHECK(false); // Should not get here
8444 DALI_TEST_CHECK(true); // We expect an assert
8449 int UtcDaliActorUnparentNegative(void)
8451 TestApplication application;
8452 Dali::Actor instance;
8455 instance.Unparent();
8456 DALI_TEST_CHECK(false); // Should not get here
8460 DALI_TEST_CHECK(true); // We expect an assert
8465 int UtcDaliActorGetChildAtNegative(void)
8467 TestApplication application;
8468 Dali::Actor instance;
8471 unsigned int arg1 = 0u;
8472 instance.GetChildAt(arg1);
8473 DALI_TEST_CHECK(false); // Should not get here
8477 DALI_TEST_CHECK(true); // We expect an assert
8482 int UtcDaliActorGetChildCountNegative(void)
8484 TestApplication application;
8485 Dali::Actor instance;
8488 instance.GetChildCount();
8489 DALI_TEST_CHECK(false); // Should not get here
8493 DALI_TEST_CHECK(true); // We expect an assert
8498 int UtcDaliActorGetTargetSizeNegative(void)
8500 TestApplication application;
8501 Dali::Actor instance;
8504 instance.GetTargetSize();
8505 DALI_TEST_CHECK(false); // Should not get here
8509 DALI_TEST_CHECK(true); // We expect an assert
8514 int UtcDaliActorScreenToLocalNegative(void)
8516 TestApplication application;
8517 Dali::Actor instance;
8524 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
8525 DALI_TEST_CHECK(false); // Should not get here
8529 DALI_TEST_CHECK(true); // We expect an assert
8534 int UtcDaliActorGetNaturalSizeNegative(void)
8536 TestApplication application;
8537 Dali::Actor instance;
8540 instance.GetNaturalSize();
8541 DALI_TEST_CHECK(false); // Should not get here
8545 DALI_TEST_CHECK(true); // We expect an assert
8550 int UtcDaliActorGetRelayoutSizeNegative(void)
8552 TestApplication application;
8553 Dali::Actor instance;
8556 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
8557 instance.GetRelayoutSize(arg1);
8558 DALI_TEST_CHECK(false); // Should not get here
8562 DALI_TEST_CHECK(true); // We expect an assert
8567 int UtcDaliActorGetResizePolicyNegative(void)
8569 TestApplication application;
8570 Dali::Actor instance;
8573 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
8574 instance.GetResizePolicy(arg1);
8575 DALI_TEST_CHECK(false); // Should not get here
8579 DALI_TEST_CHECK(true); // We expect an assert
8584 int UtcDaliActorGetRendererCountNegative(void)
8586 TestApplication application;
8587 Dali::Actor instance;
8590 instance.GetRendererCount();
8591 DALI_TEST_CHECK(false); // Should not get here
8595 DALI_TEST_CHECK(true); // We expect an assert
8600 int UtcDaliActorGetParentNegative(void)
8602 TestApplication application;
8603 Dali::Actor instance;
8606 instance.GetParent();
8607 DALI_TEST_CHECK(false); // Should not get here
8611 DALI_TEST_CHECK(true); // We expect an assert