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 UtcDaliActorRemoveRendererN(void)
4499 tet_infoline("Testing Actor::RemoveRenderer");
4500 TestApplication application;
4502 Actor actor = Actor::New();
4504 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4506 Geometry geometry = CreateQuadGeometry();
4507 Shader shader = CreateShader();
4508 Renderer renderer = Renderer::New(geometry, shader);
4510 actor.AddRenderer(renderer);
4511 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4512 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4514 actor.RemoveRenderer(10);
4515 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4516 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4521 // Clipping test helper functions:
4522 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4524 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4525 Actor actor = CreateRenderableActor(image);
4527 // Setup dimensions and position so actor is not skipped by culling.
4528 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4529 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4530 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4531 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4536 Actor CreateActorWithContent16x16()
4538 return CreateActorWithContent(16, 16);
4541 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4543 enabledDisableTrace.Reset();
4544 stencilTrace.Reset();
4545 enabledDisableTrace.Enable(true);
4546 stencilTrace.Enable(true);
4548 application.SendNotification();
4549 application.Render();
4551 enabledDisableTrace.Enable(false);
4552 stencilTrace.Enable(false);
4555 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4557 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4559 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4560 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4561 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4563 // @todo only test alpha if the framebuffer has an alpha channel
4564 //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4567 int UtcDaliActorPropertyClippingP(void)
4569 // This test checks the clippingMode property.
4570 tet_infoline("Testing Actor::Property::ClippingMode: P");
4571 TestApplication application;
4573 Actor actor = Actor::New();
4575 // Check default clippingEnabled value.
4576 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4579 bool getValueResult = getValue.Get(value);
4580 DALI_TEST_CHECK(getValueResult);
4584 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4587 // Check setting the property to the stencil mode.
4588 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4590 // Check the new value was set.
4591 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4592 getValueResult = getValue.Get(value);
4593 DALI_TEST_CHECK(getValueResult);
4597 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4600 // Check setting the property to the scissor mode.
4601 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4603 // Check the new value was set.
4604 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4605 getValueResult = getValue.Get(value);
4606 DALI_TEST_CHECK(getValueResult);
4610 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4615 int UtcDaliActorPropertyClippingN(void)
4617 // Negative test case for Clipping.
4618 tet_infoline("Testing Actor::Property::ClippingMode: N");
4619 TestApplication application;
4621 Actor actor = Actor::New();
4623 // Check default clippingEnabled value.
4624 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4627 bool getValueResult = getValue.Get(value);
4628 DALI_TEST_CHECK(getValueResult);
4632 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4635 // Check setting an invalid property value won't change the current property value.
4636 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4638 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4639 getValueResult = getValue.Get(value);
4640 DALI_TEST_CHECK(getValueResult);
4644 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4650 int UtcDaliActorPropertyClippingActor(void)
4652 // This test checks that an actor is correctly setup for clipping.
4653 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4654 TestApplication application;
4656 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4657 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4658 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4659 size_t startIndex = 0u;
4661 // Create a clipping actor.
4662 Actor actorDepth1Clip = CreateActorWithContent16x16();
4663 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4664 application.GetScene().Add(actorDepth1Clip);
4666 // Gather the call trace.
4667 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4669 // Check we are writing to the color buffer.
4670 CheckColorMask(glAbstraction, true);
4672 // Check the stencil buffer was enabled.
4673 std::ostringstream oss;
4674 oss << std::hex << GL_STENCIL_TEST;
4675 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4677 // Check the stencil buffer was cleared.
4678 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4680 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4681 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4682 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4683 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4688 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4690 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4691 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4692 TestApplication application;
4694 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4695 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4696 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4697 size_t startIndex = 0u;
4699 // Create a clipping actor.
4700 Actor actorDepth1Clip = CreateActorWithContent16x16();
4701 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4702 application.GetScene().Add(actorDepth1Clip);
4704 // Gather the call trace.
4705 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4707 // Check we are writing to the color buffer.
4708 CheckColorMask(glAbstraction, true);
4710 // Check the stencil buffer was enabled.
4711 std::ostringstream oss;
4712 oss << std::hex << GL_STENCIL_TEST;
4713 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4715 // Check the stencil buffer was cleared.
4716 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4718 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4719 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4720 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4721 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4723 // Now disable the clipping
4724 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4726 // Gather the call trace.
4727 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4729 // Check the stencil buffer was disabled.
4730 std::ostringstream stencil;
4731 stencil << std::hex << GL_STENCIL_TEST;
4732 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4734 // Ensure all values in stencil-mask are set to 1.
4736 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4741 int UtcDaliActorPropertyClippingNestedChildren(void)
4743 // This test checks that a hierarchy of actors are clipped correctly by
4744 // writing to and reading from the correct bit-planes of the stencil buffer.
4745 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4746 TestApplication application;
4747 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4748 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4749 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4751 // Create a clipping actor.
4752 Actor actorDepth1Clip = CreateActorWithContent16x16();
4753 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4754 application.GetScene().Add(actorDepth1Clip);
4756 // Create a child actor.
4757 Actor childDepth2 = CreateActorWithContent16x16();
4758 actorDepth1Clip.Add(childDepth2);
4760 // Create another clipping actor.
4761 Actor childDepth2Clip = CreateActorWithContent16x16();
4762 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4763 childDepth2.Add(childDepth2Clip);
4765 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4766 // This tests the sort algorithm.
4767 Actor childDepth3 = CreateActorWithContent16x16();
4768 childDepth2Clip.Add(childDepth3);
4769 Actor childDepth4 = CreateActorWithContent16x16();
4770 childDepth3.Add(childDepth4);
4772 // Gather the call trace.
4773 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4775 // Check we are writing to the color buffer.
4776 CheckColorMask(glAbstraction, true);
4778 // Check the stencil buffer was enabled.
4779 std::ostringstream oss;
4780 oss << std::hex << GL_STENCIL_TEST;
4781 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4783 // Perform the test twice, once for 2D layer, and once for 3D.
4784 for(unsigned int i = 0u; i < 2u; ++i)
4786 size_t startIndex = 0u;
4788 // Check the stencil buffer was cleared.
4789 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4791 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4792 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4793 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4794 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4796 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4797 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
4798 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4800 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4801 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4802 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4803 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4805 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4806 // (Both must be set to pass the check).
4807 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4808 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4810 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4813 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4814 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4821 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4823 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4824 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4825 TestApplication application;
4826 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4827 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4829 /* We create a small tree of actors as follows:
4833 Clipping enabled -> B D
4837 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4840 for(int i = 0; i < 5; ++i)
4842 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4843 Actor actor = CreateRenderableActor(image);
4845 // Setup dimensions and position so actor is not skipped by culling.
4846 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4847 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4851 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4855 float b = i > 2 ? 1.0f : -1.0f;
4856 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4862 // Enable clipping on the actor at the top of the left branch.
4863 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4865 // Build the scene graph.
4866 application.GetScene().Add(actors[0]);
4869 actors[0].Add(actors[1]);
4870 actors[1].Add(actors[2]);
4873 actors[0].Add(actors[3]);
4874 actors[3].Add(actors[4]);
4876 // Gather the call trace.
4877 enabledDisableTrace.Reset();
4878 enabledDisableTrace.Enable(true);
4879 application.SendNotification();
4880 application.Render();
4881 enabledDisableTrace.Enable(false);
4883 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4885 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
4886 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4888 size_t startIndex = 0u;
4889 std::ostringstream blend;
4890 blend << std::hex << GL_BLEND;
4891 std::ostringstream stencil;
4892 stencil << std::hex << GL_STENCIL_TEST;
4894 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4895 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4896 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4898 // Swap the clipping actor from top of left branch to top of right branch.
4899 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4900 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4902 // Gather the call trace.
4903 enabledDisableTrace.Reset();
4904 enabledDisableTrace.Enable(true);
4905 application.SendNotification();
4906 application.Render();
4907 enabledDisableTrace.Enable(false);
4909 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4910 // This proves the draw order has remained the same.
4912 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4913 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4918 int UtcDaliActorPropertyScissorClippingActor01(void)
4920 // This test checks that an actor is correctly setup for clipping.
4921 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4922 TestApplication application;
4924 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4925 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4926 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4928 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4929 const Vector2 imageSize(16.0f, 16.0f);
4931 // Create a clipping actor.
4932 Actor clippingActorA = CreateActorWithContent16x16();
4933 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4934 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4935 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4936 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4937 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4938 application.GetScene().Add(clippingActorA);
4940 // Gather the call trace.
4941 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4943 // Check we are writing to the color buffer.
4944 CheckColorMask(glAbstraction, true);
4946 // Check scissor test was enabled.
4948 std::ostringstream scissor;
4949 scissor << std::hex << GL_SCISSOR_TEST;
4950 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4952 // Check the scissor was set, and the coordinates are correct.
4953 std::stringstream compareParametersString;
4954 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4955 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4957 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4958 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4960 // Gather the call trace.
4961 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4963 // Check the scissor was set, and the coordinates are correct.
4964 compareParametersString.str(std::string());
4965 compareParametersString.clear();
4966 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4967 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4972 int UtcDaliActorPropertyScissorClippingActor02(void)
4974 // This test checks that an actor is correctly setup for clipping.
4975 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4976 TestApplication application;
4978 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4979 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4980 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4982 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4983 const Vector2 actorSize(16.0f, 16.0f);
4985 // Create a clipping actor.
4986 Actor clippingActorA = CreateRenderableActor();
4987 clippingActorA[Actor::Property::SIZE] = actorSize;
4989 Renderer renderer = clippingActorA.GetRendererAt(0);
4990 DALI_TEST_CHECK(renderer);
4992 // Make Renderer opacity 0.
4993 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4995 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4996 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4997 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4998 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4999 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5000 application.GetScene().Add(clippingActorA);
5002 // Gather the call trace.
5003 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5005 // Check we are writing to the color buffer.
5006 CheckColorMask(glAbstraction, true);
5008 // Check scissor test was enabled.
5010 std::ostringstream scissor;
5011 scissor << std::hex << GL_SCISSOR_TEST;
5012 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5014 // Check the scissor was set, and the coordinates are correct.
5015 std::stringstream compareParametersString;
5016 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5017 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5019 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
5020 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
5022 // Gather the call trace.
5023 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5025 // Check the scissor was set, and the coordinates are correct.
5026 compareParametersString.str(std::string());
5027 compareParametersString.clear();
5028 compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
5029 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
5034 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
5036 // This test checks that an actor is correctly setup for clipping.
5037 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
5038 TestApplication application;
5040 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5041 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5042 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5044 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5045 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5046 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5048 // Create a clipping actors.
5049 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5050 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5052 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5053 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5054 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5056 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5057 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5058 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5060 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5061 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5063 application.GetScene().Add(clippingActorA);
5064 application.GetScene().Add(clippingActorB);
5066 // Gather the call trace.
5067 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5069 // Check we are writing to the color buffer.
5070 CheckColorMask(glAbstraction, true);
5072 // Check scissor test was enabled.
5073 std::ostringstream scissor;
5074 scissor << std::hex << GL_SCISSOR_TEST;
5075 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5077 // Check the scissor was set, and the coordinates are correct.
5078 std::stringstream compareParametersString;
5080 std::string clipA("0, 500, 480, 200");
5081 std::string clipB("0, 380, 480, 40");
5083 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5084 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5089 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5091 // This test checks that an actor is correctly setup for clipping.
5092 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5093 TestApplication application;
5095 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5096 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5097 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5099 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5100 const Vector2 imageSize(16.0f, 16.0f);
5102 /* Create a nest of 2 scissors to test nesting (intersecting clips).
5104 A is drawn first - with scissor clipping on
5105 B is drawn second - also with scissor clipping on
5106 C is the generated clipping region, the intersection ( A ∩ B )
5110 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
5111 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
5112 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
5116 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5119 // Create a clipping actor.
5120 Actor clippingActorA = CreateActorWithContent16x16();
5121 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5122 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5123 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5124 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5125 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5126 application.GetScene().Add(clippingActorA);
5128 // Create a child clipping actor.
5129 Actor clippingActorB = CreateActorWithContent16x16();
5130 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5131 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5132 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5133 clippingActorA.Add(clippingActorB);
5135 // positionModifiers is an array of positions to position B around.
5136 // expect is an array of expected scissor clip coordinate results.
5137 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5138 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5140 // Loop through each overlap combination.
5141 for(unsigned int test = 0u; test < 4u; ++test)
5143 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5144 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5145 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5147 // Gather the call trace.
5148 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5150 // Check we are writing to the color buffer.
5151 CheckColorMask(glAbstraction, true);
5153 // Check scissor test was enabled.
5154 std::ostringstream scissor;
5155 scissor << std::hex << GL_SCISSOR_TEST;
5156 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5158 // Check the scissor was set, and the coordinates are correct.
5159 const Vector4& expectResults(expect[test]);
5160 std::stringstream compareParametersString;
5161 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5162 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5168 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5170 // This test checks that an actor is correctly setup for clipping.
5171 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5172 TestApplication application;
5174 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5175 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5176 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5178 /* Create a nest of 2 scissors and siblings of the parent.
5188 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5189 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5190 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5191 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5192 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5193 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5195 // Create a clipping actors.
5196 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5197 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5198 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5199 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5200 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5202 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5203 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5204 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5206 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5207 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5208 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5210 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5211 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5212 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5214 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5215 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5216 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5218 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5219 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5221 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5222 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5223 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5224 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5225 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5227 application.GetScene().Add(clippingActorA);
5228 clippingActorA.Add(clippingActorB);
5229 application.GetScene().Add(clippingActorC);
5230 application.GetScene().Add(clippingActorD);
5231 clippingActorD.Add(clippingActorE);
5233 // Gather the call trace.
5234 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5236 // Check we are writing to the color buffer.
5237 CheckColorMask(glAbstraction, true);
5239 // Check scissor test was enabled.
5240 std::ostringstream scissor;
5241 scissor << std::hex << GL_SCISSOR_TEST;
5242 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5244 // Check the scissor was set, and the coordinates are correct.
5245 std::string clipA("0, 500, 480, 200");
5246 std::string clipB("0, 580, 480, 40");
5247 std::string clipC("0, 200, 480, 200");
5248 std::string clipD("0, 300, 480, 200");
5250 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5251 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5252 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5253 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5254 DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5259 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5261 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5262 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5263 TestApplication application;
5265 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5266 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
5267 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5269 // Create a clipping actor.
5270 Actor actorDepth1Clip = CreateActorWithContent16x16();
5271 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5272 application.GetScene().Add(actorDepth1Clip);
5274 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5275 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5277 // Gather the call trace.
5278 GenerateTrace(application, enabledDisableTrace, stencilTrace);
5280 // Check we are writing to the color buffer.
5281 CheckColorMask(glAbstraction, true);
5283 // Check the stencil buffer was not enabled.
5284 std::ostringstream stencil;
5285 stencil << std::hex << GL_STENCIL_TEST;
5286 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5288 // Check stencil functions are not called.
5289 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5290 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5292 // Check that scissor clipping is overriden by the renderer properties.
5293 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5295 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5297 // Gather the call trace.
5298 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5300 // Check the stencil buffer was not enabled.
5301 std::ostringstream scissor;
5302 scissor << std::hex << GL_SCISSOR_TEST;
5303 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5305 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5310 int UtcDaliActorPropertyClippingActorCulled(void)
5312 // This test checks that child actors are clipped by an culled parent actor.
5313 tet_infoline("Testing child actors are clipped by an culled parent actor");
5314 TestApplication application;
5316 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5317 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5318 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5320 const Vector2 actorSize(160.0f, 160.0f);
5322 // Create a clipping actor.
5323 Actor clippingActorA = CreateRenderableActor();
5324 clippingActorA[Actor::Property::SIZE] = actorSize;
5326 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5327 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5328 clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5329 clippingActorA[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5330 clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5331 application.GetScene().Add(clippingActorA);
5333 // Create a child actor
5334 Actor childActor = CreateRenderableActor();
5335 childActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5336 childActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5337 childActor[Actor::Property::SIZE] = Vector2(50.0f, 50.0f);
5338 childActor[Actor::Property::INHERIT_POSITION] = false;
5340 // Gather the call trace.
5341 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5343 // Check scissor test was enabled.
5344 std::ostringstream scissor;
5345 scissor << std::hex << GL_SCISSOR_TEST;
5346 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5348 // Check the scissor was set, and the coordinates are correct.
5349 std::stringstream compareParametersString;
5350 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5351 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5353 // Move the clipping actor out of screen
5354 clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5356 // Gather the call trace.
5357 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5359 // Check the scissor was set, and the coordinates are correct.
5360 compareParametersString.str(std::string());
5361 compareParametersString.clear();
5362 compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5363 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5368 int UtcDaliGetPropertyN(void)
5370 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5371 TestApplication application;
5373 Actor actor = Actor::New();
5375 unsigned int propertyCount = actor.GetPropertyCount();
5376 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5380 int UtcDaliActorRaiseLower(void)
5382 tet_infoline("UtcDaliActor Raise and Lower test\n");
5384 TestApplication application;
5386 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5388 Integration::Scene stage(application.GetScene());
5390 Actor actorA = Actor::New();
5391 Actor actorB = Actor::New();
5392 Actor actorC = Actor::New();
5394 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5395 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5397 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5398 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5400 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5401 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5403 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5404 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5406 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5407 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5409 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5410 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5416 ResetTouchCallbacks();
5418 application.SendNotification();
5419 application.Render();
5421 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5422 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5423 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5425 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5426 // Only top actor will get touched.
5427 actorA.TouchedSignal().Connect(TestTouchCallback);
5428 actorB.TouchedSignal().Connect(TestTouchCallback2);
5429 actorC.TouchedSignal().Connect(TestTouchCallback3);
5431 // Connect ChildOrderChangedSignal
5432 bool orderChangedSignal(false);
5433 Actor orderChangedActor;
5434 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5435 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5437 Dali::Integration::Point point;
5438 point.SetDeviceId(1);
5439 point.SetState(PointState::DOWN);
5440 point.SetScreenPosition(Vector2(10.f, 10.f));
5441 Dali::Integration::TouchEvent touchEvent;
5442 touchEvent.AddPoint(point);
5444 application.ProcessEvent(touchEvent);
5446 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5447 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5448 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5450 ResetTouchCallbacks();
5452 tet_printf("Testing Raising of Actor\n");
5454 int preActorOrder(0);
5455 int postActorOrder(0);
5457 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5458 value.Get(preActorOrder);
5460 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5462 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5463 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5465 // Ensure sort order is calculated before next touch event
5466 application.SendNotification();
5468 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5469 value.Get(postActorOrder);
5471 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5473 application.ProcessEvent(touchEvent);
5475 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5476 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5477 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5479 ResetTouchCallbacks();
5481 tet_printf("Testing Lowering of Actor\n");
5483 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5484 value.Get(preActorOrder);
5486 orderChangedSignal = false;
5488 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5490 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5491 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5493 application.SendNotification(); // ensure sort order calculated before next touch event
5495 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5496 value.Get(postActorOrder);
5498 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5500 application.ProcessEvent(touchEvent);
5502 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5503 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5504 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5506 ResetTouchCallbacks();
5508 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5513 int UtcDaliActorRaiseToTopLowerToBottom(void)
5515 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5517 TestApplication application;
5519 Integration::Scene stage(application.GetScene());
5521 Actor actorA = Actor::New();
5522 Actor actorB = Actor::New();
5523 Actor actorC = Actor::New();
5525 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5526 // enables checking of which actor the uniform is assigned too
5527 Shader shaderA = CreateShader();
5528 shaderA.RegisterProperty("uRendererColor", 1.f);
5530 Shader shaderB = CreateShader();
5531 shaderB.RegisterProperty("uRendererColor", 2.f);
5533 Shader shaderC = CreateShader();
5534 shaderC.RegisterProperty("uRendererColor", 3.f);
5536 Geometry geometry = CreateQuadGeometry();
5538 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5539 Renderer rendererA = Renderer::New(geometry, shaderA);
5540 actorA.AddRenderer(rendererA);
5542 Renderer rendererB = Renderer::New(geometry, shaderB);
5543 actorB.AddRenderer(rendererB);
5545 Renderer rendererC = Renderer::New(geometry, shaderC);
5546 actorC.AddRenderer(rendererC);
5548 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5549 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5551 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5552 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5554 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5555 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5557 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5558 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5560 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5561 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5563 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5564 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5570 ResetTouchCallbacks();
5572 // Connect ChildOrderChangedSignal
5573 bool orderChangedSignal(false);
5574 Actor orderChangedActor;
5575 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5576 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5578 // Set up gl abstraction trace so can query the set uniform order
5579 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5580 glAbstraction.EnableSetUniformCallTrace(true);
5581 glAbstraction.ResetSetUniformCallStack();
5583 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5585 application.SendNotification();
5586 application.Render();
5588 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5590 // Test order of uniforms in stack
5591 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5592 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5593 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5595 bool CBA = (indexC > indexB) && (indexB > indexA);
5597 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5599 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5600 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5601 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5603 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5604 // Only top actor will get touched.
5605 actorA.TouchedSignal().Connect(TestTouchCallback);
5606 actorB.TouchedSignal().Connect(TestTouchCallback2);
5607 actorC.TouchedSignal().Connect(TestTouchCallback3);
5609 Dali::Integration::Point point;
5610 point.SetDeviceId(1);
5611 point.SetState(PointState::DOWN);
5612 point.SetScreenPosition(Vector2(10.f, 10.f));
5613 Dali::Integration::TouchEvent touchEvent;
5614 touchEvent.AddPoint(point);
5616 application.ProcessEvent(touchEvent);
5618 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5619 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5620 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5622 ResetTouchCallbacks();
5624 tet_printf("RaiseToTop ActorA\n");
5626 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5627 actorA.RaiseToTop();
5628 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5629 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5631 application.SendNotification(); // ensure sorting order is calculated before next touch event
5633 application.ProcessEvent(touchEvent);
5635 glSetUniformStack.Reset();
5637 application.SendNotification();
5638 application.Render();
5640 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5642 // Test order of uniforms in stack
5643 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5644 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5645 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5647 tet_infoline("Testing A above C and B at bottom\n");
5648 bool ACB = (indexA > indexC) && (indexC > indexB);
5650 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5652 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5653 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5654 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5656 ResetTouchCallbacks();
5658 tet_printf("RaiseToTop ActorB\n");
5660 orderChangedSignal = false;
5662 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5663 actorB.RaiseToTop();
5664 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5665 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5667 application.SendNotification(); // Ensure sort order is calculated before next touch event
5669 application.ProcessEvent(touchEvent);
5671 glSetUniformStack.Reset();
5673 application.SendNotification();
5674 application.Render();
5676 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5678 // Test order of uniforms in stack
5679 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5680 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5681 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5683 tet_infoline("Testing B above A and C at bottom\n");
5684 bool BAC = (indexB > indexA) && (indexA > indexC);
5686 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5688 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5689 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5690 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5692 ResetTouchCallbacks();
5694 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5696 orderChangedSignal = false;
5698 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5699 actorA.LowerToBottom();
5700 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5701 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5703 application.SendNotification();
5704 application.Render();
5706 orderChangedSignal = false;
5708 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5709 actorB.LowerToBottom();
5710 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5711 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5713 application.SendNotification();
5714 application.Render();
5716 application.ProcessEvent(touchEvent);
5718 glSetUniformStack.Reset();
5720 application.SendNotification();
5721 application.Render();
5723 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5725 // Test order of uniforms in stack
5726 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5727 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5728 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5730 tet_infoline("Testing C above A and B at bottom\n");
5731 bool CAB = (indexC > indexA) && (indexA > indexB);
5733 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5735 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5736 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5737 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5739 ResetTouchCallbacks();
5744 int UtcDaliActorRaiseAbove(void)
5746 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5748 TestApplication application;
5750 Integration::Scene stage(application.GetScene());
5752 Actor actorA = Actor::New();
5753 Actor actorB = Actor::New();
5754 Actor actorC = Actor::New();
5756 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5757 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5759 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5760 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5762 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5763 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5765 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5766 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5768 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5769 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5771 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5772 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5778 ResetTouchCallbacks();
5780 application.SendNotification();
5781 application.Render();
5783 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5784 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5785 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5787 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5788 // Only top actor will get touched.
5789 actorA.TouchedSignal().Connect(TestTouchCallback);
5790 actorB.TouchedSignal().Connect(TestTouchCallback2);
5791 actorC.TouchedSignal().Connect(TestTouchCallback3);
5793 bool orderChangedSignal(false);
5794 Actor orderChangedActor;
5795 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5796 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5798 Dali::Integration::Point point;
5799 point.SetDeviceId(1);
5800 point.SetState(PointState::DOWN);
5801 point.SetScreenPosition(Vector2(10.f, 10.f));
5802 Dali::Integration::TouchEvent touchEvent;
5803 touchEvent.AddPoint(point);
5805 application.ProcessEvent(touchEvent);
5807 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5808 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5809 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5811 ResetTouchCallbacks();
5813 tet_printf("Raise actor B Above Actor C\n");
5815 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5816 actorB.RaiseAbove(actorC);
5817 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5818 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5820 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5821 application.SendNotification();
5822 application.ProcessEvent(touchEvent);
5824 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5825 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5826 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5828 ResetTouchCallbacks();
5830 tet_printf("Raise actor A Above Actor B\n");
5832 orderChangedSignal = false;
5834 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5835 actorA.RaiseAbove(actorB);
5836 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5837 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5839 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5840 application.SendNotification();
5842 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5844 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5845 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5846 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5848 ResetTouchCallbacks();
5853 int UtcDaliActorRaiseAbove2(void)
5855 tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5857 TestApplication application;
5859 Integration::Scene stage(application.GetScene());
5861 Actor actorA = Actor::New();
5862 Actor actorB = Actor::New();
5863 Actor actorC = Actor::New();
5865 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5866 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5868 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5869 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5871 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5872 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5874 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5875 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5877 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5878 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5880 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5881 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5887 ResetTouchCallbacks();
5889 application.SendNotification();
5890 application.Render();
5892 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5893 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5894 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5896 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5897 // Only top actor will get touched.
5898 actorA.TouchedSignal().Connect(TestTouchCallback);
5899 actorB.TouchedSignal().Connect(TestTouchCallback2);
5900 actorC.TouchedSignal().Connect(TestTouchCallback3);
5902 bool orderChangedSignal(false);
5903 Actor orderChangedActor;
5904 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5905 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5907 Dali::Integration::Point point;
5908 point.SetDeviceId(1);
5909 point.SetState(PointState::DOWN);
5910 point.SetScreenPosition(Vector2(10.f, 10.f));
5911 Dali::Integration::TouchEvent touchEvent;
5912 touchEvent.AddPoint(point);
5914 application.ProcessEvent(touchEvent);
5916 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5917 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5918 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5920 ResetTouchCallbacks();
5922 tet_printf("Raise actor B Above Actor C\n");
5924 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5925 int newOrder = actorC[DevelActor::Property::SIBLING_ORDER];
5926 actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5927 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5928 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5930 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5931 application.SendNotification();
5932 application.ProcessEvent(touchEvent);
5934 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5935 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5936 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5938 ResetTouchCallbacks();
5940 tet_printf("Raise actor A Above Actor B\n");
5942 orderChangedSignal = false;
5944 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5945 newOrder = actorB[DevelActor::Property::SIBLING_ORDER];
5946 actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5947 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5948 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5950 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5951 application.SendNotification();
5953 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5955 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5956 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5957 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5959 ResetTouchCallbacks();
5964 int UtcDaliActorLowerBelow(void)
5966 tet_infoline("UtcDaliActor LowerBelow test \n");
5968 TestApplication application;
5970 Integration::Scene stage(application.GetScene());
5972 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5973 // enables checking of which actor the uniform is assigned too
5974 Shader shaderA = CreateShader();
5975 shaderA.RegisterProperty("uRendererColor", 1.f);
5977 Shader shaderB = CreateShader();
5978 shaderB.RegisterProperty("uRendererColor", 2.f);
5980 Shader shaderC = CreateShader();
5981 shaderC.RegisterProperty("uRendererColor", 3.f);
5983 Actor actorA = Actor::New();
5984 Actor actorB = Actor::New();
5985 Actor actorC = Actor::New();
5987 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5988 Geometry geometry = CreateQuadGeometry();
5990 Renderer rendererA = Renderer::New(geometry, shaderA);
5991 actorA.AddRenderer(rendererA);
5993 Renderer rendererB = Renderer::New(geometry, shaderB);
5994 actorB.AddRenderer(rendererB);
5996 Renderer rendererC = Renderer::New(geometry, shaderC);
5997 actorC.AddRenderer(rendererC);
5999 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6000 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6002 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6003 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6005 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6006 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6008 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6009 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6011 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6012 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6014 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6015 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6017 Actor container = Actor::New();
6018 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6019 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6020 stage.Add(container);
6022 container.Add(actorA);
6023 container.Add(actorB);
6024 container.Add(actorC);
6026 ResetTouchCallbacks();
6028 // Connect ChildOrderChangedSignal
6029 bool orderChangedSignal(false);
6030 Actor orderChangedActor;
6031 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6032 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6034 // Set up gl abstraction trace so can query the set uniform order
6035 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6036 glAbstraction.EnableSetUniformCallTrace(true);
6037 glAbstraction.ResetSetUniformCallStack();
6038 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6040 glAbstraction.ResetSetUniformCallStack();
6042 application.SendNotification();
6043 application.Render();
6045 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6047 // Test order of uniforms in stack
6048 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6049 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6050 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6052 tet_infoline("Testing C above B and A at bottom\n");
6053 bool CBA = (indexC > indexB) && (indexB > indexA);
6055 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6057 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6058 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6059 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6061 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6062 // Only top actor will get touched.
6063 actorA.TouchedSignal().Connect(TestTouchCallback);
6064 actorB.TouchedSignal().Connect(TestTouchCallback2);
6065 actorC.TouchedSignal().Connect(TestTouchCallback3);
6067 Dali::Integration::Point point;
6068 point.SetDeviceId(1);
6069 point.SetState(PointState::DOWN);
6070 point.SetScreenPosition(Vector2(10.f, 10.f));
6071 Dali::Integration::TouchEvent touchEvent;
6072 touchEvent.AddPoint(point);
6074 tet_infoline("UtcDaliActor Test Set up completed \n");
6076 application.ProcessEvent(touchEvent);
6078 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6079 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6080 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6082 ResetTouchCallbacks();
6084 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");
6086 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6087 actorC.LowerBelow(actorB);
6088 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6089 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6091 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6092 application.SendNotification();
6093 application.Render();
6095 application.ProcessEvent(touchEvent); // touch event
6097 glSetUniformStack.Reset();
6099 application.SendNotification();
6100 application.Render();
6102 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6104 // Test order of uniforms in stack
6105 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6106 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6107 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6109 tet_infoline("Testing render order is A, C, B");
6110 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6111 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6113 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6114 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6115 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6117 ResetTouchCallbacks();
6119 tet_printf("Lower actor C below Actor A leaving B on top\n");
6121 orderChangedSignal = false;
6123 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6124 actorC.LowerBelow(actorA);
6125 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6126 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6128 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6129 application.SendNotification();
6130 application.Render();
6132 application.ProcessEvent(touchEvent);
6134 glSetUniformStack.Reset();
6136 application.Render();
6137 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6139 // Test order of uniforms in stack
6140 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6141 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6142 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6144 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6145 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6147 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6148 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6149 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6151 ResetTouchCallbacks();
6153 tet_printf("Lower actor B below Actor C leaving A on top\n");
6155 orderChangedSignal = false;
6157 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6158 actorB.LowerBelow(actorC);
6159 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6160 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6162 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6163 application.SendNotification();
6164 application.Render();
6166 application.ProcessEvent(touchEvent);
6168 glSetUniformStack.Reset();
6170 application.Render();
6171 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6173 // Test order of uniforms in stack
6174 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6175 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6176 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6178 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6179 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6184 int UtcDaliActorLowerBelow2(void)
6186 tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
6188 TestApplication application;
6190 Integration::Scene stage(application.GetScene());
6192 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6193 // enables checking of which actor the uniform is assigned too
6194 Shader shaderA = CreateShader();
6195 shaderA.RegisterProperty("uRendererColor", 1.f);
6197 Shader shaderB = CreateShader();
6198 shaderB.RegisterProperty("uRendererColor", 2.f);
6200 Shader shaderC = CreateShader();
6201 shaderC.RegisterProperty("uRendererColor", 3.f);
6203 Actor actorA = Actor::New();
6204 Actor actorB = Actor::New();
6205 Actor actorC = Actor::New();
6207 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6208 Geometry geometry = CreateQuadGeometry();
6210 Renderer rendererA = Renderer::New(geometry, shaderA);
6211 actorA.AddRenderer(rendererA);
6213 Renderer rendererB = Renderer::New(geometry, shaderB);
6214 actorB.AddRenderer(rendererB);
6216 Renderer rendererC = Renderer::New(geometry, shaderC);
6217 actorC.AddRenderer(rendererC);
6219 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6220 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6222 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6223 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6225 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6226 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6228 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6229 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6231 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6232 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6234 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6235 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6237 Actor container = Actor::New();
6238 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6239 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6240 stage.Add(container);
6242 container.Add(actorA);
6243 container.Add(actorB);
6244 container.Add(actorC);
6246 ResetTouchCallbacks();
6248 // Connect ChildOrderChangedSignal
6249 bool orderChangedSignal(false);
6250 Actor orderChangedActor;
6251 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6252 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6254 // Set up gl abstraction trace so can query the set uniform order
6255 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6256 glAbstraction.EnableSetUniformCallTrace(true);
6257 glAbstraction.ResetSetUniformCallStack();
6258 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6260 glAbstraction.ResetSetUniformCallStack();
6262 application.SendNotification();
6263 application.Render();
6265 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6267 // Test order of uniforms in stack
6268 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6269 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6270 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6272 tet_infoline("Testing C above B and A at bottom\n");
6273 bool CBA = (indexC > indexB) && (indexB > indexA);
6275 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6277 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6278 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6279 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6281 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6282 // Only top actor will get touched.
6283 actorA.TouchedSignal().Connect(TestTouchCallback);
6284 actorB.TouchedSignal().Connect(TestTouchCallback2);
6285 actorC.TouchedSignal().Connect(TestTouchCallback3);
6287 Dali::Integration::Point point;
6288 point.SetDeviceId(1);
6289 point.SetState(PointState::DOWN);
6290 point.SetScreenPosition(Vector2(10.f, 10.f));
6291 Dali::Integration::TouchEvent touchEvent;
6292 touchEvent.AddPoint(point);
6294 tet_infoline("UtcDaliActor Test Set up completed \n");
6296 application.ProcessEvent(touchEvent);
6298 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6299 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6300 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6302 ResetTouchCallbacks();
6304 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");
6306 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6307 actorC[DevelActor::Property::SIBLING_ORDER] = 1;
6308 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6309 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6311 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6312 application.SendNotification();
6313 application.Render();
6315 application.ProcessEvent(touchEvent); // touch event
6317 glSetUniformStack.Reset();
6319 application.SendNotification();
6320 application.Render();
6322 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6324 // Test order of uniforms in stack
6325 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6326 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6327 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6329 tet_infoline("Testing render order is A, C, B");
6330 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6331 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6333 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6334 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6335 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6337 ResetTouchCallbacks();
6339 tet_printf("Lower actor C below Actor A leaving B on top\n");
6341 orderChangedSignal = false;
6343 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6344 actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6345 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6346 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6348 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6349 application.SendNotification();
6350 application.Render();
6352 application.ProcessEvent(touchEvent);
6354 glSetUniformStack.Reset();
6356 application.Render();
6357 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6359 // Test order of uniforms in stack
6360 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6361 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6362 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6364 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6365 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6367 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6368 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6369 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6371 ResetTouchCallbacks();
6373 tet_printf("Lower actor B below Actor C leaving A on top\n");
6375 orderChangedSignal = false;
6377 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6378 actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6379 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6380 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6382 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6383 application.SendNotification();
6384 application.Render();
6386 application.ProcessEvent(touchEvent);
6388 glSetUniformStack.Reset();
6390 application.Render();
6391 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6393 // Test order of uniforms in stack
6394 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6395 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6396 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6398 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6399 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6404 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6406 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6408 TestApplication application;
6410 Integration::Scene stage(application.GetScene());
6412 Actor parentA = Actor::New();
6413 Actor parentB = Actor::New();
6414 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6415 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6416 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6417 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6419 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6420 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6422 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6423 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6428 Actor actorA = Actor::New();
6429 Actor actorB = Actor::New();
6430 Actor actorC = Actor::New();
6432 parentA.Add(actorA);
6433 parentA.Add(actorB);
6435 tet_printf("Actor C added to different parent from A and B \n");
6436 parentB.Add(actorC);
6438 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6439 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6441 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6442 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6444 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6445 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6447 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6448 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6450 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6451 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6453 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6454 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6456 ResetTouchCallbacks();
6458 // Connect ChildOrderChangedSignal
6459 bool orderChangedSignal(false);
6460 Actor orderChangedActor;
6461 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6462 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6464 application.SendNotification();
6465 application.Render();
6467 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6468 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6469 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6471 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6472 // Only top actor will get touched.
6473 actorA.TouchedSignal().Connect(TestTouchCallback);
6474 actorB.TouchedSignal().Connect(TestTouchCallback2);
6475 actorC.TouchedSignal().Connect(TestTouchCallback3);
6477 Dali::Integration::Point point;
6478 point.SetDeviceId(1);
6479 point.SetState(PointState::DOWN);
6480 point.SetScreenPosition(Vector2(10.f, 10.f));
6481 Dali::Integration::TouchEvent touchEvent;
6482 touchEvent.AddPoint(point);
6484 application.ProcessEvent(touchEvent);
6486 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6487 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6488 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6490 ResetTouchCallbacks();
6492 tet_printf("Raise actor A Above Actor C which have different parents\n");
6494 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6495 actorA.RaiseAbove(actorC);
6496 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6498 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6499 application.SendNotification();
6501 application.ProcessEvent(touchEvent); // touch event
6503 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6504 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6505 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6507 ResetTouchCallbacks();
6512 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6514 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
6516 TestApplication application;
6518 Integration::Scene stage(application.GetScene());
6520 Actor actorA = Actor::New();
6521 Actor actorB = Actor::New();
6522 Actor actorC = Actor::New();
6524 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6525 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6527 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6528 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6530 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6531 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6533 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6534 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6536 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6537 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6539 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6540 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6542 ResetTouchCallbacks();
6544 // Connect ChildOrderChangedSignal
6545 bool orderChangedSignal(false);
6546 Actor orderChangedActor;
6547 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6548 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6550 application.SendNotification();
6551 application.Render();
6553 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6554 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6555 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6557 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6558 // Only top actor will get touched.
6559 actorA.TouchedSignal().Connect(TestTouchCallback);
6560 actorB.TouchedSignal().Connect(TestTouchCallback2);
6561 actorC.TouchedSignal().Connect(TestTouchCallback3);
6563 Dali::Integration::Point point;
6564 point.SetDeviceId(1);
6565 point.SetState(PointState::DOWN);
6566 point.SetScreenPosition(Vector2(10.f, 10.f));
6567 Dali::Integration::TouchEvent touchEvent;
6568 touchEvent.AddPoint(point);
6570 tet_printf("Raise actor A Above Actor C which have no parents\n");
6572 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6573 actorA.RaiseAbove(actorC);
6574 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6576 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6577 application.SendNotification();
6579 application.ProcessEvent(touchEvent);
6581 tet_printf("Not parented so RaiseAbove should show no effect\n");
6583 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6584 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6585 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6587 ResetTouchCallbacks();
6589 orderChangedSignal = false;
6592 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6594 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6595 actorA.LowerBelow(actorC);
6596 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6598 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6599 application.SendNotification();
6600 application.Render();
6602 application.ProcessEvent(touchEvent);
6604 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6605 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6606 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6607 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6609 ResetTouchCallbacks();
6611 orderChangedSignal = false;
6613 tet_printf("Adding Actor A to stage, will be on top\n");
6616 application.SendNotification();
6617 application.Render();
6619 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6621 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6622 actorB.RaiseAbove(actorC);
6623 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6625 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6626 application.SendNotification();
6628 application.ProcessEvent(touchEvent);
6630 tet_printf("C not parented so RaiseAbove should show no effect\n");
6631 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6632 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6633 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6635 ResetTouchCallbacks();
6637 orderChangedSignal = false;
6639 tet_printf("Lower actor A below Actor C when only A has a parent\n");
6641 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6642 actorA.LowerBelow(actorC);
6643 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6645 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6646 application.SendNotification();
6648 application.ProcessEvent(touchEvent);
6650 tet_printf("C not parented so LowerBelow should show no effect\n");
6651 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6652 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6653 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6655 ResetTouchCallbacks();
6657 orderChangedSignal = false;
6661 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6662 actorA.RaiseAbove(actorC);
6663 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6664 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6666 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6667 application.SendNotification();
6668 application.Render();
6670 application.ProcessEvent(touchEvent);
6672 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6673 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6674 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6675 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6680 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6682 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6684 TestApplication application;
6686 Integration::Scene stage(application.GetScene());
6688 Actor actorA = Actor::New();
6689 Actor actorB = Actor::New();
6690 Actor actorC = Actor::New();
6692 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6693 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6695 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6696 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6698 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6699 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6701 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6702 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6704 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6705 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6707 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6708 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6710 ResetTouchCallbacks();
6712 // Connect ChildOrderChangedSignal
6713 bool orderChangedSignal(false);
6714 Actor orderChangedActor;
6715 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6716 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6718 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6719 // Only top actor will get touched.
6720 actorA.TouchedSignal().Connect(TestTouchCallback);
6721 actorB.TouchedSignal().Connect(TestTouchCallback2);
6722 actorC.TouchedSignal().Connect(TestTouchCallback3);
6724 Dali::Integration::Point point;
6725 point.SetDeviceId(1);
6726 point.SetState(PointState::DOWN);
6727 point.SetScreenPosition(Vector2(10.f, 10.f));
6728 Dali::Integration::TouchEvent touchEvent;
6729 touchEvent.AddPoint(point);
6732 tet_printf("Raise actor B Above Actor C but B not parented\n");
6734 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6736 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6738 application.SendNotification();
6739 application.Render();
6741 application.ProcessEvent(touchEvent);
6743 tet_printf("Not parented so RaiseAbove should show no effect\n");
6745 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6746 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6747 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6749 tet_printf("Raise actor B Above Actor C but B not parented\n");
6750 ResetTouchCallbacks();
6752 orderChangedSignal = false;
6754 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6756 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6758 // Sort actor tree before next touch event
6759 application.SendNotification();
6760 application.Render();
6762 application.ProcessEvent(touchEvent);
6764 tet_printf("Not parented so RaiseAbove should show no effect\n");
6766 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6767 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6768 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6769 ResetTouchCallbacks();
6771 orderChangedSignal = false;
6773 tet_printf("Lower actor C below B but C not parented\n");
6775 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6777 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6779 // Sort actor tree before next touch event
6780 application.SendNotification();
6781 application.Render();
6783 application.ProcessEvent(touchEvent);
6785 tet_printf("Not parented so Lower should show no effect\n");
6787 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6788 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6789 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6790 ResetTouchCallbacks();
6792 orderChangedSignal = false;
6794 tet_printf("Raise actor B to top\n");
6796 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6797 actorB.RaiseToTop();
6798 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6800 // Sort actor tree before next touch event
6801 application.SendNotification();
6802 application.Render();
6804 application.ProcessEvent(touchEvent);
6806 tet_printf("Not parented so RaiseToTop should show no effect\n");
6808 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6809 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6810 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6811 ResetTouchCallbacks();
6813 orderChangedSignal = false;
6815 tet_printf("Add ActorB to stage so only Actor C not parented\n");
6819 tet_printf("Lower actor C to Bottom, B stays at top\n");
6821 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6822 actorC.LowerToBottom();
6823 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6825 application.SendNotification();
6826 application.Render();
6828 application.ProcessEvent(touchEvent);
6830 tet_printf("Not parented so LowerToBottom should show no effect\n");
6832 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6833 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6834 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6835 ResetTouchCallbacks();
6840 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6842 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
6844 TestApplication application;
6846 Integration::Scene stage(application.GetScene());
6848 Actor actorA = Actor::New();
6849 Actor actorB = Actor::New();
6850 Actor actorC = Actor::New();
6852 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6853 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6855 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6856 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6858 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6859 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6861 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6862 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6864 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6865 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6867 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6868 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6874 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6875 // Only top actor will get touched.
6876 actorA.TouchedSignal().Connect(TestTouchCallback);
6877 actorB.TouchedSignal().Connect(TestTouchCallback2);
6878 actorC.TouchedSignal().Connect(TestTouchCallback3);
6880 ResetTouchCallbacks();
6882 // Connect ChildOrderChangedSignal
6883 bool orderChangedSignal(false);
6884 Actor orderChangedActor;
6885 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6886 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6888 application.SendNotification();
6889 application.Render();
6891 Dali::Integration::Point point;
6892 point.SetDeviceId(1);
6893 point.SetState(PointState::DOWN);
6894 point.SetScreenPosition(Vector2(10.f, 10.f));
6895 Dali::Integration::TouchEvent touchEvent;
6896 touchEvent.AddPoint(point);
6898 application.ProcessEvent(touchEvent);
6900 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6901 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6902 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6904 ResetTouchCallbacks();
6906 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6908 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6909 actorA.RaiseAbove(actorA);
6910 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6911 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6913 application.SendNotification();
6914 application.Render();
6916 application.ProcessEvent(touchEvent);
6918 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6920 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6921 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6922 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6924 ResetTouchCallbacks();
6926 orderChangedSignal = false;
6928 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6929 actorA.RaiseAbove(actorC);
6930 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6931 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6933 application.SendNotification();
6934 application.Render();
6936 application.ProcessEvent(touchEvent);
6938 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6939 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6940 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6941 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6946 int UtcDaliActorGetScreenPosition(void)
6948 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6950 TestApplication application;
6952 Integration::Scene stage(application.GetScene());
6954 Actor actorA = Actor::New();
6955 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6957 Vector2 size2(10.0f, 20.0f);
6958 actorA.SetProperty(Actor::Property::SIZE, size2);
6960 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6962 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6966 application.SendNotification();
6967 application.Render();
6969 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6970 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6972 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6973 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6975 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6976 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6978 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6980 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6982 application.SendNotification();
6983 application.Render();
6985 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6986 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6988 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6989 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6991 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6992 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6994 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6996 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6998 application.SendNotification();
6999 application.Render();
7001 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7002 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7004 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7005 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
7007 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7008 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7010 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
7012 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
7014 application.SendNotification();
7015 application.Render();
7017 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7018 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7020 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
7021 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
7023 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7024 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7026 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
7028 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
7030 application.SendNotification();
7031 application.Render();
7033 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7034 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7036 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
7037 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
7039 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
7040 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
7042 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
7044 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7045 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
7047 Actor actorB = Actor::New();
7048 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7049 actorB.SetProperty(Actor::Property::SIZE, size2);
7050 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
7053 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7055 application.SendNotification();
7056 application.Render();
7058 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7060 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
7061 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
7066 int UtcDaliActorGetScreenPositionAfterScaling(void)
7068 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
7070 TestApplication application;
7072 Integration::Scene stage(application.GetScene());
7074 Actor actorA = Actor::New();
7075 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7077 Vector2 size2(10.0f, 20.0f);
7078 actorA.SetProperty(Actor::Property::SIZE, size2);
7079 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
7080 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7082 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
7086 application.SendNotification();
7087 application.Render();
7089 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7090 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7092 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7093 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7095 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7096 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7098 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
7100 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7102 application.SendNotification();
7103 application.Render();
7105 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7106 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7108 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7109 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7111 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
7112 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7117 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
7119 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
7121 TestApplication application;
7123 Integration::Scene stage(application.GetScene());
7125 Actor actorA = Actor::New();
7126 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7127 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7128 Vector2 size2(10.0f, 20.0f);
7129 actorA.SetProperty(Actor::Property::SIZE, size2);
7130 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7132 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7136 application.SendNotification();
7137 application.Render();
7139 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7140 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7142 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7143 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7145 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
7146 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
7148 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
7150 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
7151 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7153 application.SendNotification();
7154 application.Render();
7156 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7157 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7159 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7160 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7162 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
7163 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7169 int UtcDaliActorGetScreenPositionWithChildActors(void)
7171 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
7173 TestApplication application;
7175 Integration::Scene stage(application.GetScene());
7177 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7179 Actor actorA = Actor::New();
7180 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7181 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7182 Vector2 size1(10.0f, 20.0f);
7183 actorA.SetProperty(Actor::Property::SIZE, size1);
7184 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7186 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7188 Actor parentActorA = Actor::New();
7189 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7190 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7191 Vector2 size2(30.0f, 60.0f);
7192 parentActorA.SetProperty(Actor::Property::SIZE, size2);
7193 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7195 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7197 stage.Add(parentActorA);
7198 parentActorA.Add(actorA);
7200 application.SendNotification();
7201 application.Render();
7203 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7204 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7206 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7207 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7209 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
7210 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
7212 tet_infoline("Test 2\n");
7214 tet_infoline("change parent anchor point and parent origin then check screen position \n");
7216 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7217 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
7219 application.SendNotification();
7220 application.Render();
7222 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7223 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7225 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7226 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7228 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
7229 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
7234 int UtcDaliActorGetScreenPositionWithChildActors02(void)
7236 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
7238 TestApplication application;
7240 Integration::Scene stage(application.GetScene());
7242 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7244 Actor actorA = Actor::New();
7245 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7246 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7247 Vector2 size1(10.0f, 20.0f);
7248 actorA.SetProperty(Actor::Property::SIZE, size1);
7249 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7251 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7253 Actor parentActorA = Actor::New();
7254 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7255 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7256 Vector2 size2(30.0f, 60.0f);
7257 parentActorA.SetProperty(Actor::Property::SIZE, size2);
7258 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7260 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
7262 Actor grandParentActorA = Actor::New();
7263 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7264 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
7265 Vector2 size3(60.0f, 120.0f);
7266 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
7267 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7269 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
7271 stage.Add(grandParentActorA);
7272 grandParentActorA.Add(parentActorA);
7274 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7276 parentActorA.Add(actorA);
7278 application.SendNotification();
7279 application.Render();
7281 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7282 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7284 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7285 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7287 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
7288 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
7293 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
7295 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
7297 TestApplication application;
7299 Integration::Scene stage(application.GetScene());
7301 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7303 Actor actorA = Actor::New();
7304 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7305 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7306 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7307 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
7310 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7312 Actor actorB = Actor::New();
7313 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7314 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7315 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7316 Vector2 actorBSize(30.0f, 60.0f);
7317 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7320 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7322 Actor actorC = Actor::New();
7323 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7324 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7325 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7326 Vector2 actorCSize(60.0f, 120.0f);
7327 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7330 application.SendNotification();
7331 application.Render();
7333 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7335 Vector2 center(stage.GetSize() * 0.5f);
7337 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7338 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7339 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7341 tet_infoline("Add scale to all actors");
7343 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7344 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7345 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7347 application.SendNotification();
7348 application.Render();
7350 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7351 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7352 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7357 int UtcDaliActorGetScreenPositionResizeScene(void)
7359 tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
7361 TestApplication application;
7362 Integration::Scene scene = application.GetScene();
7364 Actor actorA = Actor::New();
7365 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7366 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7367 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7371 application.SendNotification();
7372 application.Render();
7374 Vector2 sceneSize = scene.GetSize();
7375 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7377 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7380 Vector2 newSize(1000.0f, 2000.0f);
7381 DALI_TEST_CHECK(scene.GetSize() != newSize);
7383 scene.SurfaceResized(newSize.width, newSize.height);
7385 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7387 // The screen position should not be updated yet
7388 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7390 application.SendNotification();
7391 application.Render();
7393 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7395 // The screen position should be updated
7396 sceneSize = scene.GetSize();
7397 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7402 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
7404 tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
7406 TestApplication application;
7407 Integration::Scene scene = application.GetScene();
7410 Layer layer = scene.GetRootLayer();
7411 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
7413 // Build custom camera with top-view
7414 CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
7416 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
7417 Vector3 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7418 Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7421 std::ostringstream oss;
7422 oss << cameraPos << "\n";
7423 oss << cameraOrient << "\n";
7424 tet_printf("%s\n", oss.str().c_str());
7427 cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
7428 cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
7430 // Now, upside : -Z, leftside : -X, foward : +Y
7432 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7433 cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7435 std::ostringstream oss;
7436 oss << cameraPos << "\n";
7437 oss << cameraOrient << "\n";
7438 tet_printf("%s\n", oss.str().c_str());
7442 Actor actorA = Actor::New();
7443 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7444 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7445 actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7446 actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
7448 Actor actorB = Actor::New();
7449 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7450 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7451 actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7452 actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
7457 application.SendNotification();
7458 application.Render();
7460 Vector2 sceneSize = scene.GetSize();
7461 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7463 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
7465 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7467 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
7472 int utcDaliActorPositionUsesAnchorPoint(void)
7474 TestApplication application;
7475 tet_infoline("Check default behaviour\n");
7477 Actor actor = Actor::New();
7478 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7479 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7480 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7481 application.GetScene().Add(actor);
7483 application.SendNotification();
7484 application.Render();
7486 tet_infoline("Check that the world position is in the center\n");
7487 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7489 tet_infoline("Set the position uses anchor point property to false\n");
7490 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7492 application.SendNotification();
7493 application.Render();
7495 tet_infoline("Check that the world position has changed appropriately\n");
7496 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7501 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7503 TestApplication application;
7504 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7506 Actor actor = Actor::New();
7507 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7508 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7509 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7510 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7511 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7512 application.GetScene().Add(actor);
7514 application.SendNotification();
7515 application.Render();
7517 tet_infoline("Check the world position is the same as it would be without a scale\n");
7518 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7520 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7521 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7522 application.SendNotification();
7523 application.Render();
7524 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7526 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7527 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7528 application.SendNotification();
7529 application.Render();
7530 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7535 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7537 TestApplication application;
7538 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7540 Actor actor = Actor::New();
7541 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7542 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7543 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7544 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7545 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7546 application.GetScene().Add(actor);
7548 application.SendNotification();
7549 application.Render();
7551 tet_infoline("Check the world position is the same as it would be without a rotation\n");
7552 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7554 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7555 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7556 application.SendNotification();
7557 application.Render();
7558 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7560 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7561 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7562 application.SendNotification();
7563 application.Render();
7564 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7569 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7571 TestApplication application;
7572 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7574 Actor actor = Actor::New();
7575 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7576 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7577 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7578 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7579 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7580 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7581 application.GetScene().Add(actor);
7583 application.SendNotification();
7584 application.Render();
7586 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7587 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7589 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7590 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7591 application.SendNotification();
7592 application.Render();
7593 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7595 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7596 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7597 application.SendNotification();
7598 application.Render();
7599 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7604 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7606 TestApplication application;
7607 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7609 Actor parent = Actor::New();
7611 application.GetScene().Add(parent);
7612 Vector2 stageSize(application.GetScene().GetSize());
7614 Actor actor = Actor::New();
7615 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7616 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7617 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7618 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7619 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7620 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7623 application.SendNotification();
7624 application.Render();
7626 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7628 tet_infoline("Check the world position is in the right place\n");
7629 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7631 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7632 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7633 application.SendNotification();
7634 application.Render();
7635 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7637 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7638 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7639 application.SendNotification();
7640 application.Render();
7641 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7646 int utcDaliActorVisibilityChangeSignalSelf(void)
7648 TestApplication application;
7649 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7651 Actor actor = Actor::New();
7653 VisibilityChangedFunctorData data;
7654 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7656 actor.SetProperty(Actor::Property::VISIBLE, false);
7658 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7660 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7663 actor.SetProperty(Actor::Property::VISIBLE, false);
7664 data.Check(false /* not called */, TEST_LOCATION);
7666 tet_infoline("Change the visibility using properties, ensure called");
7669 actor.SetProperty(Actor::Property::VISIBLE, true);
7670 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7672 tet_infoline("Set the visibility to current using properties, ensure not called");
7675 actor.SetProperty(Actor::Property::VISIBLE, true);
7676 data.Check(false /* not called */, TEST_LOCATION);
7681 int utcDaliActorVisibilityChangeSignalChildren(void)
7683 TestApplication application;
7684 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7686 Actor parent = Actor::New();
7687 Actor child = Actor::New();
7690 Actor grandChild = Actor::New();
7691 child.Add(grandChild);
7693 VisibilityChangedFunctorData parentData;
7694 VisibilityChangedFunctorData childData;
7695 VisibilityChangedFunctorData grandChildData;
7697 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7698 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7699 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7701 parent.SetProperty(Actor::Property::VISIBLE, false);
7702 parentData.Check(false /* not called */, TEST_LOCATION);
7703 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7704 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7706 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7709 grandChildData.Reset();
7711 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7713 parent.SetProperty(Actor::Property::VISIBLE, true);
7714 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7715 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7716 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7718 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7721 grandChildData.Reset();
7723 parent.SetProperty(Actor::Property::VISIBLE, true);
7724 parentData.Check(false /* not called */, TEST_LOCATION);
7725 childData.Check(false /* not called */, TEST_LOCATION);
7726 grandChildData.Check(false /* not called */, TEST_LOCATION);
7731 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7733 TestApplication application;
7734 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7736 Actor actor = Actor::New();
7737 application.GetScene().Add(actor);
7739 application.SendNotification();
7740 application.Render();
7742 VisibilityChangedFunctorData data;
7743 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7745 Animation animation = Animation::New(1.0f);
7746 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7748 data.Check(false, TEST_LOCATION);
7749 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7750 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7752 tet_infoline("Play the animation and check the property value");
7755 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7756 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7758 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7759 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7761 application.SendNotification();
7762 application.Render(1100); // After the animation
7764 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7769 int utcDaliActorVisibilityChangeSignalByName(void)
7771 TestApplication application;
7772 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7774 Actor actor = Actor::New();
7776 bool signalCalled = false;
7777 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7778 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7779 actor.SetProperty(Actor::Property::VISIBLE, false);
7780 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7782 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7783 signalCalled = false;
7784 actor.SetProperty(Actor::Property::VISIBLE, false);
7785 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7787 tet_infoline("Change the visibility using properties, ensure called");
7788 actor.SetProperty(Actor::Property::VISIBLE, true);
7789 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7791 tet_infoline("Set the visibility to current using properties, ensure not called");
7792 signalCalled = false;
7794 actor.SetProperty(Actor::Property::VISIBLE, true);
7795 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7800 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7802 gLayoutDirectionType = type;
7805 int UtcDaliActorLayoutDirectionProperty(void)
7807 TestApplication application;
7808 tet_infoline("Check layout direction property");
7810 Actor actor0 = Actor::New();
7811 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7812 application.GetScene().Add(actor0);
7814 application.SendNotification();
7815 application.Render();
7817 Actor actor1 = Actor::New();
7818 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7819 Actor actor2 = Actor::New();
7820 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7821 Actor actor3 = Actor::New();
7822 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7823 Actor actor4 = Actor::New();
7824 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7825 Actor actor5 = Actor::New();
7826 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7827 Actor actor6 = Actor::New();
7828 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7829 Actor actor7 = Actor::New();
7830 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7831 Actor actor8 = Actor::New();
7832 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7833 Actor actor9 = Actor::New();
7834 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7837 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7838 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7840 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7841 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7842 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7844 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7845 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7846 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7848 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7850 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7851 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7853 application.GetScene().Add(actor3);
7860 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7861 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7863 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7864 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7865 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7867 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7869 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7870 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7871 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7872 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7873 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7874 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7875 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7877 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7878 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7879 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7881 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7882 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7883 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7884 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7886 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7887 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7888 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7893 struct LayoutDirectionFunctor
7895 LayoutDirectionFunctor(bool& signalCalled)
7896 : mSignalCalled(signalCalled)
7900 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7901 : mSignalCalled(rhs.mSignalCalled)
7907 mSignalCalled = true;
7910 bool& mSignalCalled;
7913 int UtcDaliActorLayoutDirectionSignal(void)
7915 TestApplication application;
7916 tet_infoline("Check changing layout direction property sends a signal");
7918 Actor actor = Actor::New();
7919 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7920 application.GetScene().Add(actor);
7921 bool signalCalled = false;
7922 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7924 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7925 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7927 // Test that writing the same value doesn't send a signal
7928 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7929 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7931 // Test that writing a different value sends the signal
7932 signalCalled = false;
7933 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7934 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7936 signalCalled = false;
7937 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7938 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7943 struct ChildAddedSignalCheck
7945 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7946 : mSignalReceived(signalReceived),
7947 mChildHandle(childHandle)
7951 void operator()(Actor childHandle)
7953 mSignalReceived = true;
7954 mChildHandle = childHandle;
7958 mSignalReceived = true;
7959 mChildHandle = Actor();
7962 bool& mSignalReceived;
7963 Actor& mChildHandle;
7966 int UtcDaliChildAddedSignalP1(void)
7968 TestApplication application;
7969 auto stage = application.GetScene();
7971 bool signalReceived = false;
7974 ChildAddedSignalCheck signal(signalReceived, childActor);
7975 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7976 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7978 auto actorA = Actor::New();
7980 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7981 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7982 signalReceived = false;
7984 auto actorB = Actor::New();
7986 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7987 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7992 int UtcDaliChildAddedSignalP2(void)
7994 TestApplication application;
7995 auto stage = application.GetScene();
7997 bool signalReceived = false;
8000 ChildAddedSignalCheck signal(signalReceived, childActor);
8001 tet_infoline("Connect to childAdded signal by name");
8003 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
8004 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8006 auto actorA = Actor::New();
8008 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8010 // Can't test which actor was added; signal signature is void() when connecting via name.
8011 signalReceived = false;
8013 auto actorB = Actor::New();
8015 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8020 int UtcDaliChildAddedSignalN(void)
8022 TestApplication application;
8023 auto stage = application.GetScene();
8025 bool signalReceived = false;
8028 ChildAddedSignalCheck signal(signalReceived, childActor);
8029 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
8030 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8032 auto actorA = Actor::New();
8034 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8035 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8036 signalReceived = false;
8038 auto actorB = Actor::New();
8040 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8044 struct ChildRemovedSignalCheck
8046 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
8047 : mSignalReceived(signalReceived),
8048 mChildHandle(childHandle)
8052 void operator()(Actor childHandle)
8054 mSignalReceived = true;
8055 mChildHandle = childHandle;
8060 mSignalReceived = true;
8063 bool& mSignalReceived;
8064 Actor& mChildHandle;
8067 int UtcDaliChildRemovedSignalP1(void)
8069 TestApplication application;
8070 auto stage = application.GetScene();
8072 bool signalReceived = false;
8075 ChildRemovedSignalCheck signal(signalReceived, childActor);
8076 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8077 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8079 auto actorA = Actor::New();
8081 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8082 DALI_TEST_CHECK(!childActor);
8084 stage.Remove(actorA);
8085 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8086 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8088 signalReceived = false;
8089 auto actorB = Actor::New();
8091 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8093 stage.Remove(actorB);
8094 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8095 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8100 int UtcDaliChildRemovedSignalP2(void)
8102 TestApplication application;
8103 auto stage = application.GetScene();
8105 bool signalReceived = false;
8108 ChildAddedSignalCheck signal(signalReceived, childActor);
8109 tet_infoline("Connect to childRemoved signal by name");
8111 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
8112 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8114 auto actorA = Actor::New();
8116 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8118 stage.Remove(actorA);
8119 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8121 signalReceived = false;
8122 auto actorB = Actor::New();
8124 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8126 stage.Remove(actorB);
8127 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8132 int UtcDaliChildRemovedSignalN(void)
8134 TestApplication application;
8135 auto stage = application.GetScene();
8137 bool signalReceived = false;
8140 ChildRemovedSignalCheck signal(signalReceived, childActor);
8141 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8142 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8144 auto actorA = Actor::New();
8147 auto actorB = Actor::New();
8150 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8151 DALI_TEST_CHECK(!childActor);
8153 actorA.Remove(actorB);
8154 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8158 int UtcDaliChildMovedSignalP(void)
8160 TestApplication application;
8161 auto stage = application.GetScene();
8163 bool addedASignalReceived = false;
8164 bool removedASignalReceived = false;
8165 bool addedBSignalReceived = false;
8166 bool removedBSignalReceived = false;
8169 auto actorA = Actor::New();
8170 auto actorB = Actor::New();
8174 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
8175 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
8176 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
8177 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
8179 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
8180 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
8181 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
8182 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
8184 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8185 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8186 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8187 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8189 // Create a child of A
8191 auto child = Actor::New();
8194 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8195 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8196 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8197 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8198 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
8201 addedASignalReceived = false;
8202 addedBSignalReceived = false;
8203 removedASignalReceived = false;
8204 removedBSignalReceived = false;
8206 actorB.Add(child); // Expect this child to be re-parented
8207 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8208 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
8209 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
8210 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8212 // Move child back to A:
8213 addedASignalReceived = false;
8214 addedBSignalReceived = false;
8215 removedASignalReceived = false;
8216 removedBSignalReceived = false;
8218 actorA.Add(child); // Expect this child to be re-parented
8219 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8220 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8221 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8222 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
8227 int UtcDaliActorSwitchParentP(void)
8229 tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
8230 TestApplication application;
8232 Actor parent1 = Actor::New();
8233 Actor child = Actor::New();
8235 application.GetScene().Add(parent1);
8237 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8239 child.OnSceneSignal().Connect(OnSceneCallback);
8240 child.OffSceneSignal().Connect(OffSceneCallback);
8243 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
8244 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8248 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
8250 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8251 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8253 Actor parent2 = Actor::New();
8254 application.GetScene().Add(parent2);
8256 bool addSignalReceived = false;
8257 ChildAddedSignalCheck addedSignal(addSignalReceived, child);
8258 DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
8259 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8261 bool removedSignalReceived = false;
8262 ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
8263 DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
8264 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8266 DevelActor::SwitchParent(child, parent2);
8268 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8269 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8271 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8272 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
8274 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8275 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8276 DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
8277 DALI_TEST_CHECK(child.GetParent() == parent2);
8282 int utcDaliActorCulled(void)
8284 TestApplication application;
8285 auto stage = application.GetScene();
8287 tet_infoline("Check that the actor is culled if the actor is out of the screen");
8289 Actor actor = Actor::New();
8290 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
8292 Geometry geometry = CreateQuadGeometry();
8293 Shader shader = CreateShader();
8294 Renderer renderer = Renderer::New(geometry, shader);
8295 actor.AddRenderer(renderer);
8299 application.SendNotification();
8300 application.Render(0);
8302 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
8304 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
8305 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
8307 // Connect NotifySignal
8308 bool propertyNotificationSignal(false);
8309 PropertyNotification source;
8310 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
8311 notification.NotifySignal().Connect(&application, f);
8313 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
8315 application.SendNotification();
8316 application.Render();
8318 application.SendNotification();
8320 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
8322 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
8323 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
8324 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
8329 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
8331 TestApplication application;
8332 auto stage = application.GetScene();
8334 tet_infoline("Ensure we clear the screen when the last actor is removed");
8336 Actor actor = CreateRenderableActor();
8337 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8340 application.SendNotification();
8341 application.Render();
8343 auto& glAbstraction = application.GetGlAbstraction();
8344 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8348 application.SendNotification();
8349 application.Render();
8351 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8356 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
8358 TestApplication application;
8359 auto stage = application.GetScene();
8361 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
8363 Actor actor = CreateRenderableActor();
8364 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8367 application.SendNotification();
8368 application.Render();
8370 auto& glAbstraction = application.GetGlAbstraction();
8371 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8373 actor.SetProperty(Actor::Property::VISIBLE, false);
8375 application.SendNotification();
8376 application.Render();
8378 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8383 int utcDaliActorGetSizeAfterAnimation(void)
8385 TestApplication application;
8386 tet_infoline("Check the actor size before / after an animation is finished");
8388 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8390 Actor actor = Actor::New();
8391 actor.SetProperty(Actor::Property::SIZE, actorSize);
8392 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8393 application.GetScene().Add(actor);
8395 // Size should be updated without rendering.
8396 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8397 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8399 application.SendNotification();
8400 application.Render();
8402 // Size and current size should be updated.
8403 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8404 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8405 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8406 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8407 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8409 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8410 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8411 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8412 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8413 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8416 actorSize = Vector3(200.0f, 200.0f, 0.0f);
8417 actor.SetProperty(Actor::Property::SIZE, actorSize);
8419 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8420 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8422 Vector3 targetValue(10.0f, 20.0f, 0.0f);
8424 Animation animation = Animation::New(1.0f);
8425 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8428 // Size should be updated without rendering.
8429 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8430 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8432 application.SendNotification();
8433 application.Render(1100); // After the animation
8435 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8436 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8437 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8438 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8439 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8441 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8442 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8443 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8444 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8445 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8447 targetValue.width = 50.0f;
8450 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8453 application.SendNotification();
8454 application.Render(1100); // After the animation
8456 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8457 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8458 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8459 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8460 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8462 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8463 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8464 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8465 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8466 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8468 targetValue.height = 70.0f;
8471 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8474 application.SendNotification();
8475 application.Render(1100); // After the animation
8477 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8478 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8479 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8480 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8481 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8483 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8484 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8485 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8486 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8487 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8489 Vector3 offset(10.0f, 20.0f, 0.0f);
8492 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8495 application.SendNotification();
8496 application.Render(1100); // After the animation
8498 targetValue += offset;
8500 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8501 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8502 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8503 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8504 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8506 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8507 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8508 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8509 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8510 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8512 offset.width = 20.0f;
8515 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8518 application.SendNotification();
8519 application.Render(1100); // After the animation
8521 targetValue.width += offset.width;
8523 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8524 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8525 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8526 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8527 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8529 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8530 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8531 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8532 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8533 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8535 offset.height = 10.0f;
8538 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8541 application.SendNotification();
8542 application.Render(1100); // After the animation
8544 targetValue.height += offset.height;
8546 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8547 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8548 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8549 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8550 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8552 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8553 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8554 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8555 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8556 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8559 actorSize = Vector3(300.0f, 300.0f, 0.0f);
8561 actor.SetProperty(Actor::Property::SIZE, actorSize);
8563 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8564 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8566 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8567 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8569 application.SendNotification();
8570 application.Render();
8572 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8573 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8575 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8576 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8581 int utcDaliActorRelayoutAndAnimation(void)
8583 TestApplication application;
8584 tet_infoline("Check the actor size when relayoutting and playing animation");
8586 Vector3 parentSize(300.0f, 300.0f, 0.0f);
8587 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8590 Actor parentA = Actor::New();
8591 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8592 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8593 application.GetScene().Add(parentA);
8595 Actor parentB = Actor::New();
8596 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8597 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8598 application.GetScene().Add(parentB);
8600 Actor actor = Actor::New();
8601 actor.SetProperty(Actor::Property::SIZE, actorSize);
8602 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8605 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8606 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8608 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8610 Animation animation = Animation::New(1.0f);
8611 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8614 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8615 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8617 application.SendNotification();
8618 application.Render(1100); // After the animation
8620 // Size and current size should be updated.
8621 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8622 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8624 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8625 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8630 application.SendNotification();
8631 application.Render();
8633 // Size and current size should be same.
8634 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8635 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8637 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8638 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8646 Actor parentA = Actor::New();
8647 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8648 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8649 application.GetScene().Add(parentA);
8651 Actor parentB = Actor::New();
8652 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8653 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8654 application.GetScene().Add(parentB);
8656 Actor actor = Actor::New();
8657 actor.SetProperty(Actor::Property::SIZE, actorSize);
8658 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8661 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8662 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8664 application.SendNotification();
8665 application.Render();
8667 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8668 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8670 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8671 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8673 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8675 // Make an animation
8676 Animation animation = Animation::New(1.0f);
8677 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8680 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8681 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8683 application.SendNotification();
8684 application.Render(1100); // After the animation
8686 // Size and current size should be updated.
8687 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8688 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8690 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8691 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8696 application.SendNotification();
8697 application.Render();
8699 // Size and current size should be same.
8700 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8701 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8703 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8704 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8714 int utcDaliActorPartialUpdate(void)
8716 TestApplication application(
8717 TestApplication::DEFAULT_SURFACE_WIDTH,
8718 TestApplication::DEFAULT_SURFACE_HEIGHT,
8719 TestApplication::DEFAULT_HORIZONTAL_DPI,
8720 TestApplication::DEFAULT_VERTICAL_DPI,
8724 tet_infoline("Check the damaged area");
8726 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8728 std::vector<Rect<int>> damagedRects;
8729 Rect<int> clippingRect;
8730 application.SendNotification();
8731 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8733 // First render pass, nothing to render, adaptor would just do swap buffer.
8734 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8736 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8737 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8739 Actor actor = CreateRenderableActor();
8740 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8741 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8742 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8743 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8744 application.GetScene().Add(actor);
8746 application.SendNotification();
8748 // 1. Actor added, damaged rect is added size of actor
8749 damagedRects.clear();
8750 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8751 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8754 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8755 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8756 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8757 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8758 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8759 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8760 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8763 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8764 application.SendNotification();
8766 damagedRects.clear();
8767 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8768 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8771 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates
8772 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8773 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8774 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8775 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8776 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8777 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8779 // 3. Set new position
8780 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8781 application.SendNotification();
8783 damagedRects.clear();
8784 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8785 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8788 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates
8789 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8790 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8791 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8792 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8793 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8794 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8796 application.GetScene().Remove(actor);
8797 application.SendNotification();
8799 // Actor removed, last a dirty rect is reported.
8800 damagedRects.clear();
8801 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8802 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8804 clippingRect = damagedRects[0];
8806 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8807 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
8809 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8810 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8811 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8812 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8813 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8818 int utcDaliActorPartialUpdateSetColor(void)
8820 TestApplication application(
8821 TestApplication::DEFAULT_SURFACE_WIDTH,
8822 TestApplication::DEFAULT_SURFACE_HEIGHT,
8823 TestApplication::DEFAULT_HORIZONTAL_DPI,
8824 TestApplication::DEFAULT_VERTICAL_DPI,
8828 tet_infoline("Check uniform update");
8830 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8832 std::vector<Rect<int>> damagedRects;
8833 Rect<int> clippingRect;
8834 application.SendNotification();
8835 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8837 // First render pass, nothing to render, adaptor would just do swap buffer.
8838 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8840 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8841 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8843 Actor actor = CreateRenderableActor();
8844 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8845 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8846 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8847 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8848 application.GetScene().Add(actor);
8850 application.SendNotification();
8852 // 1. Actor added, damaged rect is added size of actor
8853 damagedRects.clear();
8854 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8855 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8858 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8859 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8860 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8861 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8862 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8863 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8864 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8866 damagedRects.clear();
8867 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8868 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8870 damagedRects.clear();
8871 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8872 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8875 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8876 application.SendNotification();
8878 damagedRects.clear();
8879 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8880 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8883 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8884 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8885 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8886 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8887 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8888 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8889 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8894 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8895 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8896 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8897 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8898 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8899 " uniform mediump mat4 uLightCameraViewMatrix;\n"
8903 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8904 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
8905 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8908 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8909 "uniform lowp vec4 uShadowColor;\n"
8912 " lowp float alpha;\n"
8913 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8914 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8917 int utcDaliActorPartialUpdateSetProperty(void)
8919 TestApplication application(
8920 TestApplication::DEFAULT_SURFACE_WIDTH,
8921 TestApplication::DEFAULT_SURFACE_HEIGHT,
8922 TestApplication::DEFAULT_HORIZONTAL_DPI,
8923 TestApplication::DEFAULT_VERTICAL_DPI,
8927 tet_infoline("Set/Update property with partial update");
8929 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8931 std::vector<Rect<int>> damagedRects;
8932 Rect<int> clippingRect;
8933 application.SendNotification();
8934 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8936 // First render pass, nothing to render, adaptor would just do swap buffer.
8937 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8939 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8940 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8942 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8943 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8944 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8945 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8946 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8947 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8948 application.GetScene().Add(actor);
8950 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8952 damagedRects.clear();
8953 application.SendNotification();
8954 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8955 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8958 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
8959 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8960 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8961 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8962 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8963 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8964 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8966 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8967 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8969 damagedRects.clear();
8970 application.SendNotification();
8971 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8972 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8974 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8975 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8976 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8977 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8978 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8979 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8981 // Should be no damage rects, nothing changed
8982 damagedRects.clear();
8983 application.SendNotification();
8984 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8985 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8987 // Should be 1 damage rect due to change in size
8988 damagedRects.clear();
8989 actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8990 application.SendNotification();
8991 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8992 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8994 clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8995 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
8996 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8997 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8998 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8999 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9000 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9002 damagedRects.clear();
9003 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9004 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9009 int utcDaliActorPartialUpdateTwoActors(void)
9011 TestApplication application(
9012 TestApplication::DEFAULT_SURFACE_WIDTH,
9013 TestApplication::DEFAULT_SURFACE_HEIGHT,
9014 TestApplication::DEFAULT_HORIZONTAL_DPI,
9015 TestApplication::DEFAULT_VERTICAL_DPI,
9019 tet_infoline("Check the damaged rects with partial update and two actors");
9021 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9023 Actor actor = CreateRenderableActor();
9024 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
9025 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
9026 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9027 application.GetScene().Add(actor);
9029 Actor actor2 = CreateRenderableActor();
9030 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
9031 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
9032 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9033 application.GetScene().Add(actor2);
9035 application.SendNotification();
9036 std::vector<Rect<int>> damagedRects;
9037 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9039 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9040 DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64), Rect<int>(96, 592, 112, 112)}, true, TEST_LOCATION);
9042 // in screen coordinates, adaptor would calculate it using previous frames information
9043 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
9044 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9046 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9047 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9048 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9049 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9051 // Change a Renderer of actor1
9052 Geometry geometry = CreateQuadGeometry();
9053 Shader shader = CreateShader();
9054 Renderer newRenderer = Renderer::New(geometry, shader);
9055 Renderer renderer = actor.GetRendererAt(0);
9057 actor.RemoveRenderer(renderer);
9058 actor.AddRenderer(newRenderer);
9060 damagedRects.clear();
9062 application.SendNotification();
9063 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9065 DALI_TEST_CHECK(damagedRects.size() > 0);
9066 DirtyRectChecker(damagedRects, {Rect<int>(64, 672, 64, 64)}, false, TEST_LOCATION);
9068 // in screen coordinates, adaptor would calculate it using previous frames information
9069 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9071 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9072 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9073 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9074 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9079 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
9081 TestApplication application(
9082 TestApplication::DEFAULT_SURFACE_WIDTH,
9083 TestApplication::DEFAULT_SURFACE_HEIGHT,
9084 TestApplication::DEFAULT_HORIZONTAL_DPI,
9085 TestApplication::DEFAULT_VERTICAL_DPI,
9089 tet_infoline("Check the damaged rect with partial update and update area hint");
9091 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9093 Actor actor = CreateRenderableActor();
9094 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9095 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9096 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9097 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9098 application.GetScene().Add(actor);
9100 application.SendNotification();
9101 std::vector<Rect<int>> damagedRects;
9102 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9104 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9106 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9107 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9109 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9111 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9112 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9113 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9114 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9119 damagedRects.clear();
9120 application.SendNotification();
9121 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9123 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9124 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9126 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9128 damagedRects.clear();
9129 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9130 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9132 // Ensure the damaged rect is empty
9133 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9135 // Chnage UPDATE_AREA_HINT
9136 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
9137 application.GetScene().Add(actor);
9139 application.SendNotification();
9140 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9142 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9144 clippingRect = Rect<int>(64, 704, 48, 48);
9145 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9147 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9149 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9150 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9151 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9152 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9157 damagedRects.clear();
9158 application.SendNotification();
9159 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9161 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9162 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9164 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9166 damagedRects.clear();
9167 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9168 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9170 // Ensure the damaged rect is empty
9171 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9173 // Chnage UPDATE_AREA_HINT
9174 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
9175 application.GetScene().Add(actor);
9177 application.SendNotification();
9178 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9180 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9182 clippingRect = Rect<int>(0, 720, 80, 80);
9183 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9185 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9187 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9188 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9189 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9190 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9195 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
9197 TestApplication application(
9198 TestApplication::DEFAULT_SURFACE_WIDTH,
9199 TestApplication::DEFAULT_SURFACE_HEIGHT,
9200 TestApplication::DEFAULT_HORIZONTAL_DPI,
9201 TestApplication::DEFAULT_VERTICAL_DPI,
9205 tet_infoline("Check the damaged rect with partial update and update area hint");
9207 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9209 Actor actor = CreateRenderableActor();
9210 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9211 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9212 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9213 application.GetScene().Add(actor);
9215 application.SendNotification();
9216 std::vector<Rect<int>> damagedRects;
9217 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9219 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9221 Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
9222 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9224 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9226 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9227 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9228 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9229 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9231 damagedRects.clear();
9232 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9233 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9235 // Ensure the damaged rect is empty
9236 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9238 // Change UPDATE_AREA_HINT
9239 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9241 application.SendNotification();
9242 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9244 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9246 clippingRect = Rect<int>(32, 704, 80, 80);
9247 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9249 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9251 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9252 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9253 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9254 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9256 damagedRects.clear();
9257 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9258 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9260 // Ensure the damaged rect is empty
9261 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9263 // Chnage UPDATE_AREA_HINT
9264 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
9265 application.GetScene().Add(actor);
9267 application.SendNotification();
9268 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9270 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9272 clippingRect = Rect<int>(32, 688, 96, 96);
9273 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9275 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9277 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9278 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9279 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9280 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9285 int utcDaliActorPartialUpdateActorsWithSizeHint03(void)
9287 TestApplication application(
9288 TestApplication::DEFAULT_SURFACE_WIDTH,
9289 TestApplication::DEFAULT_SURFACE_HEIGHT,
9290 TestApplication::DEFAULT_HORIZONTAL_DPI,
9291 TestApplication::DEFAULT_VERTICAL_DPI,
9295 tet_infoline("Check the damaged rect with partial update and update area hint");
9297 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9299 Actor actor = CreateRenderableActor();
9300 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9301 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9302 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9303 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9304 application.GetScene().Add(actor);
9306 application.SendNotification();
9307 std::vector<Rect<int>> damagedRects;
9308 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9310 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9312 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9313 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9315 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9317 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9318 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9319 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9320 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9322 damagedRects.clear();
9323 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9324 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9326 // Ensure the damaged rect is empty
9327 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9329 // Set UPDATE_AREA_HINT twice before rendering
9330 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 32.0f, 32.0f));
9331 application.SendNotification();
9333 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(32.0f, -32.0f, 32.0f, 32.0f));
9334 application.SendNotification();
9336 damagedRects.clear();
9337 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9339 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9341 clippingRect = Rect<int>(32, 704, 96, 96);
9342 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9344 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9346 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9347 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9348 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9349 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9354 int utcDaliActorPartialUpdateAnimation(void)
9356 TestApplication application(
9357 TestApplication::DEFAULT_SURFACE_WIDTH,
9358 TestApplication::DEFAULT_SURFACE_HEIGHT,
9359 TestApplication::DEFAULT_HORIZONTAL_DPI,
9360 TestApplication::DEFAULT_VERTICAL_DPI,
9364 tet_infoline("Check the damaged area with partial update and animation");
9366 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9367 drawTrace.Enable(true);
9370 Actor actor1 = CreateRenderableActor();
9371 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9372 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9373 application.GetScene().Add(actor1);
9375 Actor actor2 = CreateRenderableActor();
9376 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9377 actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9378 application.GetScene().Add(actor2);
9380 std::vector<Rect<int>> damagedRects;
9381 Rect<int> clippingRect;
9382 Rect<int> expectedRect1, expectedRect2;
9384 application.SendNotification();
9385 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9387 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9390 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates
9391 expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates
9392 DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION);
9394 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9395 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9397 // Make an animation
9398 Animation animation = Animation::New(1.0f);
9399 animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
9402 application.SendNotification();
9404 damagedRects.clear();
9405 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9406 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9407 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9410 damagedRects.clear();
9412 // In animation deley time
9413 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9414 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9415 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9418 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9421 damagedRects.clear();
9423 // Also in animation deley time
9424 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9425 application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
9426 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9429 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9431 // Unparent 2 actors and make a new actor
9435 Actor actor3 = CreateRenderableActor();
9436 actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9437 actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9438 application.GetScene().Add(actor3);
9440 application.SendNotification();
9442 // Started animation
9443 damagedRects.clear();
9444 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9445 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
9447 // One of dirty rect is actor3's.
9448 // We don't know the exact dirty rect of actor1 and actor2.
9449 DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION);
9451 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9452 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9454 // Finished animation, but the actor was already unparented
9455 damagedRects.clear();
9456 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9458 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9460 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9461 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9466 int utcDaliActorPartialUpdateChangeVisibility(void)
9468 TestApplication application(
9469 TestApplication::DEFAULT_SURFACE_WIDTH,
9470 TestApplication::DEFAULT_SURFACE_HEIGHT,
9471 TestApplication::DEFAULT_HORIZONTAL_DPI,
9472 TestApplication::DEFAULT_VERTICAL_DPI,
9476 tet_infoline("Check the damaged rect with partial update and visibility change");
9478 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9480 Actor actor = CreateRenderableActor();
9481 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9482 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9483 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9484 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9485 application.GetScene().Add(actor);
9487 application.SendNotification();
9489 std::vector<Rect<int>> damagedRects;
9490 Rect<int> clippingRect;
9492 // 1. Actor added, damaged rect is added size of actor
9493 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9494 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9497 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9498 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9499 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9500 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9501 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9502 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9503 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9505 damagedRects.clear();
9506 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9507 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9509 // Ensure the damaged rect is empty
9510 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9512 // 2. Make the Actor invisible
9513 actor.SetProperty(Actor::Property::VISIBLE, false);
9514 application.SendNotification();
9516 damagedRects.clear();
9517 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9518 DALI_TEST_CHECK(damagedRects.size() > 0);
9519 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9521 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9522 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9523 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9524 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9525 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9527 // 3. Make the Actor visible again
9528 actor.SetProperty(Actor::Property::VISIBLE, true);
9529 application.SendNotification();
9531 damagedRects.clear();
9532 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9533 DALI_TEST_CHECK(damagedRects.size() > 0);
9534 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9536 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9537 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9538 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9539 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9540 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9545 int utcDaliActorPartialUpdateOnOffScene(void)
9547 TestApplication application(
9548 TestApplication::DEFAULT_SURFACE_WIDTH,
9549 TestApplication::DEFAULT_SURFACE_HEIGHT,
9550 TestApplication::DEFAULT_HORIZONTAL_DPI,
9551 TestApplication::DEFAULT_VERTICAL_DPI,
9555 tet_infoline("Check the damaged rect with partial update and on/off scene");
9557 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9559 Actor actor = CreateRenderableActor();
9560 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9561 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9562 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9563 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9564 application.GetScene().Add(actor);
9566 application.SendNotification();
9568 std::vector<Rect<int>> damagedRects;
9569 Rect<int> clippingRect;
9571 // 1. Actor added, damaged rect is added size of actor
9572 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9573 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9576 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9577 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9578 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9579 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9580 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9581 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9582 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9584 damagedRects.clear();
9585 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9586 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9588 damagedRects.clear();
9589 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9590 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9592 // Ensure the damaged rect is empty
9593 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9595 // 2. Remove the Actor from the Scene
9597 application.SendNotification();
9599 damagedRects.clear();
9600 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9601 DALI_TEST_CHECK(damagedRects.size() > 0);
9602 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9604 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9605 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9606 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9607 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9608 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9610 // 3. Add the Actor to the Scene again
9611 application.GetScene().Add(actor);
9612 application.SendNotification();
9614 damagedRects.clear();
9615 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9616 DALI_TEST_CHECK(damagedRects.size() > 0);
9617 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9619 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9620 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9621 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9622 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9623 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9628 int utcDaliActorPartialUpdateSkipRendering(void)
9630 TestApplication application(
9631 TestApplication::DEFAULT_SURFACE_WIDTH,
9632 TestApplication::DEFAULT_SURFACE_HEIGHT,
9633 TestApplication::DEFAULT_HORIZONTAL_DPI,
9634 TestApplication::DEFAULT_VERTICAL_DPI,
9638 tet_infoline("Check to skip rendering in case of the empty damaged rect");
9640 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9641 drawTrace.Enable(true);
9644 Actor actor1 = CreateRenderableActor();
9645 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9646 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9647 application.GetScene().Add(actor1);
9649 std::vector<Rect<int>> damagedRects;
9650 Rect<int> clippingRect;
9651 Rect<int> expectedRect1;
9653 application.SendNotification();
9654 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9656 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9659 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates
9660 DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9662 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9663 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9665 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9667 damagedRects.clear();
9668 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9669 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9670 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9675 application.SendNotification();
9677 damagedRects.clear();
9678 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9680 DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9682 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9683 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9685 // Render again without any change
9686 damagedRects.clear();
9688 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9690 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9692 clippingRect = Rect<int>();
9693 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9696 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9698 // Add the actor again
9699 application.GetScene().Add(actor1);
9701 application.SendNotification();
9703 damagedRects.clear();
9705 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9707 DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION);
9709 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9710 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9712 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9717 int utcDaliActorPartialUpdate3DNode(void)
9719 TestApplication application(
9720 TestApplication::DEFAULT_SURFACE_WIDTH,
9721 TestApplication::DEFAULT_SURFACE_HEIGHT,
9722 TestApplication::DEFAULT_HORIZONTAL_DPI,
9723 TestApplication::DEFAULT_VERTICAL_DPI,
9727 tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9729 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9730 drawTrace.Enable(true);
9733 Actor actor1 = CreateRenderableActor();
9734 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9735 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9736 application.GetScene().Add(actor1);
9738 std::vector<Rect<int>> damagedRects;
9739 Rect<int> clippingRect;
9741 application.SendNotification();
9742 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9744 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9746 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9747 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9749 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9751 // Change the layer to 3D
9752 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9754 application.SendNotification();
9756 damagedRects.clear();
9757 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9759 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9760 DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9762 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9764 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9766 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9768 // Change the layer to 2D
9769 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9771 application.SendNotification();
9773 damagedRects.clear();
9774 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9776 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9778 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9779 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9781 // Make 3D transform
9782 actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9784 application.SendNotification();
9786 damagedRects.clear();
9787 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9789 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9790 DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION);
9792 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9794 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9796 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9801 int utcDaliActorPartialUpdateNotRenderableActor(void)
9803 TestApplication application(
9804 TestApplication::DEFAULT_SURFACE_WIDTH,
9805 TestApplication::DEFAULT_SURFACE_HEIGHT,
9806 TestApplication::DEFAULT_HORIZONTAL_DPI,
9807 TestApplication::DEFAULT_VERTICAL_DPI,
9811 tet_infoline("Check the damaged rect with not renderable parent actor");
9813 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9815 Actor parent = Actor::New();
9816 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9817 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9818 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9819 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9820 application.GetScene().Add(parent);
9822 Actor child = CreateRenderableActor();
9823 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9824 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9825 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9828 application.SendNotification();
9830 std::vector<Rect<int>> damagedRects;
9832 // 1. Actor added, damaged rect is added size of actor
9833 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9834 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9837 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9838 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9840 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9841 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9842 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9843 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9844 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9846 damagedRects.clear();
9847 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9848 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9850 damagedRects.clear();
9851 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9852 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9854 // Ensure the damaged rect is empty
9855 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9860 int utcDaliActorPartialUpdateChangeTransparency(void)
9862 TestApplication application(
9863 TestApplication::DEFAULT_SURFACE_WIDTH,
9864 TestApplication::DEFAULT_SURFACE_HEIGHT,
9865 TestApplication::DEFAULT_HORIZONTAL_DPI,
9866 TestApplication::DEFAULT_VERTICAL_DPI,
9870 tet_infoline("Check the damaged rect with changing transparency");
9872 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9874 Actor actor = CreateRenderableActor();
9875 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9876 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9877 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9878 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9879 application.GetScene().Add(actor);
9881 application.SendNotification();
9883 std::vector<Rect<int>> damagedRects;
9885 // Actor added, damaged rect is added size of actor
9886 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9887 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9890 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9891 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9893 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9894 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9895 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9896 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9897 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9899 damagedRects.clear();
9900 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9901 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9903 // Ensure the damaged rect is empty
9904 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9906 // Make the actor transparent by changing opacity of the Renderer
9907 // It changes a uniform value
9908 Renderer renderer = actor.GetRendererAt(0);
9909 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9911 application.SendNotification();
9913 // The damaged rect should be same
9914 damagedRects.clear();
9915 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9916 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9917 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9918 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9920 damagedRects.clear();
9921 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9922 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9924 // Ensure the damaged rect is empty
9925 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9927 // Make the actor opaque again
9928 renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9930 application.SendNotification();
9932 // The damaged rect should not be empty
9933 damagedRects.clear();
9934 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9935 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9936 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9937 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9939 damagedRects.clear();
9940 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9941 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9943 // Ensure the damaged rect is empty
9944 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9946 // Make the actor translucent
9947 renderer[DevelRenderer::Property::OPACITY] = 0.5f;
9949 application.SendNotification();
9951 // The damaged rect should not be empty
9952 damagedRects.clear();
9953 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9954 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9955 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9956 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9958 damagedRects.clear();
9959 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9960 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9962 // Ensure the damaged rect is empty
9963 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9965 // Change Renderer opacity - also translucent
9966 renderer[DevelRenderer::Property::OPACITY] = 0.2f;
9968 application.SendNotification();
9970 // The damaged rect should not be empty
9971 damagedRects.clear();
9972 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9973 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9974 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
9975 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9977 damagedRects.clear();
9978 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9979 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9981 // Ensure the damaged rect is empty
9982 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9984 // Make the actor culled
9985 actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9987 application.SendNotification();
9989 // The damaged rect should be same
9990 damagedRects.clear();
9991 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9992 DALI_TEST_CHECK(damagedRects.size() > 0);
9993 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
9994 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9996 damagedRects.clear();
9997 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9998 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10000 // Ensure the damaged rect is empty
10001 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10003 // Make the actor not culled again
10004 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
10006 application.SendNotification();
10008 // The damaged rect should not be empty
10009 damagedRects.clear();
10010 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10011 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10012 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10013 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10018 int utcDaliActorPartialUpdateChangeParentOpacity(void)
10020 TestApplication application(
10021 TestApplication::DEFAULT_SURFACE_WIDTH,
10022 TestApplication::DEFAULT_SURFACE_HEIGHT,
10023 TestApplication::DEFAULT_HORIZONTAL_DPI,
10024 TestApplication::DEFAULT_VERTICAL_DPI,
10028 tet_infoline("Check the damaged rect with changing parent's opacity");
10030 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10032 Actor parent = Actor::New();
10033 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10034 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10035 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10036 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10037 application.GetScene().Add(parent);
10039 Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
10040 Actor child = CreateRenderableActor(texture);
10041 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10042 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10043 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10046 application.SendNotification();
10048 std::vector<Rect<int>> damagedRects;
10050 // Actor added, damaged rect is added size of actor
10051 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10052 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10055 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10056 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10058 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10059 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10060 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10061 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10062 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10064 damagedRects.clear();
10065 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10066 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10068 damagedRects.clear();
10069 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10070 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10072 // Ensure the damaged rect is empty
10073 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10075 // Change the parent's opacity
10076 parent[Actor::Property::OPACITY] = 0.5f;
10078 application.SendNotification();
10080 // The damaged rect should be same
10081 damagedRects.clear();
10082 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10083 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10084 DALI_TEST_CHECK(damagedRects.size() > 0);
10085 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10090 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
10092 TestApplication application(
10093 TestApplication::DEFAULT_SURFACE_WIDTH,
10094 TestApplication::DEFAULT_SURFACE_HEIGHT,
10095 TestApplication::DEFAULT_HORIZONTAL_DPI,
10096 TestApplication::DEFAULT_VERTICAL_DPI,
10100 tet_infoline("Check the damaged rect with adding / removing renderer");
10102 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10104 Actor actor = CreateRenderableActor();
10105 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10106 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10107 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10108 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10109 application.GetScene().Add(actor);
10111 application.SendNotification();
10113 std::vector<Rect<int>> damagedRects;
10115 // Actor added, damaged rect is added size of actor
10116 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10117 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10120 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10121 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10123 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10124 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10125 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10126 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10127 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10129 damagedRects.clear();
10130 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10131 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10133 damagedRects.clear();
10134 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10135 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10137 // Remove the Renderer
10138 Renderer renderer = actor.GetRendererAt(0);
10139 actor.RemoveRenderer(renderer);
10141 application.SendNotification();
10143 // The damaged rect should be the actor area
10144 damagedRects.clear();
10145 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10146 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10147 DALI_TEST_CHECK(damagedRects.size() > 0);
10148 DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION);
10150 damagedRects.clear();
10151 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10152 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10154 // Ensure the damaged rect is empty
10155 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10157 // Add the Renderer again
10158 actor.AddRenderer(renderer);
10160 application.SendNotification();
10162 // The damaged rect should be the actor area
10163 damagedRects.clear();
10164 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10165 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10166 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10167 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10172 int utcDaliActorPartialUpdate3DTransform(void)
10174 TestApplication application(
10175 TestApplication::DEFAULT_SURFACE_WIDTH,
10176 TestApplication::DEFAULT_SURFACE_HEIGHT,
10177 TestApplication::DEFAULT_HORIZONTAL_DPI,
10178 TestApplication::DEFAULT_VERTICAL_DPI,
10182 tet_infoline("Check the damaged rect with 3D transformed actors");
10184 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10186 Actor actor1 = CreateRenderableActor();
10187 actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10188 actor1[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10189 actor1[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10190 actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10191 application.GetScene().Add(actor1);
10194 Actor actor2 = CreateRenderableActor();
10195 actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10196 actor2[Actor::Property::POSITION] = Vector3(160.0f, 160.0f, 0.0f);
10197 actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10198 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10199 application.GetScene().Add(actor2);
10201 application.SendNotification();
10203 std::vector<Rect<int>> damagedRects;
10205 // Actor added, damaged rect is added size of actor
10206 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10207 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10210 Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
10211 Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
10212 DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION);
10214 Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10215 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10217 damagedRects.clear();
10218 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10219 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10220 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10222 damagedRects.clear();
10223 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10224 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10225 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10227 // Rotate actor1 on y axis
10228 actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10233 application.SendNotification();
10235 damagedRects.clear();
10236 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10238 // Should update full area
10239 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10240 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10241 DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10242 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10244 // Add actor2 again
10245 application.GetScene().Add(actor2);
10247 application.SendNotification();
10249 damagedRects.clear();
10250 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10252 // Should update full area
10253 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10254 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10255 DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10256 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10258 // Reset the orientation of actor1
10259 actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
10261 application.SendNotification();
10263 damagedRects.clear();
10264 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10266 // Should update full area
10267 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10268 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10269 DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10270 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10272 // Make actor2 dirty
10273 actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
10275 application.SendNotification();
10277 damagedRects.clear();
10278 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10280 clippingRect2 = Rect<int>(160, 608, 48, 48);
10281 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10282 DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION);
10284 application.RenderWithPartialUpdate(damagedRects, clippingRect2);
10285 DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
10286 DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
10287 DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
10288 DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
10293 application.SendNotification();
10295 damagedRects.clear();
10296 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10297 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10298 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10300 // Rotate actor1 on y axis
10301 actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10303 // Add actor1 again
10304 application.GetScene().Add(actor1);
10306 application.SendNotification();
10308 damagedRects.clear();
10309 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10311 // Should update full area
10312 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10313 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10314 DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION);
10315 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10320 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
10322 TestApplication application(
10323 TestApplication::DEFAULT_SURFACE_WIDTH,
10324 TestApplication::DEFAULT_SURFACE_HEIGHT,
10325 TestApplication::DEFAULT_HORIZONTAL_DPI,
10326 TestApplication::DEFAULT_VERTICAL_DPI,
10330 tet_infoline("Check the damaged rect with one actor which has multiple renderers");
10332 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10334 Actor actor = CreateRenderableActor();
10336 // Create another renderer
10337 Geometry geometry = CreateQuadGeometry();
10338 Shader shader = CreateShader();
10339 Renderer renderer2 = Renderer::New(geometry, shader);
10340 actor.AddRenderer(renderer2);
10342 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10343 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10344 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10345 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10346 application.GetScene().Add(actor);
10348 application.SendNotification();
10350 DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
10352 std::vector<Rect<int>> damagedRects;
10354 // Actor added, damaged rect is added size of actor
10355 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10356 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10359 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10360 DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10362 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10363 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10364 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10365 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10366 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10368 damagedRects.clear();
10369 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10370 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10372 // Ensure the damaged rect is empty
10373 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10375 // Make renderer2 dirty
10376 renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
10378 application.SendNotification();
10380 // The damaged rect should be the actor area
10381 damagedRects.clear();
10382 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10384 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10385 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10386 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10388 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10390 damagedRects.clear();
10391 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10392 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10394 // Ensure the damaged rect is empty
10395 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10397 // Make renderer2 dirty
10398 renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
10400 application.SendNotification();
10402 // The damaged rect should be the actor area
10403 damagedRects.clear();
10404 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10406 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10407 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10408 DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
10410 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10412 damagedRects.clear();
10413 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10414 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10416 // Ensure the damaged rect is empty
10417 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10422 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
10424 TestApplication application(
10425 TestApplication::DEFAULT_SURFACE_WIDTH,
10426 TestApplication::DEFAULT_SURFACE_HEIGHT,
10427 TestApplication::DEFAULT_HORIZONTAL_DPI,
10428 TestApplication::DEFAULT_VERTICAL_DPI,
10432 tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
10434 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10436 Actor actor = CreateRenderableActor();
10437 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10438 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10439 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10440 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10441 application.GetScene().Add(actor);
10443 // Create another actor which has the same renderer with actor1
10444 Actor actor2 = Actor::New();
10445 Renderer renderer = actor.GetRendererAt(0);
10446 actor2.AddRenderer(renderer);
10447 actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10448 actor2[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10449 actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10450 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10451 application.GetScene().Add(actor2);
10453 application.SendNotification();
10455 std::vector<Rect<int>> damagedRects;
10457 // Actor added, damaged rect is added size of actor
10458 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10459 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10462 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10463 DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10465 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10466 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10467 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10468 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10469 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10471 damagedRects.clear();
10472 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10473 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10475 // Ensure the damaged rect is empty
10476 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10478 // Make renderer dirty
10479 renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10481 application.SendNotification();
10483 // The damaged rect should be the actor area
10484 damagedRects.clear();
10485 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10487 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10488 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10489 DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION);
10491 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10493 damagedRects.clear();
10494 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10495 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10497 // Ensure the damaged rect is empty
10498 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10503 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
10505 TestApplication application;
10507 Actor actor = Actor::New();
10508 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
10509 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
10510 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
10511 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
10512 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
10513 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10514 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10515 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
10519 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
10521 TestApplication application;
10523 Actor actor = Actor::New();
10525 // Make sure setting invalid types does not cause a crash
10528 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
10529 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
10530 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
10531 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
10532 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
10533 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
10534 tet_result(TET_PASS);
10538 tet_result(TET_FAIL);
10543 int UtcDaliActorTouchAreaOffsetPropertyP(void)
10545 TestApplication application;
10547 Actor actor = Actor::New();
10548 Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10549 DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
10550 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
10551 touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10552 DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
10556 int UtcDaliActorTouchAreaOffsetPropertyN(void)
10558 TestApplication application;
10560 Actor actor = Actor::New();
10562 // Make sure setting invalid types does not cause a crash
10565 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
10566 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
10567 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
10568 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
10569 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
10570 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
10571 tet_result(TET_PASS);
10575 tet_result(TET_FAIL);
10580 int UtcDaliActorLowerBelowNegative(void)
10582 TestApplication application;
10583 Dali::Actor instance;
10587 instance.LowerBelow(arg1);
10588 DALI_TEST_CHECK(false); // Should not get here
10592 DALI_TEST_CHECK(true); // We expect an assert
10597 int UtcDaliActorRaiseAboveNegative(void)
10599 TestApplication application;
10600 Dali::Actor instance;
10604 instance.RaiseAbove(arg1);
10605 DALI_TEST_CHECK(false); // Should not get here
10609 DALI_TEST_CHECK(true); // We expect an assert
10614 int UtcDaliActorRaiseToTopNegative(void)
10616 TestApplication application;
10617 Dali::Actor instance;
10620 instance.RaiseToTop();
10621 DALI_TEST_CHECK(false); // Should not get here
10625 DALI_TEST_CHECK(true); // We expect an assert
10630 int UtcDaliActorAddRendererNegative(void)
10632 TestApplication application;
10633 Dali::Actor instance;
10636 Dali::Renderer arg1;
10637 instance.AddRenderer(arg1);
10638 DALI_TEST_CHECK(false); // Should not get here
10642 DALI_TEST_CHECK(true); // We expect an assert
10647 int UtcDaliActorTouchedSignalNegative(void)
10649 TestApplication application;
10650 Dali::Actor instance;
10653 instance.TouchedSignal();
10654 DALI_TEST_CHECK(false); // Should not get here
10658 DALI_TEST_CHECK(true); // We expect an assert
10663 int UtcDaliActorTranslateByNegative(void)
10665 TestApplication application;
10666 Dali::Actor instance;
10669 Dali::Vector3 arg1;
10670 instance.TranslateBy(arg1);
10671 DALI_TEST_CHECK(false); // Should not get here
10675 DALI_TEST_CHECK(true); // We expect an assert
10680 int UtcDaliActorFindChildByIdNegative(void)
10682 TestApplication application;
10683 Dali::Actor instance;
10686 unsigned int arg1 = 0u;
10687 instance.FindChildById(arg1);
10688 DALI_TEST_CHECK(false); // Should not get here
10692 DALI_TEST_CHECK(true); // We expect an assert
10697 int UtcDaliActorGetRendererAtNegative(void)
10699 TestApplication application;
10700 Dali::Actor instance;
10703 unsigned int arg1 = 0u;
10704 instance.GetRendererAt(arg1);
10705 DALI_TEST_CHECK(false); // Should not get here
10709 DALI_TEST_CHECK(true); // We expect an assert
10714 int UtcDaliActorHoveredSignalNegative(void)
10716 TestApplication application;
10717 Dali::Actor instance;
10720 instance.HoveredSignal();
10721 DALI_TEST_CHECK(false); // Should not get here
10725 DALI_TEST_CHECK(true); // We expect an assert
10730 int UtcDaliActorLowerToBottomNegative(void)
10732 TestApplication application;
10733 Dali::Actor instance;
10736 instance.LowerToBottom();
10737 DALI_TEST_CHECK(false); // Should not get here
10741 DALI_TEST_CHECK(true); // We expect an assert
10746 int UtcDaliActorOnSceneSignalNegative(void)
10748 TestApplication application;
10749 Dali::Actor instance;
10752 instance.OnSceneSignal();
10753 DALI_TEST_CHECK(false); // Should not get here
10757 DALI_TEST_CHECK(true); // We expect an assert
10762 int UtcDaliActorOffSceneSignalNegative(void)
10764 TestApplication application;
10765 Dali::Actor instance;
10768 instance.OffSceneSignal();
10769 DALI_TEST_CHECK(false); // Should not get here
10773 DALI_TEST_CHECK(true); // We expect an assert
10778 int UtcDaliActorRemoveRendererNegative01(void)
10780 TestApplication application;
10781 Dali::Actor instance;
10784 unsigned int arg1 = 0u;
10785 instance.RemoveRenderer(arg1);
10786 DALI_TEST_CHECK(false); // Should not get here
10790 DALI_TEST_CHECK(true); // We expect an assert
10795 int UtcDaliActorRemoveRendererNegative02(void)
10797 TestApplication application;
10798 Dali::Actor instance;
10801 Dali::Renderer arg1;
10802 instance.RemoveRenderer(arg1);
10803 DALI_TEST_CHECK(false); // Should not get here
10807 DALI_TEST_CHECK(true); // We expect an assert
10812 int UtcDaliActorFindChildByNameNegative(void)
10814 TestApplication application;
10815 Dali::Actor instance;
10819 instance.FindChildByName(arg1);
10820 DALI_TEST_CHECK(false); // Should not get here
10824 DALI_TEST_CHECK(true); // We expect an assert
10829 int UtcDaliActorSetResizePolicyNegative(void)
10831 TestApplication application;
10832 Dali::Actor instance;
10835 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
10836 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
10837 instance.SetResizePolicy(arg1, arg2);
10838 DALI_TEST_CHECK(false); // Should not get here
10842 DALI_TEST_CHECK(true); // We expect an assert
10847 int UtcDaliActorOnRelayoutSignalNegative(void)
10849 TestApplication application;
10850 Dali::Actor instance;
10853 instance.OnRelayoutSignal();
10854 DALI_TEST_CHECK(false); // Should not get here
10858 DALI_TEST_CHECK(true); // We expect an assert
10863 int UtcDaliActorWheelEventSignalNegative(void)
10865 TestApplication application;
10866 Dali::Actor instance;
10869 instance.WheelEventSignal();
10870 DALI_TEST_CHECK(false); // Should not get here
10874 DALI_TEST_CHECK(true); // We expect an assert
10879 int UtcDaliActorGetHeightForWidthNegative(void)
10881 TestApplication application;
10882 Dali::Actor instance;
10886 instance.GetHeightForWidth(arg1);
10887 DALI_TEST_CHECK(false); // Should not get here
10891 DALI_TEST_CHECK(true); // We expect an assert
10896 int UtcDaliActorGetWidthForHeightNegative(void)
10898 TestApplication application;
10899 Dali::Actor instance;
10903 instance.GetWidthForHeight(arg1);
10904 DALI_TEST_CHECK(false); // Should not get here
10908 DALI_TEST_CHECK(true); // We expect an assert
10913 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
10915 TestApplication application;
10916 Dali::Actor instance;
10919 instance.LayoutDirectionChangedSignal();
10920 DALI_TEST_CHECK(false); // Should not get here
10924 DALI_TEST_CHECK(true); // We expect an assert
10929 int UtcDaliActorAddNegative(void)
10931 TestApplication application;
10932 Dali::Actor instance;
10936 instance.Add(arg1);
10937 DALI_TEST_CHECK(false); // Should not get here
10941 DALI_TEST_CHECK(true); // We expect an assert
10946 int UtcDaliActorLowerNegative(void)
10948 TestApplication application;
10949 Dali::Actor instance;
10953 DALI_TEST_CHECK(false); // Should not get here
10957 DALI_TEST_CHECK(true); // We expect an assert
10962 int UtcDaliActorRaiseNegative(void)
10964 TestApplication application;
10965 Dali::Actor instance;
10969 DALI_TEST_CHECK(false); // Should not get here
10973 DALI_TEST_CHECK(true); // We expect an assert
10978 int UtcDaliActorRemoveNegative(void)
10980 TestApplication application;
10981 Dali::Actor instance;
10985 instance.Remove(arg1);
10986 DALI_TEST_CHECK(false); // Should not get here
10990 DALI_TEST_CHECK(true); // We expect an assert
10995 int UtcDaliActorScaleByNegative(void)
10997 TestApplication application;
10998 Dali::Actor instance;
11001 Dali::Vector3 arg1;
11002 instance.ScaleBy(arg1);
11003 DALI_TEST_CHECK(false); // Should not get here
11007 DALI_TEST_CHECK(true); // We expect an assert
11012 int UtcDaliActorGetLayerNegative(void)
11014 TestApplication application;
11015 Dali::Actor instance;
11018 instance.GetLayer();
11019 DALI_TEST_CHECK(false); // Should not get here
11023 DALI_TEST_CHECK(true); // We expect an assert
11028 int UtcDaliActorRotateByNegative01(void)
11030 TestApplication application;
11031 Dali::Actor instance;
11034 Dali::Quaternion arg1;
11035 instance.RotateBy(arg1);
11036 DALI_TEST_CHECK(false); // Should not get here
11040 DALI_TEST_CHECK(true); // We expect an assert
11045 int UtcDaliActorRotateByNegative02(void)
11047 TestApplication application;
11048 Dali::Actor instance;
11052 Dali::Vector3 arg2;
11053 instance.RotateBy(arg1, arg2);
11054 DALI_TEST_CHECK(false); // Should not get here
11058 DALI_TEST_CHECK(true); // We expect an assert
11063 int UtcDaliActorUnparentNegative(void)
11065 TestApplication application;
11066 Dali::Actor instance;
11069 instance.Unparent();
11070 DALI_TEST_CHECK(false); // Should not get here
11074 DALI_TEST_CHECK(true); // We expect an assert
11079 int UtcDaliActorGetChildAtNegative(void)
11081 TestApplication application;
11082 Dali::Actor instance;
11085 unsigned int arg1 = 0u;
11086 instance.GetChildAt(arg1);
11087 DALI_TEST_CHECK(false); // Should not get here
11091 DALI_TEST_CHECK(true); // We expect an assert
11096 int UtcDaliActorGetChildCountNegative(void)
11098 TestApplication application;
11099 Dali::Actor instance;
11102 instance.GetChildCount();
11103 DALI_TEST_CHECK(false); // Should not get here
11107 DALI_TEST_CHECK(true); // We expect an assert
11112 int UtcDaliActorGetTargetSizeNegative(void)
11114 TestApplication application;
11115 Dali::Actor instance;
11118 instance.GetTargetSize();
11119 DALI_TEST_CHECK(false); // Should not get here
11123 DALI_TEST_CHECK(true); // We expect an assert
11128 int UtcDaliActorScreenToLocalNegative(void)
11130 TestApplication application;
11131 Dali::Actor instance;
11138 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
11139 DALI_TEST_CHECK(false); // Should not get here
11143 DALI_TEST_CHECK(true); // We expect an assert
11148 int UtcDaliActorGetNaturalSizeNegative(void)
11150 TestApplication application;
11151 Dali::Actor instance;
11154 instance.GetNaturalSize();
11155 DALI_TEST_CHECK(false); // Should not get here
11159 DALI_TEST_CHECK(true); // We expect an assert
11164 int UtcDaliActorGetRelayoutSizeNegative(void)
11166 TestApplication application;
11167 Dali::Actor instance;
11170 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
11171 instance.GetRelayoutSize(arg1);
11172 DALI_TEST_CHECK(false); // Should not get here
11176 DALI_TEST_CHECK(true); // We expect an assert
11181 int UtcDaliActorGetResizePolicyNegative(void)
11183 TestApplication application;
11184 Dali::Actor instance;
11187 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
11188 instance.GetResizePolicy(arg1);
11189 DALI_TEST_CHECK(false); // Should not get here
11193 DALI_TEST_CHECK(true); // We expect an assert
11198 int UtcDaliActorGetRendererCountNegative(void)
11200 TestApplication application;
11201 Dali::Actor instance;
11204 instance.GetRendererCount();
11205 DALI_TEST_CHECK(false); // Should not get here
11209 DALI_TEST_CHECK(true); // We expect an assert
11214 int UtcDaliActorGetParentNegative(void)
11216 TestApplication application;
11217 Dali::Actor instance;
11220 instance.GetParent();
11221 DALI_TEST_CHECK(false); // Should not get here
11225 DALI_TEST_CHECK(true); // We expect an assert
11230 int UtcDaliActorPropertyBlendEquation(void)
11232 TestApplication application;
11234 tet_infoline("Test SetProperty AdvancedBlendEquation");
11236 Geometry geometry = CreateQuadGeometry();
11237 Shader shader = CreateShader();
11238 Renderer renderer1 = Renderer::New(geometry, shader);
11240 Actor actor = Actor::New();
11241 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
11243 actor.AddRenderer(renderer1);
11244 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
11245 application.GetScene().Add(actor);
11247 if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11249 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11250 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11251 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
11254 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11256 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11257 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11258 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
11261 Renderer renderer2 = Renderer::New(geometry, shader);
11262 actor.AddRenderer(renderer2);
11267 int UtcDaliActorRegisterProperty(void)
11269 tet_infoline("Test property registration and uniform map update\n");
11271 TestApplication application;
11273 Geometry geometry = CreateQuadGeometry();
11274 Shader shader = CreateShader();
11275 Renderer renderer1 = Renderer::New(geometry, shader);
11276 Renderer renderer2 = Renderer::New(geometry, shader);
11278 Actor actor1 = Actor::New();
11279 actor1.AddRenderer(renderer1);
11280 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11281 actor1.RegisterProperty("uCustom", 1);
11282 application.GetScene().Add(actor1);
11284 Actor actor2 = Actor::New();
11285 actor2.AddRenderer(renderer2);
11286 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11287 application.GetScene().Add(actor2);
11289 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
11290 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
11291 glAbstraction.EnableSetUniformCallTrace(true);
11293 application.SendNotification();
11294 application.Render();
11296 std::stringstream out;
11298 std::string params;
11300 // Test uniform value of the custom property
11301 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11302 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11305 actor1[Actor::Property::VISIBLE] = false;
11307 application.SendNotification();
11308 application.Render();
11310 // Make visible again
11311 actor1[Actor::Property::VISIBLE] = true;
11312 actor1["uCustom"] = 2;
11314 glAbstraction.ResetSetUniformCallStack();
11316 application.SendNotification();
11317 application.Render();
11321 // The uniform value should not be changed
11322 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11323 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11328 int UtcDaliActorDoesWantedHitTest(void)
11333 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
11335 mTouchPoint(touchPoint),
11341 Vector2 mTouchPoint;
11345 TestApplication application;
11346 tet_infoline(" UtcDaliActorDoesWantedHitTest");
11348 // Fill a vector with different hit tests.
11349 struct HitTestData* hitTestData[] = {
11350 // scale touch point result
11351 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
11352 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
11353 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.
11354 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
11355 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.
11359 // get the root layer
11360 Actor actor = Actor::New();
11361 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11362 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11364 Actor lowerActor = Actor::New();
11365 lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11366 lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11368 // actor and lowerActor have no relationship.
11369 application.GetScene().Add(lowerActor);
11370 application.GetScene().Add(actor);
11372 ResetTouchCallbacks();
11373 gHitTestTouchCallBackCalled = false;
11375 unsigned int index = 0;
11376 while(NULL != hitTestData[index])
11378 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11379 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11381 lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11382 lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11384 // flush the queue and render once
11385 application.SendNotification();
11386 application.Render();
11388 DALI_TEST_CHECK(!gTouchCallBackCalled);
11389 DALI_TEST_CHECK(!gTouchCallBackCalled2);
11390 DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
11392 // connect to its touch signal
11393 actor.TouchedSignal().Connect(TestTouchCallback);
11394 lowerActor.TouchedSignal().Connect(TestTouchCallback2);
11396 // connect to its hit-test signal
11397 Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
11399 Dali::Integration::Point point;
11400 point.SetState(PointState::DOWN);
11401 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
11402 Dali::Integration::TouchEvent event;
11403 event.AddPoint(point);
11405 // flush the queue and render once
11406 application.SendNotification();
11407 application.Render();
11408 application.ProcessEvent(event);
11410 // check hit-test events
11411 DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
11412 // Passed all hit-tests of actor.
11413 DALI_TEST_CHECK(gTouchCallBackCalled == false);
11414 // The lowerActor was hit-tested.
11415 DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
11417 if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
11418 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
11419 hitTestData[index]->mScale.x,
11420 hitTestData[index]->mScale.y,
11421 hitTestData[index]->mScale.z,
11422 hitTestData[index]->mTouchPoint.x,
11423 hitTestData[index]->mTouchPoint.y,
11424 hitTestData[index]->mResult);
11426 ResetTouchCallbacks();
11427 gHitTestTouchCallBackCalled = false;
11433 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
11435 TestApplication application;
11437 Actor actor = Actor::New();
11438 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
11439 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
11440 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
11441 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
11442 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
11443 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11444 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11445 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
11449 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
11451 TestApplication application;
11453 Actor actor = Actor::New();
11455 // Make sure setting invalid types does not cause a crash
11458 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
11459 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
11460 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
11461 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
11462 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
11463 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
11464 tet_result(TET_PASS);
11468 tet_result(TET_FAIL);
11473 int UtcDaliActorCalculateWorldTransform01(void)
11475 TestApplication application;
11477 tet_infoline("Test that actor position inheritance produces right transform matrix");
11479 Actor rootActor = Actor::New();
11480 Actor branchActor = Actor::New();
11481 Actor leafActor = Actor::New();
11483 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11484 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11485 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11487 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11488 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11489 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11491 // Set anchor point to the same value as parent origin
11492 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11493 branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11494 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11496 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11497 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11498 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11500 application.GetScene().Add(rootActor);
11501 rootActor.Add(branchActor);
11502 branchActor.Add(leafActor);
11504 application.SendNotification();
11505 application.Render(0);
11506 application.SendNotification();
11507 application.Render(0);
11509 Matrix m = DevelActor::GetWorldTransform(leafActor);
11511 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11512 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11515 Vector3 worldScale;
11516 Quaternion worldRotation;
11517 m.GetTransformComponents(worldPos, worldRotation, worldScale);
11518 DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
11523 int UtcDaliActorCalculateWorldTransform02(void)
11525 TestApplication application;
11527 tet_infoline("Test that actor position produces right transform matrix");
11529 Actor rootActor = Actor::New();
11530 Actor branchActor = Actor::New();
11531 Actor leafActor = Actor::New();
11533 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11534 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11535 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11537 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11538 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11539 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11541 // Set anchor point to the same value as parent origin
11542 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11543 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11544 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11546 application.GetScene().Add(rootActor);
11547 rootActor.Add(branchActor);
11548 branchActor.Add(leafActor);
11550 leafActor[Actor::Property::INHERIT_POSITION] = false;
11551 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11552 leafActor[Actor::Property::INHERIT_SCALE] = false;
11554 application.SendNotification();
11555 application.Render(0);
11556 application.SendNotification();
11557 application.Render(0);
11559 Matrix m = DevelActor::GetWorldTransform(leafActor);
11561 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11562 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11567 int UtcDaliActorCalculateWorldTransform03(void)
11569 TestApplication application;
11571 tet_infoline("Test that actor position produces right transform matrix");
11573 Actor rootActor = Actor::New();
11574 Actor branchActor = Actor::New();
11575 Actor leafActor = Actor::New();
11577 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11578 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11579 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11581 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11582 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11583 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11585 // Set anchor point to the same value as parent origin
11586 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11587 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11588 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11590 application.GetScene().Add(rootActor);
11591 rootActor.Add(branchActor);
11592 branchActor.Add(leafActor);
11594 leafActor[Actor::Property::INHERIT_POSITION] = true;
11595 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11596 leafActor[Actor::Property::INHERIT_SCALE] = false;
11598 application.SendNotification();
11599 application.Render(0);
11600 application.SendNotification();
11601 application.Render(0);
11603 Matrix m = DevelActor::GetWorldTransform(leafActor);
11605 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11606 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11611 int UtcDaliActorCalculateWorldTransform04(void)
11613 TestApplication application;
11615 tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
11617 Actor rootActor = Actor::New();
11618 Actor branchActor = Actor::New();
11619 Actor leafActor = Actor::New();
11621 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11622 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11623 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11625 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11626 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11627 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11629 // Set anchor point to the same value as parent origin
11630 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11631 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11632 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11633 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11635 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11636 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11638 application.GetScene().Add(rootActor);
11639 rootActor.Add(branchActor);
11640 branchActor.Add(leafActor);
11642 application.SendNotification();
11643 application.Render(0);
11644 application.SendNotification();
11645 application.Render(0);
11647 Matrix m = DevelActor::GetWorldTransform(leafActor);
11649 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11650 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11655 int UtcDaliActorCalculateWorldTransform05(void)
11657 TestApplication application;
11659 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11661 Actor rootActor = Actor::New();
11662 Actor branchActor = Actor::New();
11663 Actor leafActor = Actor::New();
11665 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11666 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11667 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11669 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11670 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11671 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11673 // Set anchor point to the same value as parent origin
11674 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11675 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11676 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11677 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11679 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11680 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11682 leafActor[Actor::Property::INHERIT_POSITION] = false;
11683 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11685 application.GetScene().Add(rootActor);
11686 rootActor.Add(branchActor);
11687 branchActor.Add(leafActor);
11689 application.SendNotification();
11690 application.Render(0);
11691 application.SendNotification();
11692 application.Render(0);
11694 Matrix m = DevelActor::GetWorldTransform(leafActor);
11696 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11697 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11702 int UtcDaliActorCalculateWorldTransform06(void)
11704 TestApplication application;
11706 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11708 Actor rootActor = Actor::New();
11709 Actor branchActor = Actor::New();
11710 Actor leafActor = Actor::New();
11712 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11713 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11714 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11716 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11717 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11718 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11720 // Set anchor point to the same value as parent origin
11721 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11722 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11723 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11724 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11726 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
11727 branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11728 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11730 leafActor[Actor::Property::INHERIT_POSITION] = false;
11731 leafActor[Actor::Property::INHERIT_SCALE] = false;
11733 application.GetScene().Add(rootActor);
11734 rootActor.Add(branchActor);
11735 branchActor.Add(leafActor);
11737 application.SendNotification();
11738 application.Render(0);
11739 application.SendNotification();
11740 application.Render(0);
11742 Matrix m = DevelActor::GetWorldTransform(leafActor);
11744 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11745 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11750 int UtcDaliActorCalculateWorldTransform07(void)
11752 TestApplication application;
11754 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11756 Actor rootActor = Actor::New();
11757 Actor branchActor = Actor::New();
11758 Actor leafActor = Actor::New();
11760 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11761 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11762 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11764 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11765 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11766 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11768 // Set anchor point to the same value as parent origin
11769 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11770 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11771 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11773 // This should be ignored.
11774 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11775 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11777 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
11778 branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11779 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11781 leafActor[Actor::Property::INHERIT_POSITION] = false;
11782 leafActor[Actor::Property::INHERIT_SCALE] = false;
11783 leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
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 UtcDaliActorCalculateWorldTransform08(void)
11804 TestApplication application;
11806 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11808 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)};
11816 TestCase testCases[] = {
11817 {false, false, true},
11818 {false, true, false},
11819 {true, false, false},
11820 {false, true, true},
11821 {true, false, true},
11822 {true, true, false},
11823 {false, false, false},
11824 {true, true, true},
11827 Actor rootActor = Actor::New();
11828 Actor leafActor = Actor::New();
11830 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11831 rootActor[Actor::Property::SCALE] = Vector3(1.0f, 2.0f, 1.0f);
11832 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11833 rootActor[Actor::Property::SIZE] = Vector2(200, 400);
11834 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11835 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11837 leafActor[Actor::Property::POSITION] = Vector3(0.0f, -50.0f, 0.0f);
11838 leafActor[Actor::Property::SCALE] = Vector3(1.0f, 1.0f, 1.0f);
11839 leafActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11840 leafActor[Actor::Property::SIZE] = Vector2(200, 400);
11841 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_CENTER;
11842 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_CENTER;
11843 leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
11845 application.GetScene().Add(rootActor);
11846 rootActor.Add(leafActor);
11848 for(uint32_t i = 0; i < 8; ++i)
11850 leafActor[Actor::Property::INHERIT_POSITION] = testCases[i].translation;
11851 leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
11852 leafActor[Actor::Property::INHERIT_SCALE] = testCases[i].scaling;
11854 application.SendNotification();
11855 application.Render(0);
11856 application.SendNotification();
11857 application.Render(0);
11859 Matrix m = DevelActor::GetWorldTransform(leafActor);
11860 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11862 Vector3 worldPosition1 = Vector3(m.GetTranslation());
11863 Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
11865 DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
11866 DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
11872 int UtcDaliActorCalculateWorldColor01(void)
11874 TestApplication application;
11876 tet_infoline("Test that actor inheritance of color produces right final color");
11878 Actor rootActor = Actor::New();
11879 Actor branchActor = Actor::New();
11880 Actor leafActor = Actor::New();
11882 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11883 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11884 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11886 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11887 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11888 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11890 rootActor[Actor::Property::COLOR] = Color::WHITE;
11891 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11892 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11894 // Default is to inherit:
11895 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
11897 application.GetScene().Add(rootActor);
11898 rootActor.Add(branchActor);
11899 branchActor.Add(leafActor);
11901 application.SendNotification();
11902 application.Render(0);
11904 Vector4 color = DevelActor::GetWorldColor(leafActor);
11906 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11907 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11912 int UtcDaliActorCalculateWorldColor02(void)
11914 TestApplication application;
11916 tet_infoline("Test that actor uses own color");
11918 Actor rootActor = Actor::New();
11919 Actor branchActor = Actor::New();
11920 Actor leafActor = Actor::New();
11922 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11923 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11924 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11926 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11927 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11928 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11930 rootActor[Actor::Property::COLOR] = Color::WHITE;
11931 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11932 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11934 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
11936 application.GetScene().Add(rootActor);
11937 rootActor.Add(branchActor);
11938 branchActor.Add(leafActor);
11940 application.SendNotification();
11941 application.Render(0);
11943 Vector4 color = DevelActor::GetWorldColor(leafActor);
11945 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11946 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11947 DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
11951 int UtcDaliActorCalculateWorldColor03(void)
11953 TestApplication application;
11955 tet_infoline("Test that actor uses parent color");
11957 Actor rootActor = Actor::New();
11958 Actor branchActor = Actor::New();
11959 Actor leafActor = Actor::New();
11961 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11962 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11963 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11965 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11966 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11967 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11969 rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
11970 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11971 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11973 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
11975 application.GetScene().Add(rootActor);
11976 rootActor.Add(branchActor);
11977 branchActor.Add(leafActor);
11979 application.SendNotification();
11980 application.Render(0);
11982 Vector4 color = DevelActor::GetWorldColor(leafActor);
11984 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11985 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11986 DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
11990 int UtcDaliActorCalculateWorldColor04(void)
11992 TestApplication application;
11994 tet_infoline("Test that actor blends with parent color");
11996 Actor rootActor = Actor::New();
11997 Actor branchActor = Actor::New();
11998 Actor leafActor = Actor::New();
12000 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
12001 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
12002 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
12004 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12005 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12006 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
12008 rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
12009 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
12010 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
12012 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
12014 application.GetScene().Add(rootActor);
12015 rootActor.Add(branchActor);
12016 branchActor.Add(leafActor);
12018 application.SendNotification();
12019 application.Render(0);
12021 Vector4 color = DevelActor::GetWorldColor(leafActor);
12023 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
12024 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);