2 * Copyright (c) 2023 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/devel-api/common/capabilities.h>
24 #include <dali/integration-api/debug.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali/public-api/dali-core.h>
28 #include <mesh-builder.h>
29 #include <test-actor-utils.h>
31 #include <cfloat> // For FLT_MAX
32 #include <set> // For std::multiset
42 void utc_dali_actor_startup(void)
44 test_return_value = TET_UNDEF;
47 void utc_dali_actor_cleanup(void)
49 test_return_value = TET_PASS;
54 bool gTouchCallBackCalled = false;
55 bool gTouchCallBackCalled2 = false;
56 bool gTouchCallBackCalled3 = false;
57 bool gHitTestTouchCallBackCalled = false;
59 bool gHoverCallBackCalled = false;
61 static bool gTestConstraintCalled;
63 LayoutDirection::Type gLayoutDirectionType;
67 void operator()(Vector4& color, const PropertyInputContainer& /* inputs */)
69 gTestConstraintCalled = true;
74 * TestConstraint reference.
75 * When constraint is called, the resultRef is updated
76 * with the value supplied.
79 struct TestConstraintRef
81 TestConstraintRef(unsigned int& resultRef, unsigned int value)
82 : mResultRef(resultRef),
87 void operator()(T& current, const PropertyInputContainer& /* inputs */)
92 unsigned int& mResultRef;
96 static bool TestTouchCallback(Actor, const TouchEvent&)
98 gTouchCallBackCalled = true;
103 static bool TestTouchCallback2(Actor, const TouchEvent&)
105 gTouchCallBackCalled2 = true;
110 static bool TestTouchCallback3(Actor, const TouchEvent&)
112 gTouchCallBackCalled3 = true;
117 static bool TestHitTestTouchCallback(Actor, const TouchEvent&)
119 gHitTestTouchCallBackCalled = true;
124 static void ResetTouchCallbacks()
126 gTouchCallBackCalled = false;
127 gTouchCallBackCalled2 = false;
128 gTouchCallBackCalled3 = false;
131 static bool TestCallback3(Actor actor, const HoverEvent& event)
133 gHoverCallBackCalled = true;
138 // validation stuff for onstage & offstage signals
139 static std::vector<std::string> gActorNamesOnOffScene;
140 static int gOnSceneCallBackCalled;
141 void OnSceneCallback(Actor actor)
143 ++gOnSceneCallBackCalled;
144 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
145 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
147 static int gOffSceneCallBackCalled;
148 void OffSceneCallback(Actor actor)
150 ++gOffSceneCallBackCalled;
151 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
152 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
155 struct PositionComponentConstraint
157 PositionComponentConstraint()
161 void operator()(Vector3& pos, const PropertyInputContainer& inputs)
163 const Matrix& m = inputs[0]->GetMatrix();
166 m.GetTransformComponents(pos, rot, scale);
170 struct OrientationComponentConstraint
172 OrientationComponentConstraint()
176 void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
178 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
181 orientation = parentOrientation;
186 static bool gOnRelayoutCallBackCalled = false;
187 static std::vector<std::string> gActorNamesRelayout;
189 void OnRelayoutCallback(Actor actor)
191 gOnRelayoutCallBackCalled = true;
192 gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
195 struct VisibilityChangedFunctorData
197 VisibilityChangedFunctorData()
200 type(DevelActor::VisibilityChange::SELF),
209 type = DevelActor::VisibilityChange::SELF;
213 void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
215 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
216 DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
217 DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
218 DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
221 void Check(bool compareCalled, const std::string& location)
223 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
228 DevelActor::VisibilityChange::Type type;
232 struct VisibilityChangedFunctor
234 VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
239 void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
242 data.visible = visible;
247 VisibilityChangedFunctorData& data;
250 struct VisibilityChangedVoidFunctor
252 VisibilityChangedVoidFunctor(bool& signalCalled)
253 : mSignalCalled(signalCalled)
259 mSignalCalled = true;
265 struct ChildOrderChangedFunctor
267 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
268 : mSignalCalled(signalCalled),
273 void operator()(Actor actor)
275 mSignalCalled = true;
283 struct CulledPropertyNotificationFunctor
285 CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
286 : mSignalCalled(signalCalled),
287 mPropertyNotification(propertyNotification)
291 void operator()(PropertyNotification& source)
293 mSignalCalled = true;
294 mPropertyNotification = source;
298 PropertyNotification& mPropertyNotification;
301 // Check dirtyRect is equal with expected multiset.
302 // Note that the order of damagedRect is not important
305 bool operator()(const Rect<int>& lhs, const Rect<int>& rhs) const
309 return lhs.x < rhs.x;
313 return lhs.y < rhs.y;
315 if(lhs.width != rhs.width)
317 return lhs.width < rhs.width;
319 return lhs.height < rhs.height;
323 void DirtyRectChecker(const std::vector<Rect<int>>& damagedRects, std::multiset<Rect<int>, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation)
325 // Just check damagedRect contain all expectRectList.
326 DALI_TEST_GREATER(damagedRects.size() + 1u, expectedRectList.size(), testLocation);
328 for(auto& rect : damagedRects)
330 auto iter = expectedRectList.find(rect);
331 if(iter != expectedRectList.end())
333 expectedRectList.erase(iter);
335 else if(checkRectsExact)
337 std::ostringstream o;
338 o << rect << " exist in expectRectList" << std::endl;
339 fprintf(stderr, "Test failed in %s, checking %s", testLocation, o.str().c_str());
340 tet_result(TET_FAIL);
344 // Check all rects are matched
345 DALI_TEST_EQUALS(expectedRectList.empty(), true, testLocation);
348 } // anonymous namespace
350 //& purpose: Testing New API
351 int UtcDaliActorNew(void)
353 TestApplication application;
355 Actor actor = Actor::New();
357 DALI_TEST_CHECK(actor);
361 //& purpose: Testing Dali::Actor::DownCast()
362 int UtcDaliActorDownCastP(void)
364 TestApplication application;
365 tet_infoline("Testing Dali::Actor::DownCast()");
367 Actor actor = Actor::New();
368 BaseHandle object(actor);
369 Actor actor2 = Actor::DownCast(object);
370 DALI_TEST_CHECK(actor2);
374 //& purpose: Testing Dali::Actor::DownCast()
375 int UtcDaliActorDownCastN(void)
377 TestApplication application;
378 tet_infoline("Testing Dali::Actor::DownCast()");
380 BaseHandle unInitializedObject;
381 Actor actor = Actor::DownCast(unInitializedObject);
382 DALI_TEST_CHECK(!actor);
386 int UtcDaliActorMoveConstructor(void)
388 TestApplication application;
390 Actor actor = Actor::New();
391 DALI_TEST_CHECK(actor);
393 int id = actor.GetProperty<int>(Actor::Property::ID);
395 Actor moved = std::move(actor);
396 DALI_TEST_CHECK(moved);
397 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
398 DALI_TEST_CHECK(!actor);
403 int UtcDaliActorMoveAssignment(void)
405 TestApplication application;
407 Actor actor = Actor::New();
408 DALI_TEST_CHECK(actor);
410 int id = actor.GetProperty<int>(Actor::Property::ID);
413 moved = std::move(actor);
414 DALI_TEST_CHECK(moved);
415 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
416 DALI_TEST_CHECK(!actor);
421 //& purpose: Testing Dali::Actor::GetName()
422 int UtcDaliActorGetName(void)
424 TestApplication application;
426 Actor actor = Actor::New();
428 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
432 //& purpose: Testing Dali::Actor::SetName()
433 int UtcDaliActorSetName(void)
435 TestApplication application;
437 string str("ActorName");
438 Actor actor = Actor::New();
440 actor.SetProperty(Actor::Property::NAME, str);
441 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
445 int UtcDaliActorGetId(void)
447 tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
448 TestApplication application;
450 Actor first = Actor::New();
451 Actor second = Actor::New();
452 Actor third = Actor::New();
454 DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
455 DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
459 int UtcDaliActorIsRoot(void)
461 TestApplication application;
463 Actor actor = Actor::New();
464 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
466 // get the root layer
467 actor = application.GetScene().GetLayer(0);
468 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
472 int UtcDaliActorOnScene(void)
474 TestApplication application;
476 Actor actor = Actor::New();
477 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
479 // get the root layer
480 actor = application.GetScene().GetLayer(0);
481 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
485 int UtcDaliActorIsLayer(void)
487 TestApplication application;
489 Actor actor = Actor::New();
490 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
492 // get the root layer
493 actor = application.GetScene().GetLayer(0);
494 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
498 int UtcDaliActorGetLayer(void)
500 TestApplication application;
502 Actor actor = Actor::New();
503 application.GetScene().Add(actor);
504 Layer layer = actor.GetLayer();
506 DALI_TEST_CHECK(layer);
508 // get the root layers layer
509 actor = application.GetScene().GetLayer(0);
510 DALI_TEST_CHECK(actor.GetLayer());
514 int UtcDaliActorAddP(void)
516 tet_infoline("Testing Actor::Add");
517 TestApplication application;
519 Actor parent = Actor::New();
520 Actor child = Actor::New();
522 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
526 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
528 Actor parent2 = Actor::New();
531 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
532 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
534 // try Adding to same parent again, works
536 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
538 // try reparenting an orphaned child
540 Actor temporaryParent = Actor::New();
541 temporaryParent.Add(child);
542 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
544 // temporaryParent has now died, reparent the orphaned child
546 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
551 int UtcDaliActorAddN(void)
553 tet_infoline("Testing Actor::Add");
554 TestApplication application;
556 Actor child = Actor::New();
558 Actor parent2 = Actor::New();
564 parent2.Add(parent2);
565 tet_printf("Assertion test failed - no Exception\n");
566 tet_result(TET_FAIL);
568 catch(Dali::DaliException& e)
570 DALI_TEST_PRINT_ASSERT(e);
571 DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
572 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
576 tet_printf("Assertion test failed - wrong Exception\n");
577 tet_result(TET_FAIL);
580 // try reparenting root
583 parent2.Add(application.GetScene().GetLayer(0));
584 tet_printf("Assertion test failed - no Exception\n");
585 tet_result(TET_FAIL);
587 catch(Dali::DaliException& e)
589 DALI_TEST_PRINT_ASSERT(e);
590 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
591 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
595 tet_printf("Assertion test failed - wrong Exception\n");
596 tet_result(TET_FAIL);
604 tet_printf("Assertion test failed - no Exception\n");
605 tet_result(TET_FAIL);
607 catch(Dali::DaliException& e)
609 DALI_TEST_PRINT_ASSERT(e);
610 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
611 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
615 tet_printf("Assertion test failed - wrong Exception\n");
616 tet_result(TET_FAIL);
622 int UtcDaliActorRemoveN(void)
624 tet_infoline("Testing Actor::Remove");
625 TestApplication application;
627 Actor parent = Actor::New();
628 Actor child = Actor::New();
629 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
632 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
634 parent.Remove(child);
635 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
637 // remove again, no problem
638 parent.Remove(child);
639 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
643 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
644 // try Remove self, its a no-op
645 parent.Remove(parent);
646 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
652 parent.Remove(empty);
653 tet_printf("Assertion test failed - no Exception\n");
654 tet_result(TET_FAIL);
656 catch(Dali::DaliException& e)
658 DALI_TEST_PRINT_ASSERT(e);
659 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
660 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
664 tet_printf("Assertion test failed - wrong Exception\n");
665 tet_result(TET_FAIL);
670 int UtcDaliActorRemoveP(void)
672 TestApplication application;
674 Actor parent = Actor::New();
675 Actor child = Actor::New();
676 Actor random = Actor::New();
678 application.GetScene().Add(parent);
680 DALI_TEST_CHECK(parent.GetChildCount() == 0);
684 DALI_TEST_CHECK(parent.GetChildCount() == 1);
686 parent.Remove(random);
688 DALI_TEST_CHECK(parent.GetChildCount() == 1);
690 application.GetScene().Remove(parent);
692 DALI_TEST_CHECK(parent.GetChildCount() == 1);
696 int UtcDaliActorSwitchParentN(void)
698 tet_infoline("Testing Actor::UtcDaliActorSwitchParentN");
699 TestApplication application;
701 Actor parent1 = Actor::New();
702 Actor child = Actor::New();
704 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
708 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
710 Actor parent2 = Actor::New();
712 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
714 // Try switch parent with that both of parent1 and parent2 are off scene.
715 DevelActor::SwitchParent(child, parent2);
717 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
718 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
722 int UtcDaliActorGetChildCount(void)
724 TestApplication application;
726 Actor parent = Actor::New();
727 Actor child = Actor::New();
729 DALI_TEST_CHECK(parent.GetChildCount() == 0);
733 DALI_TEST_CHECK(parent.GetChildCount() == 1);
737 int UtcDaliActorGetChildren01(void)
739 TestApplication application;
741 Actor parent = Actor::New();
742 Actor first = Actor::New();
743 Actor second = Actor::New();
744 Actor third = Actor::New();
750 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
751 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
752 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
756 int UtcDaliActorGetChildren02(void)
758 TestApplication application;
760 Actor parent = Actor::New();
761 Actor first = Actor::New();
762 Actor second = Actor::New();
763 Actor third = Actor::New();
769 const Actor& constParent = parent;
771 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
772 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
773 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
777 int UtcDaliActorGetParent01(void)
779 TestApplication application;
781 Actor parent = Actor::New();
782 Actor child = Actor::New();
786 DALI_TEST_CHECK(child.GetParent() == parent);
790 int UtcDaliActorGetParent02(void)
792 TestApplication application;
794 Actor actor = Actor::New();
796 DALI_TEST_CHECK(!actor.GetParent());
800 int UtcDaliActorCustomProperty(void)
802 TestApplication application;
804 Actor actor = Actor::New();
805 application.GetScene().Add(actor);
807 float startValue(1.0f);
808 Property::Index index = actor.RegisterProperty("testProperty", startValue);
809 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
811 application.SendNotification();
812 application.Render(0);
813 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
815 actor.SetProperty(index, 5.0f);
817 application.SendNotification();
818 application.Render(0);
819 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
823 int UtcDaliActorCustomPropertyIntToFloat(void)
825 TestApplication application;
827 Actor actor = Actor::New();
828 application.GetScene().Add(actor);
830 float startValue(5.0f);
831 Property::Index index = actor.RegisterProperty("testProperty", startValue);
832 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
834 application.SendNotification();
835 application.Render(0);
836 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
838 actor.SetProperty(index, int(1));
840 application.SendNotification();
841 application.Render(0);
842 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
846 int UtcDaliActorCustomPropertyFloatToInt(void)
848 TestApplication application;
850 Actor actor = Actor::New();
851 application.GetScene().Add(actor);
854 Property::Index index = actor.RegisterProperty("testProperty", startValue);
855 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
857 application.SendNotification();
858 application.Render(0);
859 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
861 actor.SetProperty(index, float(1.5));
863 application.SendNotification();
864 application.Render(0);
865 DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
869 int UtcDaliActorSetParentOrigin(void)
871 TestApplication application;
873 Actor actor = Actor::New();
875 Vector3 vector(0.7f, 0.8f, 0.9f);
876 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
878 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
880 // flush the queue and render once
881 application.SendNotification();
882 application.Render();
884 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
886 application.GetScene().Add(actor);
888 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
890 // flush the queue and render once
891 application.SendNotification();
892 application.Render();
894 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
896 application.GetScene().Remove(actor);
900 int UtcDaliActorSetParentOriginIndividual(void)
902 TestApplication application;
904 Actor actor = Actor::New();
906 Vector3 vector(0.7f, 0.8f, 0.9f);
907 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
909 actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
911 // flush the queue and render once
912 application.SendNotification();
913 application.Render();
915 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
917 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
919 // flush the queue and render once
920 application.SendNotification();
921 application.Render();
923 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
925 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
927 // flush the queue and render once
928 application.SendNotification();
929 application.Render();
931 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
936 int UtcDaliActorGetCurrentParentOrigin(void)
938 TestApplication application;
940 Actor actor = Actor::New();
942 Vector3 vector(0.7f, 0.8f, 0.9f);
943 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
945 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
947 // flush the queue and render once
948 application.SendNotification();
949 application.Render();
951 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
955 int UtcDaliActorSetAnchorPoint(void)
957 TestApplication application;
959 Actor actor = Actor::New();
961 Vector3 vector(0.7f, 0.8f, 0.9f);
962 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
964 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
966 // flush the queue and render once
967 application.SendNotification();
968 application.Render();
970 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
972 application.GetScene().Add(actor);
974 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
975 // flush the queue and render once
976 application.SendNotification();
977 application.Render();
979 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
981 application.GetScene().Remove(actor);
985 int UtcDaliActorSetAnchorPointIndividual(void)
987 TestApplication application;
989 Actor actor = Actor::New();
991 Vector3 vector(0.7f, 0.8f, 0.9f);
992 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
994 actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
996 // flush the queue and render once
997 application.SendNotification();
998 application.Render();
1000 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
1002 actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
1004 // flush the queue and render once
1005 application.SendNotification();
1006 application.Render();
1008 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
1010 actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
1012 // flush the queue and render once
1013 application.SendNotification();
1014 application.Render();
1016 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
1021 int UtcDaliActorGetCurrentAnchorPoint(void)
1023 TestApplication application;
1025 Actor actor = Actor::New();
1027 Vector3 vector(0.7f, 0.8f, 0.9f);
1028 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1030 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
1032 // flush the queue and render once
1033 application.SendNotification();
1034 application.Render();
1036 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
1040 int UtcDaliActorSetSize01(void)
1042 TestApplication application;
1044 Actor actor = Actor::New();
1045 Vector3 vector(100.0f, 100.0f, 0.0f);
1047 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1049 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1051 // Immediately retrieve the size after setting
1052 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1053 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1054 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1055 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1056 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1058 // Flush the queue and render once
1059 application.SendNotification();
1060 application.Render();
1062 // Check the size in the new frame
1063 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1065 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1066 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1067 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1068 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1069 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1071 // Check async behaviour
1072 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
1073 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1074 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1075 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1076 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1078 // Change the resize policy and check whether the size stays the same
1079 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1081 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1082 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1084 // Set a new size after resize policy is changed and check the new size
1085 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1087 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1088 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1090 // Change the resize policy again and check whether the new size stays the same
1091 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1093 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1094 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1096 // Set another new size after resize policy is changed and check the new size
1097 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1099 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1100 DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1105 int UtcDaliActorSetSize02(void)
1107 TestApplication application;
1109 Actor actor = Actor::New();
1110 Vector3 vector(100.0f, 100.0f, 100.0f);
1112 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1114 actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1116 // Immediately check the size after setting
1117 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1118 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1120 // flush the queue and render once
1121 application.SendNotification();
1122 application.Render();
1124 // Check the size in the new frame
1125 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1127 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1128 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1133 // SetSize(Vector2 size)
1134 int UtcDaliActorSetSize03(void)
1136 TestApplication application;
1138 Actor actor = Actor::New();
1139 Vector3 vector(100.0f, 100.0f, 0.0f);
1141 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1143 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1145 // Immediately check the size after setting
1146 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1147 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1149 // flush the queue and render once
1150 application.SendNotification();
1151 application.Render();
1153 // Check the size in the new frame
1154 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1156 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1157 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1162 // SetSize(Vector3 size)
1163 int UtcDaliActorSetSize04(void)
1165 TestApplication application;
1167 Actor actor = Actor::New();
1168 Vector3 vector(100.0f, 100.0f, 100.0f);
1170 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1172 actor.SetProperty(Actor::Property::SIZE, vector);
1174 // Immediately check the size after setting
1175 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1176 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1178 // flush the queue and render once
1179 application.SendNotification();
1180 application.Render();
1182 // Check the size in the new frame
1183 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1185 application.GetScene().Add(actor);
1186 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1188 // Immediately check the size after setting
1189 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1190 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1192 // flush the queue and render once
1193 application.SendNotification();
1194 application.Render();
1196 // Check the size in the new frame
1197 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1199 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1200 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1202 application.GetScene().Remove(actor);
1206 int UtcDaliActorSetSize05(void)
1208 TestApplication application;
1210 Actor parent = Actor::New();
1211 Vector2 vector(200.0f, 200.0f);
1212 DALI_TEST_CHECK(vector != parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1214 parent.SetProperty(Actor::Property::SIZE, vector);
1215 Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1216 DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1218 Actor child = Actor::New();
1219 DALI_TEST_CHECK(vector != child.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1220 child.SetProperty(Actor::Property::SIZE, vector);
1221 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1222 DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1224 // flush the queue and render once
1225 application.SendNotification();
1226 application.Render();
1228 DALI_TEST_CHECK(vector == parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1233 int UtcDaliActorSetSizeIndividual(void)
1235 TestApplication application;
1237 Actor actor = Actor::New();
1239 Vector3 vector(0.7f, 0.8f, 0.9f);
1240 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1242 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1244 // Immediately check the width after setting
1245 float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1246 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1248 // flush the queue and render once
1249 application.SendNotification();
1250 application.Render();
1252 // Check the width in the new frame
1253 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1255 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1256 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1258 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1260 // Immediately check the height after setting
1261 float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1262 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1264 // flush the queue and render once
1265 application.SendNotification();
1266 application.Render();
1268 // Check the height in the new frame
1269 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1271 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1272 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1274 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1276 // Immediately check the depth after setting
1277 float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1278 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1280 // flush the queue and render once
1281 application.SendNotification();
1282 application.Render();
1284 // Check the depth in the new frame
1285 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1287 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1288 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1290 // Change the resize policy and check whether the size stays the same
1291 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1293 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1294 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1296 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1297 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1299 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1300 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1302 // Change the resize policy again and check whether the size stays the same
1303 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1305 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1306 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1308 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1309 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1311 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1312 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1317 int UtcDaliActorSetSizeIndividual02(void)
1319 TestApplication application;
1321 Actor actor = Actor::New();
1322 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1323 application.GetScene().Add(actor);
1325 Vector3 vector(100.0f, 200.0f, 400.0f);
1326 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1328 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1329 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1331 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1332 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1334 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1335 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1337 // flush the queue and render once
1338 application.SendNotification();
1339 application.Render();
1341 // Check the width in the new frame
1342 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1343 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1348 int UtcDaliActorGetCurrentSize(void)
1350 TestApplication application;
1352 Actor actor = Actor::New();
1353 Vector3 vector(100.0f, 100.0f, 20.0f);
1355 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1357 actor.SetProperty(Actor::Property::SIZE, vector);
1359 // flush the queue and render once
1360 application.SendNotification();
1361 application.Render();
1363 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1367 int UtcDaliActorGetNaturalSize(void)
1369 TestApplication application;
1371 Actor actor = Actor::New();
1372 Vector3 vector(0.0f, 0.0f, 0.0f);
1374 DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1379 int UtcDaliActorGetCurrentSizeImmediate(void)
1381 TestApplication application;
1383 Actor actor = Actor::New();
1384 Vector3 vector(100.0f, 100.0f, 20.0f);
1386 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1387 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1389 actor.SetProperty(Actor::Property::SIZE, vector);
1391 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1392 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1394 // flush the queue and render once
1395 application.SendNotification();
1396 application.Render();
1398 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1399 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1402 // Build the animation
1403 const float durationSeconds = 2.0f;
1404 Animation animation = Animation::New(durationSeconds);
1405 const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1406 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1408 DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1410 application.GetScene().Add(actor);
1412 // Start the animation
1415 application.SendNotification();
1416 application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1418 DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1423 int UtcDaliActorCalculateScreenExtents(void)
1425 TestApplication application;
1427 Actor actor = Actor::New();
1429 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1430 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1432 application.GetScene().Add(actor);
1434 application.SendNotification();
1435 application.Render();
1437 auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1438 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1439 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1440 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1441 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1442 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1444 application.GetScene().Remove(actor);
1448 int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void)
1450 TestApplication application;
1451 Integration::Scene scene = application.GetScene();
1454 Layer layer = Layer::New();
1455 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1456 layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1457 layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1461 // Build custom camera with top-view
1462 CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
1464 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1465 Vector3 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1466 Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1469 std::ostringstream oss;
1470 oss << cameraPos << "\n";
1471 oss << cameraOrient << "\n";
1472 tet_printf("%s\n", oss.str().c_str());
1475 cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1476 cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1478 // Now, upside : -Z, leftside : -X, foward : +Y
1480 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1481 cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1483 std::ostringstream oss;
1484 oss << cameraPos << "\n";
1485 oss << cameraOrient << "\n";
1486 tet_printf("%s\n", oss.str().c_str());
1490 Actor actor = Actor::New();
1491 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1492 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1493 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f));
1494 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f});
1498 application.SendNotification();
1499 application.Render();
1501 Vector2 sceneSize = scene.GetSize();
1503 auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f};
1504 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1506 std::ostringstream oss;
1507 oss << expectedExtent << "\n";
1508 oss << actualExtent << "\n";
1509 tet_printf("%s\n", oss.str().c_str());
1512 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1513 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1514 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1515 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1520 int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void)
1522 // TODO : Need to make it works well
1523 TestApplication application;
1524 Integration::Scene scene = application.GetScene();
1525 Vector2 sceneSize = scene.GetSize();
1528 Layer layer = Layer::New();
1529 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1530 layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1531 layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1532 layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1533 layer.SetProperty(Actor::Property::SIZE, sceneSize);
1537 // Build custom camera with top-view
1538 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1540 offscreenCameraActor.SetPerspectiveProjection(sceneSize);
1541 offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1542 offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1544 scene.Add(offscreenCameraActor);
1546 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1547 Vector3 cameraPos = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1548 Quaternion cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1551 std::ostringstream oss;
1552 oss << cameraPos << "\n";
1553 oss << cameraOrient << "\n";
1554 tet_printf("%s\n", oss.str().c_str());
1557 offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1558 offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1560 // Now, upside : -Z, leftside : -X, foward : +Y
1562 cameraPos = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1563 cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1565 std::ostringstream oss;
1566 oss << cameraPos << "\n";
1567 oss << cameraOrient << "\n";
1568 tet_printf("%s\n", oss.str().c_str());
1571 Vector3 sourcePosition{2.0f, 0.0f, 16.0f};
1572 Vector3 sourceSize{1.0f, 0.0f, 3.0f};
1574 Actor sourceActor = Actor::New();
1575 sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1576 sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1577 sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition);
1578 sourceActor.SetProperty(Actor::Property::SIZE, sourceSize);
1580 layer.Add(sourceActor);
1582 // Create framebuffer
1583 unsigned int width(64);
1584 unsigned int height(64);
1585 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1586 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
1587 frameBuffer.AttachColorTexture(texture);
1589 Actor rootActor = Actor::New();
1590 rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1591 rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1592 rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1593 rootActor.SetProperty(Actor::Property::SIZE, sceneSize);
1594 scene.Add(rootActor);
1596 RenderTaskList taskList = scene.GetRenderTaskList();
1597 RenderTask newTask = taskList.CreateTask();
1598 newTask.SetCameraActor(offscreenCameraActor);
1599 newTask.SetSourceActor(layer);
1600 newTask.SetInputEnabled(false);
1601 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1602 newTask.SetClearEnabled(true);
1603 newTask.SetExclusive(true);
1604 newTask.SetFrameBuffer(frameBuffer);
1605 newTask.SetScreenToFrameBufferMappingActor(rootActor);
1607 application.SendNotification();
1608 application.Render(16u);
1610 auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f,
1611 sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f,
1614 auto actualExtent = DevelActor::CalculateScreenExtents(sourceActor);
1616 std::ostringstream oss;
1617 oss << expectedExtent << "\n";
1618 oss << actualExtent << "\n";
1619 tet_printf("%s\n", oss.str().c_str());
1622 auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z};
1623 auto actualScreen = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1625 std::ostringstream oss;
1626 oss << expectedScreen << "\n";
1627 oss << actualScreen << "\n";
1628 tet_printf("%s\n", oss.str().c_str());
1631 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1632 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1633 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1634 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1636 DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1637 DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1639 // Change rootActor's size and position
1641 Vector3 rootPosition{100.0f, 200.0f, 0.0f};
1642 Vector3 rootSize{200.0f, 100.0f, 0.0f};
1644 rootActor.SetProperty(Actor::Property::POSITION, rootPosition);
1645 rootActor.SetProperty(Actor::Property::SIZE, rootSize);
1647 application.SendNotification();
1648 application.Render(16u);
1650 expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x,
1651 sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y,
1652 sourceSize.x * rootSize.x / sceneSize.x,
1653 sourceSize.z * rootSize.y / sceneSize.y};
1654 actualExtent = DevelActor::CalculateScreenExtents(sourceActor);
1656 std::ostringstream oss;
1657 oss << expectedExtent << "\n";
1658 oss << actualExtent << "\n";
1659 tet_printf("%s\n", oss.str().c_str());
1662 expectedScreen = Vector2{sceneSize.x * 0.5f + rootPosition.x + sourcePosition.x * rootSize.x / sceneSize.x, sceneSize.y * 0.5f + rootPosition.y + sourcePosition.z * rootSize.y / sceneSize.y};
1663 actualScreen = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1665 std::ostringstream oss;
1666 oss << expectedScreen << "\n";
1667 oss << actualScreen << "\n";
1668 tet_printf("%s\n", oss.str().c_str());
1671 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1672 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1673 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1674 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1676 DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1677 DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1682 // SetPosition(float x, float y)
1683 int UtcDaliActorSetPosition01(void)
1685 TestApplication application;
1687 Actor actor = Actor::New();
1689 // Set to random to start off with
1690 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1692 Vector3 vector(100.0f, 100.0f, 0.0f);
1694 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1696 actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1697 // flush the queue and render once
1698 application.SendNotification();
1699 application.Render();
1700 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1702 application.GetScene().Add(actor);
1703 actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1704 // flush the queue and render once
1705 application.SendNotification();
1706 application.Render();
1707 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1709 actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1710 actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1711 actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1712 // flush the queue and render once
1713 application.SendNotification();
1714 application.Render();
1715 DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1717 actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1718 // flush the queue and render once
1719 application.SendNotification();
1720 application.Render();
1721 DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1723 application.GetScene().Remove(actor);
1727 // SetPosition(float x, float y, float z)
1728 int UtcDaliActorSetPosition02(void)
1730 TestApplication application;
1732 Actor actor = Actor::New();
1734 // Set to random to start off with
1735 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1737 Vector3 vector(100.0f, 100.0f, 100.0f);
1739 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1741 actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1743 // flush the queue and render once
1744 application.SendNotification();
1745 application.Render();
1747 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1751 // SetPosition(Vector3 position)
1752 int UtcDaliActorSetPosition03(void)
1754 TestApplication application;
1756 Actor actor = Actor::New();
1758 // Set to random to start off with
1759 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1761 Vector3 vector(100.0f, 100.0f, 100.0f);
1763 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1765 actor.SetProperty(Actor::Property::POSITION, vector);
1767 // flush the queue and render once
1768 application.SendNotification();
1769 application.Render();
1771 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1775 int UtcDaliActorSetX(void)
1777 TestApplication application;
1779 Actor actor = Actor::New();
1781 Vector3 vector(100.0f, 0.0f, 0.0f);
1783 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1785 actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1787 // flush the queue and render once
1788 application.SendNotification();
1789 application.Render();
1791 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1795 int UtcDaliActorSetY(void)
1797 TestApplication application;
1799 Actor actor = Actor::New();
1801 Vector3 vector(0.0f, 100.0f, 0.0f);
1803 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1805 actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1807 // flush the queue and render once
1808 application.SendNotification();
1809 application.Render();
1811 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1815 int UtcDaliActorSetZ(void)
1817 TestApplication application;
1819 Actor actor = Actor::New();
1821 Vector3 vector(0.0f, 0.0f, 100.0f);
1823 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1825 actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1827 // flush the queue and render once
1828 application.SendNotification();
1829 application.Render();
1831 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1835 int UtcDaliActorSetPositionProperties(void)
1837 TestApplication application;
1839 Actor actor = Actor::New();
1841 Vector3 vector(0.7f, 0.8f, 0.9f);
1842 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1844 actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1845 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1846 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1848 // flush the queue and render once
1849 application.SendNotification();
1850 application.Render();
1852 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1853 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1854 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1855 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1856 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1858 actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1859 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1860 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1862 // flush the queue and render once
1863 application.SendNotification();
1864 application.Render();
1866 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1867 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1868 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1869 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1870 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1872 actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1873 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1874 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1876 // flush the queue and render once
1877 application.SendNotification();
1878 application.Render();
1880 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1881 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1882 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1883 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1884 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1889 int UtcDaliActorTranslateBy(void)
1891 TestApplication application;
1893 Actor actor = Actor::New();
1894 Vector3 vector(100.0f, 100.0f, 100.0f);
1896 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1898 actor.SetProperty(Actor::Property::POSITION, vector);
1900 // flush the queue and render once
1901 application.SendNotification();
1902 application.Render();
1904 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1906 actor.TranslateBy(vector);
1908 // flush the queue and render once
1909 application.SendNotification();
1910 application.Render();
1912 DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1916 int UtcDaliActorGetCurrentPosition(void)
1918 TestApplication application;
1920 Actor actor = Actor::New();
1921 Vector3 setVector(100.0f, 100.0f, 0.0f);
1922 actor.SetProperty(Actor::Property::POSITION, setVector);
1924 // flush the queue and render once
1925 application.SendNotification();
1926 application.Render();
1928 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1932 int UtcDaliActorGetCurrentWorldPosition(void)
1934 TestApplication application;
1936 Actor parent = Actor::New();
1937 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1938 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1939 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1940 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1941 application.GetScene().Add(parent);
1943 Actor child = Actor::New();
1944 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1945 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1946 Vector3 childPosition(6.0f, 6.0f, 6.0f);
1947 child.SetProperty(Actor::Property::POSITION, childPosition);
1950 // The actors should not have a world position yet
1951 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1952 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1954 application.SendNotification();
1955 application.Render(0);
1957 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1958 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1960 // The actors should have a world position now
1961 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1962 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1966 int UtcDaliActorSetInheritPosition(void)
1968 tet_infoline("Testing Actor::SetInheritPosition");
1969 TestApplication application;
1971 Actor parent = Actor::New();
1972 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1973 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1974 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1975 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1976 application.GetScene().Add(parent);
1978 Actor child = Actor::New();
1979 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1980 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1981 Vector3 childPosition(10.0f, 11.0f, 12.0f);
1982 child.SetProperty(Actor::Property::POSITION, childPosition);
1985 // The actors should not have a world position yet
1986 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1987 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1989 // first test default, which is to inherit position
1990 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1991 application.SendNotification();
1992 application.Render(0); // should only really call Update as Render is not required to update scene
1993 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1994 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1995 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1996 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1998 //Change child position
1999 Vector3 childOffset(-1.0f, 1.0f, 0.0f);
2000 child.SetProperty(Actor::Property::POSITION, childOffset);
2002 // Use local position as world postion
2003 child.SetProperty(Actor::Property::INHERIT_POSITION, false);
2004 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
2005 application.SendNotification();
2006 application.Render(0); // should only really call Update as Render is not required to update scene
2007 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2008 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2009 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2010 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
2012 //Change back to inherit position from parent
2013 child.SetProperty(Actor::Property::INHERIT_POSITION, true);
2014 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
2015 application.SendNotification();
2016 application.Render(0); // should only really call Update as Render is not required to update scene
2017 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
2018 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
2019 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
2020 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
2024 int UtcDaliActorInheritOpacity(void)
2026 tet_infoline("Testing Actor::Inherit Opacity");
2027 TestApplication application;
2029 Actor parent = Actor::New();
2030 Actor child = Actor::New();
2032 application.GetScene().Add(parent);
2034 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2035 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2037 // flush the queue and render once
2038 application.SendNotification();
2039 application.Render();
2041 parent.SetProperty(Actor::Property::OPACITY, 0.1f);
2043 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2044 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
2046 application.SendNotification();
2047 application.Render();
2049 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2050 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2051 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2052 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2053 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2054 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
2059 // SetOrientation(float angleRadians, Vector3 axis)
2060 int UtcDaliActorSetOrientation01(void)
2062 TestApplication application;
2064 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2065 Actor actor = Actor::New();
2067 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2069 // flush the queue and render once
2070 application.SendNotification();
2071 application.Render();
2073 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2077 int UtcDaliActorSetOrientation02(void)
2079 TestApplication application;
2081 Actor actor = Actor::New();
2083 Radian angle(0.785f);
2084 Vector3 axis(1.0f, 1.0f, 0.0f);
2086 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2087 Quaternion rotation(angle, axis);
2088 // flush the queue and render once
2089 application.SendNotification();
2090 application.Render();
2091 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2093 application.GetScene().Add(actor);
2094 actor.RotateBy(Degree(360), axis);
2095 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2097 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
2098 Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
2099 // flush the queue and render once
2100 application.SendNotification();
2101 application.Render();
2102 DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2104 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2105 // flush the queue and render once
2106 application.SendNotification();
2107 application.Render();
2108 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2110 application.GetScene().Remove(actor);
2114 // SetOrientation(float angleRadians, Vector3 axis)
2115 int UtcDaliActorSetOrientationProperty(void)
2117 TestApplication application;
2119 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2120 Actor actor = Actor::New();
2122 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2123 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2125 // flush the queue and render once
2126 application.SendNotification();
2127 application.Render();
2129 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2130 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2131 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2135 // RotateBy(float angleRadians, Vector3 axis)
2136 int UtcDaliActorRotateBy01(void)
2138 TestApplication application;
2140 Actor actor = Actor::New();
2142 Radian angle(M_PI * 0.25f);
2143 actor.RotateBy((angle), Vector3::ZAXIS);
2144 // flush the queue and render once
2145 application.SendNotification();
2146 application.Render();
2147 DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2149 application.GetScene().Add(actor);
2151 actor.RotateBy(angle, Vector3::ZAXIS);
2152 // flush the queue and render once
2153 application.SendNotification();
2154 application.Render();
2155 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2157 application.GetScene().Remove(actor);
2161 // RotateBy(Quaternion relativeRotation)
2162 int UtcDaliActorRotateBy02(void)
2164 TestApplication application;
2166 Actor actor = Actor::New();
2168 Radian angle(M_PI * 0.25f);
2169 Quaternion rotation(angle, Vector3::ZAXIS);
2170 actor.RotateBy(rotation);
2171 // flush the queue and render once
2172 application.SendNotification();
2173 application.Render();
2174 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2176 actor.RotateBy(rotation);
2177 // flush the queue and render once
2178 application.SendNotification();
2179 application.Render();
2180 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2184 int UtcDaliActorGetCurrentOrientation(void)
2186 TestApplication application;
2187 Actor actor = Actor::New();
2189 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2190 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2191 // flush the queue and render once
2192 application.SendNotification();
2193 application.Render();
2194 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2198 int UtcDaliActorGetCurrentWorldOrientation(void)
2200 tet_infoline("Testing Actor::GetCurrentWorldRotation");
2201 TestApplication application;
2203 Actor parent = Actor::New();
2204 Radian rotationAngle(Degree(90.0f));
2205 Quaternion rotation(rotationAngle, Vector3::YAXIS);
2206 parent.SetProperty(Actor::Property::ORIENTATION, rotation);
2207 application.GetScene().Add(parent);
2209 Actor child = Actor::New();
2210 child.SetProperty(Actor::Property::ORIENTATION, rotation);
2213 // The actors should not have a world rotation yet
2214 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2215 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2217 application.SendNotification();
2218 application.Render(0);
2220 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2221 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2223 // The actors should have a world rotation now
2224 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2225 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
2227 // turn off child rotation inheritance
2228 child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
2229 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
2230 application.SendNotification();
2231 application.Render(0);
2233 // The actors should have a world rotation now
2234 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2235 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
2239 // SetScale(float scale)
2240 int UtcDaliActorSetScale01(void)
2242 TestApplication application;
2244 Actor actor = Actor::New();
2246 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2247 actor.SetProperty(Actor::Property::SCALE, 0.25f);
2249 Vector3 scale(10.0f, 10.0f, 10.0f);
2250 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2252 actor.SetProperty(Actor::Property::SCALE, scale.x);
2254 // flush the queue and render once
2255 application.SendNotification();
2256 application.Render();
2258 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2262 // SetScale(float scaleX, float scaleY, float scaleZ)
2263 int UtcDaliActorSetScale02(void)
2265 TestApplication application;
2266 Vector3 scale(10.0f, 10.0f, 10.0f);
2268 Actor actor = Actor::New();
2270 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2271 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2273 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2275 actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
2276 // flush the queue and render once
2277 application.SendNotification();
2278 application.Render();
2279 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2281 // add to stage and test
2282 application.GetScene().Add(actor);
2283 actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
2284 // flush the queue and render once
2285 application.SendNotification();
2286 application.Render();
2287 DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
2289 application.GetScene().Remove(actor);
2294 // SetScale(Vector3 scale)
2295 int UtcDaliActorSetScale03(void)
2297 TestApplication application;
2298 Vector3 scale(10.0f, 10.0f, 10.0f);
2300 Actor actor = Actor::New();
2302 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2303 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2305 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2307 actor.SetProperty(Actor::Property::SCALE, scale);
2309 // flush the queue and render once
2310 application.SendNotification();
2311 application.Render();
2313 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2317 int UtcDaliActorSetScaleIndividual(void)
2319 TestApplication application;
2321 Actor actor = Actor::New();
2323 Vector3 vector(0.7f, 0.8f, 0.9f);
2324 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2326 actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2327 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2329 // flush the queue and render once
2330 application.SendNotification();
2331 application.Render();
2333 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2334 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2335 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2337 actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2338 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2340 // flush the queue and render once
2341 application.SendNotification();
2342 application.Render();
2344 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2345 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2346 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2348 actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2349 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2351 // flush the queue and render once
2352 application.SendNotification();
2353 application.Render();
2355 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2356 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2357 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2359 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2360 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2365 int UtcDaliActorScaleBy(void)
2367 TestApplication application;
2368 Actor actor = Actor::New();
2369 Vector3 vector(100.0f, 100.0f, 100.0f);
2371 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2373 actor.SetProperty(Actor::Property::SCALE, vector);
2375 // flush the queue and render once
2376 application.SendNotification();
2377 application.Render();
2379 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2381 actor.ScaleBy(vector);
2383 // flush the queue and render once
2384 application.SendNotification();
2385 application.Render();
2387 DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2391 int UtcDaliActorGetCurrentScale(void)
2393 TestApplication application;
2394 Vector3 scale(12.0f, 1.0f, 2.0f);
2396 Actor actor = Actor::New();
2398 actor.SetProperty(Actor::Property::SCALE, scale);
2400 // flush the queue and render once
2401 application.SendNotification();
2402 application.Render();
2404 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2408 int UtcDaliActorGetCurrentWorldScale(void)
2410 TestApplication application;
2412 Actor parent = Actor::New();
2413 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2414 parent.SetProperty(Actor::Property::SCALE, parentScale);
2415 application.GetScene().Add(parent);
2417 Actor child = Actor::New();
2418 Vector3 childScale(2.0f, 2.0f, 2.0f);
2419 child.SetProperty(Actor::Property::SCALE, childScale);
2422 // The actors should not have a scale yet
2423 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2424 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2426 // The actors should not have a world scale yet
2427 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2428 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2430 application.SendNotification();
2431 application.Render(0);
2433 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2434 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2436 // The actors should have a world scale now
2437 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2438 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2442 int UtcDaliActorInheritScale(void)
2444 tet_infoline("Testing Actor::SetInheritScale");
2445 TestApplication application;
2447 Actor parent = Actor::New();
2448 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2449 parent.SetProperty(Actor::Property::SCALE, parentScale);
2450 application.GetScene().Add(parent);
2452 Actor child = Actor::New();
2453 Vector3 childScale(2.0f, 2.0f, 2.0f);
2454 child.SetProperty(Actor::Property::SCALE, childScale);
2457 application.SendNotification();
2458 application.Render(0);
2460 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2461 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2463 child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2464 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2466 application.SendNotification();
2467 application.Render(0);
2469 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2473 int UtcDaliActorSetVisible(void)
2475 TestApplication application;
2477 Actor actor = Actor::New();
2478 actor.SetProperty(Actor::Property::VISIBLE, false);
2479 // flush the queue and render once
2480 application.SendNotification();
2481 application.Render();
2482 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2484 actor.SetProperty(Actor::Property::VISIBLE, true);
2485 // flush the queue and render once
2486 application.SendNotification();
2487 application.Render();
2488 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2490 // put actor on stage
2491 application.GetScene().Add(actor);
2492 actor.SetProperty(Actor::Property::VISIBLE, false);
2493 // flush the queue and render once
2494 application.SendNotification();
2495 application.Render();
2496 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2500 int UtcDaliActorIsVisible(void)
2502 TestApplication application;
2504 Actor actor = Actor::New();
2506 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2510 int UtcDaliActorSetOpacity(void)
2512 TestApplication application;
2514 Actor actor = Actor::New();
2515 // initial opacity is 1
2516 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2518 actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2519 // flush the queue and render once
2520 application.SendNotification();
2521 application.Render();
2522 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2524 // change opacity, actor is on stage to change is not immediate
2525 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2526 // flush the queue and render once
2527 application.SendNotification();
2528 application.Render();
2529 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2531 // put actor on stage
2532 application.GetScene().Add(actor);
2534 // change opacity, actor is on stage to change is not immediate
2535 actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2536 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2537 // flush the queue and render once
2538 application.SendNotification();
2539 application.Render();
2540 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2542 // change opacity, actor is on stage to change is not immediate
2543 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2544 // flush the queue and render once
2545 application.SendNotification();
2546 application.Render();
2547 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2551 int UtcDaliActorGetCurrentOpacity(void)
2553 TestApplication application;
2555 Actor actor = Actor::New();
2556 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2558 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2559 // flush the queue and render once
2560 application.SendNotification();
2561 application.Render();
2562 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2566 int UtcDaliActorSetSensitive(void)
2568 TestApplication application;
2569 Actor actor = Actor::New();
2571 bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2573 actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2575 DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2579 int UtcDaliActorIsSensitive(void)
2581 TestApplication application;
2582 Actor actor = Actor::New();
2583 actor.SetProperty(Actor::Property::SENSITIVE, false);
2585 DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2589 int UtcDaliActorSetColor(void)
2591 TestApplication application;
2592 Actor actor = Actor::New();
2593 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2595 DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2597 actor.SetProperty(Actor::Property::COLOR, color);
2598 // flush the queue and render once
2599 application.SendNotification();
2600 application.Render();
2601 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2603 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2604 // flush the queue and render once
2605 application.SendNotification();
2606 application.Render();
2607 DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2609 application.GetScene().Add(actor);
2610 actor.SetProperty(Actor::Property::COLOR, color);
2611 // flush the queue and render once
2612 application.SendNotification();
2613 application.Render();
2614 DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2616 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2617 // flush the queue and render once
2618 application.SendNotification();
2619 application.Render();
2620 // Actor color is not clamped
2621 DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2622 // world color is clamped
2623 DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2625 actor.SetProperty(Actor::Property::COLOR, color);
2626 DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2628 Vector3 newColor(1.0f, 0.0f, 0.0f);
2629 actor.SetProperty(Actor::Property::COLOR, newColor);
2630 DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2632 application.GetScene().Remove(actor);
2636 int UtcDaliActorSetColorIndividual(void)
2638 TestApplication application;
2640 Actor actor = Actor::New();
2642 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2643 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2645 actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2646 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2648 // flush the queue and render once
2649 application.SendNotification();
2650 application.Render();
2652 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2653 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2654 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2656 actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2657 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2659 // flush the queue and render once
2660 application.SendNotification();
2661 application.Render();
2663 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2664 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2665 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2667 actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2668 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2670 // flush the queue and render once
2671 application.SendNotification();
2672 application.Render();
2674 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2675 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2676 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2678 actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2679 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2681 // flush the queue and render once
2682 application.SendNotification();
2683 application.Render();
2685 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2686 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2687 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2689 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2690 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2692 actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2694 // flush the queue and render once
2695 application.SendNotification();
2696 application.Render();
2698 DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2703 int UtcDaliActorGetCurrentColor(void)
2705 TestApplication application;
2706 Actor actor = Actor::New();
2707 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2709 actor.SetProperty(Actor::Property::COLOR, color);
2710 // flush the queue and render once
2711 application.SendNotification();
2712 application.Render();
2713 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2717 int UtcDaliActorGetCurrentWorldColor(void)
2719 tet_infoline("Actor::GetCurrentWorldColor");
2720 TestApplication application;
2722 Actor parent = Actor::New();
2723 Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2724 parent.SetProperty(Actor::Property::COLOR, parentColor);
2725 application.GetScene().Add(parent);
2727 Actor child = Actor::New();
2728 Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2729 child.SetProperty(Actor::Property::COLOR, childColor);
2732 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2733 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2735 // verify the default color mode
2736 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2738 // The actors should not have a world color yet
2739 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2740 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2742 application.SendNotification();
2743 application.Render(0);
2745 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2746 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2748 // The actors should have a world color now
2749 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2750 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2753 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2754 application.SendNotification();
2755 application.Render(0);
2756 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2759 child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2760 application.SendNotification();
2761 application.Render(0);
2762 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2763 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2766 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2767 application.SendNotification();
2768 application.Render(0);
2769 Vector4 expectedColor(childColor);
2770 expectedColor.a *= parentColor.a;
2771 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2772 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2776 int UtcDaliActorSetColorMode(void)
2778 tet_infoline("Actor::SetColorMode");
2779 TestApplication application;
2780 Actor actor = Actor::New();
2781 Actor child = Actor::New();
2784 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2785 DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2787 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2788 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2790 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2791 DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2793 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2794 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2798 int UtcDaliActorScreenToLocal(void)
2800 TestApplication application;
2801 Actor actor = Actor::New();
2802 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2803 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2804 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2805 application.GetScene().Add(actor);
2807 // flush the queue and render once
2808 application.SendNotification();
2809 application.Render();
2814 application.SendNotification();
2815 application.Render();
2817 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2819 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2820 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2824 int UtcDaliActorSetLeaveRequired(void)
2826 TestApplication application;
2828 Actor actor = Actor::New();
2830 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2831 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2833 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2834 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2838 int UtcDaliActorGetLeaveRequired(void)
2840 TestApplication application;
2842 Actor actor = Actor::New();
2844 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2848 int UtcDaliActorSetKeyboardFocusable(void)
2850 TestApplication application;
2852 Actor actor = Actor::New();
2854 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2855 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2857 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2858 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2862 int UtcDaliActorIsKeyboardFocusable(void)
2864 TestApplication application;
2866 Actor actor = Actor::New();
2868 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2872 int UtcDaliActorSetKeyboardFocusableChildren(void)
2874 TestApplication application;
2876 Actor actor = Actor::New();
2878 actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2879 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2881 actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2882 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
2886 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
2888 TestApplication application;
2890 Actor actor = Actor::New();
2892 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2896 int UtcDaliActorSetTouchFocusable(void)
2898 TestApplication application;
2900 Actor actor = Actor::New();
2902 actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2903 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2905 actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2906 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2910 int UtcDaliActorIsTouchFocusable(void)
2912 TestApplication application;
2914 Actor actor = Actor::New();
2916 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2920 int UtcDaliActorSetUserInteractionEnabled(void)
2922 TestApplication application;
2923 Actor actor = Actor::New();
2925 bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
2927 actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
2929 DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2933 int UtcDaliActorIsUserInteractionEnabled(void)
2935 TestApplication application;
2936 Actor actor = Actor::New();
2937 actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
2939 DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2943 int UtcDaliActorRemoveConstraints(void)
2945 tet_infoline(" UtcDaliActorRemoveConstraints");
2946 TestApplication application;
2948 gTestConstraintCalled = false;
2950 Actor actor = Actor::New();
2952 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2954 actor.RemoveConstraints();
2956 DALI_TEST_CHECK(gTestConstraintCalled == false);
2958 application.GetScene().Add(actor);
2961 // flush the queue and render once
2962 application.SendNotification();
2963 application.Render();
2965 actor.RemoveConstraints();
2967 DALI_TEST_CHECK(gTestConstraintCalled == true);
2971 int UtcDaliActorRemoveConstraintTag(void)
2973 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2974 TestApplication application;
2976 Actor actor = Actor::New();
2978 // 1. Apply Constraint1 and Constraint2, and test...
2979 unsigned int result1 = 0u;
2980 unsigned int result2 = 0u;
2982 unsigned constraint1Tag = 1u;
2983 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2984 constraint1.SetTag(constraint1Tag);
2985 constraint1.Apply();
2987 unsigned constraint2Tag = 2u;
2988 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2989 constraint2.SetTag(constraint2Tag);
2990 constraint2.Apply();
2992 application.GetScene().Add(actor);
2993 // flush the queue and render once
2994 application.SendNotification();
2995 application.Render();
2997 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2998 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3000 // 2. Remove Constraint1 and test...
3003 actor.RemoveConstraints(constraint1Tag);
3004 // make color property dirty, which will trigger constraints to be reapplied.
3005 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3006 // flush the queue and render once
3007 application.SendNotification();
3008 application.Render();
3010 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3011 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3013 // 3. Re-Apply Constraint1 and test...
3016 constraint1.Apply();
3017 // make color property dirty, which will trigger constraints to be reapplied.
3018 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3019 // flush the queue and render once
3020 application.SendNotification();
3021 application.Render();
3023 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3024 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
3026 // 2. Remove Constraint2 and test...
3029 actor.RemoveConstraints(constraint2Tag);
3030 // make color property dirty, which will trigger constraints to be reapplied.
3031 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3032 // flush the queue and render once
3033 application.SendNotification();
3034 application.Render();
3036 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
3037 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3039 // 2. Remove Constraint1 as well and test...
3042 actor.RemoveConstraints(constraint1Tag);
3043 // make color property dirty, which will trigger constraints to be reapplied.
3044 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
3045 // flush the queue and render once
3046 application.SendNotification();
3047 application.Render();
3049 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3050 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3054 int UtcDaliActorTouchedSignal(void)
3056 TestApplication application;
3058 ResetTouchCallbacks();
3060 // get the root layer
3061 Actor actor = application.GetScene().GetRootLayer();
3062 DALI_TEST_CHECK(gTouchCallBackCalled == false);
3064 application.SendNotification();
3065 application.Render();
3067 // connect to its touch signal
3068 actor.TouchedSignal().Connect(TestTouchCallback);
3070 // simulate a touch event in the middle of the screen
3071 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
3072 Dali::Integration::Point point;
3073 point.SetDeviceId(1);
3074 point.SetState(PointState::DOWN);
3075 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3076 Dali::Integration::TouchEvent touchEvent;
3077 touchEvent.AddPoint(point);
3078 application.ProcessEvent(touchEvent);
3080 DALI_TEST_CHECK(gTouchCallBackCalled == true);
3084 int UtcDaliActorHoveredSignal(void)
3086 TestApplication application;
3088 gHoverCallBackCalled = false;
3090 // get the root layer
3091 Actor actor = application.GetScene().GetRootLayer();
3092 DALI_TEST_CHECK(gHoverCallBackCalled == false);
3094 application.SendNotification();
3095 application.Render();
3097 // connect to its hover signal
3098 actor.HoveredSignal().Connect(TestCallback3);
3100 // simulate a hover event in the middle of the screen
3101 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
3102 Dali::Integration::Point point;
3103 point.SetDeviceId(1);
3104 point.SetState(PointState::MOTION);
3105 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3106 Dali::Integration::HoverEvent hoverEvent;
3107 hoverEvent.AddPoint(point);
3108 application.ProcessEvent(hoverEvent);
3110 DALI_TEST_CHECK(gHoverCallBackCalled == true);
3114 int UtcDaliActorOnOffSceneSignal(void)
3116 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
3118 TestApplication application;
3121 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3122 gActorNamesOnOffScene.clear();
3124 Actor parent = Actor::New();
3125 parent.SetProperty(Actor::Property::NAME, "parent");
3126 parent.OnSceneSignal().Connect(OnSceneCallback);
3127 parent.OffSceneSignal().Connect(OffSceneCallback);
3129 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
3130 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
3132 // add parent to the scene
3133 application.GetScene().Add(parent);
3134 // onstage emitted, offstage not
3135 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3136 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3137 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3139 // test adding a child, should get onstage emitted
3141 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3142 gActorNamesOnOffScene.clear();
3144 Actor child = Actor::New();
3145 child.SetProperty(Actor::Property::NAME, "child");
3146 child.OnSceneSignal().Connect(OnSceneCallback);
3147 child.OffSceneSignal().Connect(OffSceneCallback);
3148 parent.Add(child); // add child
3149 // onscene emitted, offscene not
3150 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3151 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3152 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3154 // test removing parent from the scene
3156 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3157 gActorNamesOnOffScene.clear();
3159 application.GetScene().Remove(parent);
3160 // onscene not emitted, offscene is
3161 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3162 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
3163 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3164 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
3166 // test adding parent back to the scene
3168 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3169 gActorNamesOnOffScene.clear();
3171 application.GetScene().Add(parent);
3172 // onscene emitted, offscene not
3173 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
3174 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3175 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3176 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
3178 // test removing child
3180 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3181 gActorNamesOnOffScene.clear();
3183 parent.Remove(child);
3184 // onscene not emitted, offscene is
3185 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3186 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3187 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3189 // test removing parent
3191 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3192 gActorNamesOnOffScene.clear();
3194 application.GetScene().Remove(parent);
3195 // onscene not emitted, offscene is
3196 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3197 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3198 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3202 int UtcDaliActorFindChildByName(void)
3204 tet_infoline("Testing Dali::Actor::FindChildByName()");
3205 TestApplication application;
3207 Actor parent = Actor::New();
3208 parent.SetProperty(Actor::Property::NAME, "parent");
3209 Actor first = Actor::New();
3210 first.SetProperty(Actor::Property::NAME, "first");
3211 Actor second = Actor::New();
3212 second.SetProperty(Actor::Property::NAME, "second");
3217 Actor found = parent.FindChildByName("foo");
3218 DALI_TEST_CHECK(!found);
3220 found = parent.FindChildByName("parent");
3221 DALI_TEST_CHECK(found == parent);
3223 found = parent.FindChildByName("first");
3224 DALI_TEST_CHECK(found == first);
3226 found = parent.FindChildByName("second");
3227 DALI_TEST_CHECK(found == second);
3231 int UtcDaliActorFindChildById(void)
3233 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
3234 TestApplication application;
3236 Actor parent = Actor::New();
3237 Actor first = Actor::New();
3238 Actor second = Actor::New();
3243 Actor found = parent.FindChildById(100000);
3244 DALI_TEST_CHECK(!found);
3246 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
3247 DALI_TEST_CHECK(found == parent);
3249 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
3250 DALI_TEST_CHECK(found == first);
3252 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
3253 DALI_TEST_CHECK(found == second);
3257 int UtcDaliActorHitTest(void)
3262 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3264 mTouchPoint(touchPoint),
3270 Vector2 mTouchPoint;
3274 TestApplication application;
3275 tet_infoline(" UtcDaliActorHitTest");
3277 // Fill a vector with different hit tests.
3278 struct HitTestData* hitTestData[] = {
3279 // scale touch point result
3280 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
3281 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3282 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.
3283 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3284 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.
3288 // get the root layer
3289 Actor actor = Actor::New();
3290 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3291 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3293 application.GetScene().Add(actor);
3295 ResetTouchCallbacks();
3297 unsigned int index = 0;
3298 while(NULL != hitTestData[index])
3300 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3301 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3303 // flush the queue and render once
3304 application.SendNotification();
3305 application.Render();
3307 DALI_TEST_CHECK(!gTouchCallBackCalled);
3309 // connect to its touch signal
3310 actor.TouchedSignal().Connect(TestTouchCallback);
3312 Dali::Integration::Point point;
3313 point.SetState(PointState::DOWN);
3314 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3315 Dali::Integration::TouchEvent event;
3316 event.AddPoint(point);
3318 // flush the queue and render once
3319 application.SendNotification();
3320 application.Render();
3321 application.ProcessEvent(event);
3323 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3325 if(gTouchCallBackCalled != hitTestData[index]->mResult)
3326 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3327 hitTestData[index]->mScale.x,
3328 hitTestData[index]->mScale.y,
3329 hitTestData[index]->mScale.z,
3330 hitTestData[index]->mTouchPoint.x,
3331 hitTestData[index]->mTouchPoint.y,
3332 hitTestData[index]->mResult);
3334 ResetTouchCallbacks();
3340 int UtcDaliActorSetDrawMode(void)
3342 TestApplication application;
3343 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3345 Actor a = Actor::New();
3347 application.GetScene().Add(a);
3348 application.SendNotification();
3349 application.Render(0);
3350 application.SendNotification();
3351 application.Render(1);
3353 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3355 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3356 application.SendNotification();
3357 application.Render(1);
3359 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3361 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3362 application.SendNotification();
3363 application.Render(1);
3365 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3369 int UtcDaliActorSetDrawModeOverlayRender(void)
3371 TestApplication application;
3372 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3374 application.SendNotification();
3375 application.Render(1);
3377 std::vector<GLuint> ids;
3378 ids.push_back(8); // first rendered actor
3379 ids.push_back(9); // second rendered actor
3380 ids.push_back(10); // third rendered actor
3381 application.GetGlAbstraction().SetNextTextureIds(ids);
3383 Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3384 Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3385 Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3386 Actor a = CreateRenderableActor(imageA);
3387 Actor b = CreateRenderableActor(imageB);
3388 Actor c = CreateRenderableActor(imageC);
3390 application.SendNotification();
3391 application.Render(1);
3393 //Textures are bound when first created. Clear bound textures vector
3394 application.GetGlAbstraction().ClearBoundTextures();
3396 // Render a,b,c as regular non-overlays. so order will be:
3400 application.GetScene().Add(a);
3401 application.GetScene().Add(b);
3402 application.GetScene().Add(c);
3404 application.SendNotification();
3405 application.Render(1);
3407 // Should be 3 textures changes.
3408 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3409 typedef std::vector<GLuint>::size_type TextureSize;
3410 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3411 if(boundTextures.size() == 3)
3413 DALI_TEST_CHECK(boundTextures[0] == 8u);
3414 DALI_TEST_CHECK(boundTextures[1] == 9u);
3415 DALI_TEST_CHECK(boundTextures[2] == 10u);
3418 // Now texture ids have been set, we can monitor their render order.
3419 // render a as an overlay (last), so order will be:
3423 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3424 application.GetGlAbstraction().ClearBoundTextures();
3426 application.SendNotification();
3427 application.Render(1);
3429 // Should be 3 texture changes.
3430 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3431 if(boundTextures.size() == 3)
3433 DALI_TEST_CHECK(boundTextures[0] == 9u);
3434 DALI_TEST_CHECK(boundTextures[1] == 10u);
3435 DALI_TEST_CHECK(boundTextures[2] == 8u);
3440 int UtcDaliActorGetCurrentWorldMatrix(void)
3442 TestApplication application;
3443 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3445 Actor parent = Actor::New();
3446 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3447 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3448 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3449 Radian rotationAngle(Degree(85.0f));
3450 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3451 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3452 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3453 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3454 parent.SetProperty(Actor::Property::SCALE, parentScale);
3455 application.GetScene().Add(parent);
3457 Actor child = Actor::New();
3458 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3459 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3460 Radian childRotationAngle(Degree(23.0f));
3461 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3462 Vector3 childScale(2.0f, 2.0f, 2.0f);
3463 child.SetProperty(Actor::Property::POSITION, childPosition);
3464 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3465 child.SetProperty(Actor::Property::SCALE, childScale);
3468 application.SendNotification();
3469 application.Render(0);
3470 application.Render();
3471 application.SendNotification();
3473 Matrix parentMatrix(false);
3474 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3476 Matrix childMatrix(false);
3477 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3479 //Child matrix should be the composition of child and parent
3480 Matrix childWorldMatrix(false);
3481 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3483 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3484 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3488 int UtcDaliActorConstrainedToWorldMatrix(void)
3490 TestApplication application;
3491 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3493 Actor parent = Actor::New();
3494 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3495 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3496 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3497 Radian rotationAngle(Degree(85.0f));
3498 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3499 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3500 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3501 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3502 parent.SetProperty(Actor::Property::SCALE, parentScale);
3503 application.GetScene().Add(parent);
3505 Actor child = Actor::New();
3506 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3507 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3508 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3509 posConstraint.Apply();
3511 application.GetScene().Add(child);
3513 application.SendNotification();
3514 application.Render(0);
3515 application.Render();
3516 application.SendNotification();
3518 Matrix parentMatrix(false);
3519 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3521 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3522 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3526 int UtcDaliActorConstrainedToOrientation(void)
3528 TestApplication application;
3529 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3531 Actor parent = Actor::New();
3532 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3533 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3534 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3535 Radian rotationAngle(Degree(85.0f));
3536 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3537 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3538 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3539 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3540 parent.SetProperty(Actor::Property::SCALE, parentScale);
3541 application.GetScene().Add(parent);
3543 Actor child = Actor::New();
3544 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3545 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3546 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3547 posConstraint.Apply();
3549 application.GetScene().Add(child);
3551 application.SendNotification();
3552 application.Render(0);
3553 application.Render();
3554 application.SendNotification();
3556 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3560 int UtcDaliActorConstrainedToOpacity(void)
3562 TestApplication application;
3563 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3565 Actor parent = Actor::New();
3566 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3567 application.GetScene().Add(parent);
3569 Actor child = Actor::New();
3570 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3571 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3572 opacityConstraint.Apply();
3574 application.GetScene().Add(child);
3576 application.SendNotification();
3577 application.Render(0);
3578 application.Render();
3579 application.SendNotification();
3581 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3583 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3585 application.SendNotification();
3586 application.Render(0);
3587 application.Render();
3588 application.SendNotification();
3590 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3595 int UtcDaliActorUnparent(void)
3597 TestApplication application;
3598 tet_infoline(" UtcDaliActorUnparent");
3600 Actor parent = Actor::New();
3601 application.GetScene().Add(parent);
3603 Actor child = Actor::New();
3605 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3606 DALI_TEST_CHECK(!child.GetParent());
3608 // Test that calling Unparent with no parent is a NOOP
3611 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3612 DALI_TEST_CHECK(!child.GetParent());
3614 // Test that Unparent works
3617 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3618 DALI_TEST_CHECK(parent == child.GetParent());
3622 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3623 DALI_TEST_CHECK(!child.GetParent());
3625 // Test that UnparentAndReset works
3628 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3629 DALI_TEST_CHECK(parent == child.GetParent());
3631 UnparentAndReset(child);
3633 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3634 DALI_TEST_CHECK(!child);
3636 // Test that UnparentAndReset is a NOOP with empty handle
3637 UnparentAndReset(child);
3639 DALI_TEST_CHECK(!child);
3643 int UtcDaliActorGetChildAt(void)
3645 TestApplication application;
3646 tet_infoline(" UtcDaliActorGetChildAt");
3648 Actor parent = Actor::New();
3649 application.GetScene().Add(parent);
3651 Actor child0 = Actor::New();
3654 Actor child1 = Actor::New();
3657 Actor child2 = Actor::New();
3660 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3661 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3662 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3666 int UtcDaliActorSetGetOverlay(void)
3668 TestApplication application;
3669 tet_infoline(" UtcDaliActorSetGetOverlay");
3671 Actor parent = Actor::New();
3672 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3673 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3677 int UtcDaliActorCreateDestroy(void)
3679 Actor* actor = new Actor;
3680 DALI_TEST_CHECK(actor);
3687 struct PropertyStringIndex
3689 const char* const name;
3690 const Property::Index index;
3691 const Property::Type type;
3694 const PropertyStringIndex PROPERTY_TABLE[] =
3696 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3697 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3698 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3699 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3700 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3701 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3702 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3703 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3704 {"size", Actor::Property::SIZE, Property::VECTOR3},
3705 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3706 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3707 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3708 {"position", Actor::Property::POSITION, Property::VECTOR3},
3709 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3710 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3711 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3712 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3713 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3714 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3715 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3716 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3717 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3718 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3719 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3720 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3721 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3722 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3723 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3724 {"color", Actor::Property::COLOR, Property::VECTOR4},
3725 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3726 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3727 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3728 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3729 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3730 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3731 {"name", Actor::Property::NAME, Property::STRING},
3732 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3733 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3734 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3735 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3736 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3737 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3738 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3739 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3740 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3741 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3742 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3743 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3744 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3745 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3746 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3747 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3748 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3749 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3751 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3752 } // unnamed namespace
3754 int UtcDaliActorProperties(void)
3756 TestApplication application;
3758 Actor actor = Actor::New();
3760 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3762 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3763 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3764 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3765 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3770 int UtcDaliRelayoutProperties_ResizePolicies(void)
3772 TestApplication application;
3774 Actor actor = Actor::New();
3777 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3778 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3780 // Set resize policy for all dimensions
3781 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3782 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3784 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3787 // Set individual dimensions
3788 const char* const widthPolicy = "FILL_TO_PARENT";
3789 const char* const heightPolicy = "FIXED";
3791 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3792 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3794 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3795 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3797 // Set individual dimensions using enums
3798 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3799 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3801 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3802 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3804 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3805 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3810 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3812 TestApplication application;
3814 Actor actor = Actor::New();
3817 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3819 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3820 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3821 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3824 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3825 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3827 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3828 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3830 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3831 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3836 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3838 TestApplication application;
3840 Actor actor = Actor::New();
3843 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3844 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3846 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3847 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3848 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3851 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3853 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3854 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3859 int UtcDaliRelayoutProperties_DimensionDependency(void)
3861 TestApplication application;
3863 Actor actor = Actor::New();
3866 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3867 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3870 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3871 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3873 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3874 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3876 // Test setting another resize policy
3877 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3878 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3883 int UtcDaliRelayoutProperties_Padding(void)
3885 TestApplication application;
3887 Actor actor = Actor::New();
3890 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3893 actor.SetProperty(Actor::Property::PADDING, padding);
3894 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3896 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3901 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3903 TestApplication application;
3905 Actor actor = Actor::New();
3908 Vector2 minSize(1.0f, 2.0f);
3910 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3911 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3913 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3915 Vector2 maxSize(3.0f, 4.0f);
3917 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3918 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3920 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3925 int UtcDaliActorGetHeightForWidth(void)
3927 TestApplication application;
3929 Actor actor = Actor::New();
3931 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3936 int UtcDaliActorGetWidthForHeight(void)
3938 TestApplication application;
3940 Actor actor = Actor::New();
3942 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3947 int UtcDaliActorGetRelayoutSize(void)
3949 TestApplication application;
3951 Actor actor = Actor::New();
3953 // Add actor to stage
3954 application.GetScene().Add(actor);
3956 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3958 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3959 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3961 // Flush the queue and render once
3962 application.SendNotification();
3963 application.Render();
3965 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3970 int UtcDaliActorSetPadding(void)
3972 TestApplication application;
3974 Actor actor = Actor::New();
3977 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3979 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3980 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3981 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3982 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3984 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3985 actor.SetProperty(Actor::Property::PADDING, padding2);
3987 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3989 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3990 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3991 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3992 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3997 int UtcDaliActorSetMinimumSize(void)
3999 TestApplication application;
4001 Actor actor = Actor::New();
4003 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4005 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
4006 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
4008 Vector2 size2(1.0f, 2.0f);
4009 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
4011 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
4013 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4014 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4019 int UtcDaliActorSetMaximumSize(void)
4021 TestApplication application;
4023 Actor actor = Actor::New();
4025 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4027 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
4028 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
4030 Vector2 size2(1.0f, 2.0f);
4031 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
4033 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
4035 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
4036 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
4041 int UtcDaliActorOnRelayoutSignal(void)
4043 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
4045 TestApplication application;
4048 gOnRelayoutCallBackCalled = false;
4049 gActorNamesRelayout.clear();
4051 Actor actor = Actor::New();
4052 actor.SetProperty(Actor::Property::NAME, "actor");
4053 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
4056 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
4058 // Add actor to stage
4059 application.GetScene().Add(actor);
4061 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4062 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
4064 // Flush the queue and render once
4065 application.SendNotification();
4066 application.Render();
4068 // OnRelayout emitted
4069 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
4070 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
4075 int UtcDaliActorGetHierachyDepth(void)
4077 TestApplication application;
4078 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
4080 /* Build tree of actors:
4090 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
4092 Integration::Scene stage(application.GetScene());
4094 Actor actorA = Actor::New();
4095 Actor actorB = Actor::New();
4096 Actor actorC = Actor::New();
4097 Actor actorD = Actor::New();
4098 Actor actorE = Actor::New();
4099 Actor actorF = Actor::New();
4101 //Test that root actor has depth equal 0
4102 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4104 //Test actors return depth -1 when not connected to the tree
4105 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4106 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4107 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4108 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4109 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4110 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4112 //Create the hierarchy
4120 //Test actors return correct depth
4121 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4122 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4123 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4124 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4125 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4126 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4128 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
4129 actorA.Remove(actorB);
4131 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4132 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4133 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4135 //Removing actorA from the stage. All actors should have depth equal -1
4136 stage.Remove(actorA);
4138 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4139 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4140 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4141 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4142 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4143 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4148 int UtcDaliActorAnchorPointPropertyAsString(void)
4150 TestApplication application;
4152 Actor actor = Actor::New();
4154 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
4155 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4157 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
4158 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4160 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
4161 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4163 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
4164 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4166 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
4167 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
4169 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
4170 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4172 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
4173 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4175 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
4176 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4178 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
4179 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4181 // Invalid should not change anything
4182 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
4183 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4188 int UtcDaliActorParentOriginPropertyAsString(void)
4190 TestApplication application;
4192 Actor actor = Actor::New();
4194 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
4195 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4197 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
4198 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4200 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
4201 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4203 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
4204 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4206 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
4207 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
4209 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
4210 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4212 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
4213 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4215 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
4216 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4218 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
4219 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4221 // Invalid should not change anything
4222 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
4223 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4228 int UtcDaliActorColorModePropertyAsString(void)
4230 TestApplication application;
4232 Actor actor = Actor::New();
4234 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
4235 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4237 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
4238 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4240 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
4241 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4243 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
4244 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4246 // Invalid should not change anything
4247 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
4248 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4253 int UtcDaliActorDrawModePropertyAsString(void)
4255 TestApplication application;
4257 Actor actor = Actor::New();
4259 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
4260 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4262 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
4263 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4265 // Invalid should not change anything
4266 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
4267 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4272 int UtcDaliActorColorModePropertyAsEnum(void)
4274 TestApplication application;
4276 Actor actor = Actor::New();
4278 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
4279 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4281 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
4282 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4284 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
4285 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4287 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
4288 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4293 int UtcDaliActorDrawModePropertyAsEnum(void)
4295 TestApplication application;
4297 Actor actor = Actor::New();
4299 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
4300 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4302 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
4303 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4308 int UtcDaliActorAddRendererP(void)
4310 tet_infoline("Testing Actor::AddRenderer");
4311 TestApplication application;
4313 Actor actor = Actor::New();
4315 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4317 Geometry geometry = CreateQuadGeometry();
4318 Shader shader = CreateShader();
4319 Renderer renderer = Renderer::New(geometry, shader);
4321 actor.AddRenderer(renderer);
4322 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4323 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4328 int UtcDaliActorAddRendererN01(void)
4330 tet_infoline("Testing Actor::AddRenderer");
4331 TestApplication application;
4333 Actor actor = Actor::New();
4339 actor.AddRenderer(renderer);
4340 tet_printf("Assertion test failed - no Exception\n");
4341 tet_result(TET_FAIL);
4343 catch(Dali::DaliException& e)
4345 DALI_TEST_PRINT_ASSERT(e);
4346 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4347 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4351 tet_printf("Assertion test failed - wrong Exception\n");
4352 tet_result(TET_FAIL);
4358 int UtcDaliActorAddRendererN02(void)
4360 tet_infoline("UtcDaliActorAddRendererN02");
4366 TestApplication application;
4368 Geometry geometry = CreateQuadGeometry();
4369 Shader shader = CreateShader();
4370 renderer = Renderer::New(geometry, shader);
4372 actor = Actor::New();
4375 // try illegal AddRenderer
4378 actor.AddRenderer(renderer);
4379 tet_printf("Assertion test failed - no Exception\n");
4380 tet_result(TET_FAIL);
4382 catch(Dali::DaliException& e)
4384 DALI_TEST_PRINT_ASSERT(e);
4385 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4389 tet_printf("Assertion test failed - wrong Exception\n");
4390 tet_result(TET_FAIL);
4396 int UtcDaliActorAddRendererOnScene(void)
4398 tet_infoline("Testing Actor::AddRenderer");
4399 TestApplication application;
4401 Actor actor = Actor::New();
4402 application.GetScene().Add(actor);
4404 application.SendNotification();
4405 application.Render(0);
4407 Geometry geometry = CreateQuadGeometry();
4408 Shader shader = CreateShader();
4409 Renderer renderer = Renderer::New(geometry, shader);
4411 application.SendNotification();
4412 application.Render(0);
4416 actor.AddRenderer(renderer);
4417 tet_result(TET_PASS);
4421 tet_result(TET_FAIL);
4427 int UtcDaliActorRemoveRendererP1(void)
4429 tet_infoline("Testing Actor::RemoveRenderer");
4430 TestApplication application;
4432 Actor actor = Actor::New();
4434 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4437 Geometry geometry = CreateQuadGeometry();
4438 Shader shader = CreateShader();
4439 Renderer renderer = Renderer::New(geometry, shader);
4441 actor.AddRenderer(renderer);
4442 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4443 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4445 application.SendNotification();
4446 application.Render();
4450 Renderer renderer = actor.GetRendererAt(0);
4451 actor.RemoveRenderer(renderer);
4452 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4454 application.SendNotification();
4455 application.Render();
4458 // Call one final time to ensure that the renderer is actually removed after
4459 // the handle goes out of scope, and excercises the deletion code path in
4460 // scene graph and render.
4461 application.SendNotification();
4462 application.Render();
4467 int UtcDaliActorRemoveRendererP2(void)
4469 tet_infoline("Testing Actor::RemoveRenderer");
4470 TestApplication application;
4472 Actor actor = Actor::New();
4474 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4476 Geometry geometry = CreateQuadGeometry();
4477 Shader shader = CreateShader();
4478 Renderer renderer = Renderer::New(geometry, shader);
4480 actor.AddRenderer(renderer);
4481 application.SendNotification();
4482 application.Render();
4484 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4485 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4487 actor.RemoveRenderer(0);
4488 application.SendNotification();
4489 application.Render();
4491 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4493 // Shut down whilst holding onto the renderer handle.
4497 int UtcDaliActorRemoveRendererP3(void)
4499 tet_infoline("Testing Actor::RemoveRenderer");
4500 TestApplication application;
4502 Actor actor1 = Actor::New();
4503 Actor actor2 = Actor::New();
4504 Actor actor3 = Actor::New();
4506 application.GetScene().Add(actor1);
4507 application.GetScene().Add(actor2);
4508 application.GetScene().Add(actor3);
4510 // Make each actors size bigger than zero, so we can assuem that actor is rendered
4511 actor1.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4512 actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4513 actor3.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
4515 // Register some dummy property to seperate actor1 and actor2 in Render::Renderer
4516 actor1.RegisterProperty("dummy1", 1);
4517 actor2.RegisterProperty("dummy2", 2.0f);
4518 actor3.RegisterProperty("dummy3", Vector2(3.0f, 4.0f));
4520 DALI_TEST_EQUALS(actor1.GetRendererCount(), 0u, TEST_LOCATION);
4521 DALI_TEST_EQUALS(actor2.GetRendererCount(), 0u, TEST_LOCATION);
4522 DALI_TEST_EQUALS(actor3.GetRendererCount(), 0u, TEST_LOCATION);
4524 Geometry geometry = CreateQuadGeometry();
4525 Shader shader = CreateShader();
4526 Renderer renderer1 = Renderer::New(geometry, shader);
4527 Renderer renderer2 = Renderer::New(geometry, shader);
4529 actor1.AddRenderer(renderer1);
4530 actor1.AddRenderer(renderer2);
4531 actor2.AddRenderer(renderer1);
4532 actor2.AddRenderer(renderer2);
4533 actor3.AddRenderer(renderer1);
4534 actor3.AddRenderer(renderer2);
4535 application.SendNotification();
4536 application.Render();
4538 DALI_TEST_EQUALS(actor1.GetRendererCount(), 2u, TEST_LOCATION);
4539 DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer1, TEST_LOCATION);
4540 DALI_TEST_EQUALS(actor1.GetRendererAt(1), renderer2, TEST_LOCATION);
4542 DALI_TEST_EQUALS(actor2.GetRendererCount(), 2u, TEST_LOCATION);
4543 DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4544 DALI_TEST_EQUALS(actor2.GetRendererAt(1), renderer2, TEST_LOCATION);
4546 DALI_TEST_EQUALS(actor3.GetRendererCount(), 2u, TEST_LOCATION);
4547 DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer1, TEST_LOCATION);
4548 DALI_TEST_EQUALS(actor3.GetRendererAt(1), renderer2, TEST_LOCATION);
4550 actor1.RemoveRenderer(0);
4551 actor2.RemoveRenderer(1);
4552 actor3.RemoveRenderer(0);
4553 application.SendNotification();
4554 application.Render();
4556 DALI_TEST_EQUALS(actor1.GetRendererCount(), 1u, TEST_LOCATION);
4557 DALI_TEST_EQUALS(actor1.GetRendererAt(0), renderer2, TEST_LOCATION);
4558 DALI_TEST_EQUALS(actor2.GetRendererCount(), 1u, TEST_LOCATION);
4559 DALI_TEST_EQUALS(actor2.GetRendererAt(0), renderer1, TEST_LOCATION);
4560 DALI_TEST_EQUALS(actor3.GetRendererCount(), 1u, TEST_LOCATION);
4561 DALI_TEST_EQUALS(actor3.GetRendererAt(0), renderer2, TEST_LOCATION);
4563 // Shut down whilst holding onto the renderer handle.
4567 int UtcDaliActorRemoveRendererN(void)
4569 tet_infoline("Testing Actor::RemoveRenderer");
4570 TestApplication application;
4572 Actor actor = Actor::New();
4574 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4576 Geometry geometry = CreateQuadGeometry();
4577 Shader shader = CreateShader();
4578 Renderer renderer = Renderer::New(geometry, shader);
4580 actor.AddRenderer(renderer);
4581 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4582 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4584 actor.RemoveRenderer(10);
4585 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4586 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4591 // Clipping test helper functions:
4592 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4594 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4595 Actor actor = CreateRenderableActor(image);
4597 // Setup dimensions and position so actor is not skipped by culling.
4598 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4599 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4600 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4601 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4606 Actor CreateActorWithContent16x16()
4608 return CreateActorWithContent(16, 16);
4611 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4613 enabledDisableTrace.Reset();
4614 stencilTrace.Reset();
4615 enabledDisableTrace.Enable(true);
4616 stencilTrace.Enable(true);
4618 application.SendNotification();
4619 application.Render();
4621 enabledDisableTrace.Enable(false);
4622 stencilTrace.Enable(false);
4625 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4627 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4629 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4630 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4631 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4633 // @todo only test alpha if the framebuffer has an alpha channel
4634 //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4637 int UtcDaliActorPropertyClippingP(void)
4639 // This test checks the clippingMode property.
4640 tet_infoline("Testing Actor::Property::ClippingMode: P");
4641 TestApplication application;
4643 Actor actor = Actor::New();
4645 // Check default clippingEnabled value.
4646 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4649 bool getValueResult = getValue.Get(value);
4650 DALI_TEST_CHECK(getValueResult);
4654 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4657 // Check setting the property to the stencil mode.
4658 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4660 // Check the new value was set.
4661 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4662 getValueResult = getValue.Get(value);
4663 DALI_TEST_CHECK(getValueResult);
4667 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4670 // Check setting the property to the scissor mode.
4671 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4673 // Check the new value was set.
4674 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4675 getValueResult = getValue.Get(value);
4676 DALI_TEST_CHECK(getValueResult);
4680 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4685 int UtcDaliActorPropertyClippingN(void)
4687 // Negative test case for Clipping.
4688 tet_infoline("Testing Actor::Property::ClippingMode: N");
4689 TestApplication application;
4691 Actor actor = Actor::New();
4693 // Check default clippingEnabled value.
4694 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4697 bool getValueResult = getValue.Get(value);
4698 DALI_TEST_CHECK(getValueResult);
4702 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4705 // Check setting an invalid property value won't change the current property value.
4706 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4708 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4709 getValueResult = getValue.Get(value);
4710 DALI_TEST_CHECK(getValueResult);
4714 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4720 int UtcDaliActorPropertyClippingActor(void)
4722 // This test checks that an actor is correctly setup for clipping.
4723 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4724 TestApplication application;
4726 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4727 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4728 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4729 size_t startIndex = 0u;
4731 // Create a clipping actor.
4732 Actor actorDepth1Clip = CreateActorWithContent16x16();
4733 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4734 application.GetScene().Add(actorDepth1Clip);
4736 // Gather the call trace.
4737 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4739 // Check we are writing to the color buffer.
4740 CheckColorMask(glAbstraction, true);
4742 // Check the stencil buffer was enabled.
4743 std::ostringstream oss;
4744 oss << std::hex << GL_STENCIL_TEST;
4745 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4747 // Check the stencil buffer was cleared.
4748 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4750 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4751 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4752 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4753 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4758 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4760 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4761 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4762 TestApplication application;
4764 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4765 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4766 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4767 size_t startIndex = 0u;
4769 // Create a clipping actor.
4770 Actor actorDepth1Clip = CreateActorWithContent16x16();
4771 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4772 application.GetScene().Add(actorDepth1Clip);
4774 // Gather the call trace.
4775 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4777 // Check we are writing to the color buffer.
4778 CheckColorMask(glAbstraction, true);
4780 // Check the stencil buffer was enabled.
4781 std::ostringstream oss;
4782 oss << std::hex << GL_STENCIL_TEST;
4783 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4785 // Check the stencil buffer was cleared.
4786 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4788 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4789 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4790 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4791 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4793 // Now disable the clipping
4794 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4796 // Gather the call trace.
4797 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4799 // Check the stencil buffer was disabled.
4800 std::ostringstream stencil;
4801 stencil << std::hex << GL_STENCIL_TEST;
4802 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4804 // Ensure all values in stencil-mask are set to 1.
4806 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4811 int UtcDaliActorPropertyClippingNestedChildren(void)
4813 // This test checks that a hierarchy of actors are clipped correctly by
4814 // writing to and reading from the correct bit-planes of the stencil buffer.
4815 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4816 TestApplication application;
4817 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4818 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4819 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4821 // Create a clipping actor.
4822 Actor actorDepth1Clip = CreateActorWithContent16x16();
4823 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4824 application.GetScene().Add(actorDepth1Clip);
4826 // Create a child actor.
4827 Actor childDepth2 = CreateActorWithContent16x16();
4828 actorDepth1Clip.Add(childDepth2);
4830 // Create another clipping actor.
4831 Actor childDepth2Clip = CreateActorWithContent16x16();
4832 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4833 childDepth2.Add(childDepth2Clip);
4835 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4836 // This tests the sort algorithm.
4837 Actor childDepth3 = CreateActorWithContent16x16();
4838 childDepth2Clip.Add(childDepth3);
4839 Actor childDepth4 = CreateActorWithContent16x16();
4840 childDepth3.Add(childDepth4);
4842 // Gather the call trace.
4843 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4845 // Check we are writing to the color buffer.
4846 CheckColorMask(glAbstraction, true);
4848 // Check the stencil buffer was enabled.
4849 std::ostringstream oss;
4850 oss << std::hex << GL_STENCIL_TEST;
4851 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4853 // Perform the test twice, once for 2D layer, and once for 3D.
4854 for(unsigned int i = 0u; i < 2u; ++i)
4856 size_t startIndex = 0u;
4858 // Check the stencil buffer was cleared.
4859 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4861 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4862 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4863 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4864 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4866 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4867 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
4868 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4870 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4871 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4872 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4873 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4875 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4876 // (Both must be set to pass the check).
4877 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4878 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4880 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4883 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4884 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4891 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4893 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4894 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4895 TestApplication application;
4896 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4897 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4899 /* We create a small tree of actors as follows:
4903 Clipping enabled -> B D
4907 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4910 for(int i = 0; i < 5; ++i)
4912 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4913 Actor actor = CreateRenderableActor(image);
4915 // Setup dimensions and position so actor is not skipped by culling.
4916 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4917 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4921 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4925 float b = i > 2 ? 1.0f : -1.0f;
4926 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4932 // Enable clipping on the actor at the top of the left branch.
4933 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4935 // Build the scene graph.
4936 application.GetScene().Add(actors[0]);
4939 actors[0].Add(actors[1]);
4940 actors[1].Add(actors[2]);
4943 actors[0].Add(actors[3]);
4944 actors[3].Add(actors[4]);
4946 // Gather the call trace.
4947 enabledDisableTrace.Reset();
4948 enabledDisableTrace.Enable(true);
4949 application.SendNotification();
4950 application.Render();
4951 enabledDisableTrace.Enable(false);
4953 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4955 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
4956 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4958 size_t startIndex = 0u;
4959 std::ostringstream blend;
4960 blend << std::hex << GL_BLEND;
4961 std::ostringstream stencil;
4962 stencil << std::hex << GL_STENCIL_TEST;
4964 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4965 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4966 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4968 // Swap the clipping actor from top of left branch to top of right branch.
4969 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4970 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4972 // Gather the call trace.
4973 enabledDisableTrace.Reset();
4974 enabledDisableTrace.Enable(true);
4975 application.SendNotification();
4976 application.Render();
4977 enabledDisableTrace.Enable(false);
4979 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4980 // This proves the draw order has remained the same.
4982 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4983 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4988 int UtcDaliActorPropertyScissorClippingActor01(void)
4990 // This test checks that an actor is correctly setup for clipping.
4991 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4992 TestApplication application;
4994 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4995 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4996 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4998 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4999 const Vector2 imageSize(16.0f, 16.0f);
5001 // Create a clipping actor.
5002 Actor clippingActorA = CreateActorWithContent16x16();
5003 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5004 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5005 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5006 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5007 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5008 application.GetScene().Add(clippingActorA);
5010 // Gather the call trace.
5011 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5013 // Check we are writing to the color buffer.
5014 CheckColorMask(glAbstraction, true);
5016 // Check scissor test was enabled.
5018 std::ostringstream scissor;
5019 scissor << std::hex << GL_SCISSOR_TEST;
5020 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5022 // Check the scissor was set, and the coordinates are correct.
5023 std::stringstream compareParametersString;
5024 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
5025 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5027 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5028 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5030 // Gather the call trace.
5031 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5033 // Check the scissor was set, and the coordinates are correct.
5034 compareParametersString.str(std::string());
5035 compareParametersString.clear();
5036 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
5037 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5042 int UtcDaliActorPropertyScissorClippingActor02(void)
5044 // This test checks that an actor is correctly setup for clipping.
5045 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
5046 TestApplication application;
5048 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5049 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5050 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5052 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5053 const Vector2 actorSize(16.0f, 16.0f);
5055 // Create a clipping actor.
5056 Actor clippingActorA = CreateRenderableActor();
5057 clippingActorA[Actor::Property::SIZE] = actorSize;
5059 Renderer renderer = clippingActorA.GetRendererAt(0);
5060 DALI_TEST_CHECK(renderer);
5062 // Make Renderer opacity 0.
5063 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
5065 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5066 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5067 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
5068 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
5069 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5070 application.GetScene().Add(clippingActorA);
5072 // Gather the call trace.
5073 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5075 // Check we are writing to the color buffer.
5076 CheckColorMask(glAbstraction, true);
5078 // Check scissor test was enabled.
5080 std::ostringstream scissor;
5081 scissor << std::hex << GL_SCISSOR_TEST;
5082 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5084 // Check the scissor was set, and the coordinates are correct.
5085 std::stringstream compareParametersString;
5086 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5087 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5089 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5090 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5092 // Gather the call trace.
5093 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5095 // Check the scissor was set, and the coordinates are correct.
5096 compareParametersString.str(std::string());
5097 compareParametersString.clear();
5098 compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5099 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5104 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
5106 // This test checks that an actor is correctly setup for clipping.
5107 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
5108 TestApplication application;
5110 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5111 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5112 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5114 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5115 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5116 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5118 // Create a clipping actors.
5119 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5120 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5122 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5123 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5124 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5126 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5127 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5128 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5130 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5131 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5133 application.GetScene().Add(clippingActorA);
5134 application.GetScene().Add(clippingActorB);
5136 // Gather the call trace.
5137 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5139 // Check we are writing to the color buffer.
5140 CheckColorMask(glAbstraction, true);
5142 // Check scissor test was enabled.
5143 std::ostringstream scissor;
5144 scissor << std::hex << GL_SCISSOR_TEST;
5145 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5147 // Check the scissor was set, and the coordinates are correct.
5148 std::stringstream compareParametersString;
5150 std::string clipA("0, 500, 480, 200");
5151 std::string clipB("0, 380, 480, 40");
5153 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5154 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5159 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5161 // This test checks that an actor is correctly setup for clipping.
5162 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5163 TestApplication application;
5165 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5166 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5167 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5169 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5170 const Vector2 imageSize(16.0f, 16.0f);
5172 /* Create a nest of 2 scissors to test nesting (intersecting clips).
5174 A is drawn first - with scissor clipping on
5175 B is drawn second - also with scissor clipping on
5176 C is the generated clipping region, the intersection ( A ∩ B )
5180 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
5181 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
5182 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
5186 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5189 // Create a clipping actor.
5190 Actor clippingActorA = CreateActorWithContent16x16();
5191 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5192 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5193 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5194 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5195 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5196 application.GetScene().Add(clippingActorA);
5198 // Create a child clipping actor.
5199 Actor clippingActorB = CreateActorWithContent16x16();
5200 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5201 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5202 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5203 clippingActorA.Add(clippingActorB);
5205 // positionModifiers is an array of positions to position B around.
5206 // expect is an array of expected scissor clip coordinate results.
5207 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5208 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5210 // Loop through each overlap combination.
5211 for(unsigned int test = 0u; test < 4u; ++test)
5213 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5214 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5215 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5217 // Gather the call trace.
5218 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5220 // Check we are writing to the color buffer.
5221 CheckColorMask(glAbstraction, true);
5223 // Check scissor test was enabled.
5224 std::ostringstream scissor;
5225 scissor << std::hex << GL_SCISSOR_TEST;
5226 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5228 // Check the scissor was set, and the coordinates are correct.
5229 const Vector4& expectResults(expect[test]);
5230 std::stringstream compareParametersString;
5231 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5232 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5238 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5240 // This test checks that an actor is correctly setup for clipping.
5241 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5242 TestApplication application;
5244 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5245 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5246 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5248 /* Create a nest of 2 scissors and siblings of the parent.
5258 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5259 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5260 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5261 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5262 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5263 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5265 // Create a clipping actors.
5266 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5267 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5268 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5269 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5270 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5272 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5273 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5274 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5276 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5277 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5278 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5280 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5281 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5282 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5284 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5285 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5286 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5288 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5289 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5291 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5292 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5293 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5294 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5295 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5297 application.GetScene().Add(clippingActorA);
5298 clippingActorA.Add(clippingActorB);
5299 application.GetScene().Add(clippingActorC);
5300 application.GetScene().Add(clippingActorD);
5301 clippingActorD.Add(clippingActorE);
5303 // Gather the call trace.
5304 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5306 // Check we are writing to the color buffer.
5307 CheckColorMask(glAbstraction, true);
5309 // Check scissor test was enabled.
5310 std::ostringstream scissor;
5311 scissor << std::hex << GL_SCISSOR_TEST;
5312 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5314 // Check the scissor was set, and the coordinates are correct.
5315 std::string clipA("0, 500, 480, 200");
5316 std::string clipB("0, 580, 480, 40");
5317 std::string clipC("0, 200, 480, 200");
5318 std::string clipD("0, 300, 480, 200");
5320 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5321 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5322 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5323 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5324 DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5329 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5331 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5332 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5333 TestApplication application;
5335 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5336 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
5337 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5339 // Create a clipping actor.
5340 Actor actorDepth1Clip = CreateActorWithContent16x16();
5341 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5342 application.GetScene().Add(actorDepth1Clip);
5344 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5345 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5347 // Gather the call trace.
5348 GenerateTrace(application, enabledDisableTrace, stencilTrace);
5350 // Check we are writing to the color buffer.
5351 CheckColorMask(glAbstraction, true);
5353 // Check the stencil buffer was not enabled.
5354 std::ostringstream stencil;
5355 stencil << std::hex << GL_STENCIL_TEST;
5356 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5358 // Check stencil functions are not called.
5359 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5360 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5362 // Check that scissor clipping is overriden by the renderer properties.
5363 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5365 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5367 // Gather the call trace.
5368 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5370 // Check the stencil buffer was not enabled.
5371 std::ostringstream scissor;
5372 scissor << std::hex << GL_SCISSOR_TEST;
5373 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5375 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5380 int UtcDaliActorPropertyClippingActorCulled(void)
5382 // This test checks that child actors are clipped by an culled parent actor.
5383 tet_infoline("Testing child actors are clipped by an culled parent actor");
5384 TestApplication application;
5386 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5387 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5388 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5390 const Vector2 actorSize(160.0f, 160.0f);
5392 // Create a clipping actor.
5393 Actor clippingActorA = CreateRenderableActor();
5394 clippingActorA[Actor::Property::SIZE] = actorSize;
5396 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5397 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5398 clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5399 clippingActorA[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5400 clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5401 application.GetScene().Add(clippingActorA);
5403 // Create a child actor
5404 Actor childActor = CreateRenderableActor();
5405 childActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5406 childActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5407 childActor[Actor::Property::SIZE] = Vector2(50.0f, 50.0f);
5408 childActor[Actor::Property::INHERIT_POSITION] = false;
5410 // Gather the call trace.
5411 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5413 // Check scissor test was enabled.
5414 std::ostringstream scissor;
5415 scissor << std::hex << GL_SCISSOR_TEST;
5416 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5418 // Check the scissor was set, and the coordinates are correct.
5419 std::stringstream compareParametersString;
5420 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5421 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5423 // Move the clipping actor out of screen
5424 clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5426 // Gather the call trace.
5427 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5429 // Check the scissor was set, and the coordinates are correct.
5430 compareParametersString.str(std::string());
5431 compareParametersString.clear();
5432 compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5433 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5438 int UtcDaliGetPropertyN(void)
5440 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5441 TestApplication application;
5443 Actor actor = Actor::New();
5445 unsigned int propertyCount = actor.GetPropertyCount();
5446 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5450 int UtcDaliActorRaiseLower(void)
5452 tet_infoline("UtcDaliActor Raise and Lower test\n");
5454 TestApplication application;
5456 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5458 Integration::Scene stage(application.GetScene());
5460 Actor actorA = Actor::New();
5461 Actor actorB = Actor::New();
5462 Actor actorC = Actor::New();
5464 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5465 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5467 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5468 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5470 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5471 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5473 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5474 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5476 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5477 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5479 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5480 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5486 ResetTouchCallbacks();
5488 application.SendNotification();
5489 application.Render();
5491 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5492 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5493 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5495 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5496 // Only top actor will get touched.
5497 actorA.TouchedSignal().Connect(TestTouchCallback);
5498 actorB.TouchedSignal().Connect(TestTouchCallback2);
5499 actorC.TouchedSignal().Connect(TestTouchCallback3);
5501 // Connect ChildOrderChangedSignal
5502 bool orderChangedSignal(false);
5503 Actor orderChangedActor;
5504 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5505 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5507 Dali::Integration::Point point;
5508 point.SetDeviceId(1);
5509 point.SetState(PointState::DOWN);
5510 point.SetScreenPosition(Vector2(10.f, 10.f));
5511 Dali::Integration::TouchEvent touchEvent;
5512 touchEvent.AddPoint(point);
5514 application.ProcessEvent(touchEvent);
5516 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5517 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5518 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5520 ResetTouchCallbacks();
5522 tet_printf("Testing Raising of Actor\n");
5524 int preActorOrder(0);
5525 int postActorOrder(0);
5527 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5528 value.Get(preActorOrder);
5530 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5532 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5533 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5535 // Ensure sort order is calculated before next touch event
5536 application.SendNotification();
5538 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5539 value.Get(postActorOrder);
5541 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5543 application.ProcessEvent(touchEvent);
5545 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5546 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5547 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5549 ResetTouchCallbacks();
5551 tet_printf("Testing Lowering of Actor\n");
5553 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5554 value.Get(preActorOrder);
5556 orderChangedSignal = false;
5558 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5560 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5561 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5563 application.SendNotification(); // ensure sort order calculated before next touch event
5565 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5566 value.Get(postActorOrder);
5568 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5570 application.ProcessEvent(touchEvent);
5572 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5573 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5574 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5576 ResetTouchCallbacks();
5578 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5583 int UtcDaliActorRaiseToTopLowerToBottom(void)
5585 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5587 TestApplication application;
5589 Integration::Scene stage(application.GetScene());
5591 Actor actorA = Actor::New();
5592 Actor actorB = Actor::New();
5593 Actor actorC = Actor::New();
5595 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5596 // enables checking of which actor the uniform is assigned too
5597 Shader shaderA = CreateShader();
5598 shaderA.RegisterProperty("uRendererColor", 1.f);
5600 Shader shaderB = CreateShader();
5601 shaderB.RegisterProperty("uRendererColor", 2.f);
5603 Shader shaderC = CreateShader();
5604 shaderC.RegisterProperty("uRendererColor", 3.f);
5606 Geometry geometry = CreateQuadGeometry();
5608 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5609 Renderer rendererA = Renderer::New(geometry, shaderA);
5610 actorA.AddRenderer(rendererA);
5612 Renderer rendererB = Renderer::New(geometry, shaderB);
5613 actorB.AddRenderer(rendererB);
5615 Renderer rendererC = Renderer::New(geometry, shaderC);
5616 actorC.AddRenderer(rendererC);
5618 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5619 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5621 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5622 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5624 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5625 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5627 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5628 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5630 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5631 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5633 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5634 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5640 ResetTouchCallbacks();
5642 // Connect ChildOrderChangedSignal
5643 bool orderChangedSignal(false);
5644 Actor orderChangedActor;
5645 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5646 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5648 // Set up gl abstraction trace so can query the set uniform order
5649 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5650 glAbstraction.EnableSetUniformCallTrace(true);
5651 glAbstraction.ResetSetUniformCallStack();
5653 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5655 application.SendNotification();
5656 application.Render();
5658 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5660 // Test order of uniforms in stack
5661 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5662 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5663 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5665 bool CBA = (indexC > indexB) && (indexB > indexA);
5667 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5669 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5670 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5671 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5673 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5674 // Only top actor will get touched.
5675 actorA.TouchedSignal().Connect(TestTouchCallback);
5676 actorB.TouchedSignal().Connect(TestTouchCallback2);
5677 actorC.TouchedSignal().Connect(TestTouchCallback3);
5679 Dali::Integration::Point point;
5680 point.SetDeviceId(1);
5681 point.SetState(PointState::DOWN);
5682 point.SetScreenPosition(Vector2(10.f, 10.f));
5683 Dali::Integration::TouchEvent touchEvent;
5684 touchEvent.AddPoint(point);
5686 application.ProcessEvent(touchEvent);
5688 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5689 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5690 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5692 ResetTouchCallbacks();
5694 tet_printf("RaiseToTop ActorA\n");
5696 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5697 actorA.RaiseToTop();
5698 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5699 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5701 application.SendNotification(); // ensure sorting order is calculated before next touch event
5703 application.ProcessEvent(touchEvent);
5705 glSetUniformStack.Reset();
5707 application.SendNotification();
5708 application.Render();
5710 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5712 // Test order of uniforms in stack
5713 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5714 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5715 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5717 tet_infoline("Testing A above C and B at bottom\n");
5718 bool ACB = (indexA > indexC) && (indexC > indexB);
5720 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5722 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5723 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5724 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5726 ResetTouchCallbacks();
5728 tet_printf("RaiseToTop ActorB\n");
5730 orderChangedSignal = false;
5732 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5733 actorB.RaiseToTop();
5734 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5735 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5737 application.SendNotification(); // Ensure sort order is calculated before next touch event
5739 application.ProcessEvent(touchEvent);
5741 glSetUniformStack.Reset();
5743 application.SendNotification();
5744 application.Render();
5746 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5748 // Test order of uniforms in stack
5749 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5750 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5751 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5753 tet_infoline("Testing B above A and C at bottom\n");
5754 bool BAC = (indexB > indexA) && (indexA > indexC);
5756 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5758 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5759 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5760 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5762 ResetTouchCallbacks();
5764 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5766 orderChangedSignal = false;
5768 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5769 actorA.LowerToBottom();
5770 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5771 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5773 application.SendNotification();
5774 application.Render();
5776 orderChangedSignal = false;
5778 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5779 actorB.LowerToBottom();
5780 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5781 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5783 application.SendNotification();
5784 application.Render();
5786 application.ProcessEvent(touchEvent);
5788 glSetUniformStack.Reset();
5790 application.SendNotification();
5791 application.Render();
5793 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5795 // Test order of uniforms in stack
5796 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5797 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5798 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5800 tet_infoline("Testing C above A and B at bottom\n");
5801 bool CAB = (indexC > indexA) && (indexA > indexB);
5803 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5805 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5806 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5807 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5809 ResetTouchCallbacks();
5814 int UtcDaliActorRaiseAbove(void)
5816 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5818 TestApplication application;
5820 Integration::Scene stage(application.GetScene());
5822 Actor actorA = Actor::New();
5823 Actor actorB = Actor::New();
5824 Actor actorC = Actor::New();
5826 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5827 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5829 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5830 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5832 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5833 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5835 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5836 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5838 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5839 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5841 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5842 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5848 ResetTouchCallbacks();
5850 application.SendNotification();
5851 application.Render();
5853 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5854 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5855 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5857 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5858 // Only top actor will get touched.
5859 actorA.TouchedSignal().Connect(TestTouchCallback);
5860 actorB.TouchedSignal().Connect(TestTouchCallback2);
5861 actorC.TouchedSignal().Connect(TestTouchCallback3);
5863 bool orderChangedSignal(false);
5864 Actor orderChangedActor;
5865 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5866 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5868 Dali::Integration::Point point;
5869 point.SetDeviceId(1);
5870 point.SetState(PointState::DOWN);
5871 point.SetScreenPosition(Vector2(10.f, 10.f));
5872 Dali::Integration::TouchEvent touchEvent;
5873 touchEvent.AddPoint(point);
5875 application.ProcessEvent(touchEvent);
5877 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5878 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5879 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5881 ResetTouchCallbacks();
5883 tet_printf("Raise actor B Above Actor C\n");
5885 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5886 actorB.RaiseAbove(actorC);
5887 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5888 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5890 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5891 application.SendNotification();
5892 application.ProcessEvent(touchEvent);
5894 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5895 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5896 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5898 ResetTouchCallbacks();
5900 tet_printf("Raise actor A Above Actor B\n");
5902 orderChangedSignal = false;
5904 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5905 actorA.RaiseAbove(actorB);
5906 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5907 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5909 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5910 application.SendNotification();
5912 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5914 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5915 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5916 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5918 ResetTouchCallbacks();
5923 int UtcDaliActorRaiseAbove2(void)
5925 tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5927 TestApplication application;
5929 Integration::Scene stage(application.GetScene());
5931 Actor actorA = Actor::New();
5932 Actor actorB = Actor::New();
5933 Actor actorC = Actor::New();
5935 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5936 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5938 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5939 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5941 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5942 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5944 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5945 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5947 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5948 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5950 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5951 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5957 ResetTouchCallbacks();
5959 application.SendNotification();
5960 application.Render();
5962 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5963 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5964 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5966 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5967 // Only top actor will get touched.
5968 actorA.TouchedSignal().Connect(TestTouchCallback);
5969 actorB.TouchedSignal().Connect(TestTouchCallback2);
5970 actorC.TouchedSignal().Connect(TestTouchCallback3);
5972 bool orderChangedSignal(false);
5973 Actor orderChangedActor;
5974 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5975 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5977 Dali::Integration::Point point;
5978 point.SetDeviceId(1);
5979 point.SetState(PointState::DOWN);
5980 point.SetScreenPosition(Vector2(10.f, 10.f));
5981 Dali::Integration::TouchEvent touchEvent;
5982 touchEvent.AddPoint(point);
5984 application.ProcessEvent(touchEvent);
5986 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5987 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5988 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5990 ResetTouchCallbacks();
5992 tet_printf("Raise actor B Above Actor C\n");
5994 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5995 int newOrder = actorC[DevelActor::Property::SIBLING_ORDER];
5996 actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5997 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5998 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6000 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6001 application.SendNotification();
6002 application.ProcessEvent(touchEvent);
6004 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6005 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6006 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6008 ResetTouchCallbacks();
6010 tet_printf("Raise actor A Above Actor B\n");
6012 orderChangedSignal = false;
6014 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6015 newOrder = actorB[DevelActor::Property::SIBLING_ORDER];
6016 actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
6017 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6018 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6020 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6021 application.SendNotification();
6023 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
6025 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6026 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6027 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6029 ResetTouchCallbacks();
6034 int UtcDaliActorLowerBelow(void)
6036 tet_infoline("UtcDaliActor LowerBelow test \n");
6038 TestApplication application;
6040 Integration::Scene stage(application.GetScene());
6042 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6043 // enables checking of which actor the uniform is assigned too
6044 Shader shaderA = CreateShader();
6045 shaderA.RegisterProperty("uRendererColor", 1.f);
6047 Shader shaderB = CreateShader();
6048 shaderB.RegisterProperty("uRendererColor", 2.f);
6050 Shader shaderC = CreateShader();
6051 shaderC.RegisterProperty("uRendererColor", 3.f);
6053 Actor actorA = Actor::New();
6054 Actor actorB = Actor::New();
6055 Actor actorC = Actor::New();
6057 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6058 Geometry geometry = CreateQuadGeometry();
6060 Renderer rendererA = Renderer::New(geometry, shaderA);
6061 actorA.AddRenderer(rendererA);
6063 Renderer rendererB = Renderer::New(geometry, shaderB);
6064 actorB.AddRenderer(rendererB);
6066 Renderer rendererC = Renderer::New(geometry, shaderC);
6067 actorC.AddRenderer(rendererC);
6069 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6070 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6072 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6073 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6075 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6076 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6078 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6079 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6081 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6082 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6084 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6085 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6087 Actor container = Actor::New();
6088 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6089 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6090 stage.Add(container);
6092 container.Add(actorA);
6093 container.Add(actorB);
6094 container.Add(actorC);
6096 ResetTouchCallbacks();
6098 // Connect ChildOrderChangedSignal
6099 bool orderChangedSignal(false);
6100 Actor orderChangedActor;
6101 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6102 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6104 // Set up gl abstraction trace so can query the set uniform order
6105 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6106 glAbstraction.EnableSetUniformCallTrace(true);
6107 glAbstraction.ResetSetUniformCallStack();
6108 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6110 glAbstraction.ResetSetUniformCallStack();
6112 application.SendNotification();
6113 application.Render();
6115 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6117 // Test order of uniforms in stack
6118 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6119 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6120 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6122 tet_infoline("Testing C above B and A at bottom\n");
6123 bool CBA = (indexC > indexB) && (indexB > indexA);
6125 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6127 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6128 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6129 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6131 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6132 // Only top actor will get touched.
6133 actorA.TouchedSignal().Connect(TestTouchCallback);
6134 actorB.TouchedSignal().Connect(TestTouchCallback2);
6135 actorC.TouchedSignal().Connect(TestTouchCallback3);
6137 Dali::Integration::Point point;
6138 point.SetDeviceId(1);
6139 point.SetState(PointState::DOWN);
6140 point.SetScreenPosition(Vector2(10.f, 10.f));
6141 Dali::Integration::TouchEvent touchEvent;
6142 touchEvent.AddPoint(point);
6144 tet_infoline("UtcDaliActor Test Set up completed \n");
6146 application.ProcessEvent(touchEvent);
6148 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6149 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6150 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6152 ResetTouchCallbacks();
6154 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");
6156 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6157 actorC.LowerBelow(actorB);
6158 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6159 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6161 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6162 application.SendNotification();
6163 application.Render();
6165 application.ProcessEvent(touchEvent); // touch event
6167 glSetUniformStack.Reset();
6169 application.SendNotification();
6170 application.Render();
6172 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6174 // Test order of uniforms in stack
6175 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6176 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6177 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6179 tet_infoline("Testing render order is A, C, B");
6180 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6181 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6183 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6184 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6185 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6187 ResetTouchCallbacks();
6189 tet_printf("Lower actor C below Actor A leaving B on top\n");
6191 orderChangedSignal = false;
6193 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6194 actorC.LowerBelow(actorA);
6195 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6196 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6198 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6199 application.SendNotification();
6200 application.Render();
6202 application.ProcessEvent(touchEvent);
6204 glSetUniformStack.Reset();
6206 application.Render();
6207 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6209 // Test order of uniforms in stack
6210 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6211 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6212 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6214 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6215 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6217 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6218 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6219 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6221 ResetTouchCallbacks();
6223 tet_printf("Lower actor B below Actor C leaving A on top\n");
6225 orderChangedSignal = false;
6227 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6228 actorB.LowerBelow(actorC);
6229 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6230 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6232 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6233 application.SendNotification();
6234 application.Render();
6236 application.ProcessEvent(touchEvent);
6238 glSetUniformStack.Reset();
6240 application.Render();
6241 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6243 // Test order of uniforms in stack
6244 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6245 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6246 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6248 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6249 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6254 int UtcDaliActorLowerBelow2(void)
6256 tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
6258 TestApplication application;
6260 Integration::Scene stage(application.GetScene());
6262 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6263 // enables checking of which actor the uniform is assigned too
6264 Shader shaderA = CreateShader();
6265 shaderA.RegisterProperty("uRendererColor", 1.f);
6267 Shader shaderB = CreateShader();
6268 shaderB.RegisterProperty("uRendererColor", 2.f);
6270 Shader shaderC = CreateShader();
6271 shaderC.RegisterProperty("uRendererColor", 3.f);
6273 Actor actorA = Actor::New();
6274 Actor actorB = Actor::New();
6275 Actor actorC = Actor::New();
6277 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6278 Geometry geometry = CreateQuadGeometry();
6280 Renderer rendererA = Renderer::New(geometry, shaderA);
6281 actorA.AddRenderer(rendererA);
6283 Renderer rendererB = Renderer::New(geometry, shaderB);
6284 actorB.AddRenderer(rendererB);
6286 Renderer rendererC = Renderer::New(geometry, shaderC);
6287 actorC.AddRenderer(rendererC);
6289 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6290 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6292 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6293 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6295 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6296 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6298 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6299 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6301 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6302 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6304 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6305 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6307 Actor container = Actor::New();
6308 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6309 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6310 stage.Add(container);
6312 container.Add(actorA);
6313 container.Add(actorB);
6314 container.Add(actorC);
6316 ResetTouchCallbacks();
6318 // Connect ChildOrderChangedSignal
6319 bool orderChangedSignal(false);
6320 Actor orderChangedActor;
6321 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6322 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6324 // Set up gl abstraction trace so can query the set uniform order
6325 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6326 glAbstraction.EnableSetUniformCallTrace(true);
6327 glAbstraction.ResetSetUniformCallStack();
6328 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6330 glAbstraction.ResetSetUniformCallStack();
6332 application.SendNotification();
6333 application.Render();
6335 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6337 // Test order of uniforms in stack
6338 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6339 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6340 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6342 tet_infoline("Testing C above B and A at bottom\n");
6343 bool CBA = (indexC > indexB) && (indexB > indexA);
6345 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6347 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6348 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6349 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6351 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6352 // Only top actor will get touched.
6353 actorA.TouchedSignal().Connect(TestTouchCallback);
6354 actorB.TouchedSignal().Connect(TestTouchCallback2);
6355 actorC.TouchedSignal().Connect(TestTouchCallback3);
6357 Dali::Integration::Point point;
6358 point.SetDeviceId(1);
6359 point.SetState(PointState::DOWN);
6360 point.SetScreenPosition(Vector2(10.f, 10.f));
6361 Dali::Integration::TouchEvent touchEvent;
6362 touchEvent.AddPoint(point);
6364 tet_infoline("UtcDaliActor Test Set up completed \n");
6366 application.ProcessEvent(touchEvent);
6368 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6369 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6370 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6372 ResetTouchCallbacks();
6374 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");
6376 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6377 actorC[DevelActor::Property::SIBLING_ORDER] = 1;
6378 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6379 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6381 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6382 application.SendNotification();
6383 application.Render();
6385 application.ProcessEvent(touchEvent); // touch event
6387 glSetUniformStack.Reset();
6389 application.SendNotification();
6390 application.Render();
6392 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6394 // Test order of uniforms in stack
6395 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6396 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6397 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6399 tet_infoline("Testing render order is A, C, B");
6400 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6401 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6403 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6404 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6405 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6407 ResetTouchCallbacks();
6409 tet_printf("Lower actor C below Actor A leaving B on top\n");
6411 orderChangedSignal = false;
6413 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6414 actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6415 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6416 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6418 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6419 application.SendNotification();
6420 application.Render();
6422 application.ProcessEvent(touchEvent);
6424 glSetUniformStack.Reset();
6426 application.Render();
6427 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6429 // Test order of uniforms in stack
6430 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6431 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6432 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6434 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6435 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6437 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6438 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6439 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6441 ResetTouchCallbacks();
6443 tet_printf("Lower actor B below Actor C leaving A on top\n");
6445 orderChangedSignal = false;
6447 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6448 actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6449 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6450 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6452 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6453 application.SendNotification();
6454 application.Render();
6456 application.ProcessEvent(touchEvent);
6458 glSetUniformStack.Reset();
6460 application.Render();
6461 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6463 // Test order of uniforms in stack
6464 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6465 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6466 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6468 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6469 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6474 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6476 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6478 TestApplication application;
6480 Integration::Scene stage(application.GetScene());
6482 Actor parentA = Actor::New();
6483 Actor parentB = Actor::New();
6484 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6485 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6486 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6487 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6489 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6490 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6492 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6493 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6498 Actor actorA = Actor::New();
6499 Actor actorB = Actor::New();
6500 Actor actorC = Actor::New();
6502 parentA.Add(actorA);
6503 parentA.Add(actorB);
6505 tet_printf("Actor C added to different parent from A and B \n");
6506 parentB.Add(actorC);
6508 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6509 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6511 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6512 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6514 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6515 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6517 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6518 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6520 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6521 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6523 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6524 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6526 ResetTouchCallbacks();
6528 // Connect ChildOrderChangedSignal
6529 bool orderChangedSignal(false);
6530 Actor orderChangedActor;
6531 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6532 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6534 application.SendNotification();
6535 application.Render();
6537 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6538 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6539 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6541 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6542 // Only top actor will get touched.
6543 actorA.TouchedSignal().Connect(TestTouchCallback);
6544 actorB.TouchedSignal().Connect(TestTouchCallback2);
6545 actorC.TouchedSignal().Connect(TestTouchCallback3);
6547 Dali::Integration::Point point;
6548 point.SetDeviceId(1);
6549 point.SetState(PointState::DOWN);
6550 point.SetScreenPosition(Vector2(10.f, 10.f));
6551 Dali::Integration::TouchEvent touchEvent;
6552 touchEvent.AddPoint(point);
6554 application.ProcessEvent(touchEvent);
6556 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6557 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6558 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6560 ResetTouchCallbacks();
6562 tet_printf("Raise actor A Above Actor C which have different parents\n");
6564 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6565 actorA.RaiseAbove(actorC);
6566 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6568 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6569 application.SendNotification();
6571 application.ProcessEvent(touchEvent); // touch event
6573 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6574 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6575 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6577 ResetTouchCallbacks();
6582 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6584 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
6586 TestApplication application;
6588 Integration::Scene stage(application.GetScene());
6590 Actor actorA = Actor::New();
6591 Actor actorB = Actor::New();
6592 Actor actorC = Actor::New();
6594 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6595 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6597 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6598 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6600 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6601 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6603 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6604 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6606 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6607 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6609 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6610 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6612 ResetTouchCallbacks();
6614 // Connect ChildOrderChangedSignal
6615 bool orderChangedSignal(false);
6616 Actor orderChangedActor;
6617 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6618 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6620 application.SendNotification();
6621 application.Render();
6623 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6624 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6625 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6627 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6628 // Only top actor will get touched.
6629 actorA.TouchedSignal().Connect(TestTouchCallback);
6630 actorB.TouchedSignal().Connect(TestTouchCallback2);
6631 actorC.TouchedSignal().Connect(TestTouchCallback3);
6633 Dali::Integration::Point point;
6634 point.SetDeviceId(1);
6635 point.SetState(PointState::DOWN);
6636 point.SetScreenPosition(Vector2(10.f, 10.f));
6637 Dali::Integration::TouchEvent touchEvent;
6638 touchEvent.AddPoint(point);
6640 tet_printf("Raise actor A Above Actor C which have no parents\n");
6642 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6643 actorA.RaiseAbove(actorC);
6644 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6646 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6647 application.SendNotification();
6649 application.ProcessEvent(touchEvent);
6651 tet_printf("Not parented so RaiseAbove should show no effect\n");
6653 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6654 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6655 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6657 ResetTouchCallbacks();
6659 orderChangedSignal = false;
6662 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6664 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6665 actorA.LowerBelow(actorC);
6666 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6668 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6669 application.SendNotification();
6670 application.Render();
6672 application.ProcessEvent(touchEvent);
6674 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6675 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6676 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6677 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6679 ResetTouchCallbacks();
6681 orderChangedSignal = false;
6683 tet_printf("Adding Actor A to stage, will be on top\n");
6686 application.SendNotification();
6687 application.Render();
6689 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6691 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6692 actorB.RaiseAbove(actorC);
6693 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6695 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6696 application.SendNotification();
6698 application.ProcessEvent(touchEvent);
6700 tet_printf("C not parented so RaiseAbove should show no effect\n");
6701 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6702 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6703 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6705 ResetTouchCallbacks();
6707 orderChangedSignal = false;
6709 tet_printf("Lower actor A below Actor C when only A has a parent\n");
6711 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6712 actorA.LowerBelow(actorC);
6713 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6715 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6716 application.SendNotification();
6718 application.ProcessEvent(touchEvent);
6720 tet_printf("C not parented so LowerBelow should show no effect\n");
6721 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6722 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6723 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6725 ResetTouchCallbacks();
6727 orderChangedSignal = false;
6731 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6732 actorA.RaiseAbove(actorC);
6733 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6734 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6736 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6737 application.SendNotification();
6738 application.Render();
6740 application.ProcessEvent(touchEvent);
6742 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6743 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6744 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6745 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6750 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6752 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6754 TestApplication application;
6756 Integration::Scene stage(application.GetScene());
6758 Actor actorA = Actor::New();
6759 Actor actorB = Actor::New();
6760 Actor actorC = Actor::New();
6762 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6763 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6765 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6766 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6768 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6769 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6771 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6772 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6774 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6775 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6777 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6778 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6780 ResetTouchCallbacks();
6782 // Connect ChildOrderChangedSignal
6783 bool orderChangedSignal(false);
6784 Actor orderChangedActor;
6785 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6786 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6788 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6789 // Only top actor will get touched.
6790 actorA.TouchedSignal().Connect(TestTouchCallback);
6791 actorB.TouchedSignal().Connect(TestTouchCallback2);
6792 actorC.TouchedSignal().Connect(TestTouchCallback3);
6794 Dali::Integration::Point point;
6795 point.SetDeviceId(1);
6796 point.SetState(PointState::DOWN);
6797 point.SetScreenPosition(Vector2(10.f, 10.f));
6798 Dali::Integration::TouchEvent touchEvent;
6799 touchEvent.AddPoint(point);
6802 tet_printf("Raise actor B Above Actor C but B not parented\n");
6804 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6806 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6808 application.SendNotification();
6809 application.Render();
6811 application.ProcessEvent(touchEvent);
6813 tet_printf("Not parented so RaiseAbove should show no effect\n");
6815 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6816 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6817 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6819 tet_printf("Raise actor B Above Actor C but B not parented\n");
6820 ResetTouchCallbacks();
6822 orderChangedSignal = false;
6824 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6826 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6828 // Sort actor tree before next touch event
6829 application.SendNotification();
6830 application.Render();
6832 application.ProcessEvent(touchEvent);
6834 tet_printf("Not parented so RaiseAbove should show no effect\n");
6836 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6837 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6838 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6839 ResetTouchCallbacks();
6841 orderChangedSignal = false;
6843 tet_printf("Lower actor C below B but C not parented\n");
6845 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6847 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6849 // Sort actor tree before next touch event
6850 application.SendNotification();
6851 application.Render();
6853 application.ProcessEvent(touchEvent);
6855 tet_printf("Not parented so Lower should show no effect\n");
6857 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6858 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6859 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6860 ResetTouchCallbacks();
6862 orderChangedSignal = false;
6864 tet_printf("Raise actor B to top\n");
6866 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6867 actorB.RaiseToTop();
6868 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6870 // Sort actor tree before next touch event
6871 application.SendNotification();
6872 application.Render();
6874 application.ProcessEvent(touchEvent);
6876 tet_printf("Not parented so RaiseToTop should show no effect\n");
6878 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6879 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6880 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6881 ResetTouchCallbacks();
6883 orderChangedSignal = false;
6885 tet_printf("Add ActorB to stage so only Actor C not parented\n");
6889 tet_printf("Lower actor C to Bottom, B stays at top\n");
6891 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6892 actorC.LowerToBottom();
6893 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6895 application.SendNotification();
6896 application.Render();
6898 application.ProcessEvent(touchEvent);
6900 tet_printf("Not parented so LowerToBottom should show no effect\n");
6902 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6903 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6904 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6905 ResetTouchCallbacks();
6910 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6912 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
6914 TestApplication application;
6916 Integration::Scene stage(application.GetScene());
6918 Actor actorA = Actor::New();
6919 Actor actorB = Actor::New();
6920 Actor actorC = Actor::New();
6922 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6923 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6925 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6926 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6928 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6929 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6931 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6932 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6934 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6935 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6937 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6938 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6944 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6945 // Only top actor will get touched.
6946 actorA.TouchedSignal().Connect(TestTouchCallback);
6947 actorB.TouchedSignal().Connect(TestTouchCallback2);
6948 actorC.TouchedSignal().Connect(TestTouchCallback3);
6950 ResetTouchCallbacks();
6952 // Connect ChildOrderChangedSignal
6953 bool orderChangedSignal(false);
6954 Actor orderChangedActor;
6955 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6956 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6958 application.SendNotification();
6959 application.Render();
6961 Dali::Integration::Point point;
6962 point.SetDeviceId(1);
6963 point.SetState(PointState::DOWN);
6964 point.SetScreenPosition(Vector2(10.f, 10.f));
6965 Dali::Integration::TouchEvent touchEvent;
6966 touchEvent.AddPoint(point);
6968 application.ProcessEvent(touchEvent);
6970 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6971 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6972 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6974 ResetTouchCallbacks();
6976 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6978 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6979 actorA.RaiseAbove(actorA);
6980 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6981 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6983 application.SendNotification();
6984 application.Render();
6986 application.ProcessEvent(touchEvent);
6988 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6990 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6991 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6992 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6994 ResetTouchCallbacks();
6996 orderChangedSignal = false;
6998 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6999 actorA.RaiseAbove(actorC);
7000 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
7001 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
7003 application.SendNotification();
7004 application.Render();
7006 application.ProcessEvent(touchEvent);
7008 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
7009 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
7010 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
7011 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
7016 int UtcDaliActorGetScreenPosition(void)
7018 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
7020 TestApplication application;
7022 Integration::Scene stage(application.GetScene());
7024 Actor actorA = Actor::New();
7025 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7027 Vector2 size2(10.0f, 20.0f);
7028 actorA.SetProperty(Actor::Property::SIZE, size2);
7030 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7032 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
7036 application.SendNotification();
7037 application.Render();
7039 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7040 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7042 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7043 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
7045 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7046 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7048 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
7050 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7052 application.SendNotification();
7053 application.Render();
7055 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7056 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7058 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7059 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
7061 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7062 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7064 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
7066 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7068 application.SendNotification();
7069 application.Render();
7071 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7072 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7074 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7075 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
7077 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7078 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7080 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
7082 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
7084 application.SendNotification();
7085 application.Render();
7087 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7088 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7090 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
7091 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
7093 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7094 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7096 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
7098 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
7100 application.SendNotification();
7101 application.Render();
7103 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7104 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7106 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7107 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
7109 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
7110 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
7112 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
7114 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7115 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
7117 Actor actorB = Actor::New();
7118 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7119 actorB.SetProperty(Actor::Property::SIZE, size2);
7120 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
7123 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7125 application.SendNotification();
7126 application.Render();
7128 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7130 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
7131 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
7136 int UtcDaliActorGetScreenPositionAfterScaling(void)
7138 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
7140 TestApplication application;
7142 Integration::Scene stage(application.GetScene());
7144 Actor actorA = Actor::New();
7145 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7147 Vector2 size2(10.0f, 20.0f);
7148 actorA.SetProperty(Actor::Property::SIZE, size2);
7149 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
7150 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7152 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
7156 application.SendNotification();
7157 application.Render();
7159 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7160 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7162 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7163 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7165 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7166 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7168 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
7170 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7172 application.SendNotification();
7173 application.Render();
7175 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7176 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7178 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7179 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7181 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
7182 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7187 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
7189 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
7191 TestApplication application;
7193 Integration::Scene stage(application.GetScene());
7195 Actor actorA = Actor::New();
7196 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7197 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7198 Vector2 size2(10.0f, 20.0f);
7199 actorA.SetProperty(Actor::Property::SIZE, size2);
7200 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7202 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7206 application.SendNotification();
7207 application.Render();
7209 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7210 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7212 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7213 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7215 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
7216 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
7218 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
7220 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
7221 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7223 application.SendNotification();
7224 application.Render();
7226 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7227 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7229 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7230 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7232 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
7233 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7239 int UtcDaliActorGetScreenPositionWithChildActors(void)
7241 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
7243 TestApplication application;
7245 Integration::Scene stage(application.GetScene());
7247 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7249 Actor actorA = Actor::New();
7250 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7251 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7252 Vector2 size1(10.0f, 20.0f);
7253 actorA.SetProperty(Actor::Property::SIZE, size1);
7254 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7256 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7258 Actor parentActorA = Actor::New();
7259 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7260 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7261 Vector2 size2(30.0f, 60.0f);
7262 parentActorA.SetProperty(Actor::Property::SIZE, size2);
7263 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7265 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7267 stage.Add(parentActorA);
7268 parentActorA.Add(actorA);
7270 application.SendNotification();
7271 application.Render();
7273 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7274 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7276 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7277 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7279 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
7280 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
7282 tet_infoline("Test 2\n");
7284 tet_infoline("change parent anchor point and parent origin then check screen position \n");
7286 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7287 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
7289 application.SendNotification();
7290 application.Render();
7292 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7293 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7295 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7296 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7298 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
7299 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
7304 int UtcDaliActorGetScreenPositionWithChildActors02(void)
7306 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
7308 TestApplication application;
7310 Integration::Scene stage(application.GetScene());
7312 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7314 Actor actorA = Actor::New();
7315 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7316 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7317 Vector2 size1(10.0f, 20.0f);
7318 actorA.SetProperty(Actor::Property::SIZE, size1);
7319 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7321 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7323 Actor parentActorA = Actor::New();
7324 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7325 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7326 Vector2 size2(30.0f, 60.0f);
7327 parentActorA.SetProperty(Actor::Property::SIZE, size2);
7328 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7330 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
7332 Actor grandParentActorA = Actor::New();
7333 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7334 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
7335 Vector2 size3(60.0f, 120.0f);
7336 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
7337 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7339 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
7341 stage.Add(grandParentActorA);
7342 grandParentActorA.Add(parentActorA);
7344 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7346 parentActorA.Add(actorA);
7348 application.SendNotification();
7349 application.Render();
7351 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7352 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7354 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7355 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7357 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
7358 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
7363 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
7365 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
7367 TestApplication application;
7369 Integration::Scene stage(application.GetScene());
7371 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7373 Actor actorA = Actor::New();
7374 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7375 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7376 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7377 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
7380 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7382 Actor actorB = Actor::New();
7383 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7384 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7385 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7386 Vector2 actorBSize(30.0f, 60.0f);
7387 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7390 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7392 Actor actorC = Actor::New();
7393 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7394 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7395 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7396 Vector2 actorCSize(60.0f, 120.0f);
7397 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7400 application.SendNotification();
7401 application.Render();
7403 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7405 Vector2 center(stage.GetSize() * 0.5f);
7407 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7408 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7409 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7411 tet_infoline("Add scale to all actors");
7413 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7414 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7415 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7417 application.SendNotification();
7418 application.Render();
7420 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7421 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7422 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7427 int UtcDaliActorGetScreenPositionResizeScene(void)
7429 tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
7431 TestApplication application;
7432 Integration::Scene scene = application.GetScene();
7434 Actor actorA = Actor::New();
7435 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7436 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7437 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7441 application.SendNotification();
7442 application.Render();
7444 Vector2 sceneSize = scene.GetSize();
7445 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7447 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7450 Vector2 newSize(1000.0f, 2000.0f);
7451 DALI_TEST_CHECK(scene.GetSize() != newSize);
7453 scene.SurfaceResized(newSize.width, newSize.height);
7455 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7457 // The screen position should not be updated yet
7458 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7460 application.SendNotification();
7461 application.Render();
7463 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7465 // The screen position should be updated
7466 sceneSize = scene.GetSize();
7467 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7472 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
7474 tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
7476 TestApplication application;
7477 Integration::Scene scene = application.GetScene();
7480 Layer layer = scene.GetRootLayer();
7481 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
7483 // Build custom camera with top-view
7484 CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
7486 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
7487 Vector3 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7488 Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7491 std::ostringstream oss;
7492 oss << cameraPos << "\n";
7493 oss << cameraOrient << "\n";
7494 tet_printf("%s\n", oss.str().c_str());
7497 cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
7498 cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
7500 // Now, upside : -Z, leftside : -X, foward : +Y
7502 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7503 cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7505 std::ostringstream oss;
7506 oss << cameraPos << "\n";
7507 oss << cameraOrient << "\n";
7508 tet_printf("%s\n", oss.str().c_str());
7512 Actor actorA = Actor::New();
7513 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7514 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7515 actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7516 actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
7518 Actor actorB = Actor::New();
7519 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7520 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7521 actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7522 actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
7527 application.SendNotification();
7528 application.Render();
7530 Vector2 sceneSize = scene.GetSize();
7531 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7533 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
7535 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7537 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
7542 int utcDaliActorPositionUsesAnchorPoint(void)
7544 TestApplication application;
7545 tet_infoline("Check default behaviour\n");
7547 Actor actor = Actor::New();
7548 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7549 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7550 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7551 application.GetScene().Add(actor);
7553 application.SendNotification();
7554 application.Render();
7556 tet_infoline("Check that the world position is in the center\n");
7557 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7559 tet_infoline("Set the position uses anchor point property to false\n");
7560 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7562 application.SendNotification();
7563 application.Render();
7565 tet_infoline("Check that the world position has changed appropriately\n");
7566 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7571 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7573 TestApplication application;
7574 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7576 Actor actor = Actor::New();
7577 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7578 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7579 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7580 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7581 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7582 application.GetScene().Add(actor);
7584 application.SendNotification();
7585 application.Render();
7587 tet_infoline("Check the world position is the same as it would be without a scale\n");
7588 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7590 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7591 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7592 application.SendNotification();
7593 application.Render();
7594 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7596 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7597 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7598 application.SendNotification();
7599 application.Render();
7600 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7605 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7607 TestApplication application;
7608 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7610 Actor actor = Actor::New();
7611 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7612 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7613 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7614 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7615 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7616 application.GetScene().Add(actor);
7618 application.SendNotification();
7619 application.Render();
7621 tet_infoline("Check the world position is the same as it would be without a rotation\n");
7622 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7624 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7625 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7626 application.SendNotification();
7627 application.Render();
7628 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7630 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7631 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7632 application.SendNotification();
7633 application.Render();
7634 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7639 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7641 TestApplication application;
7642 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7644 Actor actor = Actor::New();
7645 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7646 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7647 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7648 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7649 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7650 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7651 application.GetScene().Add(actor);
7653 application.SendNotification();
7654 application.Render();
7656 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7657 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7659 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7660 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7661 application.SendNotification();
7662 application.Render();
7663 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7665 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7666 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7667 application.SendNotification();
7668 application.Render();
7669 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7674 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7676 TestApplication application;
7677 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7679 Actor parent = Actor::New();
7681 application.GetScene().Add(parent);
7682 Vector2 stageSize(application.GetScene().GetSize());
7684 Actor actor = Actor::New();
7685 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7686 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7687 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7688 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7689 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7690 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7693 application.SendNotification();
7694 application.Render();
7696 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7698 tet_infoline("Check the world position is in the right place\n");
7699 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7701 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7702 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7703 application.SendNotification();
7704 application.Render();
7705 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7707 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7708 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7709 application.SendNotification();
7710 application.Render();
7711 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7716 int utcDaliActorVisibilityChangeSignalSelf(void)
7718 TestApplication application;
7719 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7721 Actor actor = Actor::New();
7723 VisibilityChangedFunctorData data;
7724 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7726 actor.SetProperty(Actor::Property::VISIBLE, false);
7728 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7730 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7733 actor.SetProperty(Actor::Property::VISIBLE, false);
7734 data.Check(false /* not called */, TEST_LOCATION);
7736 tet_infoline("Change the visibility using properties, ensure called");
7739 actor.SetProperty(Actor::Property::VISIBLE, true);
7740 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7742 tet_infoline("Set the visibility to current using properties, ensure not called");
7745 actor.SetProperty(Actor::Property::VISIBLE, true);
7746 data.Check(false /* not called */, TEST_LOCATION);
7751 int utcDaliActorVisibilityChangeSignalChildren(void)
7753 TestApplication application;
7754 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7756 Actor parent = Actor::New();
7757 Actor child = Actor::New();
7760 Actor grandChild = Actor::New();
7761 child.Add(grandChild);
7763 VisibilityChangedFunctorData parentData;
7764 VisibilityChangedFunctorData childData;
7765 VisibilityChangedFunctorData grandChildData;
7767 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7768 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7769 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7771 parent.SetProperty(Actor::Property::VISIBLE, false);
7772 parentData.Check(false /* not called */, TEST_LOCATION);
7773 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7774 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7776 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7779 grandChildData.Reset();
7781 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7783 parent.SetProperty(Actor::Property::VISIBLE, true);
7784 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7785 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7786 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7788 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7791 grandChildData.Reset();
7793 parent.SetProperty(Actor::Property::VISIBLE, true);
7794 parentData.Check(false /* not called */, TEST_LOCATION);
7795 childData.Check(false /* not called */, TEST_LOCATION);
7796 grandChildData.Check(false /* not called */, TEST_LOCATION);
7801 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7803 TestApplication application;
7804 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7806 Actor actor = Actor::New();
7807 application.GetScene().Add(actor);
7809 application.SendNotification();
7810 application.Render();
7812 VisibilityChangedFunctorData data;
7813 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7815 Animation animation = Animation::New(1.0f);
7816 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7818 data.Check(false, TEST_LOCATION);
7819 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7820 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7822 tet_infoline("Play the animation and check the property value");
7825 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7826 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7828 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7829 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7831 application.SendNotification();
7832 application.Render(1100); // After the animation
7834 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7839 int utcDaliActorVisibilityChangeSignalByName(void)
7841 TestApplication application;
7842 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7844 Actor actor = Actor::New();
7846 bool signalCalled = false;
7847 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7848 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7849 actor.SetProperty(Actor::Property::VISIBLE, false);
7850 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7852 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7853 signalCalled = false;
7854 actor.SetProperty(Actor::Property::VISIBLE, false);
7855 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7857 tet_infoline("Change the visibility using properties, ensure called");
7858 actor.SetProperty(Actor::Property::VISIBLE, true);
7859 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7861 tet_infoline("Set the visibility to current using properties, ensure not called");
7862 signalCalled = false;
7864 actor.SetProperty(Actor::Property::VISIBLE, true);
7865 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7870 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7872 gLayoutDirectionType = type;
7875 int UtcDaliActorLayoutDirectionProperty(void)
7877 TestApplication application;
7878 tet_infoline("Check layout direction property");
7880 Actor actor0 = Actor::New();
7881 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7882 application.GetScene().Add(actor0);
7884 application.SendNotification();
7885 application.Render();
7887 Actor actor1 = Actor::New();
7888 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7889 Actor actor2 = Actor::New();
7890 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7891 Actor actor3 = Actor::New();
7892 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7893 Actor actor4 = Actor::New();
7894 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7895 Actor actor5 = Actor::New();
7896 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7897 Actor actor6 = Actor::New();
7898 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7899 Actor actor7 = Actor::New();
7900 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7901 Actor actor8 = Actor::New();
7902 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7903 Actor actor9 = Actor::New();
7904 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7907 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7908 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7910 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7911 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7912 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7914 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7915 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7916 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7918 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7920 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7921 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7923 application.GetScene().Add(actor3);
7930 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7931 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7933 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7934 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7935 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7937 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7939 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7940 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7941 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7942 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7943 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7944 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7945 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7947 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7948 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7949 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7951 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7952 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7953 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7954 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7956 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7957 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7958 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7963 struct LayoutDirectionFunctor
7965 LayoutDirectionFunctor(bool& signalCalled)
7966 : mSignalCalled(signalCalled)
7970 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7971 : mSignalCalled(rhs.mSignalCalled)
7977 mSignalCalled = true;
7980 bool& mSignalCalled;
7983 int UtcDaliActorLayoutDirectionSignal(void)
7985 TestApplication application;
7986 tet_infoline("Check changing layout direction property sends a signal");
7988 Actor actor = Actor::New();
7989 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7990 application.GetScene().Add(actor);
7991 bool signalCalled = false;
7992 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7994 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7995 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7997 // Test that writing the same value doesn't send a signal
7998 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7999 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
8001 // Test that writing a different value sends the signal
8002 signalCalled = false;
8003 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
8004 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
8006 signalCalled = false;
8007 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
8008 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
8013 struct ChildAddedSignalCheck
8015 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
8016 : mSignalReceived(signalReceived),
8017 mChildHandle(childHandle)
8021 void operator()(Actor childHandle)
8023 mSignalReceived = true;
8024 mChildHandle = childHandle;
8028 mSignalReceived = true;
8029 mChildHandle = Actor();
8032 bool& mSignalReceived;
8033 Actor& mChildHandle;
8036 int UtcDaliChildAddedSignalP1(void)
8038 TestApplication application;
8039 auto stage = application.GetScene();
8041 bool signalReceived = false;
8044 ChildAddedSignalCheck signal(signalReceived, childActor);
8045 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
8046 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8048 auto actorA = Actor::New();
8050 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8051 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8052 signalReceived = false;
8054 auto actorB = Actor::New();
8056 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8057 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8062 int UtcDaliChildAddedSignalP2(void)
8064 TestApplication application;
8065 auto stage = application.GetScene();
8067 bool signalReceived = false;
8070 ChildAddedSignalCheck signal(signalReceived, childActor);
8071 tet_infoline("Connect to childAdded signal by name");
8073 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
8074 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8076 auto actorA = Actor::New();
8078 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8080 // Can't test which actor was added; signal signature is void() when connecting via name.
8081 signalReceived = false;
8083 auto actorB = Actor::New();
8085 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8090 int UtcDaliChildAddedSignalN(void)
8092 TestApplication application;
8093 auto stage = application.GetScene();
8095 bool signalReceived = false;
8098 ChildAddedSignalCheck signal(signalReceived, childActor);
8099 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
8100 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8102 auto actorA = Actor::New();
8104 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8105 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8106 signalReceived = false;
8108 auto actorB = Actor::New();
8110 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8114 struct ChildRemovedSignalCheck
8116 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
8117 : mSignalReceived(signalReceived),
8118 mChildHandle(childHandle)
8122 void operator()(Actor childHandle)
8124 mSignalReceived = true;
8125 mChildHandle = childHandle;
8130 mSignalReceived = true;
8133 bool& mSignalReceived;
8134 Actor& mChildHandle;
8137 int UtcDaliChildRemovedSignalP1(void)
8139 TestApplication application;
8140 auto stage = application.GetScene();
8142 bool signalReceived = false;
8145 ChildRemovedSignalCheck signal(signalReceived, childActor);
8146 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8147 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8149 auto actorA = Actor::New();
8151 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8152 DALI_TEST_CHECK(!childActor);
8154 stage.Remove(actorA);
8155 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8156 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8158 signalReceived = false;
8159 auto actorB = Actor::New();
8161 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8163 stage.Remove(actorB);
8164 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8165 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8170 int UtcDaliChildRemovedSignalP2(void)
8172 TestApplication application;
8173 auto stage = application.GetScene();
8175 bool signalReceived = false;
8178 ChildAddedSignalCheck signal(signalReceived, childActor);
8179 tet_infoline("Connect to childRemoved signal by name");
8181 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
8182 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8184 auto actorA = Actor::New();
8186 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8188 stage.Remove(actorA);
8189 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8191 signalReceived = false;
8192 auto actorB = Actor::New();
8194 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8196 stage.Remove(actorB);
8197 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8202 int UtcDaliChildRemovedSignalN(void)
8204 TestApplication application;
8205 auto stage = application.GetScene();
8207 bool signalReceived = false;
8210 ChildRemovedSignalCheck signal(signalReceived, childActor);
8211 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8212 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8214 auto actorA = Actor::New();
8217 auto actorB = Actor::New();
8220 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8221 DALI_TEST_CHECK(!childActor);
8223 actorA.Remove(actorB);
8224 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8228 int UtcDaliChildMovedSignalP(void)
8230 TestApplication application;
8231 auto stage = application.GetScene();
8233 bool addedASignalReceived = false;
8234 bool removedASignalReceived = false;
8235 bool addedBSignalReceived = false;
8236 bool removedBSignalReceived = false;
8239 auto actorA = Actor::New();
8240 auto actorB = Actor::New();
8244 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
8245 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
8246 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
8247 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
8249 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
8250 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
8251 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
8252 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
8254 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8255 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8256 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8257 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8259 // Create a child of A
8261 auto child = Actor::New();
8264 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8265 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8266 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8267 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8268 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
8271 addedASignalReceived = false;
8272 addedBSignalReceived = false;
8273 removedASignalReceived = false;
8274 removedBSignalReceived = false;
8276 actorB.Add(child); // Expect this child to be re-parented
8277 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8278 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
8279 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
8280 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8282 // Move child back to A:
8283 addedASignalReceived = false;
8284 addedBSignalReceived = false;
8285 removedASignalReceived = false;
8286 removedBSignalReceived = false;
8288 actorA.Add(child); // Expect this child to be re-parented
8289 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8290 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8291 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8292 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
8297 int UtcDaliActorSwitchParentP(void)
8299 tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
8300 TestApplication application;
8302 Actor parent1 = Actor::New();
8303 Actor child = Actor::New();
8305 application.GetScene().Add(parent1);
8307 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8309 child.OnSceneSignal().Connect(OnSceneCallback);
8310 child.OffSceneSignal().Connect(OffSceneCallback);
8313 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
8314 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8318 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
8320 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8321 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8323 Actor parent2 = Actor::New();
8324 application.GetScene().Add(parent2);
8326 bool addSignalReceived = false;
8327 ChildAddedSignalCheck addedSignal(addSignalReceived, child);
8328 DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
8329 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8331 bool removedSignalReceived = false;
8332 ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
8333 DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
8334 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8336 DevelActor::SwitchParent(child, parent2);
8338 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8339 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8341 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8342 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
8344 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8345 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8346 DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
8347 DALI_TEST_CHECK(child.GetParent() == parent2);
8352 int utcDaliActorCulled(void)
8354 TestApplication application;
8355 auto stage = application.GetScene();
8357 tet_infoline("Check that the actor is culled if the actor is out of the screen");
8359 Actor actor = Actor::New();
8360 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
8362 Geometry geometry = CreateQuadGeometry();
8363 Shader shader = CreateShader();
8364 Renderer renderer = Renderer::New(geometry, shader);
8365 actor.AddRenderer(renderer);
8369 application.SendNotification();
8370 application.Render(0);
8372 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
8374 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
8375 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
8377 // Connect NotifySignal
8378 bool propertyNotificationSignal(false);
8379 PropertyNotification source;
8380 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
8381 notification.NotifySignal().Connect(&application, f);
8383 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
8385 application.SendNotification();
8386 application.Render();
8388 application.SendNotification();
8390 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
8392 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
8393 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
8394 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
8399 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
8401 TestApplication application;
8402 auto stage = application.GetScene();
8404 tet_infoline("Ensure we clear the screen when the last actor is removed");
8406 Actor actor = CreateRenderableActor();
8407 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8410 application.SendNotification();
8411 application.Render();
8413 auto& glAbstraction = application.GetGlAbstraction();
8414 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8418 application.SendNotification();
8419 application.Render();
8421 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8426 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
8428 TestApplication application;
8429 auto stage = application.GetScene();
8431 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
8433 Actor actor = CreateRenderableActor();
8434 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8437 application.SendNotification();
8438 application.Render();
8440 auto& glAbstraction = application.GetGlAbstraction();
8441 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8443 actor.SetProperty(Actor::Property::VISIBLE, false);
8445 application.SendNotification();
8446 application.Render();
8448 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8453 int utcDaliActorGetSizeAfterAnimation(void)
8455 TestApplication application;
8456 tet_infoline("Check the actor size before / after an animation is finished");
8458 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8460 Actor actor = Actor::New();
8461 actor.SetProperty(Actor::Property::SIZE, actorSize);
8462 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8463 application.GetScene().Add(actor);
8465 // Size should be updated without rendering.
8466 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8467 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8469 application.SendNotification();
8470 application.Render();
8472 // Size and current size should be updated.
8473 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8474 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8475 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8476 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8477 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8479 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8480 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8481 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8482 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8483 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8486 actorSize = Vector3(200.0f, 200.0f, 0.0f);
8487 actor.SetProperty(Actor::Property::SIZE, actorSize);
8489 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8490 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8492 Vector3 targetValue(10.0f, 20.0f, 0.0f);
8494 Animation animation = Animation::New(1.0f);
8495 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8498 // Size should be updated without rendering.
8499 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8500 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8502 application.SendNotification();
8503 application.Render(1100); // After the animation
8505 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8506 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8507 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8508 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8509 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8511 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8512 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8513 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8514 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8515 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8517 targetValue.width = 50.0f;
8520 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8523 application.SendNotification();
8524 application.Render(1100); // After the animation
8526 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8527 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8528 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8529 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8530 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8532 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8533 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8534 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8535 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8536 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8538 targetValue.height = 70.0f;
8541 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8544 application.SendNotification();
8545 application.Render(1100); // After the animation
8547 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8548 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8549 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8550 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8551 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8553 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8554 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8555 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8556 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8557 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8559 Vector3 offset(10.0f, 20.0f, 0.0f);
8562 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8565 application.SendNotification();
8566 application.Render(1100); // After the animation
8568 targetValue += offset;
8570 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8571 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8572 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8573 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8574 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8576 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8577 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8578 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8579 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8580 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8582 offset.width = 20.0f;
8585 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8588 application.SendNotification();
8589 application.Render(1100); // After the animation
8591 targetValue.width += offset.width;
8593 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8594 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8595 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8596 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8597 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8599 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8600 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8601 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8602 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8603 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8605 offset.height = 10.0f;
8608 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8611 application.SendNotification();
8612 application.Render(1100); // After the animation
8614 targetValue.height += offset.height;
8616 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8617 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8618 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8619 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8620 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8622 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8623 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8624 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8625 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8626 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8629 actorSize = Vector3(300.0f, 300.0f, 0.0f);
8631 actor.SetProperty(Actor::Property::SIZE, actorSize);
8633 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8634 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8636 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8637 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8639 application.SendNotification();
8640 application.Render();
8642 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8643 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8645 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8646 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8651 int utcDaliActorGetSizeAfterAnimation2(void)
8653 TestApplication application;
8654 tet_infoline("Check the actor size before / after an animation is finished if before size is equal to animation target size");
8656 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8658 Actor actor = Actor::New();
8659 actor.SetProperty(Actor::Property::SIZE, actorSize);
8660 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8661 application.GetScene().Add(actor);
8663 // Size should be updated without rendering.
8664 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8665 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8667 application.SendNotification();
8668 application.Render();
8670 // Size and current size should be updated.
8671 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8672 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8673 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8674 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8675 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8677 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8678 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8679 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8680 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8681 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8684 actorSize = Vector3(200.0f, 200.0f, 0.0f);
8685 actor.SetProperty(Actor::Property::SIZE, actorSize);
8687 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8688 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8690 Vector3 targetValue(actorSize);
8692 Animation animation = Animation::New(1.0f);
8693 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8696 // Size should be updated without rendering.
8697 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8698 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8700 application.SendNotification();
8701 application.Render(100); // During the animation
8703 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8704 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8705 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8706 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8707 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8709 // We should get target value because targetValue is equal to current actor size.
8710 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8711 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8712 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8713 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8714 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8716 application.SendNotification();
8717 application.Render(1000); // After animation finished
8719 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8720 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8722 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8723 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8728 int utcDaliActorRelayoutAndAnimation(void)
8730 TestApplication application;
8731 tet_infoline("Check the actor size when relayoutting and playing animation");
8733 Vector3 parentSize(300.0f, 300.0f, 0.0f);
8734 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8737 Actor parentA = Actor::New();
8738 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8739 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8740 application.GetScene().Add(parentA);
8742 Actor parentB = Actor::New();
8743 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8744 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8745 application.GetScene().Add(parentB);
8747 Actor actor = Actor::New();
8748 actor.SetProperty(Actor::Property::SIZE, actorSize);
8749 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8752 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8753 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8755 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8757 Animation animation = Animation::New(1.0f);
8758 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8761 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8762 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8764 application.SendNotification();
8765 application.Render(1100); // After the animation
8767 // Size and current size should be updated.
8768 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8769 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8771 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8772 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8777 application.SendNotification();
8778 application.Render();
8780 // Size and current size should be same.
8781 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8782 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8784 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8785 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8793 Actor parentA = Actor::New();
8794 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8795 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8796 application.GetScene().Add(parentA);
8798 Actor parentB = Actor::New();
8799 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8800 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8801 application.GetScene().Add(parentB);
8803 Actor actor = Actor::New();
8804 actor.SetProperty(Actor::Property::SIZE, actorSize);
8805 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8808 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8809 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8811 application.SendNotification();
8812 application.Render();
8814 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8815 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8817 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8818 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8820 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8822 // Make an animation
8823 Animation animation = Animation::New(1.0f);
8824 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8827 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8828 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8830 application.SendNotification();
8831 application.Render(1100); // After the animation
8833 // Size and current size should be updated.
8834 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8835 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8837 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8838 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8843 application.SendNotification();
8844 application.Render();
8846 // Size and current size should be same.
8847 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8848 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8850 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8851 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8861 int utcDaliActorPartialUpdate(void)
8863 TestApplication application(
8864 TestApplication::DEFAULT_SURFACE_WIDTH,
8865 TestApplication::DEFAULT_SURFACE_HEIGHT,
8866 TestApplication::DEFAULT_HORIZONTAL_DPI,
8867 TestApplication::DEFAULT_VERTICAL_DPI,
8871 tet_infoline("Check the damaged area");
8873 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8875 std::vector<Rect<int>> damagedRects;
8876 Rect<int> clippingRect;
8877 application.SendNotification();
8878 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8880 // First render pass, nothing to render, adaptor would just do swap buffer.
8881 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8883 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8884 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8886 Actor actor = CreateRenderableActor();
8887 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8888 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8889 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8890 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8891 application.GetScene().Add(actor);
8893 application.SendNotification();
8895 // 1. Actor added, damaged rect is added size of actor
8896 damagedRects.clear();
8897 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8898 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8901 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8902 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8903 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8904 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8905 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8906 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8907 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8910 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8911 application.SendNotification();
8913 damagedRects.clear();
8914 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8915 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8918 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
8919 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8920 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8921 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8922 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8923 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8924 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8926 // 3. Set new position
8927 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8928 application.SendNotification();
8930 damagedRects.clear();
8931 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8932 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8935 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
8936 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8937 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8938 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8939 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8940 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8941 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8943 application.GetScene().Remove(actor);
8944 application.SendNotification();
8946 // Actor removed, last a dirty rect is reported.
8947 damagedRects.clear();
8948 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8949 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8951 clippingRect = damagedRects[0];
8953 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8954 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
8956 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8957 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8958 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8959 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8960 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8965 int utcDaliActorPartialUpdateSetColor(void)
8967 TestApplication application(
8968 TestApplication::DEFAULT_SURFACE_WIDTH,
8969 TestApplication::DEFAULT_SURFACE_HEIGHT,
8970 TestApplication::DEFAULT_HORIZONTAL_DPI,
8971 TestApplication::DEFAULT_VERTICAL_DPI,
8975 tet_infoline("Check uniform update");
8977 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8979 std::vector<Rect<int>> damagedRects;
8980 Rect<int> clippingRect;
8981 application.SendNotification();
8982 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8984 // First render pass, nothing to render, adaptor would just do swap buffer.
8985 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8987 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8988 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8990 Actor actor = CreateRenderableActor();
8991 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8992 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8993 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8994 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8995 application.GetScene().Add(actor);
8997 application.SendNotification();
8999 // 1. Actor added, damaged rect is added size of actor
9000 damagedRects.clear();
9001 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9002 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9005 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9006 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9007 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9008 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9009 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9010 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9011 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9013 damagedRects.clear();
9014 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9015 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9017 damagedRects.clear();
9018 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9019 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9022 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
9023 application.SendNotification();
9025 damagedRects.clear();
9026 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9027 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9030 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9031 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9032 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9033 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9034 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9035 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9036 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9041 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
9042 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
9043 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
9044 const char* const RENDER_SHADOW_VERTEX_SOURCE =
9045 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
9046 " uniform mediump mat4 uLightCameraViewMatrix;\n"
9050 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
9051 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
9052 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
9055 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
9056 "uniform lowp vec4 uShadowColor;\n"
9059 " lowp float alpha;\n"
9060 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
9061 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
9064 int utcDaliActorPartialUpdateSetProperty(void)
9066 TestApplication application(
9067 TestApplication::DEFAULT_SURFACE_WIDTH,
9068 TestApplication::DEFAULT_SURFACE_HEIGHT,
9069 TestApplication::DEFAULT_HORIZONTAL_DPI,
9070 TestApplication::DEFAULT_VERTICAL_DPI,
9074 tet_infoline("Set/Update property with partial update");
9076 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9078 std::vector<Rect<int>> damagedRects;
9079 Rect<int> clippingRect;
9080 application.SendNotification();
9081 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9083 // First render pass, nothing to render, adaptor would just do swap buffer.
9084 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9086 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9087 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9089 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
9090 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
9091 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9092 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9093 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9094 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9095 application.GetScene().Add(actor);
9097 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
9099 damagedRects.clear();
9100 application.SendNotification();
9101 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9102 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9105 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9106 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9107 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9108 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9109 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9110 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9111 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9113 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
9114 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
9116 damagedRects.clear();
9117 application.SendNotification();
9118 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9119 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9121 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9122 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9123 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9124 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9125 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9126 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9128 // Should be no damage rects, nothing changed
9129 damagedRects.clear();
9130 application.SendNotification();
9131 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9132 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9134 // Should be 1 damage rect due to change in size
9135 damagedRects.clear();
9136 actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
9137 application.SendNotification();
9138 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9139 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9141 clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
9142 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9143 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9144 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9145 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9146 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9147 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9149 damagedRects.clear();
9150 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9151 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9156 int utcDaliActorPartialUpdateTwoActors(void)
9158 TestApplication application(
9159 TestApplication::DEFAULT_SURFACE_WIDTH,
9160 TestApplication::DEFAULT_SURFACE_HEIGHT,
9161 TestApplication::DEFAULT_HORIZONTAL_DPI,
9162 TestApplication::DEFAULT_VERTICAL_DPI,
9166 tet_infoline("Check the damaged rects with partial update and two actors");
9168 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9170 Actor actor = CreateRenderableActor();
9171 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
9172 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
9173 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9174 application.GetScene().Add(actor);
9176 Actor actor2 = CreateRenderableActor();
9177 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
9178 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
9179 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9180 application.GetScene().Add(actor2);
9182 application.SendNotification();
9183 std::vector<Rect<int>> damagedRects;
9184 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9186 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9187 DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64), Rect<int>(96, 592, 112, 112)}, true, TEST_LOCATION);
9189 // in screen coordinates, adaptor would calculate it using previous frames information
9190 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
9191 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9193 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9194 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9195 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9196 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9198 // Change a Renderer of actor1
9199 Geometry geometry = CreateQuadGeometry();
9200 Shader shader = CreateShader();
9201 Renderer newRenderer = Renderer::New(geometry, shader);
9202 Renderer renderer = actor.GetRendererAt(0);
9204 actor.RemoveRenderer(renderer);
9205 actor.AddRenderer(newRenderer);
9207 damagedRects.clear();
9209 application.SendNotification();
9210 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9212 DALI_TEST_CHECK(damagedRects.size() > 0);
9213 DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64)}, false, TEST_LOCATION);
9215 // in screen coordinates, adaptor would calculate it using previous frames information
9216 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9218 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9219 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9220 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9221 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9226 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
9228 TestApplication application(
9229 TestApplication::DEFAULT_SURFACE_WIDTH,
9230 TestApplication::DEFAULT_SURFACE_HEIGHT,
9231 TestApplication::DEFAULT_HORIZONTAL_DPI,
9232 TestApplication::DEFAULT_VERTICAL_DPI,
9236 tet_infoline("Check the damaged rect with partial update and update area hint");
9238 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9240 Actor actor = CreateRenderableActor();
9241 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9242 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9243 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9244 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9245 application.GetScene().Add(actor);
9247 application.SendNotification();
9248 std::vector<Rect<int>> damagedRects;
9249 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9251 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9253 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9254 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9256 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9258 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9259 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9260 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9261 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9266 damagedRects.clear();
9267 application.SendNotification();
9268 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9270 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9271 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9273 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9275 damagedRects.clear();
9276 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9277 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9279 // Ensure the damaged rect is empty
9280 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9282 // Chnage UPDATE_AREA_HINT
9283 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
9284 application.GetScene().Add(actor);
9286 application.SendNotification();
9287 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9289 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9291 clippingRect = Rect<int>(64, 704, 48, 48);
9292 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9294 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9296 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9297 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9298 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9299 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9304 damagedRects.clear();
9305 application.SendNotification();
9306 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9308 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9309 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9311 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9313 damagedRects.clear();
9314 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9315 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9317 // Ensure the damaged rect is empty
9318 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9320 // Chnage UPDATE_AREA_HINT
9321 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
9322 application.GetScene().Add(actor);
9324 application.SendNotification();
9325 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9327 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9329 clippingRect = Rect<int>(0, 720, 80, 80);
9330 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9332 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9334 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9335 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9336 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9337 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9342 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
9344 TestApplication application(
9345 TestApplication::DEFAULT_SURFACE_WIDTH,
9346 TestApplication::DEFAULT_SURFACE_HEIGHT,
9347 TestApplication::DEFAULT_HORIZONTAL_DPI,
9348 TestApplication::DEFAULT_VERTICAL_DPI,
9352 tet_infoline("Check the damaged rect with partial update and update area hint");
9354 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9356 Actor actor = CreateRenderableActor();
9357 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9358 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9359 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9360 application.GetScene().Add(actor);
9362 application.SendNotification();
9363 std::vector<Rect<int>> damagedRects;
9364 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9366 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9368 Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
9369 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9371 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9373 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9374 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9375 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9376 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9378 damagedRects.clear();
9379 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9380 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9382 // Ensure the damaged rect is empty
9383 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9385 // Change UPDATE_AREA_HINT
9386 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9388 application.SendNotification();
9389 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9391 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9393 clippingRect = Rect<int>(32, 704, 80, 80);
9394 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9396 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9398 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9399 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9400 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9401 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9403 damagedRects.clear();
9404 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9405 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9407 // Ensure the damaged rect is empty
9408 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9410 // Chnage UPDATE_AREA_HINT
9411 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
9412 application.GetScene().Add(actor);
9414 application.SendNotification();
9415 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9417 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9419 clippingRect = Rect<int>(32, 688, 96, 96);
9420 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9422 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9424 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9425 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9426 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9427 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9432 int utcDaliActorPartialUpdateActorsWithSizeHint03(void)
9434 TestApplication application(
9435 TestApplication::DEFAULT_SURFACE_WIDTH,
9436 TestApplication::DEFAULT_SURFACE_HEIGHT,
9437 TestApplication::DEFAULT_HORIZONTAL_DPI,
9438 TestApplication::DEFAULT_VERTICAL_DPI,
9442 tet_infoline("Check the damaged rect with partial update and update area hint");
9444 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9446 Actor actor = CreateRenderableActor();
9447 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9448 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9449 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9450 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9451 application.GetScene().Add(actor);
9453 application.SendNotification();
9454 std::vector<Rect<int>> damagedRects;
9455 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9457 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9459 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9460 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9462 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9464 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9465 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9466 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9467 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9469 damagedRects.clear();
9470 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9471 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9473 // Ensure the damaged rect is empty
9474 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9476 // Set UPDATE_AREA_HINT twice before rendering
9477 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 32.0f, 32.0f));
9478 application.SendNotification();
9480 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(32.0f, -32.0f, 32.0f, 32.0f));
9481 application.SendNotification();
9483 damagedRects.clear();
9484 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9486 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9488 clippingRect = Rect<int>(32, 704, 96, 96);
9489 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9491 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9493 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9494 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9495 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9496 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9501 int utcDaliActorPartialUpdateAnimation(void)
9503 TestApplication application(
9504 TestApplication::DEFAULT_SURFACE_WIDTH,
9505 TestApplication::DEFAULT_SURFACE_HEIGHT,
9506 TestApplication::DEFAULT_HORIZONTAL_DPI,
9507 TestApplication::DEFAULT_VERTICAL_DPI,
9511 tet_infoline("Check the damaged area with partial update and animation");
9513 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9514 drawTrace.Enable(true);
9517 Actor actor1 = CreateRenderableActor();
9518 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9519 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9520 application.GetScene().Add(actor1);
9522 Actor actor2 = CreateRenderableActor();
9523 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9524 actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9525 application.GetScene().Add(actor2);
9527 std::vector<Rect<int>> damagedRects;
9528 Rect<int> clippingRect;
9529 Rect<int> expectedRect1, expectedRect2;
9531 application.SendNotification();
9532 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9534 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9537 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates
9538 expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
9539 DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION);
9541 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9542 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9544 // Make an animation
9545 Animation animation = Animation::New(1.0f);
9546 animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
9549 application.SendNotification();
9551 damagedRects.clear();
9552 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9553 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9554 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9557 damagedRects.clear();
9559 // In animation deley time
9560 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9561 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9562 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9565 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9568 damagedRects.clear();
9570 // Also in animation deley time
9571 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9572 application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
9573 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9576 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9578 // Unparent 2 actors and make a new actor
9582 Actor actor3 = CreateRenderableActor();
9583 actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9584 actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9585 application.GetScene().Add(actor3);
9587 application.SendNotification();
9589 // Started animation
9590 damagedRects.clear();
9591 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9592 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
9594 // One of dirty rect is actor3's.
9595 // We don't know the exact dirty rect of actor1 and actor2.
9596 DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION);
9598 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9599 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9601 // Finished animation, but the actor was already unparented
9602 damagedRects.clear();
9603 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9605 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9607 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9608 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9613 int utcDaliActorPartialUpdateChangeVisibility(void)
9615 TestApplication application(
9616 TestApplication::DEFAULT_SURFACE_WIDTH,
9617 TestApplication::DEFAULT_SURFACE_HEIGHT,
9618 TestApplication::DEFAULT_HORIZONTAL_DPI,
9619 TestApplication::DEFAULT_VERTICAL_DPI,
9623 tet_infoline("Check the damaged rect with partial update and visibility change");
9625 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9627 Actor actor = CreateRenderableActor();
9628 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9629 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9630 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9631 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9632 application.GetScene().Add(actor);
9634 application.SendNotification();
9636 std::vector<Rect<int>> damagedRects;
9637 Rect<int> clippingRect;
9639 // 1. Actor added, damaged rect is added size of actor
9640 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9641 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9644 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9645 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9646 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9647 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9648 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9649 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9650 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9652 damagedRects.clear();
9653 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9654 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9656 // Ensure the damaged rect is empty
9657 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9659 // 2. Make the Actor invisible
9660 actor.SetProperty(Actor::Property::VISIBLE, false);
9661 application.SendNotification();
9663 damagedRects.clear();
9664 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9665 DALI_TEST_CHECK(damagedRects.size() > 0);
9666 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9668 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9669 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9670 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9671 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9672 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9674 // 3. Make the Actor visible again
9675 actor.SetProperty(Actor::Property::VISIBLE, true);
9676 application.SendNotification();
9678 damagedRects.clear();
9679 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9680 DALI_TEST_CHECK(damagedRects.size() > 0);
9681 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9683 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9684 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9685 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9686 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9687 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9692 int utcDaliActorPartialUpdateOnOffScene(void)
9694 TestApplication application(
9695 TestApplication::DEFAULT_SURFACE_WIDTH,
9696 TestApplication::DEFAULT_SURFACE_HEIGHT,
9697 TestApplication::DEFAULT_HORIZONTAL_DPI,
9698 TestApplication::DEFAULT_VERTICAL_DPI,
9702 tet_infoline("Check the damaged rect with partial update and on/off scene");
9704 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9706 Actor actor = CreateRenderableActor();
9707 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9708 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9709 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9710 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9711 application.GetScene().Add(actor);
9713 application.SendNotification();
9715 std::vector<Rect<int>> damagedRects;
9716 Rect<int> clippingRect;
9718 // 1. Actor added, damaged rect is added size of actor
9719 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9720 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9723 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9724 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9725 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9726 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9727 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9728 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9729 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9731 damagedRects.clear();
9732 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9733 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9735 damagedRects.clear();
9736 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9737 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9739 // Ensure the damaged rect is empty
9740 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9742 // 2. Remove the Actor from the Scene
9744 application.SendNotification();
9746 damagedRects.clear();
9747 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9748 DALI_TEST_CHECK(damagedRects.size() > 0);
9749 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9751 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9752 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9753 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9754 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9755 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9757 // 3. Add the Actor to the Scene again
9758 application.GetScene().Add(actor);
9759 application.SendNotification();
9761 damagedRects.clear();
9762 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9763 DALI_TEST_CHECK(damagedRects.size() > 0);
9764 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9766 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9767 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9768 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9769 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9770 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9775 int utcDaliActorPartialUpdateSkipRendering(void)
9777 TestApplication application(
9778 TestApplication::DEFAULT_SURFACE_WIDTH,
9779 TestApplication::DEFAULT_SURFACE_HEIGHT,
9780 TestApplication::DEFAULT_HORIZONTAL_DPI,
9781 TestApplication::DEFAULT_VERTICAL_DPI,
9785 tet_infoline("Check to skip rendering in case of the empty damaged rect");
9787 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9788 drawTrace.Enable(true);
9791 Actor actor1 = CreateRenderableActor();
9792 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9793 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9794 application.GetScene().Add(actor1);
9796 std::vector<Rect<int>> damagedRects;
9797 Rect<int> clippingRect;
9798 Rect<int> expectedRect1;
9800 application.SendNotification();
9801 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9803 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9806 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates
9807 DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9809 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9810 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9812 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9814 damagedRects.clear();
9815 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9816 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9817 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9822 application.SendNotification();
9824 damagedRects.clear();
9825 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9827 DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9829 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9830 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9832 // Render again without any change
9833 damagedRects.clear();
9835 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9837 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9839 clippingRect = Rect<int>();
9840 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9843 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9845 // Add the actor again
9846 application.GetScene().Add(actor1);
9848 application.SendNotification();
9850 damagedRects.clear();
9852 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9854 DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9856 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9857 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9859 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9864 int utcDaliActorPartialUpdate3DNode(void)
9866 TestApplication application(
9867 TestApplication::DEFAULT_SURFACE_WIDTH,
9868 TestApplication::DEFAULT_SURFACE_HEIGHT,
9869 TestApplication::DEFAULT_HORIZONTAL_DPI,
9870 TestApplication::DEFAULT_VERTICAL_DPI,
9874 tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9876 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9877 drawTrace.Enable(true);
9880 Actor actor1 = CreateRenderableActor();
9881 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9882 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9883 application.GetScene().Add(actor1);
9885 std::vector<Rect<int>> damagedRects;
9886 Rect<int> clippingRect;
9888 application.SendNotification();
9889 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9891 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9893 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9894 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9896 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9898 // Change the layer to 3D
9899 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9901 application.SendNotification();
9903 damagedRects.clear();
9904 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9906 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9907 DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9909 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9911 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9913 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9915 // Change the layer to 2D
9916 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9918 application.SendNotification();
9920 damagedRects.clear();
9921 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9923 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9925 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9926 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9928 // Make 3D transform
9929 actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9931 application.SendNotification();
9933 damagedRects.clear();
9934 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9936 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9937 DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9939 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9941 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9943 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9948 int utcDaliActorPartialUpdateNotRenderableActor(void)
9950 TestApplication application(
9951 TestApplication::DEFAULT_SURFACE_WIDTH,
9952 TestApplication::DEFAULT_SURFACE_HEIGHT,
9953 TestApplication::DEFAULT_HORIZONTAL_DPI,
9954 TestApplication::DEFAULT_VERTICAL_DPI,
9958 tet_infoline("Check the damaged rect with not renderable parent actor");
9960 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9962 Actor parent = Actor::New();
9963 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9964 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9965 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9966 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9967 application.GetScene().Add(parent);
9969 Actor child = CreateRenderableActor();
9970 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9971 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9972 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9975 application.SendNotification();
9977 std::vector<Rect<int>> damagedRects;
9979 // 1. Actor added, damaged rect is added size of actor
9980 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9981 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9984 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9985 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9987 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9988 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9989 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9990 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9991 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9993 damagedRects.clear();
9994 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9995 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9997 damagedRects.clear();
9998 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9999 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10001 // Ensure the damaged rect is empty
10002 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10007 int utcDaliActorPartialUpdateChangeTransparency(void)
10009 TestApplication application(
10010 TestApplication::DEFAULT_SURFACE_WIDTH,
10011 TestApplication::DEFAULT_SURFACE_HEIGHT,
10012 TestApplication::DEFAULT_HORIZONTAL_DPI,
10013 TestApplication::DEFAULT_VERTICAL_DPI,
10017 tet_infoline("Check the damaged rect with changing transparency");
10019 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10021 Actor actor = CreateRenderableActor();
10022 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10023 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10024 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10025 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10026 application.GetScene().Add(actor);
10028 application.SendNotification();
10030 std::vector<Rect<int>> damagedRects;
10032 // Actor added, damaged rect is added size of actor
10033 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10034 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10037 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10038 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10040 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10041 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10042 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10043 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10044 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10046 damagedRects.clear();
10047 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10048 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10050 // Ensure the damaged rect is empty
10051 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10053 // Make the actor transparent by changing opacity of the Renderer
10054 // It changes a uniform value
10055 Renderer renderer = actor.GetRendererAt(0);
10056 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
10058 application.SendNotification();
10060 // The damaged rect should be same
10061 damagedRects.clear();
10062 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10063 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10064 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10065 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10067 damagedRects.clear();
10068 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10069 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10071 // Ensure the damaged rect is empty
10072 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10074 // Make the actor opaque again
10075 renderer[DevelRenderer::Property::OPACITY] = 1.0f;
10077 application.SendNotification();
10079 // The damaged rect should not be empty
10080 damagedRects.clear();
10081 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10082 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10083 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10084 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10086 damagedRects.clear();
10087 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10088 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10090 // Ensure the damaged rect is empty
10091 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10093 // Make the actor translucent
10094 renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10096 application.SendNotification();
10098 // The damaged rect should not be empty
10099 damagedRects.clear();
10100 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10101 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10102 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10103 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10105 damagedRects.clear();
10106 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10107 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10109 // Ensure the damaged rect is empty
10110 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10112 // Change Renderer opacity - also translucent
10113 renderer[DevelRenderer::Property::OPACITY] = 0.2f;
10115 application.SendNotification();
10117 // The damaged rect should not be empty
10118 damagedRects.clear();
10119 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10120 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10121 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10122 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10124 damagedRects.clear();
10125 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10126 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10128 // Ensure the damaged rect is empty
10129 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10131 // Make the actor culled
10132 actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
10134 application.SendNotification();
10136 // The damaged rect should be same
10137 damagedRects.clear();
10138 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10139 DALI_TEST_CHECK(damagedRects.size() > 0);
10140 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10141 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10143 damagedRects.clear();
10144 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10145 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10147 // Ensure the damaged rect is empty
10148 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10150 // Make the actor not culled again
10151 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
10153 application.SendNotification();
10155 // The damaged rect should not be empty
10156 damagedRects.clear();
10157 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10158 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10159 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10160 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10165 int utcDaliActorPartialUpdateChangeParentOpacity(void)
10167 TestApplication application(
10168 TestApplication::DEFAULT_SURFACE_WIDTH,
10169 TestApplication::DEFAULT_SURFACE_HEIGHT,
10170 TestApplication::DEFAULT_HORIZONTAL_DPI,
10171 TestApplication::DEFAULT_VERTICAL_DPI,
10175 tet_infoline("Check the damaged rect with changing parent's opacity");
10177 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10179 Actor parent = Actor::New();
10180 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10181 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10182 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10183 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10184 application.GetScene().Add(parent);
10186 Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
10187 Actor child = CreateRenderableActor(texture);
10188 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10189 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10190 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10193 application.SendNotification();
10195 std::vector<Rect<int>> damagedRects;
10197 // Actor added, damaged rect is added size of actor
10198 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10199 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10202 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10203 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10205 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10206 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10207 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10208 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10209 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10211 damagedRects.clear();
10212 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10213 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10215 damagedRects.clear();
10216 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10217 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10219 // Ensure the damaged rect is empty
10220 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10222 // Change the parent's opacity
10223 parent[Actor::Property::OPACITY] = 0.5f;
10225 application.SendNotification();
10227 // The damaged rect should be same
10228 damagedRects.clear();
10229 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10230 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10231 DALI_TEST_CHECK(damagedRects.size() > 0);
10232 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10237 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
10239 TestApplication application(
10240 TestApplication::DEFAULT_SURFACE_WIDTH,
10241 TestApplication::DEFAULT_SURFACE_HEIGHT,
10242 TestApplication::DEFAULT_HORIZONTAL_DPI,
10243 TestApplication::DEFAULT_VERTICAL_DPI,
10247 tet_infoline("Check the damaged rect with adding / removing renderer");
10249 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10251 Actor actor = CreateRenderableActor();
10252 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10253 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10254 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10255 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10256 application.GetScene().Add(actor);
10258 application.SendNotification();
10260 std::vector<Rect<int>> damagedRects;
10262 // Actor added, damaged rect is added size of actor
10263 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10264 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10267 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10268 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10270 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10271 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10272 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10273 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10274 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10276 damagedRects.clear();
10277 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10278 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10280 damagedRects.clear();
10281 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10282 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10284 // Remove the Renderer
10285 Renderer renderer = actor.GetRendererAt(0);
10286 actor.RemoveRenderer(renderer);
10288 application.SendNotification();
10290 // The damaged rect should be the actor area
10291 damagedRects.clear();
10292 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10293 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10294 DALI_TEST_CHECK(damagedRects.size() > 0);
10295 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10297 damagedRects.clear();
10298 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10299 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10301 // Ensure the damaged rect is empty
10302 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10304 // Add the Renderer again
10305 actor.AddRenderer(renderer);
10307 application.SendNotification();
10309 // The damaged rect should be the actor area
10310 damagedRects.clear();
10311 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10312 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10313 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10314 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10319 int utcDaliActorPartialUpdate3DTransform(void)
10321 TestApplication application(
10322 TestApplication::DEFAULT_SURFACE_WIDTH,
10323 TestApplication::DEFAULT_SURFACE_HEIGHT,
10324 TestApplication::DEFAULT_HORIZONTAL_DPI,
10325 TestApplication::DEFAULT_VERTICAL_DPI,
10329 tet_infoline("Check the damaged rect with 3D transformed actors");
10331 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10333 Actor actor1 = CreateRenderableActor();
10334 actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10335 actor1[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10336 actor1[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10337 actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10338 application.GetScene().Add(actor1);
10341 Actor actor2 = CreateRenderableActor();
10342 actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10343 actor2[Actor::Property::POSITION] = Vector3(160.0f, 160.0f, 0.0f);
10344 actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10345 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10346 application.GetScene().Add(actor2);
10348 application.SendNotification();
10350 std::vector<Rect<int>> damagedRects;
10352 // Actor added, damaged rect is added size of actor
10353 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10354 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10357 Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
10358 Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
10359 DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION);
10361 Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10362 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10364 damagedRects.clear();
10365 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10366 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10367 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10369 damagedRects.clear();
10370 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10371 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10372 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10374 // Rotate actor1 on y axis
10375 actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10380 application.SendNotification();
10382 damagedRects.clear();
10383 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10385 // Should update full area
10386 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10387 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10388 DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10389 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10391 // Add actor2 again
10392 application.GetScene().Add(actor2);
10394 application.SendNotification();
10396 damagedRects.clear();
10397 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10399 // Should update full area
10400 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10401 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10402 DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10403 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10405 // Reset the orientation of actor1
10406 actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
10408 application.SendNotification();
10410 damagedRects.clear();
10411 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10413 // Should update full area
10414 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10415 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10416 DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10417 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10419 // Make actor2 dirty
10420 actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
10422 application.SendNotification();
10424 damagedRects.clear();
10425 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10427 clippingRect2 = Rect<int>(160, 608, 48, 48);
10428 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10429 DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION);
10431 application.RenderWithPartialUpdate(damagedRects, clippingRect2);
10432 DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
10433 DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
10434 DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
10435 DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
10440 application.SendNotification();
10442 damagedRects.clear();
10443 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10444 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10445 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10447 // Rotate actor1 on y axis
10448 actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10450 // Add actor1 again
10451 application.GetScene().Add(actor1);
10453 application.SendNotification();
10455 damagedRects.clear();
10456 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10458 // Should update full area
10459 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10460 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10461 DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10462 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10467 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
10469 TestApplication application(
10470 TestApplication::DEFAULT_SURFACE_WIDTH,
10471 TestApplication::DEFAULT_SURFACE_HEIGHT,
10472 TestApplication::DEFAULT_HORIZONTAL_DPI,
10473 TestApplication::DEFAULT_VERTICAL_DPI,
10477 tet_infoline("Check the damaged rect with one actor which has multiple renderers");
10479 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10481 Actor actor = CreateRenderableActor();
10483 // Create another renderer
10484 Geometry geometry = CreateQuadGeometry();
10485 Shader shader = CreateShader();
10486 Renderer renderer2 = Renderer::New(geometry, shader);
10487 actor.AddRenderer(renderer2);
10489 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10490 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10491 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10492 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10493 application.GetScene().Add(actor);
10495 application.SendNotification();
10497 DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
10499 std::vector<Rect<int>> damagedRects;
10501 // Actor added, damaged rect is added size of actor
10502 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10503 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10506 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10507 DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10509 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10510 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10511 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10512 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10513 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10515 damagedRects.clear();
10516 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10517 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10519 // Ensure the damaged rect is empty
10520 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10522 // Make renderer2 dirty
10523 renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
10525 application.SendNotification();
10527 // The damaged rect should be the actor area
10528 damagedRects.clear();
10529 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10531 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10532 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10533 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10535 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10537 damagedRects.clear();
10538 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10539 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10541 // Ensure the damaged rect is empty
10542 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10544 // Make renderer2 dirty
10545 renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
10547 application.SendNotification();
10549 // The damaged rect should be the actor area
10550 damagedRects.clear();
10551 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10553 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10554 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10555 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10557 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10559 damagedRects.clear();
10560 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10561 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10563 // Ensure the damaged rect is empty
10564 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10569 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
10571 TestApplication application(
10572 TestApplication::DEFAULT_SURFACE_WIDTH,
10573 TestApplication::DEFAULT_SURFACE_HEIGHT,
10574 TestApplication::DEFAULT_HORIZONTAL_DPI,
10575 TestApplication::DEFAULT_VERTICAL_DPI,
10579 tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
10581 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10583 Actor actor = CreateRenderableActor();
10584 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10585 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10586 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10587 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10588 application.GetScene().Add(actor);
10590 // Create another actor which has the same renderer with actor1
10591 Actor actor2 = Actor::New();
10592 Renderer renderer = actor.GetRendererAt(0);
10593 actor2.AddRenderer(renderer);
10594 actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10595 actor2[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10596 actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10597 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10598 application.GetScene().Add(actor2);
10600 application.SendNotification();
10602 std::vector<Rect<int>> damagedRects;
10604 // Actor added, damaged rect is added size of actor
10605 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10606 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10609 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10610 DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10612 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10613 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10614 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10615 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10616 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10618 damagedRects.clear();
10619 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10620 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10622 // Ensure the damaged rect is empty
10623 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10625 // Make renderer dirty
10626 renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10628 application.SendNotification();
10630 // The damaged rect should be the actor area
10631 damagedRects.clear();
10632 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10634 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10635 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10636 DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10638 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10640 damagedRects.clear();
10641 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10642 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10644 // Ensure the damaged rect is empty
10645 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10650 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
10652 TestApplication application;
10654 Actor actor = Actor::New();
10655 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
10656 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
10657 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
10658 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
10659 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
10660 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10661 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10662 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
10666 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
10668 TestApplication application;
10670 Actor actor = Actor::New();
10672 // Make sure setting invalid types does not cause a crash
10675 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
10676 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
10677 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
10678 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
10679 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
10680 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
10681 tet_result(TET_PASS);
10685 tet_result(TET_FAIL);
10690 int UtcDaliActorTouchAreaOffsetPropertyP(void)
10692 TestApplication application;
10694 Actor actor = Actor::New();
10695 Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10696 DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
10697 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
10698 touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10699 DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
10703 int UtcDaliActorTouchAreaOffsetPropertyN(void)
10705 TestApplication application;
10707 Actor actor = Actor::New();
10709 // Make sure setting invalid types does not cause a crash
10712 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
10713 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
10714 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
10715 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
10716 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
10717 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
10718 tet_result(TET_PASS);
10722 tet_result(TET_FAIL);
10727 int UtcDaliActorLowerBelowNegative(void)
10729 TestApplication application;
10730 Dali::Actor instance;
10734 instance.LowerBelow(arg1);
10735 DALI_TEST_CHECK(false); // Should not get here
10739 DALI_TEST_CHECK(true); // We expect an assert
10744 int UtcDaliActorRaiseAboveNegative(void)
10746 TestApplication application;
10747 Dali::Actor instance;
10751 instance.RaiseAbove(arg1);
10752 DALI_TEST_CHECK(false); // Should not get here
10756 DALI_TEST_CHECK(true); // We expect an assert
10761 int UtcDaliActorRaiseToTopNegative(void)
10763 TestApplication application;
10764 Dali::Actor instance;
10767 instance.RaiseToTop();
10768 DALI_TEST_CHECK(false); // Should not get here
10772 DALI_TEST_CHECK(true); // We expect an assert
10777 int UtcDaliActorAddRendererNegative(void)
10779 TestApplication application;
10780 Dali::Actor instance;
10783 Dali::Renderer arg1;
10784 instance.AddRenderer(arg1);
10785 DALI_TEST_CHECK(false); // Should not get here
10789 DALI_TEST_CHECK(true); // We expect an assert
10794 int UtcDaliActorTouchedSignalNegative(void)
10796 TestApplication application;
10797 Dali::Actor instance;
10800 instance.TouchedSignal();
10801 DALI_TEST_CHECK(false); // Should not get here
10805 DALI_TEST_CHECK(true); // We expect an assert
10810 int UtcDaliActorTranslateByNegative(void)
10812 TestApplication application;
10813 Dali::Actor instance;
10816 Dali::Vector3 arg1;
10817 instance.TranslateBy(arg1);
10818 DALI_TEST_CHECK(false); // Should not get here
10822 DALI_TEST_CHECK(true); // We expect an assert
10827 int UtcDaliActorFindChildByIdNegative(void)
10829 TestApplication application;
10830 Dali::Actor instance;
10833 unsigned int arg1 = 0u;
10834 instance.FindChildById(arg1);
10835 DALI_TEST_CHECK(false); // Should not get here
10839 DALI_TEST_CHECK(true); // We expect an assert
10844 int UtcDaliActorGetRendererAtNegative(void)
10846 TestApplication application;
10847 Dali::Actor instance;
10850 unsigned int arg1 = 0u;
10851 instance.GetRendererAt(arg1);
10852 DALI_TEST_CHECK(false); // Should not get here
10856 DALI_TEST_CHECK(true); // We expect an assert
10861 int UtcDaliActorHoveredSignalNegative(void)
10863 TestApplication application;
10864 Dali::Actor instance;
10867 instance.HoveredSignal();
10868 DALI_TEST_CHECK(false); // Should not get here
10872 DALI_TEST_CHECK(true); // We expect an assert
10877 int UtcDaliActorLowerToBottomNegative(void)
10879 TestApplication application;
10880 Dali::Actor instance;
10883 instance.LowerToBottom();
10884 DALI_TEST_CHECK(false); // Should not get here
10888 DALI_TEST_CHECK(true); // We expect an assert
10893 int UtcDaliActorOnSceneSignalNegative(void)
10895 TestApplication application;
10896 Dali::Actor instance;
10899 instance.OnSceneSignal();
10900 DALI_TEST_CHECK(false); // Should not get here
10904 DALI_TEST_CHECK(true); // We expect an assert
10909 int UtcDaliActorOffSceneSignalNegative(void)
10911 TestApplication application;
10912 Dali::Actor instance;
10915 instance.OffSceneSignal();
10916 DALI_TEST_CHECK(false); // Should not get here
10920 DALI_TEST_CHECK(true); // We expect an assert
10925 int UtcDaliActorRemoveRendererNegative01(void)
10927 TestApplication application;
10928 Dali::Actor instance;
10931 unsigned int arg1 = 0u;
10932 instance.RemoveRenderer(arg1);
10933 DALI_TEST_CHECK(false); // Should not get here
10937 DALI_TEST_CHECK(true); // We expect an assert
10942 int UtcDaliActorRemoveRendererNegative02(void)
10944 TestApplication application;
10945 Dali::Actor instance;
10948 Dali::Renderer arg1;
10949 instance.RemoveRenderer(arg1);
10950 DALI_TEST_CHECK(false); // Should not get here
10954 DALI_TEST_CHECK(true); // We expect an assert
10959 int UtcDaliActorFindChildByNameNegative(void)
10961 TestApplication application;
10962 Dali::Actor instance;
10966 instance.FindChildByName(arg1);
10967 DALI_TEST_CHECK(false); // Should not get here
10971 DALI_TEST_CHECK(true); // We expect an assert
10976 int UtcDaliActorSetResizePolicyNegative(void)
10978 TestApplication application;
10979 Dali::Actor instance;
10982 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
10983 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
10984 instance.SetResizePolicy(arg1, arg2);
10985 DALI_TEST_CHECK(false); // Should not get here
10989 DALI_TEST_CHECK(true); // We expect an assert
10994 int UtcDaliActorOnRelayoutSignalNegative(void)
10996 TestApplication application;
10997 Dali::Actor instance;
11000 instance.OnRelayoutSignal();
11001 DALI_TEST_CHECK(false); // Should not get here
11005 DALI_TEST_CHECK(true); // We expect an assert
11010 int UtcDaliActorWheelEventSignalNegative(void)
11012 TestApplication application;
11013 Dali::Actor instance;
11016 instance.WheelEventSignal();
11017 DALI_TEST_CHECK(false); // Should not get here
11021 DALI_TEST_CHECK(true); // We expect an assert
11026 int UtcDaliActorGetHeightForWidthNegative(void)
11028 TestApplication application;
11029 Dali::Actor instance;
11033 instance.GetHeightForWidth(arg1);
11034 DALI_TEST_CHECK(false); // Should not get here
11038 DALI_TEST_CHECK(true); // We expect an assert
11043 int UtcDaliActorGetWidthForHeightNegative(void)
11045 TestApplication application;
11046 Dali::Actor instance;
11050 instance.GetWidthForHeight(arg1);
11051 DALI_TEST_CHECK(false); // Should not get here
11055 DALI_TEST_CHECK(true); // We expect an assert
11060 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
11062 TestApplication application;
11063 Dali::Actor instance;
11066 instance.LayoutDirectionChangedSignal();
11067 DALI_TEST_CHECK(false); // Should not get here
11071 DALI_TEST_CHECK(true); // We expect an assert
11076 int UtcDaliActorAddNegative(void)
11078 TestApplication application;
11079 Dali::Actor instance;
11083 instance.Add(arg1);
11084 DALI_TEST_CHECK(false); // Should not get here
11088 DALI_TEST_CHECK(true); // We expect an assert
11093 int UtcDaliActorLowerNegative(void)
11095 TestApplication application;
11096 Dali::Actor instance;
11100 DALI_TEST_CHECK(false); // Should not get here
11104 DALI_TEST_CHECK(true); // We expect an assert
11109 int UtcDaliActorRaiseNegative(void)
11111 TestApplication application;
11112 Dali::Actor instance;
11116 DALI_TEST_CHECK(false); // Should not get here
11120 DALI_TEST_CHECK(true); // We expect an assert
11125 int UtcDaliActorRemoveNegative(void)
11127 TestApplication application;
11128 Dali::Actor instance;
11132 instance.Remove(arg1);
11133 DALI_TEST_CHECK(false); // Should not get here
11137 DALI_TEST_CHECK(true); // We expect an assert
11142 int UtcDaliActorScaleByNegative(void)
11144 TestApplication application;
11145 Dali::Actor instance;
11148 Dali::Vector3 arg1;
11149 instance.ScaleBy(arg1);
11150 DALI_TEST_CHECK(false); // Should not get here
11154 DALI_TEST_CHECK(true); // We expect an assert
11159 int UtcDaliActorGetLayerNegative(void)
11161 TestApplication application;
11162 Dali::Actor instance;
11165 instance.GetLayer();
11166 DALI_TEST_CHECK(false); // Should not get here
11170 DALI_TEST_CHECK(true); // We expect an assert
11175 int UtcDaliActorRotateByNegative01(void)
11177 TestApplication application;
11178 Dali::Actor instance;
11181 Dali::Quaternion arg1;
11182 instance.RotateBy(arg1);
11183 DALI_TEST_CHECK(false); // Should not get here
11187 DALI_TEST_CHECK(true); // We expect an assert
11192 int UtcDaliActorRotateByNegative02(void)
11194 TestApplication application;
11195 Dali::Actor instance;
11199 Dali::Vector3 arg2;
11200 instance.RotateBy(arg1, arg2);
11201 DALI_TEST_CHECK(false); // Should not get here
11205 DALI_TEST_CHECK(true); // We expect an assert
11210 int UtcDaliActorUnparentNegative(void)
11212 TestApplication application;
11213 Dali::Actor instance;
11216 instance.Unparent();
11217 DALI_TEST_CHECK(false); // Should not get here
11221 DALI_TEST_CHECK(true); // We expect an assert
11226 int UtcDaliActorGetChildAtNegative(void)
11228 TestApplication application;
11229 Dali::Actor instance;
11232 unsigned int arg1 = 0u;
11233 instance.GetChildAt(arg1);
11234 DALI_TEST_CHECK(false); // Should not get here
11238 DALI_TEST_CHECK(true); // We expect an assert
11243 int UtcDaliActorGetChildCountNegative(void)
11245 TestApplication application;
11246 Dali::Actor instance;
11249 instance.GetChildCount();
11250 DALI_TEST_CHECK(false); // Should not get here
11254 DALI_TEST_CHECK(true); // We expect an assert
11259 int UtcDaliActorGetTargetSizeNegative(void)
11261 TestApplication application;
11262 Dali::Actor instance;
11265 instance.GetTargetSize();
11266 DALI_TEST_CHECK(false); // Should not get here
11270 DALI_TEST_CHECK(true); // We expect an assert
11275 int UtcDaliActorScreenToLocalNegative(void)
11277 TestApplication application;
11278 Dali::Actor instance;
11285 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
11286 DALI_TEST_CHECK(false); // Should not get here
11290 DALI_TEST_CHECK(true); // We expect an assert
11295 int UtcDaliActorGetNaturalSizeNegative(void)
11297 TestApplication application;
11298 Dali::Actor instance;
11301 instance.GetNaturalSize();
11302 DALI_TEST_CHECK(false); // Should not get here
11306 DALI_TEST_CHECK(true); // We expect an assert
11311 int UtcDaliActorGetRelayoutSizeNegative(void)
11313 TestApplication application;
11314 Dali::Actor instance;
11317 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
11318 instance.GetRelayoutSize(arg1);
11319 DALI_TEST_CHECK(false); // Should not get here
11323 DALI_TEST_CHECK(true); // We expect an assert
11328 int UtcDaliActorGetResizePolicyNegative(void)
11330 TestApplication application;
11331 Dali::Actor instance;
11334 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
11335 instance.GetResizePolicy(arg1);
11336 DALI_TEST_CHECK(false); // Should not get here
11340 DALI_TEST_CHECK(true); // We expect an assert
11345 int UtcDaliActorGetRendererCountNegative(void)
11347 TestApplication application;
11348 Dali::Actor instance;
11351 instance.GetRendererCount();
11352 DALI_TEST_CHECK(false); // Should not get here
11356 DALI_TEST_CHECK(true); // We expect an assert
11361 int UtcDaliActorGetParentNegative(void)
11363 TestApplication application;
11364 Dali::Actor instance;
11367 instance.GetParent();
11368 DALI_TEST_CHECK(false); // Should not get here
11372 DALI_TEST_CHECK(true); // We expect an assert
11377 int UtcDaliActorPropertyBlendEquation(void)
11379 TestApplication application;
11381 tet_infoline("Test SetProperty AdvancedBlendEquation");
11383 Geometry geometry = CreateQuadGeometry();
11384 Shader shader = CreateShader();
11385 Renderer renderer1 = Renderer::New(geometry, shader);
11387 Actor actor = Actor::New();
11388 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
11390 actor.AddRenderer(renderer1);
11391 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
11392 application.GetScene().Add(actor);
11394 if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11396 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11397 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11398 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
11401 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11403 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11404 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11405 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
11408 Renderer renderer2 = Renderer::New(geometry, shader);
11409 actor.AddRenderer(renderer2);
11414 int UtcDaliActorRegisterProperty(void)
11416 tet_infoline("Test property registration and uniform map update\n");
11418 TestApplication application;
11420 Geometry geometry = CreateQuadGeometry();
11421 Shader shader = CreateShader();
11422 Renderer renderer1 = Renderer::New(geometry, shader);
11423 Renderer renderer2 = Renderer::New(geometry, shader);
11425 Actor actor1 = Actor::New();
11426 actor1.AddRenderer(renderer1);
11427 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11428 actor1.RegisterProperty("uCustom", 1);
11429 application.GetScene().Add(actor1);
11431 Actor actor2 = Actor::New();
11432 actor2.AddRenderer(renderer2);
11433 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11434 application.GetScene().Add(actor2);
11436 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
11437 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
11438 glAbstraction.EnableSetUniformCallTrace(true);
11440 application.SendNotification();
11441 application.Render();
11443 std::stringstream out;
11445 std::string params;
11447 // Test uniform value of the custom property
11448 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11449 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11452 actor1[Actor::Property::VISIBLE] = false;
11454 application.SendNotification();
11455 application.Render();
11457 // Make visible again
11458 actor1[Actor::Property::VISIBLE] = true;
11459 actor1["uCustom"] = 2;
11461 glAbstraction.ResetSetUniformCallStack();
11463 application.SendNotification();
11464 application.Render();
11468 // The uniform value should not be changed
11469 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11470 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11475 int UtcDaliActorDoesWantedHitTest(void)
11480 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
11482 mTouchPoint(touchPoint),
11488 Vector2 mTouchPoint;
11492 TestApplication application;
11493 tet_infoline(" UtcDaliActorDoesWantedHitTest");
11495 // Fill a vector with different hit tests.
11496 struct HitTestData* hitTestData[] = {
11497 // scale touch point result
11498 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
11499 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
11500 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.
11501 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
11502 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.
11506 // get the root layer
11507 Actor actor = Actor::New();
11508 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11509 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11511 Actor lowerActor = Actor::New();
11512 lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11513 lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11515 // actor and lowerActor have no relationship.
11516 application.GetScene().Add(lowerActor);
11517 application.GetScene().Add(actor);
11519 ResetTouchCallbacks();
11520 gHitTestTouchCallBackCalled = false;
11522 unsigned int index = 0;
11523 while(NULL != hitTestData[index])
11525 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11526 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11528 lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11529 lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11531 // flush the queue and render once
11532 application.SendNotification();
11533 application.Render();
11535 DALI_TEST_CHECK(!gTouchCallBackCalled);
11536 DALI_TEST_CHECK(!gTouchCallBackCalled2);
11537 DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
11539 // connect to its touch signal
11540 actor.TouchedSignal().Connect(TestTouchCallback);
11541 lowerActor.TouchedSignal().Connect(TestTouchCallback2);
11543 // connect to its hit-test signal
11544 Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
11546 Dali::Integration::Point point;
11547 point.SetState(PointState::DOWN);
11548 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
11549 Dali::Integration::TouchEvent event;
11550 event.AddPoint(point);
11552 // flush the queue and render once
11553 application.SendNotification();
11554 application.Render();
11555 application.ProcessEvent(event);
11557 // check hit-test events
11558 DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
11559 // Passed all hit-tests of actor.
11560 DALI_TEST_CHECK(gTouchCallBackCalled == false);
11561 // The lowerActor was hit-tested.
11562 DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
11564 if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
11565 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
11566 hitTestData[index]->mScale.x,
11567 hitTestData[index]->mScale.y,
11568 hitTestData[index]->mScale.z,
11569 hitTestData[index]->mTouchPoint.x,
11570 hitTestData[index]->mTouchPoint.y,
11571 hitTestData[index]->mResult);
11573 ResetTouchCallbacks();
11574 gHitTestTouchCallBackCalled = false;
11580 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
11582 TestApplication application;
11584 Actor actor = Actor::New();
11585 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
11586 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
11587 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
11588 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
11589 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
11590 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11591 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11592 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
11596 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
11598 TestApplication application;
11600 Actor actor = Actor::New();
11602 // Make sure setting invalid types does not cause a crash
11605 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
11606 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
11607 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
11608 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
11609 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
11610 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
11611 tet_result(TET_PASS);
11615 tet_result(TET_FAIL);
11620 int UtcDaliActorCalculateWorldTransform01(void)
11622 TestApplication application;
11624 tet_infoline("Test that actor position inheritance produces right transform matrix");
11626 Actor rootActor = Actor::New();
11627 Actor branchActor = Actor::New();
11628 Actor leafActor = Actor::New();
11630 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11631 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11632 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11634 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11635 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11636 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11638 // Set anchor point to the same value as parent origin
11639 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11640 branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11641 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11643 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11644 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11645 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11647 application.GetScene().Add(rootActor);
11648 rootActor.Add(branchActor);
11649 branchActor.Add(leafActor);
11651 application.SendNotification();
11652 application.Render(0);
11653 application.SendNotification();
11654 application.Render(0);
11656 Matrix m = DevelActor::GetWorldTransform(leafActor);
11658 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11659 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11662 Vector3 worldScale;
11663 Quaternion worldRotation;
11664 m.GetTransformComponents(worldPos, worldRotation, worldScale);
11665 DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
11670 int UtcDaliActorCalculateWorldTransform02(void)
11672 TestApplication application;
11674 tet_infoline("Test that actor position produces right transform matrix");
11676 Actor rootActor = Actor::New();
11677 Actor branchActor = Actor::New();
11678 Actor leafActor = Actor::New();
11680 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11681 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11682 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11684 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11685 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11686 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11688 // Set anchor point to the same value as parent origin
11689 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11690 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11691 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11693 application.GetScene().Add(rootActor);
11694 rootActor.Add(branchActor);
11695 branchActor.Add(leafActor);
11697 leafActor[Actor::Property::INHERIT_POSITION] = false;
11698 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11699 leafActor[Actor::Property::INHERIT_SCALE] = false;
11701 application.SendNotification();
11702 application.Render(0);
11703 application.SendNotification();
11704 application.Render(0);
11706 Matrix m = DevelActor::GetWorldTransform(leafActor);
11708 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11709 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11714 int UtcDaliActorCalculateWorldTransform03(void)
11716 TestApplication application;
11718 tet_infoline("Test that actor position produces right transform matrix");
11720 Actor rootActor = Actor::New();
11721 Actor branchActor = Actor::New();
11722 Actor leafActor = Actor::New();
11724 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11725 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11726 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11728 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11729 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11730 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11732 // Set anchor point to the same value as parent origin
11733 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11734 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11735 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11737 application.GetScene().Add(rootActor);
11738 rootActor.Add(branchActor);
11739 branchActor.Add(leafActor);
11741 leafActor[Actor::Property::INHERIT_POSITION] = true;
11742 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11743 leafActor[Actor::Property::INHERIT_SCALE] = false;
11745 application.SendNotification();
11746 application.Render(0);
11747 application.SendNotification();
11748 application.Render(0);
11750 Matrix m = DevelActor::GetWorldTransform(leafActor);
11752 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11753 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11758 int UtcDaliActorCalculateWorldTransform04(void)
11760 TestApplication application;
11762 tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
11764 Actor rootActor = Actor::New();
11765 Actor branchActor = Actor::New();
11766 Actor leafActor = Actor::New();
11768 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11769 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11770 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11772 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11773 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11774 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11776 // Set anchor point to the same value as parent origin
11777 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11778 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11779 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11780 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11782 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11783 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11785 application.GetScene().Add(rootActor);
11786 rootActor.Add(branchActor);
11787 branchActor.Add(leafActor);
11789 application.SendNotification();
11790 application.Render(0);
11791 application.SendNotification();
11792 application.Render(0);
11794 Matrix m = DevelActor::GetWorldTransform(leafActor);
11796 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11797 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11802 int UtcDaliActorCalculateWorldTransform05(void)
11804 TestApplication application;
11806 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11808 Actor rootActor = Actor::New();
11809 Actor branchActor = Actor::New();
11810 Actor leafActor = Actor::New();
11812 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11813 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11814 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11816 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11817 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11818 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11820 // Set anchor point to the same value as parent origin
11821 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11822 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11823 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11824 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11826 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11827 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11829 leafActor[Actor::Property::INHERIT_POSITION] = false;
11830 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11832 application.GetScene().Add(rootActor);
11833 rootActor.Add(branchActor);
11834 branchActor.Add(leafActor);
11836 application.SendNotification();
11837 application.Render(0);
11838 application.SendNotification();
11839 application.Render(0);
11841 Matrix m = DevelActor::GetWorldTransform(leafActor);
11843 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11844 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11849 int UtcDaliActorCalculateWorldTransform06(void)
11851 TestApplication application;
11853 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11855 Actor rootActor = Actor::New();
11856 Actor branchActor = Actor::New();
11857 Actor leafActor = Actor::New();
11859 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11860 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11861 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11863 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11864 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11865 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11867 // Set anchor point to the same value as parent origin
11868 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11869 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11870 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11871 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11873 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
11874 branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11875 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11877 leafActor[Actor::Property::INHERIT_POSITION] = false;
11878 leafActor[Actor::Property::INHERIT_SCALE] = false;
11880 application.GetScene().Add(rootActor);
11881 rootActor.Add(branchActor);
11882 branchActor.Add(leafActor);
11884 application.SendNotification();
11885 application.Render(0);
11886 application.SendNotification();
11887 application.Render(0);
11889 Matrix m = DevelActor::GetWorldTransform(leafActor);
11891 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11892 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11897 int UtcDaliActorCalculateWorldTransform07(void)
11899 TestApplication application;
11901 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11903 Actor rootActor = Actor::New();
11904 Actor branchActor = Actor::New();
11905 Actor leafActor = Actor::New();
11907 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11908 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11909 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11911 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11912 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11913 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11915 // Set anchor point to the same value as parent origin
11916 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11917 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11918 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11920 // This should be ignored.
11921 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11922 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11924 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
11925 branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11926 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11928 leafActor[Actor::Property::INHERIT_POSITION] = false;
11929 leafActor[Actor::Property::INHERIT_SCALE] = false;
11930 leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
11932 application.GetScene().Add(rootActor);
11933 rootActor.Add(branchActor);
11934 branchActor.Add(leafActor);
11936 application.SendNotification();
11937 application.Render(0);
11938 application.SendNotification();
11939 application.Render(0);
11941 Matrix m = DevelActor::GetWorldTransform(leafActor);
11943 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11944 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11949 int UtcDaliActorCalculateWorldTransform08(void)
11951 TestApplication application;
11953 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11955 Vector3 solutions[] = {Vector3(250, 0, 0), Vector3(0, 250, 0), Vector3(650, 0, 0), Vector3(0, 250, 0), Vector3(650, 0, 0), Vector3(400, 250, 0), Vector3(200, -50, 0), Vector3(500, 200, 0)};
11963 TestCase testCases[] = {
11964 {false, false, true},
11965 {false, true, false},
11966 {true, false, false},
11967 {false, true, true},
11968 {true, false, true},
11969 {true, true, false},
11970 {false, false, false},
11971 {true, true, true},
11974 Actor rootActor = Actor::New();
11975 Actor leafActor = Actor::New();
11977 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11978 rootActor[Actor::Property::SCALE] = Vector3(1.0f, 2.0f, 1.0f);
11979 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11980 rootActor[Actor::Property::SIZE] = Vector2(200, 400);
11981 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11982 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11984 leafActor[Actor::Property::POSITION] = Vector3(0.0f, -50.0f, 0.0f);
11985 leafActor[Actor::Property::SCALE] = Vector3(1.0f, 1.0f, 1.0f);
11986 leafActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11987 leafActor[Actor::Property::SIZE] = Vector2(200, 400);
11988 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_CENTER;
11989 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_CENTER;
11990 leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
11992 application.GetScene().Add(rootActor);
11993 rootActor.Add(leafActor);
11995 for(uint32_t i = 0; i < 8; ++i)
11997 leafActor[Actor::Property::INHERIT_POSITION] = testCases[i].translation;
11998 leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
11999 leafActor[Actor::Property::INHERIT_SCALE] = testCases[i].scaling;
12001 application.SendNotification();
12002 application.Render(0);
12003 application.SendNotification();
12004 application.Render(0);
12006 Matrix m = DevelActor::GetWorldTransform(leafActor);
12007 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
12009 Vector3 worldPosition1 = Vector3(m.GetTranslation());
12010 Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
12012 DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
12013 DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
12019 int UtcDaliActorCalculateWorldColor01(void)
12021 TestApplication application;
12023 tet_infoline("Test that actor inheritance of color produces right final color");
12025 Actor rootActor = Actor::New();
12026 Actor branchActor = Actor::New();
12027 Actor leafActor = Actor::New();
12029 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
12030 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
12031 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12033 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12034 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12035 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12037 rootActor[Actor::Property::COLOR] = Color::WHITE;
12038 Vector4 testColor1(1.0f, 1.0f, 0.5f, 0.8f);
12039 branchActor[Actor::Property::COLOR] = testColor1;
12040 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12042 // Default is to inherit:
12043 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
12045 application.GetScene().Add(rootActor);
12046 rootActor.Add(branchActor);
12047 branchActor.Add(leafActor);
12049 application.SendNotification();
12050 application.Render(16);
12051 Vector4 color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
12052 DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
12054 application.SendNotification();
12055 application.Render(16);
12056 color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
12057 DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
12059 application.SendNotification();
12060 application.Render(16);
12061 color = branchActor.GetCurrentProperty<Vector4>(Actor::Property::COLOR);
12062 DALI_TEST_EQUALS(color, testColor1, TEST_LOCATION);
12064 color = DevelActor::GetWorldColor(leafActor);
12066 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12067 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12072 int UtcDaliActorCalculateWorldColor02(void)
12074 TestApplication application;
12076 tet_infoline("Test that actor uses own color");
12078 Actor rootActor = Actor::New();
12079 Actor branchActor = Actor::New();
12080 Actor leafActor = Actor::New();
12082 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
12083 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
12084 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12086 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12087 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12088 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12090 rootActor[Actor::Property::COLOR] = Color::WHITE;
12091 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12092 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12094 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
12096 application.GetScene().Add(rootActor);
12097 rootActor.Add(branchActor);
12098 branchActor.Add(leafActor);
12100 application.SendNotification();
12101 application.Render(0);
12103 Vector4 color = DevelActor::GetWorldColor(leafActor);
12105 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12106 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12107 DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
12111 int UtcDaliActorCalculateWorldColor03(void)
12113 TestApplication application;
12115 tet_infoline("Test that actor uses parent color");
12117 Actor rootActor = Actor::New();
12118 Actor branchActor = Actor::New();
12119 Actor leafActor = Actor::New();
12121 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
12122 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
12123 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12125 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12126 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12127 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12129 rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
12130 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12131 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12133 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
12135 application.GetScene().Add(rootActor);
12136 rootActor.Add(branchActor);
12137 branchActor.Add(leafActor);
12139 application.SendNotification();
12140 application.Render(0);
12142 Vector4 color = DevelActor::GetWorldColor(leafActor);
12144 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12145 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12146 DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
12150 int UtcDaliActorCalculateWorldColor04(void)
12152 TestApplication application;
12154 tet_infoline("Test that actor blends with parent color");
12156 Actor rootActor = Actor::New();
12157 Actor branchActor = Actor::New();
12158 Actor leafActor = Actor::New();
12160 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
12161 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
12162 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12164 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12165 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12166 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12168 rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
12169 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12170 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12172 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
12174 application.GetScene().Add(rootActor);
12175 rootActor.Add(branchActor);
12176 branchActor.Add(leafActor);
12178 application.SendNotification();
12179 application.Render(0);
12181 Vector4 color = DevelActor::GetWorldColor(leafActor);
12183 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12184 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
12189 int UtcDaliActorCalculateLookAt(void)
12191 TestApplication application;
12193 tet_infoline("Test that actor rotate right value of orientation");
12195 Actor actor = Actor::New();
12197 actor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
12198 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
12199 actor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
12201 application.GetScene().Add(actor);
12203 application.SendNotification();
12204 application.Render(0);
12206 Quaternion actorQuaternion;
12208 tet_printf("Test with target only\n");
12209 Dali::DevelActor::LookAt(actor, Vector3::ZERO);
12210 actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12211 DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
12213 tet_printf("Test with target + up\n");
12214 Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::ZAXIS);
12215 actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12216 DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::XAXIS) * Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_YAXIS), TEST_LOCATION);
12218 tet_printf("Test with target + up + localForward\n");
12219 Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_XAXIS);
12220 actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12221 DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(180.0f)), Vector3::XAXIS), TEST_LOCATION);
12223 tet_printf("Test with target + up + localForward + localUp\n");
12224 Dali::DevelActor::LookAt(actor, Vector3::ZERO, Vector3::NEGATIVE_YAXIS, Vector3::NEGATIVE_YAXIS, Vector3::XAXIS);
12225 actorQuaternion = actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12226 DALI_TEST_EQUALS(actorQuaternion, Quaternion(Radian(Degree(90.0f)), Vector3::NEGATIVE_ZAXIS), TEST_LOCATION);
12228 // Reset quaternion
12229 actor[Actor::Property::ORIENTATION] = Quaternion();
12231 Actor actor2 = Actor::New();
12232 actor2[Actor::Property::POSITION] = Vector3(0.0f, 50.0f, -10.0f);
12233 actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
12234 actor2[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
12237 tet_printf("Test whether lookat calculate well by using event side values only\n");
12238 Dali::DevelActor::LookAt(actor2, Vector3(100.0f, 50.0f, 1.0f));
12239 actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12240 DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);
12242 actor[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0f)), Vector3::ZAXIS);
12244 DALI_TEST_EQUALS(Dali::DevelActor::GetWorldTransform(actor2).GetTranslation3(), Vector3(50.0f, 0.0f, -10.0f), TEST_LOCATION);
12246 tet_printf("Test whether lookat calculate well inherit by parent orientation\n");
12247 Dali::DevelActor::LookAt(actor2, Vector3(50.0f, 0.0f, 1.0f), Vector3::NEGATIVE_XAXIS);
12248 actorQuaternion = actor2.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
12249 DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION);