2 * Copyright (c) 2021 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
41 void utc_dali_actor_startup(void)
43 test_return_value = TET_UNDEF;
46 void utc_dali_actor_cleanup(void)
48 test_return_value = TET_PASS;
53 bool gTouchCallBackCalled = false;
54 bool gTouchCallBackCalled2 = false;
55 bool gTouchCallBackCalled3 = false;
57 bool gHoverCallBackCalled = false;
59 static bool gTestConstraintCalled;
61 LayoutDirection::Type gLayoutDirectionType;
65 void operator()(Vector4& color, const PropertyInputContainer& /* inputs */)
67 gTestConstraintCalled = true;
72 * TestConstraint reference.
73 * When constraint is called, the resultRef is updated
74 * with the value supplied.
77 struct TestConstraintRef
79 TestConstraintRef(unsigned int& resultRef, unsigned int value)
80 : mResultRef(resultRef),
85 void operator()(T& current, const PropertyInputContainer& /* inputs */)
90 unsigned int& mResultRef;
94 static bool TestTouchCallback(Actor, const TouchEvent&)
96 gTouchCallBackCalled = true;
101 static bool TestTouchCallback2(Actor, const TouchEvent&)
103 gTouchCallBackCalled2 = true;
108 static bool TestTouchCallback3(Actor, const TouchEvent&)
110 gTouchCallBackCalled3 = true;
115 static void ResetTouchCallbacks()
117 gTouchCallBackCalled = false;
118 gTouchCallBackCalled2 = false;
119 gTouchCallBackCalled3 = false;
122 static bool TestCallback3(Actor actor, const HoverEvent& event)
124 gHoverCallBackCalled = true;
129 // validation stuff for onstage & offstage signals
130 static std::vector<std::string> gActorNamesOnOffScene;
131 static int gOnSceneCallBackCalled;
132 void OnSceneCallback(Actor actor)
134 ++gOnSceneCallBackCalled;
135 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
136 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
138 static int gOffSceneCallBackCalled;
139 void OffSceneCallback(Actor actor)
141 ++gOffSceneCallBackCalled;
142 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
143 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
146 struct PositionComponentConstraint
148 PositionComponentConstraint()
152 void operator()(Vector3& pos, const PropertyInputContainer& inputs)
154 const Matrix& m = inputs[0]->GetMatrix();
157 m.GetTransformComponents(pos, rot, scale);
161 struct OrientationComponentConstraint
163 OrientationComponentConstraint()
167 void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
169 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
172 orientation = parentOrientation;
177 static bool gOnRelayoutCallBackCalled = false;
178 static std::vector<std::string> gActorNamesRelayout;
180 void OnRelayoutCallback(Actor actor)
182 gOnRelayoutCallBackCalled = true;
183 gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
186 struct VisibilityChangedFunctorData
188 VisibilityChangedFunctorData()
191 type(DevelActor::VisibilityChange::SELF),
200 type = DevelActor::VisibilityChange::SELF;
204 void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
206 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
207 DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
208 DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
209 DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
212 void Check(bool compareCalled, const std::string& location)
214 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
219 DevelActor::VisibilityChange::Type type;
223 struct VisibilityChangedFunctor
225 VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
230 void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
233 data.visible = visible;
238 VisibilityChangedFunctorData& data;
241 struct VisibilityChangedVoidFunctor
243 VisibilityChangedVoidFunctor(bool& signalCalled)
244 : mSignalCalled(signalCalled)
250 mSignalCalled = true;
256 struct ChildOrderChangedFunctor
258 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
259 : mSignalCalled(signalCalled),
264 void operator()(Actor actor)
266 mSignalCalled = true;
274 struct CulledPropertyNotificationFunctor
276 CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
277 : mSignalCalled(signalCalled),
278 mPropertyNotification(propertyNotification)
282 void operator()(PropertyNotification& source)
284 mSignalCalled = true;
285 mPropertyNotification = source;
289 PropertyNotification& mPropertyNotification;
292 } // anonymous namespace
294 //& purpose: Testing New API
295 int UtcDaliActorNew(void)
297 TestApplication application;
299 Actor actor = Actor::New();
301 DALI_TEST_CHECK(actor);
305 //& purpose: Testing Dali::Actor::DownCast()
306 int UtcDaliActorDownCastP(void)
308 TestApplication application;
309 tet_infoline("Testing Dali::Actor::DownCast()");
311 Actor actor = Actor::New();
312 BaseHandle object(actor);
313 Actor actor2 = Actor::DownCast(object);
314 DALI_TEST_CHECK(actor2);
318 //& purpose: Testing Dali::Actor::DownCast()
319 int UtcDaliActorDownCastN(void)
321 TestApplication application;
322 tet_infoline("Testing Dali::Actor::DownCast()");
324 BaseHandle unInitializedObject;
325 Actor actor = Actor::DownCast(unInitializedObject);
326 DALI_TEST_CHECK(!actor);
330 int UtcDaliActorMoveConstructor(void)
332 TestApplication application;
334 Actor actor = Actor::New();
335 DALI_TEST_CHECK(actor);
337 int id = actor.GetProperty<int>(Actor::Property::ID);
339 Actor moved = std::move(actor);
340 DALI_TEST_CHECK(moved);
341 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
342 DALI_TEST_CHECK(!actor);
347 int UtcDaliActorMoveAssignment(void)
349 TestApplication application;
351 Actor actor = Actor::New();
352 DALI_TEST_CHECK(actor);
354 int id = actor.GetProperty<int>(Actor::Property::ID);
357 moved = std::move(actor);
358 DALI_TEST_CHECK(moved);
359 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
360 DALI_TEST_CHECK(!actor);
365 //& purpose: Testing Dali::Actor::GetName()
366 int UtcDaliActorGetName(void)
368 TestApplication application;
370 Actor actor = Actor::New();
372 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
376 //& purpose: Testing Dali::Actor::SetName()
377 int UtcDaliActorSetName(void)
379 TestApplication application;
381 string str("ActorName");
382 Actor actor = Actor::New();
384 actor.SetProperty(Actor::Property::NAME, str);
385 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
389 int UtcDaliActorGetId(void)
391 tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
392 TestApplication application;
394 Actor first = Actor::New();
395 Actor second = Actor::New();
396 Actor third = Actor::New();
398 DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
399 DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
403 int UtcDaliActorIsRoot(void)
405 TestApplication application;
407 Actor actor = Actor::New();
408 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
410 // get the root layer
411 actor = application.GetScene().GetLayer(0);
412 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
416 int UtcDaliActorOnScene(void)
418 TestApplication application;
420 Actor actor = Actor::New();
421 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
423 // get the root layer
424 actor = application.GetScene().GetLayer(0);
425 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
429 int UtcDaliActorIsLayer(void)
431 TestApplication application;
433 Actor actor = Actor::New();
434 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
436 // get the root layer
437 actor = application.GetScene().GetLayer(0);
438 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
442 int UtcDaliActorGetLayer(void)
444 TestApplication application;
446 Actor actor = Actor::New();
447 application.GetScene().Add(actor);
448 Layer layer = actor.GetLayer();
450 DALI_TEST_CHECK(layer);
452 // get the root layers layer
453 actor = application.GetScene().GetLayer(0);
454 DALI_TEST_CHECK(actor.GetLayer());
458 int UtcDaliActorAddP(void)
460 tet_infoline("Testing Actor::Add");
461 TestApplication application;
463 Actor parent = Actor::New();
464 Actor child = Actor::New();
466 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
470 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
472 Actor parent2 = Actor::New();
475 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
476 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
478 // try Adding to same parent again, works
480 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
482 // try reparenting an orphaned child
484 Actor temporaryParent = Actor::New();
485 temporaryParent.Add(child);
486 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
488 // temporaryParent has now died, reparent the orphaned child
490 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
495 int UtcDaliActorAddN(void)
497 tet_infoline("Testing Actor::Add");
498 TestApplication application;
500 Actor child = Actor::New();
502 Actor parent2 = Actor::New();
508 parent2.Add(parent2);
509 tet_printf("Assertion test failed - no Exception\n");
510 tet_result(TET_FAIL);
512 catch(Dali::DaliException& e)
514 DALI_TEST_PRINT_ASSERT(e);
515 DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
516 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
520 tet_printf("Assertion test failed - wrong Exception\n");
521 tet_result(TET_FAIL);
524 // try reparenting root
527 parent2.Add(application.GetScene().GetLayer(0));
528 tet_printf("Assertion test failed - no Exception\n");
529 tet_result(TET_FAIL);
531 catch(Dali::DaliException& e)
533 DALI_TEST_PRINT_ASSERT(e);
534 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
535 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
539 tet_printf("Assertion test failed - wrong Exception\n");
540 tet_result(TET_FAIL);
548 tet_printf("Assertion test failed - no Exception\n");
549 tet_result(TET_FAIL);
551 catch(Dali::DaliException& e)
553 DALI_TEST_PRINT_ASSERT(e);
554 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
555 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
559 tet_printf("Assertion test failed - wrong Exception\n");
560 tet_result(TET_FAIL);
566 int UtcDaliActorRemoveN(void)
568 tet_infoline("Testing Actor::Remove");
569 TestApplication application;
571 Actor parent = Actor::New();
572 Actor child = Actor::New();
573 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
576 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
578 parent.Remove(child);
579 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
581 // remove again, no problem
582 parent.Remove(child);
583 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
587 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
588 // try Remove self, its a no-op
589 parent.Remove(parent);
590 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
596 parent.Remove(empty);
597 tet_printf("Assertion test failed - no Exception\n");
598 tet_result(TET_FAIL);
600 catch(Dali::DaliException& e)
602 DALI_TEST_PRINT_ASSERT(e);
603 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
604 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
608 tet_printf("Assertion test failed - wrong Exception\n");
609 tet_result(TET_FAIL);
614 int UtcDaliActorRemoveP(void)
616 TestApplication application;
618 Actor parent = Actor::New();
619 Actor child = Actor::New();
620 Actor random = Actor::New();
622 application.GetScene().Add(parent);
624 DALI_TEST_CHECK(parent.GetChildCount() == 0);
628 DALI_TEST_CHECK(parent.GetChildCount() == 1);
630 parent.Remove(random);
632 DALI_TEST_CHECK(parent.GetChildCount() == 1);
634 application.GetScene().Remove(parent);
636 DALI_TEST_CHECK(parent.GetChildCount() == 1);
640 int UtcDaliActorGetChildCount(void)
642 TestApplication application;
644 Actor parent = Actor::New();
645 Actor child = Actor::New();
647 DALI_TEST_CHECK(parent.GetChildCount() == 0);
651 DALI_TEST_CHECK(parent.GetChildCount() == 1);
655 int UtcDaliActorGetChildren01(void)
657 TestApplication application;
659 Actor parent = Actor::New();
660 Actor first = Actor::New();
661 Actor second = Actor::New();
662 Actor third = Actor::New();
668 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
669 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
670 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
674 int UtcDaliActorGetChildren02(void)
676 TestApplication application;
678 Actor parent = Actor::New();
679 Actor first = Actor::New();
680 Actor second = Actor::New();
681 Actor third = Actor::New();
687 const Actor& constParent = parent;
689 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
690 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
691 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
695 int UtcDaliActorGetParent01(void)
697 TestApplication application;
699 Actor parent = Actor::New();
700 Actor child = Actor::New();
704 DALI_TEST_CHECK(child.GetParent() == parent);
708 int UtcDaliActorGetParent02(void)
710 TestApplication application;
712 Actor actor = Actor::New();
714 DALI_TEST_CHECK(!actor.GetParent());
718 int UtcDaliActorCustomProperty(void)
720 TestApplication application;
722 Actor actor = Actor::New();
723 application.GetScene().Add(actor);
725 float startValue(1.0f);
726 Property::Index index = actor.RegisterProperty("testProperty", startValue);
727 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
729 application.SendNotification();
730 application.Render(0);
731 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
733 actor.SetProperty(index, 5.0f);
735 application.SendNotification();
736 application.Render(0);
737 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
741 int UtcDaliActorCustomPropertyIntToFloat(void)
743 TestApplication application;
745 Actor actor = Actor::New();
746 application.GetScene().Add(actor);
748 float startValue(5.0f);
749 Property::Index index = actor.RegisterProperty("testProperty", startValue);
750 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
752 application.SendNotification();
753 application.Render(0);
754 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
756 actor.SetProperty(index, int(1));
758 application.SendNotification();
759 application.Render(0);
760 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
764 int UtcDaliActorCustomPropertyFloatToInt(void)
766 TestApplication application;
768 Actor actor = Actor::New();
769 application.GetScene().Add(actor);
772 Property::Index index = actor.RegisterProperty("testProperty", startValue);
773 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
775 application.SendNotification();
776 application.Render(0);
777 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
779 actor.SetProperty(index, float(1.5));
781 application.SendNotification();
782 application.Render(0);
783 DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
787 int UtcDaliActorSetParentOrigin(void)
789 TestApplication application;
791 Actor actor = Actor::New();
793 Vector3 vector(0.7f, 0.8f, 0.9f);
794 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
796 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
798 // flush the queue and render once
799 application.SendNotification();
800 application.Render();
802 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
804 application.GetScene().Add(actor);
806 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
808 // flush the queue and render once
809 application.SendNotification();
810 application.Render();
812 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
814 application.GetScene().Remove(actor);
818 int UtcDaliActorSetParentOriginIndividual(void)
820 TestApplication application;
822 Actor actor = Actor::New();
824 Vector3 vector(0.7f, 0.8f, 0.9f);
825 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
827 actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
829 // flush the queue and render once
830 application.SendNotification();
831 application.Render();
833 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
835 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
837 // flush the queue and render once
838 application.SendNotification();
839 application.Render();
841 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
843 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
845 // flush the queue and render once
846 application.SendNotification();
847 application.Render();
849 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
854 int UtcDaliActorGetCurrentParentOrigin(void)
856 TestApplication application;
858 Actor actor = Actor::New();
860 Vector3 vector(0.7f, 0.8f, 0.9f);
861 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
863 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
865 // flush the queue and render once
866 application.SendNotification();
867 application.Render();
869 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
873 int UtcDaliActorSetAnchorPoint(void)
875 TestApplication application;
877 Actor actor = Actor::New();
879 Vector3 vector(0.7f, 0.8f, 0.9f);
880 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
882 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
884 // flush the queue and render once
885 application.SendNotification();
886 application.Render();
888 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
890 application.GetScene().Add(actor);
892 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
893 // flush the queue and render once
894 application.SendNotification();
895 application.Render();
897 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
899 application.GetScene().Remove(actor);
903 int UtcDaliActorSetAnchorPointIndividual(void)
905 TestApplication application;
907 Actor actor = Actor::New();
909 Vector3 vector(0.7f, 0.8f, 0.9f);
910 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
912 actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
914 // flush the queue and render once
915 application.SendNotification();
916 application.Render();
918 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
920 actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
922 // flush the queue and render once
923 application.SendNotification();
924 application.Render();
926 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
928 actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
930 // flush the queue and render once
931 application.SendNotification();
932 application.Render();
934 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
939 int UtcDaliActorGetCurrentAnchorPoint(void)
941 TestApplication application;
943 Actor actor = Actor::New();
945 Vector3 vector(0.7f, 0.8f, 0.9f);
946 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
948 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
950 // flush the queue and render once
951 application.SendNotification();
952 application.Render();
954 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
958 int UtcDaliActorSetSize01(void)
960 TestApplication application;
962 Actor actor = Actor::New();
963 Vector3 vector(100.0f, 100.0f, 0.0f);
965 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
967 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
969 // Immediately retrieve the size after setting
970 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
971 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
972 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
973 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
974 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
976 // Flush the queue and render once
977 application.SendNotification();
978 application.Render();
980 // Check the size in the new frame
981 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
983 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
984 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
985 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
986 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
987 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
989 // Check async behaviour
990 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
991 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
992 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
993 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
994 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
996 // Change the resize policy and check whether the size stays the same
997 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
999 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1000 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1002 // Set a new size after resize policy is changed and check the new size
1003 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1005 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1006 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1008 // Change the resize policy again and check whether the new size stays the same
1009 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1011 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1012 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1014 // Set another new size after resize policy is changed and check the new size
1015 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1017 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1018 DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1023 int UtcDaliActorSetSize02(void)
1025 TestApplication application;
1027 Actor actor = Actor::New();
1028 Vector3 vector(100.0f, 100.0f, 100.0f);
1030 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1032 actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1034 // Immediately check the size after setting
1035 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1036 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1038 // flush the queue and render once
1039 application.SendNotification();
1040 application.Render();
1042 // Check the size in the new frame
1043 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1045 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1046 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1051 // SetSize(Vector2 size)
1052 int UtcDaliActorSetSize03(void)
1054 TestApplication application;
1056 Actor actor = Actor::New();
1057 Vector3 vector(100.0f, 100.0f, 0.0f);
1059 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1061 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1063 // Immediately check the size after setting
1064 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1065 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1067 // flush the queue and render once
1068 application.SendNotification();
1069 application.Render();
1071 // Check the size in the new frame
1072 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1074 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1075 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1080 // SetSize(Vector3 size)
1081 int UtcDaliActorSetSize04(void)
1083 TestApplication application;
1085 Actor actor = Actor::New();
1086 Vector3 vector(100.0f, 100.0f, 100.0f);
1088 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1090 actor.SetProperty(Actor::Property::SIZE, vector);
1092 // Immediately check the size after setting
1093 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1094 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1096 // flush the queue and render once
1097 application.SendNotification();
1098 application.Render();
1100 // Check the size in the new frame
1101 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1103 application.GetScene().Add(actor);
1104 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1106 // Immediately check the size after setting
1107 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1108 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1110 // flush the queue and render once
1111 application.SendNotification();
1112 application.Render();
1114 // Check the size in the new frame
1115 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1117 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1118 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1120 application.GetScene().Remove(actor);
1124 int UtcDaliActorSetSizeIndividual(void)
1126 TestApplication application;
1128 Actor actor = Actor::New();
1130 Vector3 vector(0.7f, 0.8f, 0.9f);
1131 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1133 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1135 // Immediately check the width after setting
1136 float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1137 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1139 // flush the queue and render once
1140 application.SendNotification();
1141 application.Render();
1143 // Check the width in the new frame
1144 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1146 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1147 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1149 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1151 // Immediately check the height after setting
1152 float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1153 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1155 // flush the queue and render once
1156 application.SendNotification();
1157 application.Render();
1159 // Check the height in the new frame
1160 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1162 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1163 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1165 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1167 // Immediately check the depth after setting
1168 float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1169 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1171 // flush the queue and render once
1172 application.SendNotification();
1173 application.Render();
1175 // Check the depth in the new frame
1176 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1178 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1179 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1181 // Change the resize policy and check whether the size stays the same
1182 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1184 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1185 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1187 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1188 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1190 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1191 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1193 // Change the resize policy again and check whether the size stays the same
1194 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1196 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1197 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1199 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1200 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1202 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1203 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1208 int UtcDaliActorSetSizeIndividual02(void)
1210 TestApplication application;
1212 Actor actor = Actor::New();
1213 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1214 application.GetScene().Add(actor);
1216 Vector3 vector(100.0f, 200.0f, 400.0f);
1217 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1219 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1220 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1222 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1223 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1225 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1226 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1228 // flush the queue and render once
1229 application.SendNotification();
1230 application.Render();
1232 // Check the width in the new frame
1233 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1234 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1239 int UtcDaliActorGetCurrentSize(void)
1241 TestApplication application;
1243 Actor actor = Actor::New();
1244 Vector3 vector(100.0f, 100.0f, 20.0f);
1246 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1248 actor.SetProperty(Actor::Property::SIZE, vector);
1250 // flush the queue and render once
1251 application.SendNotification();
1252 application.Render();
1254 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1258 int UtcDaliActorGetNaturalSize(void)
1260 TestApplication application;
1262 Actor actor = Actor::New();
1263 Vector3 vector(0.0f, 0.0f, 0.0f);
1265 DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1270 int UtcDaliActorGetCurrentSizeImmediate(void)
1272 TestApplication application;
1274 Actor actor = Actor::New();
1275 Vector3 vector(100.0f, 100.0f, 20.0f);
1277 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1278 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1280 actor.SetProperty(Actor::Property::SIZE, vector);
1282 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1283 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1285 // flush the queue and render once
1286 application.SendNotification();
1287 application.Render();
1289 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1290 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1293 // Build the animation
1294 const float durationSeconds = 2.0f;
1295 Animation animation = Animation::New(durationSeconds);
1296 const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1297 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1299 DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1301 application.GetScene().Add(actor);
1303 // Start the animation
1306 application.SendNotification();
1307 application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1309 DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1314 int UtcDaliActorCalculateScreenExtents(void)
1316 TestApplication application;
1318 Actor actor = Actor::New();
1320 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1321 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1323 application.SendNotification();
1324 application.Render();
1326 auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f};
1327 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1328 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1329 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1330 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1331 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1333 application.GetScene().Remove(actor);
1337 // SetPosition(float x, float y)
1338 int UtcDaliActorSetPosition01(void)
1340 TestApplication application;
1342 Actor actor = Actor::New();
1344 // Set to random to start off with
1345 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1347 Vector3 vector(100.0f, 100.0f, 0.0f);
1349 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1351 actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1352 // flush the queue and render once
1353 application.SendNotification();
1354 application.Render();
1355 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1357 application.GetScene().Add(actor);
1358 actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1359 // flush the queue and render once
1360 application.SendNotification();
1361 application.Render();
1362 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1364 actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1365 actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1366 actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1367 // flush the queue and render once
1368 application.SendNotification();
1369 application.Render();
1370 DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1372 actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1373 // flush the queue and render once
1374 application.SendNotification();
1375 application.Render();
1376 DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1378 application.GetScene().Remove(actor);
1382 // SetPosition(float x, float y, float z)
1383 int UtcDaliActorSetPosition02(void)
1385 TestApplication application;
1387 Actor actor = Actor::New();
1389 // Set to random to start off with
1390 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1392 Vector3 vector(100.0f, 100.0f, 100.0f);
1394 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1396 actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1398 // flush the queue and render once
1399 application.SendNotification();
1400 application.Render();
1402 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1406 // SetPosition(Vector3 position)
1407 int UtcDaliActorSetPosition03(void)
1409 TestApplication application;
1411 Actor actor = Actor::New();
1413 // Set to random to start off with
1414 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1416 Vector3 vector(100.0f, 100.0f, 100.0f);
1418 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1420 actor.SetProperty(Actor::Property::POSITION, vector);
1422 // flush the queue and render once
1423 application.SendNotification();
1424 application.Render();
1426 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1430 int UtcDaliActorSetX(void)
1432 TestApplication application;
1434 Actor actor = Actor::New();
1436 Vector3 vector(100.0f, 0.0f, 0.0f);
1438 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1440 actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1442 // flush the queue and render once
1443 application.SendNotification();
1444 application.Render();
1446 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1450 int UtcDaliActorSetY(void)
1452 TestApplication application;
1454 Actor actor = Actor::New();
1456 Vector3 vector(0.0f, 100.0f, 0.0f);
1458 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1460 actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1462 // flush the queue and render once
1463 application.SendNotification();
1464 application.Render();
1466 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1470 int UtcDaliActorSetZ(void)
1472 TestApplication application;
1474 Actor actor = Actor::New();
1476 Vector3 vector(0.0f, 0.0f, 100.0f);
1478 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1480 actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1482 // flush the queue and render once
1483 application.SendNotification();
1484 application.Render();
1486 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1490 int UtcDaliActorSetPositionProperties(void)
1492 TestApplication application;
1494 Actor actor = Actor::New();
1496 Vector3 vector(0.7f, 0.8f, 0.9f);
1497 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1499 actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1500 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1501 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1503 // flush the queue and render once
1504 application.SendNotification();
1505 application.Render();
1507 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1508 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1509 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1510 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1511 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1513 actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1514 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1515 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1517 // flush the queue and render once
1518 application.SendNotification();
1519 application.Render();
1521 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1522 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1523 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1524 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1525 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1527 actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1528 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1529 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1531 // flush the queue and render once
1532 application.SendNotification();
1533 application.Render();
1535 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1536 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1537 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1538 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1539 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1544 int UtcDaliActorTranslateBy(void)
1546 TestApplication application;
1548 Actor actor = Actor::New();
1549 Vector3 vector(100.0f, 100.0f, 100.0f);
1551 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1553 actor.SetProperty(Actor::Property::POSITION, vector);
1555 // flush the queue and render once
1556 application.SendNotification();
1557 application.Render();
1559 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1561 actor.TranslateBy(vector);
1563 // flush the queue and render once
1564 application.SendNotification();
1565 application.Render();
1567 DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1571 int UtcDaliActorGetCurrentPosition(void)
1573 TestApplication application;
1575 Actor actor = Actor::New();
1576 Vector3 setVector(100.0f, 100.0f, 0.0f);
1577 actor.SetProperty(Actor::Property::POSITION, setVector);
1579 // flush the queue and render once
1580 application.SendNotification();
1581 application.Render();
1583 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1587 int UtcDaliActorGetCurrentWorldPosition(void)
1589 TestApplication application;
1591 Actor parent = Actor::New();
1592 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1593 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1594 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1595 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1596 application.GetScene().Add(parent);
1598 Actor child = Actor::New();
1599 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1600 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1601 Vector3 childPosition(6.0f, 6.0f, 6.0f);
1602 child.SetProperty(Actor::Property::POSITION, childPosition);
1605 // The actors should not have a world position yet
1606 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1607 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1609 application.SendNotification();
1610 application.Render(0);
1612 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1613 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1615 // The actors should have a world position now
1616 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1617 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1621 int UtcDaliActorSetInheritPosition(void)
1623 tet_infoline("Testing Actor::SetInheritPosition");
1624 TestApplication application;
1626 Actor parent = Actor::New();
1627 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1628 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1629 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1630 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1631 application.GetScene().Add(parent);
1633 Actor child = Actor::New();
1634 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1635 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1636 Vector3 childPosition(10.0f, 11.0f, 12.0f);
1637 child.SetProperty(Actor::Property::POSITION, childPosition);
1640 // The actors should not have a world position yet
1641 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1642 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1644 // first test default, which is to inherit position
1645 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1646 application.SendNotification();
1647 application.Render(0); // should only really call Update as Render is not required to update scene
1648 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1649 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1650 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1651 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1653 //Change child position
1654 Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1655 child.SetProperty(Actor::Property::POSITION, childOffset);
1657 // Use local position as world postion
1658 child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1659 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1660 application.SendNotification();
1661 application.Render(0); // should only really call Update as Render is not required to update scene
1662 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1663 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1664 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1665 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1667 //Change back to inherit position from parent
1668 child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1669 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1670 application.SendNotification();
1671 application.Render(0); // should only really call Update as Render is not required to update scene
1672 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1673 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1674 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1675 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1679 int UtcDaliActorInheritOpacity(void)
1681 tet_infoline("Testing Actor::Inherit Opacity");
1682 TestApplication application;
1684 Actor parent = Actor::New();
1685 Actor child = Actor::New();
1687 application.GetScene().Add(parent);
1689 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1690 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1692 // flush the queue and render once
1693 application.SendNotification();
1694 application.Render();
1696 parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1698 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1699 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1701 application.SendNotification();
1702 application.Render();
1704 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1705 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1706 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1707 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1708 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1709 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1714 // SetOrientation(float angleRadians, Vector3 axis)
1715 int UtcDaliActorSetOrientation01(void)
1717 TestApplication application;
1719 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1720 Actor actor = Actor::New();
1722 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1724 // flush the queue and render once
1725 application.SendNotification();
1726 application.Render();
1728 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1732 int UtcDaliActorSetOrientation02(void)
1734 TestApplication application;
1736 Actor actor = Actor::New();
1738 Radian angle(0.785f);
1739 Vector3 axis(1.0f, 1.0f, 0.0f);
1741 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1742 Quaternion rotation(angle, axis);
1743 // flush the queue and render once
1744 application.SendNotification();
1745 application.Render();
1746 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1748 application.GetScene().Add(actor);
1749 actor.RotateBy(Degree(360), axis);
1750 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1752 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
1753 Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
1754 // flush the queue and render once
1755 application.SendNotification();
1756 application.Render();
1757 DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1759 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1760 // flush the queue and render once
1761 application.SendNotification();
1762 application.Render();
1763 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1765 application.GetScene().Remove(actor);
1769 // SetOrientation(float angleRadians, Vector3 axis)
1770 int UtcDaliActorSetOrientationProperty(void)
1772 TestApplication application;
1774 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1775 Actor actor = Actor::New();
1777 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1778 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1780 // flush the queue and render once
1781 application.SendNotification();
1782 application.Render();
1784 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1785 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1786 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1790 // RotateBy(float angleRadians, Vector3 axis)
1791 int UtcDaliActorRotateBy01(void)
1793 TestApplication application;
1795 Actor actor = Actor::New();
1797 Radian angle(M_PI * 0.25f);
1798 actor.RotateBy((angle), Vector3::ZAXIS);
1799 // flush the queue and render once
1800 application.SendNotification();
1801 application.Render();
1802 DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1804 application.GetScene().Add(actor);
1806 actor.RotateBy(angle, Vector3::ZAXIS);
1807 // flush the queue and render once
1808 application.SendNotification();
1809 application.Render();
1810 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1812 application.GetScene().Remove(actor);
1816 // RotateBy(Quaternion relativeRotation)
1817 int UtcDaliActorRotateBy02(void)
1819 TestApplication application;
1821 Actor actor = Actor::New();
1823 Radian angle(M_PI * 0.25f);
1824 Quaternion rotation(angle, Vector3::ZAXIS);
1825 actor.RotateBy(rotation);
1826 // flush the queue and render once
1827 application.SendNotification();
1828 application.Render();
1829 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1831 actor.RotateBy(rotation);
1832 // flush the queue and render once
1833 application.SendNotification();
1834 application.Render();
1835 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1839 int UtcDaliActorGetCurrentOrientation(void)
1841 TestApplication application;
1842 Actor actor = Actor::New();
1844 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1845 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1846 // flush the queue and render once
1847 application.SendNotification();
1848 application.Render();
1849 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1853 int UtcDaliActorGetCurrentWorldOrientation(void)
1855 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1856 TestApplication application;
1858 Actor parent = Actor::New();
1859 Radian rotationAngle(Degree(90.0f));
1860 Quaternion rotation(rotationAngle, Vector3::YAXIS);
1861 parent.SetProperty(Actor::Property::ORIENTATION, rotation);
1862 application.GetScene().Add(parent);
1864 Actor child = Actor::New();
1865 child.SetProperty(Actor::Property::ORIENTATION, rotation);
1868 // The actors should not have a world rotation yet
1869 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1870 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1872 application.SendNotification();
1873 application.Render(0);
1875 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1876 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1878 // The actors should have a world rotation now
1879 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1880 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
1882 // turn off child rotation inheritance
1883 child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
1884 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
1885 application.SendNotification();
1886 application.Render(0);
1888 // The actors should have a world rotation now
1889 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1890 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
1894 // SetScale(float scale)
1895 int UtcDaliActorSetScale01(void)
1897 TestApplication application;
1899 Actor actor = Actor::New();
1901 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1902 actor.SetProperty(Actor::Property::SCALE, 0.25f);
1904 Vector3 scale(10.0f, 10.0f, 10.0f);
1905 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1907 actor.SetProperty(Actor::Property::SCALE, scale.x);
1909 // flush the queue and render once
1910 application.SendNotification();
1911 application.Render();
1913 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1917 // SetScale(float scaleX, float scaleY, float scaleZ)
1918 int UtcDaliActorSetScale02(void)
1920 TestApplication application;
1921 Vector3 scale(10.0f, 10.0f, 10.0f);
1923 Actor actor = Actor::New();
1925 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1926 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1928 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1930 actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
1931 // flush the queue and render once
1932 application.SendNotification();
1933 application.Render();
1934 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1936 // add to stage and test
1937 application.GetScene().Add(actor);
1938 actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
1939 // flush the queue and render once
1940 application.SendNotification();
1941 application.Render();
1942 DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
1944 application.GetScene().Remove(actor);
1949 // SetScale(Vector3 scale)
1950 int UtcDaliActorSetScale03(void)
1952 TestApplication application;
1953 Vector3 scale(10.0f, 10.0f, 10.0f);
1955 Actor actor = Actor::New();
1957 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1958 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1960 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1962 actor.SetProperty(Actor::Property::SCALE, scale);
1964 // flush the queue and render once
1965 application.SendNotification();
1966 application.Render();
1968 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1972 int UtcDaliActorSetScaleIndividual(void)
1974 TestApplication application;
1976 Actor actor = Actor::New();
1978 Vector3 vector(0.7f, 0.8f, 0.9f);
1979 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
1981 actor.SetProperty(Actor::Property::SCALE_X, vector.x);
1982 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1984 // flush the queue and render once
1985 application.SendNotification();
1986 application.Render();
1988 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
1989 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1990 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1992 actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
1993 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
1995 // flush the queue and render once
1996 application.SendNotification();
1997 application.Render();
1999 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2000 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2001 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2003 actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2004 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2006 // flush the queue and render once
2007 application.SendNotification();
2008 application.Render();
2010 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2011 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2012 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2014 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2015 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2020 int UtcDaliActorScaleBy(void)
2022 TestApplication application;
2023 Actor actor = Actor::New();
2024 Vector3 vector(100.0f, 100.0f, 100.0f);
2026 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2028 actor.SetProperty(Actor::Property::SCALE, vector);
2030 // flush the queue and render once
2031 application.SendNotification();
2032 application.Render();
2034 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2036 actor.ScaleBy(vector);
2038 // flush the queue and render once
2039 application.SendNotification();
2040 application.Render();
2042 DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2046 int UtcDaliActorGetCurrentScale(void)
2048 TestApplication application;
2049 Vector3 scale(12.0f, 1.0f, 2.0f);
2051 Actor actor = Actor::New();
2053 actor.SetProperty(Actor::Property::SCALE, scale);
2055 // flush the queue and render once
2056 application.SendNotification();
2057 application.Render();
2059 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2063 int UtcDaliActorGetCurrentWorldScale(void)
2065 TestApplication application;
2067 Actor parent = Actor::New();
2068 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2069 parent.SetProperty(Actor::Property::SCALE, parentScale);
2070 application.GetScene().Add(parent);
2072 Actor child = Actor::New();
2073 Vector3 childScale(2.0f, 2.0f, 2.0f);
2074 child.SetProperty(Actor::Property::SCALE, childScale);
2077 // The actors should not have a scale yet
2078 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2079 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2081 // The actors should not have a world scale yet
2082 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2083 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2085 application.SendNotification();
2086 application.Render(0);
2088 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2089 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2091 // The actors should have a world scale now
2092 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2093 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2097 int UtcDaliActorInheritScale(void)
2099 tet_infoline("Testing Actor::SetInheritScale");
2100 TestApplication application;
2102 Actor parent = Actor::New();
2103 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2104 parent.SetProperty(Actor::Property::SCALE, parentScale);
2105 application.GetScene().Add(parent);
2107 Actor child = Actor::New();
2108 Vector3 childScale(2.0f, 2.0f, 2.0f);
2109 child.SetProperty(Actor::Property::SCALE, childScale);
2112 application.SendNotification();
2113 application.Render(0);
2115 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2116 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2118 child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2119 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2121 application.SendNotification();
2122 application.Render(0);
2124 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2128 int UtcDaliActorSetVisible(void)
2130 TestApplication application;
2132 Actor actor = Actor::New();
2133 actor.SetProperty(Actor::Property::VISIBLE, false);
2134 // flush the queue and render once
2135 application.SendNotification();
2136 application.Render();
2137 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2139 actor.SetProperty(Actor::Property::VISIBLE, true);
2140 // flush the queue and render once
2141 application.SendNotification();
2142 application.Render();
2143 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2145 // put actor on stage
2146 application.GetScene().Add(actor);
2147 actor.SetProperty(Actor::Property::VISIBLE, false);
2148 // flush the queue and render once
2149 application.SendNotification();
2150 application.Render();
2151 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2155 int UtcDaliActorIsVisible(void)
2157 TestApplication application;
2159 Actor actor = Actor::New();
2161 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2165 int UtcDaliActorSetOpacity(void)
2167 TestApplication application;
2169 Actor actor = Actor::New();
2170 // initial opacity is 1
2171 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2173 actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2174 // flush the queue and render once
2175 application.SendNotification();
2176 application.Render();
2177 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2179 // change opacity, actor is on stage to change is not immediate
2180 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2181 // flush the queue and render once
2182 application.SendNotification();
2183 application.Render();
2184 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2186 // put actor on stage
2187 application.GetScene().Add(actor);
2189 // change opacity, actor is on stage to change is not immediate
2190 actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2191 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2192 // flush the queue and render once
2193 application.SendNotification();
2194 application.Render();
2195 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2197 // change opacity, actor is on stage to change is not immediate
2198 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2199 // flush the queue and render once
2200 application.SendNotification();
2201 application.Render();
2202 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2206 int UtcDaliActorGetCurrentOpacity(void)
2208 TestApplication application;
2210 Actor actor = Actor::New();
2211 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2213 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2214 // flush the queue and render once
2215 application.SendNotification();
2216 application.Render();
2217 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2221 int UtcDaliActorSetSensitive(void)
2223 TestApplication application;
2224 Actor actor = Actor::New();
2226 bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2228 actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2230 DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2234 int UtcDaliActorIsSensitive(void)
2236 TestApplication application;
2237 Actor actor = Actor::New();
2238 actor.SetProperty(Actor::Property::SENSITIVE, false);
2240 DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2244 int UtcDaliActorSetColor(void)
2246 TestApplication application;
2247 Actor actor = Actor::New();
2248 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2250 DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2252 actor.SetProperty(Actor::Property::COLOR, color);
2253 // flush the queue and render once
2254 application.SendNotification();
2255 application.Render();
2256 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2258 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2259 // flush the queue and render once
2260 application.SendNotification();
2261 application.Render();
2262 DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2264 application.GetScene().Add(actor);
2265 actor.SetProperty(Actor::Property::COLOR, color);
2266 // flush the queue and render once
2267 application.SendNotification();
2268 application.Render();
2269 DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2271 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2272 // flush the queue and render once
2273 application.SendNotification();
2274 application.Render();
2275 // Actor color is not clamped
2276 DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2277 // world color is clamped
2278 DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2280 actor.SetProperty(Actor::Property::COLOR, color);
2281 DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2283 Vector3 newColor(1.0f, 0.0f, 0.0f);
2284 actor.SetProperty(Actor::Property::COLOR, newColor);
2285 DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2287 application.GetScene().Remove(actor);
2291 int UtcDaliActorSetColorIndividual(void)
2293 TestApplication application;
2295 Actor actor = Actor::New();
2297 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2298 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2300 actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2301 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2303 // flush the queue and render once
2304 application.SendNotification();
2305 application.Render();
2307 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2308 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2309 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2311 actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2312 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2314 // flush the queue and render once
2315 application.SendNotification();
2316 application.Render();
2318 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2319 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2320 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2322 actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2323 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2325 // flush the queue and render once
2326 application.SendNotification();
2327 application.Render();
2329 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2330 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2331 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2333 actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2334 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2336 // flush the queue and render once
2337 application.SendNotification();
2338 application.Render();
2340 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2341 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2342 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2344 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2345 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2347 actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2349 // flush the queue and render once
2350 application.SendNotification();
2351 application.Render();
2353 DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2358 int UtcDaliActorGetCurrentColor(void)
2360 TestApplication application;
2361 Actor actor = Actor::New();
2362 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2364 actor.SetProperty(Actor::Property::COLOR, color);
2365 // flush the queue and render once
2366 application.SendNotification();
2367 application.Render();
2368 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2372 int UtcDaliActorGetCurrentWorldColor(void)
2374 tet_infoline("Actor::GetCurrentWorldColor");
2375 TestApplication application;
2377 Actor parent = Actor::New();
2378 Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2379 parent.SetProperty(Actor::Property::COLOR, parentColor);
2380 application.GetScene().Add(parent);
2382 Actor child = Actor::New();
2383 Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2384 child.SetProperty(Actor::Property::COLOR, childColor);
2387 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2388 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2390 // verify the default color mode
2391 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2393 // The actors should not have a world color yet
2394 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2395 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2397 application.SendNotification();
2398 application.Render(0);
2400 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2401 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2403 // The actors should have a world color now
2404 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2405 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2408 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2409 application.SendNotification();
2410 application.Render(0);
2411 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2414 child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2415 application.SendNotification();
2416 application.Render(0);
2417 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2418 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2421 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2422 application.SendNotification();
2423 application.Render(0);
2424 Vector4 expectedColor(childColor);
2425 expectedColor.a *= parentColor.a;
2426 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2427 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2431 int UtcDaliActorSetColorMode(void)
2433 tet_infoline("Actor::SetColorMode");
2434 TestApplication application;
2435 Actor actor = Actor::New();
2436 Actor child = Actor::New();
2439 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2440 DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2442 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2443 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2445 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2446 DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2448 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2449 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2453 int UtcDaliActorScreenToLocal(void)
2455 TestApplication application;
2456 Actor actor = Actor::New();
2457 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2458 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2459 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2460 application.GetScene().Add(actor);
2462 // flush the queue and render once
2463 application.SendNotification();
2464 application.Render();
2469 application.SendNotification();
2470 application.Render();
2472 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2474 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2475 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2479 int UtcDaliActorSetLeaveRequired(void)
2481 TestApplication application;
2483 Actor actor = Actor::New();
2485 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2486 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2488 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2489 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2493 int UtcDaliActorGetLeaveRequired(void)
2495 TestApplication application;
2497 Actor actor = Actor::New();
2499 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2503 int UtcDaliActorSetKeyboardFocusable(void)
2505 TestApplication application;
2507 Actor actor = Actor::New();
2509 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2510 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2512 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2513 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2517 int UtcDaliActorIsKeyboardFocusable(void)
2519 TestApplication application;
2521 Actor actor = Actor::New();
2523 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2527 int UtcDaliActorRemoveConstraints(void)
2529 tet_infoline(" UtcDaliActorRemoveConstraints");
2530 TestApplication application;
2532 gTestConstraintCalled = false;
2534 Actor actor = Actor::New();
2536 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2538 actor.RemoveConstraints();
2540 DALI_TEST_CHECK(gTestConstraintCalled == false);
2542 application.GetScene().Add(actor);
2545 // flush the queue and render once
2546 application.SendNotification();
2547 application.Render();
2549 actor.RemoveConstraints();
2551 DALI_TEST_CHECK(gTestConstraintCalled == true);
2555 int UtcDaliActorRemoveConstraintTag(void)
2557 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2558 TestApplication application;
2560 Actor actor = Actor::New();
2562 // 1. Apply Constraint1 and Constraint2, and test...
2563 unsigned int result1 = 0u;
2564 unsigned int result2 = 0u;
2566 unsigned constraint1Tag = 1u;
2567 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2568 constraint1.SetTag(constraint1Tag);
2569 constraint1.Apply();
2571 unsigned constraint2Tag = 2u;
2572 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2573 constraint2.SetTag(constraint2Tag);
2574 constraint2.Apply();
2576 application.GetScene().Add(actor);
2577 // flush the queue and render once
2578 application.SendNotification();
2579 application.Render();
2581 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2582 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2584 // 2. Remove Constraint1 and test...
2587 actor.RemoveConstraints(constraint1Tag);
2588 // make color property dirty, which will trigger constraints to be reapplied.
2589 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2590 // flush the queue and render once
2591 application.SendNotification();
2592 application.Render();
2594 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2595 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2597 // 3. Re-Apply Constraint1 and test...
2600 constraint1.Apply();
2601 // make color property dirty, which will trigger constraints to be reapplied.
2602 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2603 // flush the queue and render once
2604 application.SendNotification();
2605 application.Render();
2607 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2608 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2610 // 2. Remove Constraint2 and test...
2613 actor.RemoveConstraints(constraint2Tag);
2614 // make color property dirty, which will trigger constraints to be reapplied.
2615 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2616 // flush the queue and render once
2617 application.SendNotification();
2618 application.Render();
2620 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2621 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2623 // 2. Remove Constraint1 as well and test...
2626 actor.RemoveConstraints(constraint1Tag);
2627 // make color property dirty, which will trigger constraints to be reapplied.
2628 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2629 // flush the queue and render once
2630 application.SendNotification();
2631 application.Render();
2633 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2634 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2638 int UtcDaliActorTouchedSignal(void)
2640 TestApplication application;
2642 ResetTouchCallbacks();
2644 // get the root layer
2645 Actor actor = application.GetScene().GetRootLayer();
2646 DALI_TEST_CHECK(gTouchCallBackCalled == false);
2648 application.SendNotification();
2649 application.Render();
2651 // connect to its touch signal
2652 actor.TouchedSignal().Connect(TestTouchCallback);
2654 // simulate a touch event in the middle of the screen
2655 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2656 Dali::Integration::Point point;
2657 point.SetDeviceId(1);
2658 point.SetState(PointState::DOWN);
2659 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2660 Dali::Integration::TouchEvent touchEvent;
2661 touchEvent.AddPoint(point);
2662 application.ProcessEvent(touchEvent);
2664 DALI_TEST_CHECK(gTouchCallBackCalled == true);
2668 int UtcDaliActorHoveredSignal(void)
2670 TestApplication application;
2672 gHoverCallBackCalled = false;
2674 // get the root layer
2675 Actor actor = application.GetScene().GetRootLayer();
2676 DALI_TEST_CHECK(gHoverCallBackCalled == false);
2678 application.SendNotification();
2679 application.Render();
2681 // connect to its hover signal
2682 actor.HoveredSignal().Connect(TestCallback3);
2684 // simulate a hover event in the middle of the screen
2685 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2686 Dali::Integration::Point point;
2687 point.SetDeviceId(1);
2688 point.SetState(PointState::MOTION);
2689 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2690 Dali::Integration::HoverEvent hoverEvent;
2691 hoverEvent.AddPoint(point);
2692 application.ProcessEvent(hoverEvent);
2694 DALI_TEST_CHECK(gHoverCallBackCalled == true);
2698 int UtcDaliActorOnOffSceneSignal(void)
2700 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2702 TestApplication application;
2705 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2706 gActorNamesOnOffScene.clear();
2708 Actor parent = Actor::New();
2709 parent.SetProperty(Actor::Property::NAME, "parent");
2710 parent.OnSceneSignal().Connect(OnSceneCallback);
2711 parent.OffSceneSignal().Connect(OffSceneCallback);
2713 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2714 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2716 // add parent to the scene
2717 application.GetScene().Add(parent);
2718 // onstage emitted, offstage not
2719 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2720 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2721 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2723 // test adding a child, should get onstage emitted
2725 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2726 gActorNamesOnOffScene.clear();
2728 Actor child = Actor::New();
2729 child.SetProperty(Actor::Property::NAME, "child");
2730 child.OnSceneSignal().Connect(OnSceneCallback);
2731 child.OffSceneSignal().Connect(OffSceneCallback);
2732 parent.Add(child); // add child
2733 // onscene emitted, offscene not
2734 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2735 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2736 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2738 // test removing parent from the scene
2740 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2741 gActorNamesOnOffScene.clear();
2743 application.GetScene().Remove(parent);
2744 // onscene not emitted, offscene is
2745 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2746 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2747 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2748 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2750 // test adding parent back to the scene
2752 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2753 gActorNamesOnOffScene.clear();
2755 application.GetScene().Add(parent);
2756 // onscene emitted, offscene not
2757 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2758 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2759 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2760 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2762 // test removing child
2764 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2765 gActorNamesOnOffScene.clear();
2767 parent.Remove(child);
2768 // onscene not emitted, offscene is
2769 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2770 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2771 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2773 // test removing parent
2775 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2776 gActorNamesOnOffScene.clear();
2778 application.GetScene().Remove(parent);
2779 // onscene not emitted, offscene is
2780 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2781 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2782 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2786 int UtcDaliActorFindChildByName(void)
2788 tet_infoline("Testing Dali::Actor::FindChildByName()");
2789 TestApplication application;
2791 Actor parent = Actor::New();
2792 parent.SetProperty(Actor::Property::NAME, "parent");
2793 Actor first = Actor::New();
2794 first.SetProperty(Actor::Property::NAME, "first");
2795 Actor second = Actor::New();
2796 second.SetProperty(Actor::Property::NAME, "second");
2801 Actor found = parent.FindChildByName("foo");
2802 DALI_TEST_CHECK(!found);
2804 found = parent.FindChildByName("parent");
2805 DALI_TEST_CHECK(found == parent);
2807 found = parent.FindChildByName("first");
2808 DALI_TEST_CHECK(found == first);
2810 found = parent.FindChildByName("second");
2811 DALI_TEST_CHECK(found == second);
2815 int UtcDaliActorFindChildById(void)
2817 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2818 TestApplication application;
2820 Actor parent = Actor::New();
2821 Actor first = Actor::New();
2822 Actor second = Actor::New();
2827 Actor found = parent.FindChildById(100000);
2828 DALI_TEST_CHECK(!found);
2830 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2831 DALI_TEST_CHECK(found == parent);
2833 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2834 DALI_TEST_CHECK(found == first);
2836 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2837 DALI_TEST_CHECK(found == second);
2841 int UtcDaliActorHitTest(void)
2846 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2848 mTouchPoint(touchPoint),
2854 Vector2 mTouchPoint;
2858 TestApplication application;
2859 tet_infoline(" UtcDaliActorHitTest");
2861 // Fill a vector with different hit tests.
2862 struct HitTestData* hitTestData[] = {
2863 // scale touch point result
2864 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
2865 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2866 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.
2867 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2868 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.
2872 // get the root layer
2873 Actor actor = Actor::New();
2874 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2875 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2877 application.GetScene().Add(actor);
2879 ResetTouchCallbacks();
2881 unsigned int index = 0;
2882 while(NULL != hitTestData[index])
2884 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2885 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2887 // flush the queue and render once
2888 application.SendNotification();
2889 application.Render();
2891 DALI_TEST_CHECK(!gTouchCallBackCalled);
2893 // connect to its touch signal
2894 actor.TouchedSignal().Connect(TestTouchCallback);
2896 Dali::Integration::Point point;
2897 point.SetState(PointState::DOWN);
2898 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2899 Dali::Integration::TouchEvent event;
2900 event.AddPoint(point);
2902 // flush the queue and render once
2903 application.SendNotification();
2904 application.Render();
2905 application.ProcessEvent(event);
2907 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
2909 if(gTouchCallBackCalled != hitTestData[index]->mResult)
2910 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2911 hitTestData[index]->mScale.x,
2912 hitTestData[index]->mScale.y,
2913 hitTestData[index]->mScale.z,
2914 hitTestData[index]->mTouchPoint.x,
2915 hitTestData[index]->mTouchPoint.y,
2916 hitTestData[index]->mResult);
2918 ResetTouchCallbacks();
2924 int UtcDaliActorSetDrawMode(void)
2926 TestApplication application;
2927 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2929 Actor a = Actor::New();
2931 application.GetScene().Add(a);
2932 application.SendNotification();
2933 application.Render(0);
2934 application.SendNotification();
2935 application.Render(1);
2937 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
2939 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2940 application.SendNotification();
2941 application.Render(1);
2943 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
2945 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
2946 application.SendNotification();
2947 application.Render(1);
2949 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
2953 int UtcDaliActorSetDrawModeOverlayRender(void)
2955 TestApplication application;
2956 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2958 application.SendNotification();
2959 application.Render(1);
2961 std::vector<GLuint> ids;
2962 ids.push_back(8); // first rendered actor
2963 ids.push_back(9); // second rendered actor
2964 ids.push_back(10); // third rendered actor
2965 application.GetGlAbstraction().SetNextTextureIds(ids);
2967 Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2968 Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2969 Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2970 Actor a = CreateRenderableActor(imageA);
2971 Actor b = CreateRenderableActor(imageB);
2972 Actor c = CreateRenderableActor(imageC);
2974 application.SendNotification();
2975 application.Render(1);
2977 //Textures are bound when first created. Clear bound textures vector
2978 application.GetGlAbstraction().ClearBoundTextures();
2980 // Render a,b,c as regular non-overlays. so order will be:
2984 application.GetScene().Add(a);
2985 application.GetScene().Add(b);
2986 application.GetScene().Add(c);
2988 application.SendNotification();
2989 application.Render(1);
2991 // Should be 3 textures changes.
2992 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
2993 typedef std::vector<GLuint>::size_type TextureSize;
2994 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
2995 if(boundTextures.size() == 3)
2997 DALI_TEST_CHECK(boundTextures[0] == 8u);
2998 DALI_TEST_CHECK(boundTextures[1] == 9u);
2999 DALI_TEST_CHECK(boundTextures[2] == 10u);
3002 // Now texture ids have been set, we can monitor their render order.
3003 // render a as an overlay (last), so order will be:
3007 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3008 application.GetGlAbstraction().ClearBoundTextures();
3010 application.SendNotification();
3011 application.Render(1);
3013 // Should be 3 texture changes.
3014 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3015 if(boundTextures.size() == 3)
3017 DALI_TEST_CHECK(boundTextures[0] == 9u);
3018 DALI_TEST_CHECK(boundTextures[1] == 10u);
3019 DALI_TEST_CHECK(boundTextures[2] == 8u);
3024 int UtcDaliActorGetCurrentWorldMatrix(void)
3026 TestApplication application;
3027 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3029 Actor parent = Actor::New();
3030 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3031 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3032 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3033 Radian rotationAngle(Degree(85.0f));
3034 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3035 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3036 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3037 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3038 parent.SetProperty(Actor::Property::SCALE, parentScale);
3039 application.GetScene().Add(parent);
3041 Actor child = Actor::New();
3042 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3043 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3044 Radian childRotationAngle(Degree(23.0f));
3045 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3046 Vector3 childScale(2.0f, 2.0f, 2.0f);
3047 child.SetProperty(Actor::Property::POSITION, childPosition);
3048 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3049 child.SetProperty(Actor::Property::SCALE, childScale);
3052 application.SendNotification();
3053 application.Render(0);
3054 application.Render();
3055 application.SendNotification();
3057 Matrix parentMatrix(false);
3058 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3060 Matrix childMatrix(false);
3061 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3063 //Child matrix should be the composition of child and parent
3064 Matrix childWorldMatrix(false);
3065 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3067 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3068 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3072 int UtcDaliActorConstrainedToWorldMatrix(void)
3074 TestApplication application;
3075 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3077 Actor parent = Actor::New();
3078 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3079 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3080 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3081 Radian rotationAngle(Degree(85.0f));
3082 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3083 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3084 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3085 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3086 parent.SetProperty(Actor::Property::SCALE, parentScale);
3087 application.GetScene().Add(parent);
3089 Actor child = Actor::New();
3090 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3091 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3092 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3093 posConstraint.Apply();
3095 application.GetScene().Add(child);
3097 application.SendNotification();
3098 application.Render(0);
3099 application.Render();
3100 application.SendNotification();
3102 Matrix parentMatrix(false);
3103 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3105 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3106 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3110 int UtcDaliActorConstrainedToOrientation(void)
3112 TestApplication application;
3113 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3115 Actor parent = Actor::New();
3116 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3117 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3118 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3119 Radian rotationAngle(Degree(85.0f));
3120 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3121 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3122 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3123 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3124 parent.SetProperty(Actor::Property::SCALE, parentScale);
3125 application.GetScene().Add(parent);
3127 Actor child = Actor::New();
3128 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3129 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3130 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3131 posConstraint.Apply();
3133 application.GetScene().Add(child);
3135 application.SendNotification();
3136 application.Render(0);
3137 application.Render();
3138 application.SendNotification();
3140 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3144 int UtcDaliActorConstrainedToOpacity(void)
3146 TestApplication application;
3147 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3149 Actor parent = Actor::New();
3150 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3151 application.GetScene().Add(parent);
3153 Actor child = Actor::New();
3154 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3155 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3156 opacityConstraint.Apply();
3158 application.GetScene().Add(child);
3160 application.SendNotification();
3161 application.Render(0);
3162 application.Render();
3163 application.SendNotification();
3165 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3167 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3169 application.SendNotification();
3170 application.Render(0);
3171 application.Render();
3172 application.SendNotification();
3174 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3179 int UtcDaliActorUnparent(void)
3181 TestApplication application;
3182 tet_infoline(" UtcDaliActorUnparent");
3184 Actor parent = Actor::New();
3185 application.GetScene().Add(parent);
3187 Actor child = Actor::New();
3189 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3190 DALI_TEST_CHECK(!child.GetParent());
3192 // Test that calling Unparent with no parent is a NOOP
3195 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3196 DALI_TEST_CHECK(!child.GetParent());
3198 // Test that Unparent works
3201 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3202 DALI_TEST_CHECK(parent == child.GetParent());
3206 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3207 DALI_TEST_CHECK(!child.GetParent());
3209 // Test that UnparentAndReset works
3212 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3213 DALI_TEST_CHECK(parent == child.GetParent());
3215 UnparentAndReset(child);
3217 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3218 DALI_TEST_CHECK(!child);
3220 // Test that UnparentAndReset is a NOOP with empty handle
3221 UnparentAndReset(child);
3223 DALI_TEST_CHECK(!child);
3227 int UtcDaliActorGetChildAt(void)
3229 TestApplication application;
3230 tet_infoline(" UtcDaliActorGetChildAt");
3232 Actor parent = Actor::New();
3233 application.GetScene().Add(parent);
3235 Actor child0 = Actor::New();
3238 Actor child1 = Actor::New();
3241 Actor child2 = Actor::New();
3244 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3245 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3246 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3250 int UtcDaliActorSetGetOverlay(void)
3252 TestApplication application;
3253 tet_infoline(" UtcDaliActorSetGetOverlay");
3255 Actor parent = Actor::New();
3256 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3257 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3261 int UtcDaliActorCreateDestroy(void)
3263 Actor* actor = new Actor;
3264 DALI_TEST_CHECK(actor);
3271 struct PropertyStringIndex
3273 const char* const name;
3274 const Property::Index index;
3275 const Property::Type type;
3278 const PropertyStringIndex PROPERTY_TABLE[] =
3280 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3281 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3282 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3283 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3284 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3285 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3286 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3287 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3288 {"size", Actor::Property::SIZE, Property::VECTOR3},
3289 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3290 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3291 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3292 {"position", Actor::Property::POSITION, Property::VECTOR3},
3293 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3294 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3295 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3296 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3297 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3298 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3299 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3300 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3301 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3302 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3303 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3304 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3305 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3306 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3307 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3308 {"color", Actor::Property::COLOR, Property::VECTOR4},
3309 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3310 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3311 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3312 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3313 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3314 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3315 {"name", Actor::Property::NAME, Property::STRING},
3316 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3317 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3318 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3319 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3320 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3321 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3322 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3323 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3324 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3325 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3326 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3327 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3328 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3329 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3330 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3331 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3332 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3333 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3335 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3336 } // unnamed namespace
3338 int UtcDaliActorProperties(void)
3340 TestApplication application;
3342 Actor actor = Actor::New();
3344 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3346 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3347 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3348 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3349 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3354 int UtcDaliRelayoutProperties_ResizePolicies(void)
3356 TestApplication application;
3358 Actor actor = Actor::New();
3361 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3362 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3364 // Set resize policy for all dimensions
3365 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3366 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3368 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3371 // Set individual dimensions
3372 const char* const widthPolicy = "FILL_TO_PARENT";
3373 const char* const heightPolicy = "FIXED";
3375 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3376 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3378 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3379 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3381 // Set individual dimensions using enums
3382 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3383 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3385 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3386 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3388 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3389 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3394 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3396 TestApplication application;
3398 Actor actor = Actor::New();
3401 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3403 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3404 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3405 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3408 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3409 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3411 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3412 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3414 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3415 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3420 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3422 TestApplication application;
3424 Actor actor = Actor::New();
3427 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3428 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3430 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3431 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3432 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3435 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3437 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3438 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3443 int UtcDaliRelayoutProperties_DimensionDependency(void)
3445 TestApplication application;
3447 Actor actor = Actor::New();
3450 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3451 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3454 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3455 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3457 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3458 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3460 // Test setting another resize policy
3461 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3462 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3467 int UtcDaliRelayoutProperties_Padding(void)
3469 TestApplication application;
3471 Actor actor = Actor::New();
3474 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3477 actor.SetProperty(Actor::Property::PADDING, padding);
3478 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3480 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3485 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3487 TestApplication application;
3489 Actor actor = Actor::New();
3492 Vector2 minSize(1.0f, 2.0f);
3494 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3495 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3497 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3499 Vector2 maxSize(3.0f, 4.0f);
3501 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3502 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3504 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3509 int UtcDaliActorGetHeightForWidth(void)
3511 TestApplication application;
3513 Actor actor = Actor::New();
3515 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3520 int UtcDaliActorGetWidthForHeight(void)
3522 TestApplication application;
3524 Actor actor = Actor::New();
3526 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3531 int UtcDaliActorGetRelayoutSize(void)
3533 TestApplication application;
3535 Actor actor = Actor::New();
3537 // Add actor to stage
3538 application.GetScene().Add(actor);
3540 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3542 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3543 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3545 // Flush the queue and render once
3546 application.SendNotification();
3547 application.Render();
3549 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3554 int UtcDaliActorSetPadding(void)
3556 TestApplication application;
3558 Actor actor = Actor::New();
3561 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3563 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3564 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3565 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3566 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3568 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3569 actor.SetProperty(Actor::Property::PADDING, padding2);
3571 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3573 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3574 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3575 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3576 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3581 int UtcDaliActorSetMinimumSize(void)
3583 TestApplication application;
3585 Actor actor = Actor::New();
3587 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3589 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3590 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3592 Vector2 size2(1.0f, 2.0f);
3593 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3595 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3597 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3598 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3603 int UtcDaliActorSetMaximumSize(void)
3605 TestApplication application;
3607 Actor actor = Actor::New();
3609 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3611 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3612 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3614 Vector2 size2(1.0f, 2.0f);
3615 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3617 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3619 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3620 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3625 int UtcDaliActorOnRelayoutSignal(void)
3627 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3629 TestApplication application;
3632 gOnRelayoutCallBackCalled = false;
3633 gActorNamesRelayout.clear();
3635 Actor actor = Actor::New();
3636 actor.SetProperty(Actor::Property::NAME, "actor");
3637 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3640 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3642 // Add actor to stage
3643 application.GetScene().Add(actor);
3645 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3646 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3648 // Flush the queue and render once
3649 application.SendNotification();
3650 application.Render();
3652 // OnRelayout emitted
3653 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3654 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3659 int UtcDaliActorGetHierachyDepth(void)
3661 TestApplication application;
3662 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3664 /* Build tree of actors:
3674 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3676 Integration::Scene stage(application.GetScene());
3678 Actor actorA = Actor::New();
3679 Actor actorB = Actor::New();
3680 Actor actorC = Actor::New();
3681 Actor actorD = Actor::New();
3682 Actor actorE = Actor::New();
3683 Actor actorF = Actor::New();
3685 //Test that root actor has depth equal 0
3686 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3688 //Test actors return depth -1 when not connected to the tree
3689 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3690 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3691 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3692 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3693 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3694 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3696 //Create the hierarchy
3704 //Test actors return correct depth
3705 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3706 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3707 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3708 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3709 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3710 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3712 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3713 actorA.Remove(actorB);
3715 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3716 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3717 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3719 //Removing actorA from the stage. All actors should have depth equal -1
3720 stage.Remove(actorA);
3722 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3723 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3724 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3725 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3726 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3727 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3732 int UtcDaliActorAnchorPointPropertyAsString(void)
3734 TestApplication application;
3736 Actor actor = Actor::New();
3738 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3739 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3741 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3742 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3744 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3745 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3747 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3748 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3750 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3751 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3753 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3754 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3756 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3757 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3759 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3760 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3762 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3763 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3765 // Invalid should not change anything
3766 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3767 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3772 int UtcDaliActorParentOriginPropertyAsString(void)
3774 TestApplication application;
3776 Actor actor = Actor::New();
3778 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3779 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3781 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3782 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3784 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3785 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3787 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3788 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3790 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3791 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3793 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3794 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3796 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3797 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3799 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3800 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3802 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3803 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3805 // Invalid should not change anything
3806 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3807 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3812 int UtcDaliActorColorModePropertyAsString(void)
3814 TestApplication application;
3816 Actor actor = Actor::New();
3818 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3819 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3821 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3822 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3824 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3825 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3827 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3828 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3830 // Invalid should not change anything
3831 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3832 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3837 int UtcDaliActorDrawModePropertyAsString(void)
3839 TestApplication application;
3841 Actor actor = Actor::New();
3843 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3844 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3846 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3847 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3849 // Invalid should not change anything
3850 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3851 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3856 int UtcDaliActorColorModePropertyAsEnum(void)
3858 TestApplication application;
3860 Actor actor = Actor::New();
3862 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3863 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3865 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3866 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3868 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3869 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3871 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3872 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3877 int UtcDaliActorDrawModePropertyAsEnum(void)
3879 TestApplication application;
3881 Actor actor = Actor::New();
3883 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3884 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3886 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3887 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3892 int UtcDaliActorAddRendererP(void)
3894 tet_infoline("Testing Actor::AddRenderer");
3895 TestApplication application;
3897 Actor actor = Actor::New();
3899 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3901 Geometry geometry = CreateQuadGeometry();
3902 Shader shader = CreateShader();
3903 Renderer renderer = Renderer::New(geometry, shader);
3905 actor.AddRenderer(renderer);
3906 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3907 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
3912 int UtcDaliActorAddRendererN01(void)
3914 tet_infoline("Testing Actor::AddRenderer");
3915 TestApplication application;
3917 Actor actor = Actor::New();
3923 actor.AddRenderer(renderer);
3924 tet_printf("Assertion test failed - no Exception\n");
3925 tet_result(TET_FAIL);
3927 catch(Dali::DaliException& e)
3929 DALI_TEST_PRINT_ASSERT(e);
3930 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3931 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3935 tet_printf("Assertion test failed - wrong Exception\n");
3936 tet_result(TET_FAIL);
3942 int UtcDaliActorAddRendererN02(void)
3944 tet_infoline("UtcDaliActorAddRendererN02");
3950 TestApplication application;
3952 Geometry geometry = CreateQuadGeometry();
3953 Shader shader = CreateShader();
3954 renderer = Renderer::New(geometry, shader);
3956 actor = Actor::New();
3959 // try illegal AddRenderer
3962 actor.AddRenderer(renderer);
3963 tet_printf("Assertion test failed - no Exception\n");
3964 tet_result(TET_FAIL);
3966 catch(Dali::DaliException& e)
3968 DALI_TEST_PRINT_ASSERT(e);
3969 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
3973 tet_printf("Assertion test failed - wrong Exception\n");
3974 tet_result(TET_FAIL);
3980 int UtcDaliActorAddRendererOnScene(void)
3982 tet_infoline("Testing Actor::AddRenderer");
3983 TestApplication application;
3985 Actor actor = Actor::New();
3986 application.GetScene().Add(actor);
3988 application.SendNotification();
3989 application.Render(0);
3991 Geometry geometry = CreateQuadGeometry();
3992 Shader shader = CreateShader();
3993 Renderer renderer = Renderer::New(geometry, shader);
3995 application.SendNotification();
3996 application.Render(0);
4000 actor.AddRenderer(renderer);
4001 tet_result(TET_PASS);
4005 tet_result(TET_FAIL);
4011 int UtcDaliActorRemoveRendererP1(void)
4013 tet_infoline("Testing Actor::RemoveRenderer");
4014 TestApplication application;
4016 Actor actor = Actor::New();
4018 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4021 Geometry geometry = CreateQuadGeometry();
4022 Shader shader = CreateShader();
4023 Renderer renderer = Renderer::New(geometry, shader);
4025 actor.AddRenderer(renderer);
4026 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4027 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4029 application.SendNotification();
4030 application.Render();
4034 Renderer renderer = actor.GetRendererAt(0);
4035 actor.RemoveRenderer(renderer);
4036 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4038 application.SendNotification();
4039 application.Render();
4042 // Call one final time to ensure that the renderer is actually removed after
4043 // the handle goes out of scope, and excercises the deletion code path in
4044 // scene graph and render.
4045 application.SendNotification();
4046 application.Render();
4051 int UtcDaliActorRemoveRendererP2(void)
4053 tet_infoline("Testing Actor::RemoveRenderer");
4054 TestApplication application;
4056 Actor actor = Actor::New();
4058 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4060 Geometry geometry = CreateQuadGeometry();
4061 Shader shader = CreateShader();
4062 Renderer renderer = Renderer::New(geometry, shader);
4064 actor.AddRenderer(renderer);
4065 application.SendNotification();
4066 application.Render();
4068 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4069 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4071 actor.RemoveRenderer(0);
4072 application.SendNotification();
4073 application.Render();
4075 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4077 // Shut down whilst holding onto the renderer handle.
4081 int UtcDaliActorRemoveRendererN(void)
4083 tet_infoline("Testing Actor::RemoveRenderer");
4084 TestApplication application;
4086 Actor actor = Actor::New();
4088 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4090 Geometry geometry = CreateQuadGeometry();
4091 Shader shader = CreateShader();
4092 Renderer renderer = Renderer::New(geometry, shader);
4094 actor.AddRenderer(renderer);
4095 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4096 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4098 actor.RemoveRenderer(10);
4099 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4100 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4105 // Clipping test helper functions:
4106 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4108 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4109 Actor actor = CreateRenderableActor(image);
4111 // Setup dimensions and position so actor is not skipped by culling.
4112 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4113 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4114 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4115 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4120 Actor CreateActorWithContent16x16()
4122 return CreateActorWithContent(16, 16);
4125 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4127 enabledDisableTrace.Reset();
4128 stencilTrace.Reset();
4129 enabledDisableTrace.Enable(true);
4130 stencilTrace.Enable(true);
4132 application.SendNotification();
4133 application.Render();
4135 enabledDisableTrace.Enable(false);
4136 stencilTrace.Enable(false);
4139 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4141 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4143 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4144 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4145 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4146 DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4149 int UtcDaliActorPropertyClippingP(void)
4151 // This test checks the clippingMode property.
4152 tet_infoline("Testing Actor::Property::ClippingMode: P");
4153 TestApplication application;
4155 Actor actor = Actor::New();
4157 // Check default clippingEnabled value.
4158 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4161 bool getValueResult = getValue.Get(value);
4162 DALI_TEST_CHECK(getValueResult);
4166 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4169 // Check setting the property to the stencil mode.
4170 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4172 // Check the new value was set.
4173 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4174 getValueResult = getValue.Get(value);
4175 DALI_TEST_CHECK(getValueResult);
4179 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4182 // Check setting the property to the scissor mode.
4183 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4185 // Check the new value was set.
4186 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4187 getValueResult = getValue.Get(value);
4188 DALI_TEST_CHECK(getValueResult);
4192 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4197 int UtcDaliActorPropertyClippingN(void)
4199 // Negative test case for Clipping.
4200 tet_infoline("Testing Actor::Property::ClippingMode: N");
4201 TestApplication application;
4203 Actor actor = Actor::New();
4205 // Check default clippingEnabled value.
4206 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4209 bool getValueResult = getValue.Get(value);
4210 DALI_TEST_CHECK(getValueResult);
4214 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4217 // Check setting an invalid property value won't change the current property value.
4218 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4220 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4221 getValueResult = getValue.Get(value);
4222 DALI_TEST_CHECK(getValueResult);
4226 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4232 int UtcDaliActorPropertyClippingActor(void)
4234 // This test checks that an actor is correctly setup for clipping.
4235 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4236 TestApplication application;
4238 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4239 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4240 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4241 size_t startIndex = 0u;
4243 // Create a clipping actor.
4244 Actor actorDepth1Clip = CreateActorWithContent16x16();
4245 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4246 application.GetScene().Add(actorDepth1Clip);
4248 // Gather the call trace.
4249 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4251 // Check we are writing to the color buffer.
4252 CheckColorMask(glAbstraction, true);
4254 // Check the stencil buffer was enabled.
4255 std::ostringstream oss;
4256 oss << std::hex << GL_STENCIL_TEST;
4257 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4259 // Check the stencil buffer was cleared.
4260 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4262 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4263 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4264 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4265 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4270 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4272 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4273 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4274 TestApplication application;
4276 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4277 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4278 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4279 size_t startIndex = 0u;
4281 // Create a clipping actor.
4282 Actor actorDepth1Clip = CreateActorWithContent16x16();
4283 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4284 application.GetScene().Add(actorDepth1Clip);
4286 // Gather the call trace.
4287 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4289 // Check we are writing to the color buffer.
4290 CheckColorMask(glAbstraction, true);
4292 // Check the stencil buffer was enabled.
4293 std::ostringstream oss;
4294 oss << std::hex << GL_STENCIL_TEST;
4295 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4297 // Check the stencil buffer was cleared.
4298 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4300 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4301 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4302 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4303 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4305 // Now disable the clipping
4306 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4308 // Gather the call trace.
4309 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4311 // Check the stencil buffer was disabled.
4312 std::ostringstream stencil;
4313 stencil << std::hex << GL_STENCIL_TEST;
4314 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4316 // Ensure all values in stencil-mask are set to 1.
4318 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4323 int UtcDaliActorPropertyClippingNestedChildren(void)
4325 // This test checks that a hierarchy of actors are clipped correctly by
4326 // writing to and reading from the correct bit-planes of the stencil buffer.
4327 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4328 TestApplication application;
4329 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4330 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4331 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4333 // Create a clipping actor.
4334 Actor actorDepth1Clip = CreateActorWithContent16x16();
4335 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4336 application.GetScene().Add(actorDepth1Clip);
4338 // Create a child actor.
4339 Actor childDepth2 = CreateActorWithContent16x16();
4340 actorDepth1Clip.Add(childDepth2);
4342 // Create another clipping actor.
4343 Actor childDepth2Clip = CreateActorWithContent16x16();
4344 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4345 childDepth2.Add(childDepth2Clip);
4347 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4348 // This tests the sort algorithm.
4349 Actor childDepth3 = CreateActorWithContent16x16();
4350 childDepth2Clip.Add(childDepth3);
4351 Actor childDepth4 = CreateActorWithContent16x16();
4352 childDepth3.Add(childDepth4);
4354 // Gather the call trace.
4355 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4357 // Check we are writing to the color buffer.
4358 CheckColorMask(glAbstraction, true);
4360 // Check the stencil buffer was enabled.
4361 std::ostringstream oss;
4362 oss << std::hex << GL_STENCIL_TEST;
4363 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4365 // Perform the test twice, once for 2D layer, and once for 3D.
4366 for(unsigned int i = 0u; i < 2u; ++i)
4368 size_t startIndex = 0u;
4370 // Check the stencil buffer was cleared.
4371 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4373 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4374 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4375 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4376 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4378 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4379 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
4380 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4382 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4383 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4384 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4385 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4387 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4388 // (Both must be set to pass the check).
4389 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4390 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4392 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4395 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4396 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4403 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4405 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4406 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4407 TestApplication application;
4408 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4409 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4411 /* We create a small tree of actors as follows:
4415 Clipping enabled -> B D
4419 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4422 for(int i = 0; i < 5; ++i)
4424 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4425 Actor actor = CreateRenderableActor(image);
4427 // Setup dimensions and position so actor is not skipped by culling.
4428 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4429 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4433 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4437 float b = i > 2 ? 1.0f : -1.0f;
4438 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4444 // Enable clipping on the actor at the top of the left branch.
4445 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4447 // Build the scene graph.
4448 application.GetScene().Add(actors[0]);
4451 actors[0].Add(actors[1]);
4452 actors[1].Add(actors[2]);
4455 actors[0].Add(actors[3]);
4456 actors[3].Add(actors[4]);
4458 // Gather the call trace.
4459 enabledDisableTrace.Reset();
4460 enabledDisableTrace.Enable(true);
4461 application.SendNotification();
4462 application.Render();
4463 enabledDisableTrace.Enable(false);
4465 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4467 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
4468 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4470 size_t startIndex = 0u;
4471 std::ostringstream blend;
4472 blend << std::hex << GL_BLEND;
4473 std::ostringstream stencil;
4474 stencil << std::hex << GL_STENCIL_TEST;
4476 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4477 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4478 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4480 // Swap the clipping actor from top of left branch to top of right branch.
4481 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4482 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4484 // Gather the call trace.
4485 enabledDisableTrace.Reset();
4486 enabledDisableTrace.Enable(true);
4487 application.SendNotification();
4488 application.Render();
4489 enabledDisableTrace.Enable(false);
4491 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4492 // This proves the draw order has remained the same.
4494 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4495 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4500 int UtcDaliActorPropertyScissorClippingActor(void)
4502 // This test checks that an actor is correctly setup for clipping.
4503 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4504 TestApplication application;
4506 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4507 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4508 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4510 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4511 const Vector2 imageSize(16.0f, 16.0f);
4513 // Create a clipping actor.
4514 Actor clippingActorA = CreateActorWithContent16x16();
4515 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4516 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4517 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4518 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4519 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4520 application.GetScene().Add(clippingActorA);
4522 // Gather the call trace.
4523 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4525 // Check we are writing to the color buffer.
4526 CheckColorMask(glAbstraction, true);
4528 // Check scissor test was enabled.
4530 std::ostringstream scissor;
4531 scissor << std::hex << GL_SCISSOR_TEST;
4532 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4534 // Check the scissor was set, and the coordinates are correct.
4535 std::stringstream compareParametersString;
4536 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4537 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4539 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4540 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4542 // Gather the call trace.
4543 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4545 // Check the scissor was set, and the coordinates are correct.
4546 compareParametersString.str(std::string());
4547 compareParametersString.clear();
4548 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4549 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4554 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4556 // This test checks that an actor is correctly setup for clipping.
4557 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4558 TestApplication application;
4560 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4561 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4562 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4564 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4565 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4566 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4568 // Create a clipping actors.
4569 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4570 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4572 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4573 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4574 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4576 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4577 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4578 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4580 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4581 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4583 application.GetScene().Add(clippingActorA);
4584 application.GetScene().Add(clippingActorB);
4586 // Gather the call trace.
4587 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4589 // Check we are writing to the color buffer.
4590 CheckColorMask(glAbstraction, true);
4592 // Check scissor test was enabled.
4593 std::ostringstream scissor;
4594 scissor << std::hex << GL_SCISSOR_TEST;
4595 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4597 // Check the scissor was set, and the coordinates are correct.
4598 std::stringstream compareParametersString;
4600 std::string clipA("0, 500, 480, 200");
4601 std::string clipB("0, 380, 480, 40");
4603 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4604 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4609 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4611 // This test checks that an actor is correctly setup for clipping.
4612 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4613 TestApplication application;
4615 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4616 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4617 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4619 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4620 const Vector2 imageSize(16.0f, 16.0f);
4622 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4624 A is drawn first - with scissor clipping on
4625 B is drawn second - also with scissor clipping on
4626 C is the generated clipping region, the intersection ( A ∩ B )
4630 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4631 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4632 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4636 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4639 // Create a clipping actor.
4640 Actor clippingActorA = CreateActorWithContent16x16();
4641 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4642 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4643 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4644 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4645 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4646 application.GetScene().Add(clippingActorA);
4648 // Create a child clipping actor.
4649 Actor clippingActorB = CreateActorWithContent16x16();
4650 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4651 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4652 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4653 clippingActorA.Add(clippingActorB);
4655 // positionModifiers is an array of positions to position B around.
4656 // expect is an array of expected scissor clip coordinate results.
4657 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4658 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4660 // Loop through each overlap combination.
4661 for(unsigned int test = 0u; test < 4u; ++test)
4663 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4664 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4665 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4667 // Gather the call trace.
4668 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4670 // Check we are writing to the color buffer.
4671 CheckColorMask(glAbstraction, true);
4673 // Check scissor test was enabled.
4674 std::ostringstream scissor;
4675 scissor << std::hex << GL_SCISSOR_TEST;
4676 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4678 // Check the scissor was set, and the coordinates are correct.
4679 const Vector4& expectResults(expect[test]);
4680 std::stringstream compareParametersString;
4681 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4682 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4688 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4690 // This test checks that an actor is correctly setup for clipping.
4691 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4692 TestApplication application;
4694 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4695 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4696 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4698 /* Create a nest of 2 scissors and siblings of the parent.
4708 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4709 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4710 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4711 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4712 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4713 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4715 // Create a clipping actors.
4716 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4717 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4718 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4719 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4720 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4722 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4723 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4724 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4726 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4727 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4728 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4730 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4731 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4732 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4734 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4735 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4736 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4738 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4739 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4741 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4742 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4743 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4744 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4745 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4747 application.GetScene().Add(clippingActorA);
4748 clippingActorA.Add(clippingActorB);
4749 application.GetScene().Add(clippingActorC);
4750 application.GetScene().Add(clippingActorD);
4751 clippingActorD.Add(clippingActorE);
4753 // Gather the call trace.
4754 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4756 // Check we are writing to the color buffer.
4757 CheckColorMask(glAbstraction, true);
4759 // Check scissor test was enabled.
4760 std::ostringstream scissor;
4761 scissor << std::hex << GL_SCISSOR_TEST;
4762 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4764 // Check the scissor was set, and the coordinates are correct.
4765 std::string clipA("0, 500, 480, 200");
4766 std::string clipB("0, 580, 480, 40");
4767 std::string clipC("0, 200, 480, 200");
4768 std::string clipD("0, 300, 480, 200");
4770 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4771 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4772 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4773 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4774 DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4779 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4781 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4782 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4783 TestApplication application;
4785 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4786 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4787 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4789 // Create a clipping actor.
4790 Actor actorDepth1Clip = CreateActorWithContent16x16();
4791 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4792 application.GetScene().Add(actorDepth1Clip);
4794 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4795 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4797 // Gather the call trace.
4798 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4800 // Check we are writing to the color buffer.
4801 CheckColorMask(glAbstraction, true);
4803 // Check the stencil buffer was not enabled.
4804 std::ostringstream stencil;
4805 stencil << std::hex << GL_STENCIL_TEST;
4806 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
4808 // Check stencil functions are not called.
4809 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4810 // TODO: Temporarily commented out the line below when caching is disabled. Will need to add it back.
4811 // DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask"));
4812 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4814 // Check that scissor clipping is overriden by the renderer properties.
4815 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4817 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4819 // Gather the call trace.
4820 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4822 // Check the stencil buffer was not enabled.
4823 std::ostringstream scissor;
4824 scissor << std::hex << GL_SCISSOR_TEST;
4825 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4827 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4832 int UtcDaliGetPropertyN(void)
4834 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
4835 TestApplication application;
4837 Actor actor = Actor::New();
4839 unsigned int propertyCount = actor.GetPropertyCount();
4840 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
4844 int UtcDaliActorRaiseLower(void)
4846 tet_infoline("UtcDaliActor Raise and Lower test\n");
4848 TestApplication application;
4850 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
4852 Integration::Scene stage(application.GetScene());
4854 Actor actorA = Actor::New();
4855 Actor actorB = Actor::New();
4856 Actor actorC = Actor::New();
4858 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4859 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4861 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4862 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4864 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4865 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4867 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4868 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4870 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4871 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4873 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4874 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4880 ResetTouchCallbacks();
4882 application.SendNotification();
4883 application.Render();
4885 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4886 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4887 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4889 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4890 // Only top actor will get touched.
4891 actorA.TouchedSignal().Connect(TestTouchCallback);
4892 actorB.TouchedSignal().Connect(TestTouchCallback2);
4893 actorC.TouchedSignal().Connect(TestTouchCallback3);
4895 // Connect ChildOrderChangedSignal
4896 bool orderChangedSignal(false);
4897 Actor orderChangedActor;
4898 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
4899 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
4901 Dali::Integration::Point point;
4902 point.SetDeviceId(1);
4903 point.SetState(PointState::DOWN);
4904 point.SetScreenPosition(Vector2(10.f, 10.f));
4905 Dali::Integration::TouchEvent touchEvent;
4906 touchEvent.AddPoint(point);
4908 application.ProcessEvent(touchEvent);
4910 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4911 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4912 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4914 ResetTouchCallbacks();
4916 tet_printf("Testing Raising of Actor\n");
4918 int preActorOrder(0);
4919 int postActorOrder(0);
4921 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4922 value.Get(preActorOrder);
4924 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4926 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4927 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4929 // Ensure sort order is calculated before next touch event
4930 application.SendNotification();
4932 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4933 value.Get(postActorOrder);
4935 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4937 application.ProcessEvent(touchEvent);
4939 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4940 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
4941 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4943 ResetTouchCallbacks();
4945 tet_printf("Testing Lowering of Actor\n");
4947 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4948 value.Get(preActorOrder);
4950 orderChangedSignal = false;
4952 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4954 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4955 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4957 application.SendNotification(); // ensure sort order calculated before next touch event
4959 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4960 value.Get(postActorOrder);
4962 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4964 application.ProcessEvent(touchEvent);
4966 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4967 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4968 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4970 ResetTouchCallbacks();
4972 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
4977 int UtcDaliActorRaiseToTopLowerToBottom(void)
4979 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
4981 TestApplication application;
4983 Integration::Scene stage(application.GetScene());
4985 Actor actorA = Actor::New();
4986 Actor actorB = Actor::New();
4987 Actor actorC = Actor::New();
4989 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4990 // enables checking of which actor the uniform is assigned too
4991 Shader shaderA = CreateShader();
4992 shaderA.RegisterProperty("uRendererColor", 1.f);
4994 Shader shaderB = CreateShader();
4995 shaderB.RegisterProperty("uRendererColor", 2.f);
4997 Shader shaderC = CreateShader();
4998 shaderC.RegisterProperty("uRendererColor", 3.f);
5000 Geometry geometry = CreateQuadGeometry();
5002 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5003 Renderer rendererA = Renderer::New(geometry, shaderA);
5004 actorA.AddRenderer(rendererA);
5006 Renderer rendererB = Renderer::New(geometry, shaderB);
5007 actorB.AddRenderer(rendererB);
5009 Renderer rendererC = Renderer::New(geometry, shaderC);
5010 actorC.AddRenderer(rendererC);
5012 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5013 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5015 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5016 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5018 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5019 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5021 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5022 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5024 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5025 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5027 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5028 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5034 ResetTouchCallbacks();
5036 // Connect ChildOrderChangedSignal
5037 bool orderChangedSignal(false);
5038 Actor orderChangedActor;
5039 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5040 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5042 // Set up gl abstraction trace so can query the set uniform order
5043 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5044 glAbstraction.EnableSetUniformCallTrace(true);
5045 glAbstraction.ResetSetUniformCallStack();
5047 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5049 application.SendNotification();
5050 application.Render();
5052 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5054 // Test order of uniforms in stack
5055 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5056 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5057 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5059 bool CBA = (indexC > indexB) && (indexB > indexA);
5061 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5063 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5064 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5065 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5067 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5068 // Only top actor will get touched.
5069 actorA.TouchedSignal().Connect(TestTouchCallback);
5070 actorB.TouchedSignal().Connect(TestTouchCallback2);
5071 actorC.TouchedSignal().Connect(TestTouchCallback3);
5073 Dali::Integration::Point point;
5074 point.SetDeviceId(1);
5075 point.SetState(PointState::DOWN);
5076 point.SetScreenPosition(Vector2(10.f, 10.f));
5077 Dali::Integration::TouchEvent touchEvent;
5078 touchEvent.AddPoint(point);
5080 application.ProcessEvent(touchEvent);
5082 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5083 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5084 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5086 ResetTouchCallbacks();
5088 tet_printf("RaiseToTop ActorA\n");
5090 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5091 actorA.RaiseToTop();
5092 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5093 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5095 application.SendNotification(); // ensure sorting order is calculated before next touch event
5097 application.ProcessEvent(touchEvent);
5099 glSetUniformStack.Reset();
5101 application.SendNotification();
5102 application.Render();
5104 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5106 // Test order of uniforms in stack
5107 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5108 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5109 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5111 tet_infoline("Testing A above C and B at bottom\n");
5112 bool ACB = (indexA > indexC) && (indexC > indexB);
5114 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5116 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5117 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5118 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5120 ResetTouchCallbacks();
5122 tet_printf("RaiseToTop ActorB\n");
5124 orderChangedSignal = false;
5126 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5127 actorB.RaiseToTop();
5128 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5129 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5131 application.SendNotification(); // Ensure sort order is calculated before next touch event
5133 application.ProcessEvent(touchEvent);
5135 glSetUniformStack.Reset();
5137 application.SendNotification();
5138 application.Render();
5140 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5142 // Test order of uniforms in stack
5143 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5144 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5145 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5147 tet_infoline("Testing B above A and C at bottom\n");
5148 bool BAC = (indexB > indexA) && (indexA > indexC);
5150 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5152 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5153 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5154 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5156 ResetTouchCallbacks();
5158 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5160 orderChangedSignal = false;
5162 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5163 actorA.LowerToBottom();
5164 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5165 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5167 application.SendNotification();
5168 application.Render();
5170 orderChangedSignal = false;
5172 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5173 actorB.LowerToBottom();
5174 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5175 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5177 application.SendNotification();
5178 application.Render();
5180 application.ProcessEvent(touchEvent);
5182 glSetUniformStack.Reset();
5184 application.SendNotification();
5185 application.Render();
5187 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5189 // Test order of uniforms in stack
5190 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5191 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5192 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5194 tet_infoline("Testing C above A and B at bottom\n");
5195 bool CAB = (indexC > indexA) && (indexA > indexB);
5197 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5199 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5200 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5201 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5203 ResetTouchCallbacks();
5208 int UtcDaliActorRaiseAbove(void)
5210 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5212 TestApplication application;
5214 Integration::Scene stage(application.GetScene());
5216 Actor actorA = Actor::New();
5217 Actor actorB = Actor::New();
5218 Actor actorC = Actor::New();
5220 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5221 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5223 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5224 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5226 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5227 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5229 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5230 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5232 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5233 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5235 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5236 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5242 ResetTouchCallbacks();
5244 application.SendNotification();
5245 application.Render();
5247 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5248 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5249 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5251 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5252 // Only top actor will get touched.
5253 actorA.TouchedSignal().Connect(TestTouchCallback);
5254 actorB.TouchedSignal().Connect(TestTouchCallback2);
5255 actorC.TouchedSignal().Connect(TestTouchCallback3);
5257 bool orderChangedSignal(false);
5258 Actor orderChangedActor;
5259 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5260 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5262 Dali::Integration::Point point;
5263 point.SetDeviceId(1);
5264 point.SetState(PointState::DOWN);
5265 point.SetScreenPosition(Vector2(10.f, 10.f));
5266 Dali::Integration::TouchEvent touchEvent;
5267 touchEvent.AddPoint(point);
5269 application.ProcessEvent(touchEvent);
5271 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5272 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5273 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5275 ResetTouchCallbacks();
5277 tet_printf("Raise actor B Above Actor C\n");
5279 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5280 actorB.RaiseAbove(actorC);
5281 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5282 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5284 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5285 application.SendNotification();
5286 application.ProcessEvent(touchEvent);
5288 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5289 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5290 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5292 ResetTouchCallbacks();
5294 tet_printf("Raise actor A Above Actor B\n");
5296 orderChangedSignal = false;
5298 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5299 actorA.RaiseAbove(actorB);
5300 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5301 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5303 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5304 application.SendNotification();
5306 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5308 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5309 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5310 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5312 ResetTouchCallbacks();
5317 int UtcDaliActorRaiseAbove2(void)
5319 tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5321 TestApplication application;
5323 Integration::Scene stage(application.GetScene());
5325 Actor actorA = Actor::New();
5326 Actor actorB = Actor::New();
5327 Actor actorC = Actor::New();
5329 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5330 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5332 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5333 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5335 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5336 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5338 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5339 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5341 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5342 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5344 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5345 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5351 ResetTouchCallbacks();
5353 application.SendNotification();
5354 application.Render();
5356 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5357 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5358 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5360 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5361 // Only top actor will get touched.
5362 actorA.TouchedSignal().Connect(TestTouchCallback);
5363 actorB.TouchedSignal().Connect(TestTouchCallback2);
5364 actorC.TouchedSignal().Connect(TestTouchCallback3);
5366 bool orderChangedSignal(false);
5367 Actor orderChangedActor;
5368 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5369 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5371 Dali::Integration::Point point;
5372 point.SetDeviceId(1);
5373 point.SetState(PointState::DOWN);
5374 point.SetScreenPosition(Vector2(10.f, 10.f));
5375 Dali::Integration::TouchEvent touchEvent;
5376 touchEvent.AddPoint(point);
5378 application.ProcessEvent(touchEvent);
5380 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5381 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5382 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5384 ResetTouchCallbacks();
5386 tet_printf("Raise actor B Above Actor C\n");
5388 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5389 int newOrder = actorC[DevelActor::Property::SIBLING_ORDER];
5390 actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5391 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5392 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5394 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5395 application.SendNotification();
5396 application.ProcessEvent(touchEvent);
5398 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5399 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5400 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5402 ResetTouchCallbacks();
5404 tet_printf("Raise actor A Above Actor B\n");
5406 orderChangedSignal = false;
5408 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5409 newOrder = actorB[DevelActor::Property::SIBLING_ORDER];
5410 actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5411 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5412 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5414 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5415 application.SendNotification();
5417 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5419 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5420 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5421 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5423 ResetTouchCallbacks();
5428 int UtcDaliActorLowerBelow(void)
5430 tet_infoline("UtcDaliActor LowerBelow test \n");
5432 TestApplication application;
5434 Integration::Scene stage(application.GetScene());
5436 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5437 // enables checking of which actor the uniform is assigned too
5438 Shader shaderA = CreateShader();
5439 shaderA.RegisterProperty("uRendererColor", 1.f);
5441 Shader shaderB = CreateShader();
5442 shaderB.RegisterProperty("uRendererColor", 2.f);
5444 Shader shaderC = CreateShader();
5445 shaderC.RegisterProperty("uRendererColor", 3.f);
5447 Actor actorA = Actor::New();
5448 Actor actorB = Actor::New();
5449 Actor actorC = Actor::New();
5451 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5452 Geometry geometry = CreateQuadGeometry();
5454 Renderer rendererA = Renderer::New(geometry, shaderA);
5455 actorA.AddRenderer(rendererA);
5457 Renderer rendererB = Renderer::New(geometry, shaderB);
5458 actorB.AddRenderer(rendererB);
5460 Renderer rendererC = Renderer::New(geometry, shaderC);
5461 actorC.AddRenderer(rendererC);
5463 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5464 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5466 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5467 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5469 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5470 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5472 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5473 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5475 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5476 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5478 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5479 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5481 Actor container = Actor::New();
5482 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5483 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5484 stage.Add(container);
5486 container.Add(actorA);
5487 container.Add(actorB);
5488 container.Add(actorC);
5490 ResetTouchCallbacks();
5492 // Connect ChildOrderChangedSignal
5493 bool orderChangedSignal(false);
5494 Actor orderChangedActor;
5495 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5496 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5498 // Set up gl abstraction trace so can query the set uniform order
5499 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5500 glAbstraction.EnableSetUniformCallTrace(true);
5501 glAbstraction.ResetSetUniformCallStack();
5502 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5504 glAbstraction.ResetSetUniformCallStack();
5506 application.SendNotification();
5507 application.Render();
5509 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5511 // Test order of uniforms in stack
5512 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5513 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5514 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5516 tet_infoline("Testing C above B and A at bottom\n");
5517 bool CBA = (indexC > indexB) && (indexB > indexA);
5519 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5521 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5522 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5523 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5525 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5526 // Only top actor will get touched.
5527 actorA.TouchedSignal().Connect(TestTouchCallback);
5528 actorB.TouchedSignal().Connect(TestTouchCallback2);
5529 actorC.TouchedSignal().Connect(TestTouchCallback3);
5531 Dali::Integration::Point point;
5532 point.SetDeviceId(1);
5533 point.SetState(PointState::DOWN);
5534 point.SetScreenPosition(Vector2(10.f, 10.f));
5535 Dali::Integration::TouchEvent touchEvent;
5536 touchEvent.AddPoint(point);
5538 tet_infoline("UtcDaliActor Test Set up completed \n");
5540 application.ProcessEvent(touchEvent);
5542 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5543 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5544 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5546 ResetTouchCallbacks();
5548 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");
5550 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5551 actorC.LowerBelow(actorB);
5552 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5553 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5555 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5556 application.SendNotification();
5557 application.Render();
5559 application.ProcessEvent(touchEvent); // touch event
5561 glSetUniformStack.Reset();
5563 application.SendNotification();
5564 application.Render();
5566 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5568 // Test order of uniforms in stack
5569 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5570 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5571 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5573 tet_infoline("Testing render order is A, C, B");
5574 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5575 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5577 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5578 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5579 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5581 ResetTouchCallbacks();
5583 tet_printf("Lower actor C below Actor A leaving B on top\n");
5585 orderChangedSignal = false;
5587 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5588 actorC.LowerBelow(actorA);
5589 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5590 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5592 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5593 application.SendNotification();
5594 application.Render();
5596 application.ProcessEvent(touchEvent);
5598 glSetUniformStack.Reset();
5600 application.Render();
5601 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5603 // Test order of uniforms in stack
5604 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5605 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5606 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5608 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5609 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5611 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5612 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5613 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5615 ResetTouchCallbacks();
5617 tet_printf("Lower actor B below Actor C leaving A on top\n");
5619 orderChangedSignal = false;
5621 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5622 actorB.LowerBelow(actorC);
5623 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5624 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5626 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5627 application.SendNotification();
5628 application.Render();
5630 application.ProcessEvent(touchEvent);
5632 glSetUniformStack.Reset();
5634 application.Render();
5635 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5637 // Test order of uniforms in stack
5638 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5639 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5640 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5642 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5643 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5648 int UtcDaliActorLowerBelow2(void)
5650 tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
5652 TestApplication application;
5654 Integration::Scene stage(application.GetScene());
5656 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5657 // enables checking of which actor the uniform is assigned too
5658 Shader shaderA = CreateShader();
5659 shaderA.RegisterProperty("uRendererColor", 1.f);
5661 Shader shaderB = CreateShader();
5662 shaderB.RegisterProperty("uRendererColor", 2.f);
5664 Shader shaderC = CreateShader();
5665 shaderC.RegisterProperty("uRendererColor", 3.f);
5667 Actor actorA = Actor::New();
5668 Actor actorB = Actor::New();
5669 Actor actorC = Actor::New();
5671 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5672 Geometry geometry = CreateQuadGeometry();
5674 Renderer rendererA = Renderer::New(geometry, shaderA);
5675 actorA.AddRenderer(rendererA);
5677 Renderer rendererB = Renderer::New(geometry, shaderB);
5678 actorB.AddRenderer(rendererB);
5680 Renderer rendererC = Renderer::New(geometry, shaderC);
5681 actorC.AddRenderer(rendererC);
5683 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5684 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5686 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5687 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5689 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5690 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5692 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5693 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5695 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5696 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5698 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5699 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5701 Actor container = Actor::New();
5702 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5703 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5704 stage.Add(container);
5706 container.Add(actorA);
5707 container.Add(actorB);
5708 container.Add(actorC);
5710 ResetTouchCallbacks();
5712 // Connect ChildOrderChangedSignal
5713 bool orderChangedSignal(false);
5714 Actor orderChangedActor;
5715 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5716 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5718 // Set up gl abstraction trace so can query the set uniform order
5719 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5720 glAbstraction.EnableSetUniformCallTrace(true);
5721 glAbstraction.ResetSetUniformCallStack();
5722 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5724 glAbstraction.ResetSetUniformCallStack();
5726 application.SendNotification();
5727 application.Render();
5729 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5731 // Test order of uniforms in stack
5732 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5733 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5734 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5736 tet_infoline("Testing C above B and A at bottom\n");
5737 bool CBA = (indexC > indexB) && (indexB > indexA);
5739 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5741 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5742 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5743 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5745 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5746 // Only top actor will get touched.
5747 actorA.TouchedSignal().Connect(TestTouchCallback);
5748 actorB.TouchedSignal().Connect(TestTouchCallback2);
5749 actorC.TouchedSignal().Connect(TestTouchCallback3);
5751 Dali::Integration::Point point;
5752 point.SetDeviceId(1);
5753 point.SetState(PointState::DOWN);
5754 point.SetScreenPosition(Vector2(10.f, 10.f));
5755 Dali::Integration::TouchEvent touchEvent;
5756 touchEvent.AddPoint(point);
5758 tet_infoline("UtcDaliActor Test Set up completed \n");
5760 application.ProcessEvent(touchEvent);
5762 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5763 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5764 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5766 ResetTouchCallbacks();
5768 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");
5770 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5771 actorC[DevelActor::Property::SIBLING_ORDER] = 1;
5772 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5773 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5775 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5776 application.SendNotification();
5777 application.Render();
5779 application.ProcessEvent(touchEvent); // touch event
5781 glSetUniformStack.Reset();
5783 application.SendNotification();
5784 application.Render();
5786 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5788 // Test order of uniforms in stack
5789 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5790 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5791 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5793 tet_infoline("Testing render order is A, C, B");
5794 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5795 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5797 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5798 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5799 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5801 ResetTouchCallbacks();
5803 tet_printf("Lower actor C below Actor A leaving B on top\n");
5805 orderChangedSignal = false;
5807 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5808 actorC[DevelActor::Property::SIBLING_ORDER] = 0;
5809 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5810 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5812 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5813 application.SendNotification();
5814 application.Render();
5816 application.ProcessEvent(touchEvent);
5818 glSetUniformStack.Reset();
5820 application.Render();
5821 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5823 // Test order of uniforms in stack
5824 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5825 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5826 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5828 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5829 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5831 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5832 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5833 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5835 ResetTouchCallbacks();
5837 tet_printf("Lower actor B below Actor C leaving A on top\n");
5839 orderChangedSignal = false;
5841 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5842 actorB[DevelActor::Property::SIBLING_ORDER] = 0;
5843 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5844 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5846 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5847 application.SendNotification();
5848 application.Render();
5850 application.ProcessEvent(touchEvent);
5852 glSetUniformStack.Reset();
5854 application.Render();
5855 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5857 // Test order of uniforms in stack
5858 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5859 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5860 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5862 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5863 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5868 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5870 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
5872 TestApplication application;
5874 Integration::Scene stage(application.GetScene());
5876 Actor parentA = Actor::New();
5877 Actor parentB = Actor::New();
5878 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5879 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5880 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5881 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5883 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5884 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5886 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5887 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5892 Actor actorA = Actor::New();
5893 Actor actorB = Actor::New();
5894 Actor actorC = Actor::New();
5896 parentA.Add(actorA);
5897 parentA.Add(actorB);
5899 tet_printf("Actor C added to different parent from A and B \n");
5900 parentB.Add(actorC);
5902 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5903 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5905 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5906 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5908 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5909 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5911 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5912 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5914 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5915 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5917 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5918 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5920 ResetTouchCallbacks();
5922 // Connect ChildOrderChangedSignal
5923 bool orderChangedSignal(false);
5924 Actor orderChangedActor;
5925 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5926 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5928 application.SendNotification();
5929 application.Render();
5931 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5932 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5933 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5935 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5936 // Only top actor will get touched.
5937 actorA.TouchedSignal().Connect(TestTouchCallback);
5938 actorB.TouchedSignal().Connect(TestTouchCallback2);
5939 actorC.TouchedSignal().Connect(TestTouchCallback3);
5941 Dali::Integration::Point point;
5942 point.SetDeviceId(1);
5943 point.SetState(PointState::DOWN);
5944 point.SetScreenPosition(Vector2(10.f, 10.f));
5945 Dali::Integration::TouchEvent touchEvent;
5946 touchEvent.AddPoint(point);
5948 application.ProcessEvent(touchEvent);
5950 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5951 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5952 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5954 ResetTouchCallbacks();
5956 tet_printf("Raise actor A Above Actor C which have different parents\n");
5958 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5959 actorA.RaiseAbove(actorC);
5960 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5962 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5963 application.SendNotification();
5965 application.ProcessEvent(touchEvent); // touch event
5967 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5968 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5969 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5971 ResetTouchCallbacks();
5976 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5978 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
5980 TestApplication application;
5982 Integration::Scene stage(application.GetScene());
5984 Actor actorA = Actor::New();
5985 Actor actorB = Actor::New();
5986 Actor actorC = Actor::New();
5988 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5989 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5991 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5992 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5994 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5995 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5997 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5998 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6000 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6001 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6003 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6004 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6006 ResetTouchCallbacks();
6008 // Connect ChildOrderChangedSignal
6009 bool orderChangedSignal(false);
6010 Actor orderChangedActor;
6011 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6012 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6014 application.SendNotification();
6015 application.Render();
6017 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6018 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6019 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6021 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6022 // Only top actor will get touched.
6023 actorA.TouchedSignal().Connect(TestTouchCallback);
6024 actorB.TouchedSignal().Connect(TestTouchCallback2);
6025 actorC.TouchedSignal().Connect(TestTouchCallback3);
6027 Dali::Integration::Point point;
6028 point.SetDeviceId(1);
6029 point.SetState(PointState::DOWN);
6030 point.SetScreenPosition(Vector2(10.f, 10.f));
6031 Dali::Integration::TouchEvent touchEvent;
6032 touchEvent.AddPoint(point);
6034 tet_printf("Raise actor A Above Actor C which have no parents\n");
6036 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6037 actorA.RaiseAbove(actorC);
6038 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6040 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6041 application.SendNotification();
6043 application.ProcessEvent(touchEvent);
6045 tet_printf("Not parented so RaiseAbove should show no effect\n");
6047 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6048 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6049 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6051 ResetTouchCallbacks();
6053 orderChangedSignal = false;
6056 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6058 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6059 actorA.LowerBelow(actorC);
6060 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6062 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6063 application.SendNotification();
6064 application.Render();
6066 application.ProcessEvent(touchEvent);
6068 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6069 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6070 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6071 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6073 ResetTouchCallbacks();
6075 orderChangedSignal = false;
6077 tet_printf("Adding Actor A to stage, will be on top\n");
6080 application.SendNotification();
6081 application.Render();
6083 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6085 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6086 actorB.RaiseAbove(actorC);
6087 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6089 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6090 application.SendNotification();
6092 application.ProcessEvent(touchEvent);
6094 tet_printf("C not parented so RaiseAbove should show no effect\n");
6095 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6096 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6097 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6099 ResetTouchCallbacks();
6101 orderChangedSignal = false;
6103 tet_printf("Lower actor A below Actor C when only A has a parent\n");
6105 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6106 actorA.LowerBelow(actorC);
6107 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6109 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6110 application.SendNotification();
6112 application.ProcessEvent(touchEvent);
6114 tet_printf("C not parented so LowerBelow should show no effect\n");
6115 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6116 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6117 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6119 ResetTouchCallbacks();
6121 orderChangedSignal = false;
6125 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6126 actorA.RaiseAbove(actorC);
6127 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6128 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6130 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6131 application.SendNotification();
6132 application.Render();
6134 application.ProcessEvent(touchEvent);
6136 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6137 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6138 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6139 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6144 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6146 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6148 TestApplication application;
6150 Integration::Scene stage(application.GetScene());
6152 Actor actorA = Actor::New();
6153 Actor actorB = Actor::New();
6154 Actor actorC = Actor::New();
6156 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6157 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6159 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6160 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6162 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6163 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6165 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6166 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6168 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6169 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6171 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6172 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6174 ResetTouchCallbacks();
6176 // Connect ChildOrderChangedSignal
6177 bool orderChangedSignal(false);
6178 Actor orderChangedActor;
6179 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6180 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6182 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6183 // Only top actor will get touched.
6184 actorA.TouchedSignal().Connect(TestTouchCallback);
6185 actorB.TouchedSignal().Connect(TestTouchCallback2);
6186 actorC.TouchedSignal().Connect(TestTouchCallback3);
6188 Dali::Integration::Point point;
6189 point.SetDeviceId(1);
6190 point.SetState(PointState::DOWN);
6191 point.SetScreenPosition(Vector2(10.f, 10.f));
6192 Dali::Integration::TouchEvent touchEvent;
6193 touchEvent.AddPoint(point);
6196 tet_printf("Raise actor B Above Actor C but B not parented\n");
6198 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6200 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6202 application.SendNotification();
6203 application.Render();
6205 application.ProcessEvent(touchEvent);
6207 tet_printf("Not parented so RaiseAbove should show no effect\n");
6209 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6210 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6211 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6213 tet_printf("Raise actor B Above Actor C but B not parented\n");
6214 ResetTouchCallbacks();
6216 orderChangedSignal = false;
6218 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6220 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6222 // Sort actor tree before next touch event
6223 application.SendNotification();
6224 application.Render();
6226 application.ProcessEvent(touchEvent);
6228 tet_printf("Not parented so RaiseAbove should show no effect\n");
6230 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6231 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6232 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6233 ResetTouchCallbacks();
6235 orderChangedSignal = false;
6237 tet_printf("Lower actor C below B but C not parented\n");
6239 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6241 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6243 // Sort actor tree before next touch event
6244 application.SendNotification();
6245 application.Render();
6247 application.ProcessEvent(touchEvent);
6249 tet_printf("Not parented so Lower should show no effect\n");
6251 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6252 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6253 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6254 ResetTouchCallbacks();
6256 orderChangedSignal = false;
6258 tet_printf("Raise actor B to top\n");
6260 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6261 actorB.RaiseToTop();
6262 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6264 // Sort actor tree before next touch event
6265 application.SendNotification();
6266 application.Render();
6268 application.ProcessEvent(touchEvent);
6270 tet_printf("Not parented so RaiseToTop should show no effect\n");
6272 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6273 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6274 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6275 ResetTouchCallbacks();
6277 orderChangedSignal = false;
6279 tet_printf("Add ActorB to stage so only Actor C not parented\n");
6283 tet_printf("Lower actor C to Bottom, B stays at top\n");
6285 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6286 actorC.LowerToBottom();
6287 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6289 application.SendNotification();
6290 application.Render();
6292 application.ProcessEvent(touchEvent);
6294 tet_printf("Not parented so LowerToBottom should show no effect\n");
6296 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6297 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6298 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6299 ResetTouchCallbacks();
6304 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6306 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
6308 TestApplication application;
6310 Integration::Scene stage(application.GetScene());
6312 Actor actorA = Actor::New();
6313 Actor actorB = Actor::New();
6314 Actor actorC = Actor::New();
6316 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6317 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6319 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6320 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6322 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6323 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6325 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6326 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6328 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6329 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6331 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6332 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6338 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6339 // Only top actor will get touched.
6340 actorA.TouchedSignal().Connect(TestTouchCallback);
6341 actorB.TouchedSignal().Connect(TestTouchCallback2);
6342 actorC.TouchedSignal().Connect(TestTouchCallback3);
6344 ResetTouchCallbacks();
6346 // Connect ChildOrderChangedSignal
6347 bool orderChangedSignal(false);
6348 Actor orderChangedActor;
6349 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6350 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6352 application.SendNotification();
6353 application.Render();
6355 Dali::Integration::Point point;
6356 point.SetDeviceId(1);
6357 point.SetState(PointState::DOWN);
6358 point.SetScreenPosition(Vector2(10.f, 10.f));
6359 Dali::Integration::TouchEvent touchEvent;
6360 touchEvent.AddPoint(point);
6362 application.ProcessEvent(touchEvent);
6364 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6365 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6366 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6368 ResetTouchCallbacks();
6370 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6372 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6373 actorA.RaiseAbove(actorA);
6374 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6375 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6377 application.SendNotification();
6378 application.Render();
6380 application.ProcessEvent(touchEvent);
6382 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6384 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6385 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6386 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6388 ResetTouchCallbacks();
6390 orderChangedSignal = false;
6392 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6393 actorA.RaiseAbove(actorC);
6394 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6395 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6397 application.SendNotification();
6398 application.Render();
6400 application.ProcessEvent(touchEvent);
6402 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6403 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6404 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6405 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6410 int UtcDaliActorGetScreenPosition(void)
6412 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6414 TestApplication application;
6416 Integration::Scene stage(application.GetScene());
6418 Actor actorA = Actor::New();
6419 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6421 Vector2 size2(10.0f, 20.0f);
6422 actorA.SetProperty(Actor::Property::SIZE, size2);
6424 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6426 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6430 application.SendNotification();
6431 application.Render();
6433 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6434 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6436 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6437 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6439 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6440 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6442 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6444 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6446 application.SendNotification();
6447 application.Render();
6449 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6450 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6452 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6453 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6455 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6456 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6458 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6460 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6462 application.SendNotification();
6463 application.Render();
6465 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6466 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6468 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6469 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6471 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6472 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6474 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6476 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6478 application.SendNotification();
6479 application.Render();
6481 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6482 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6484 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6485 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6487 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6488 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6490 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6492 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6494 application.SendNotification();
6495 application.Render();
6497 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6498 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6500 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6501 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6503 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6504 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6506 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6508 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6509 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6511 Actor actorB = Actor::New();
6512 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6513 actorB.SetProperty(Actor::Property::SIZE, size2);
6514 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6517 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6519 application.SendNotification();
6520 application.Render();
6522 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6524 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6525 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6530 int UtcDaliActorGetScreenPositionAfterScaling(void)
6532 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6534 TestApplication application;
6536 Integration::Scene stage(application.GetScene());
6538 Actor actorA = Actor::New();
6539 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6541 Vector2 size2(10.0f, 20.0f);
6542 actorA.SetProperty(Actor::Property::SIZE, size2);
6543 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6544 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6546 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6550 application.SendNotification();
6551 application.Render();
6553 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6554 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6556 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6557 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6559 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6560 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6562 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6564 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6566 application.SendNotification();
6567 application.Render();
6569 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6570 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6572 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6573 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6575 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6576 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6581 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6583 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6585 TestApplication application;
6587 Integration::Scene stage(application.GetScene());
6589 Actor actorA = Actor::New();
6590 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6591 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6592 Vector2 size2(10.0f, 20.0f);
6593 actorA.SetProperty(Actor::Property::SIZE, size2);
6594 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6596 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6600 application.SendNotification();
6601 application.Render();
6603 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6604 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6606 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6607 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6609 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6610 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6612 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6614 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6615 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6617 application.SendNotification();
6618 application.Render();
6620 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6621 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6623 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6624 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6626 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6627 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6633 int UtcDaliActorGetScreenPositionWithChildActors(void)
6635 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6637 TestApplication application;
6639 Integration::Scene stage(application.GetScene());
6641 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6643 Actor actorA = Actor::New();
6644 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6645 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6646 Vector2 size1(10.0f, 20.0f);
6647 actorA.SetProperty(Actor::Property::SIZE, size1);
6648 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6650 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6652 Actor parentActorA = Actor::New();
6653 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6654 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6655 Vector2 size2(30.0f, 60.0f);
6656 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6657 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6659 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6661 stage.Add(parentActorA);
6662 parentActorA.Add(actorA);
6664 application.SendNotification();
6665 application.Render();
6667 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6668 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6670 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6671 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6673 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6674 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6676 tet_infoline("Test 2\n");
6678 tet_infoline("change parent anchor point and parent origin then check screen position \n");
6680 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6681 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6683 application.SendNotification();
6684 application.Render();
6686 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6687 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6689 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6690 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6692 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6693 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6698 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6700 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6702 TestApplication application;
6704 Integration::Scene stage(application.GetScene());
6706 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6708 Actor actorA = Actor::New();
6709 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6710 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6711 Vector2 size1(10.0f, 20.0f);
6712 actorA.SetProperty(Actor::Property::SIZE, size1);
6713 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6715 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6717 Actor parentActorA = Actor::New();
6718 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6719 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6720 Vector2 size2(30.0f, 60.0f);
6721 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6722 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6724 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6726 Actor grandParentActorA = Actor::New();
6727 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6728 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6729 Vector2 size3(60.0f, 120.0f);
6730 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6731 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6733 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6735 stage.Add(grandParentActorA);
6736 grandParentActorA.Add(parentActorA);
6738 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6740 parentActorA.Add(actorA);
6742 application.SendNotification();
6743 application.Render();
6745 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6746 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6748 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6749 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6751 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6752 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6757 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6759 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6761 TestApplication application;
6763 Integration::Scene stage(application.GetScene());
6765 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6767 Actor actorA = Actor::New();
6768 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6769 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6770 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6771 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6774 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6776 Actor actorB = Actor::New();
6777 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6778 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6779 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6780 Vector2 actorBSize(30.0f, 60.0f);
6781 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6784 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6786 Actor actorC = Actor::New();
6787 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6788 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6789 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6790 Vector2 actorCSize(60.0f, 120.0f);
6791 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6794 application.SendNotification();
6795 application.Render();
6797 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
6799 Vector2 center(stage.GetSize() * 0.5f);
6801 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6802 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6803 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6805 tet_infoline("Add scale to all actors");
6807 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6808 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
6809 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
6811 application.SendNotification();
6812 application.Render();
6814 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
6815 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
6816 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
6821 int utcDaliActorPositionUsesAnchorPoint(void)
6823 TestApplication application;
6824 tet_infoline("Check default behaviour\n");
6826 Actor actor = Actor::New();
6827 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6828 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6829 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6830 application.GetScene().Add(actor);
6832 application.SendNotification();
6833 application.Render();
6835 tet_infoline("Check that the world position is in the center\n");
6836 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6838 tet_infoline("Set the position uses anchor point property to false\n");
6839 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6841 application.SendNotification();
6842 application.Render();
6844 tet_infoline("Check that the world position has changed appropriately\n");
6845 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6850 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6852 TestApplication application;
6853 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6855 Actor actor = Actor::New();
6856 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6857 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6858 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6859 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6860 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6861 application.GetScene().Add(actor);
6863 application.SendNotification();
6864 application.Render();
6866 tet_infoline("Check the world position is the same as it would be without a scale\n");
6867 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6869 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6870 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6871 application.SendNotification();
6872 application.Render();
6873 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
6875 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6876 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6877 application.SendNotification();
6878 application.Render();
6879 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6884 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6886 TestApplication application;
6887 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6889 Actor actor = Actor::New();
6890 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6891 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6892 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6893 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6894 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6895 application.GetScene().Add(actor);
6897 application.SendNotification();
6898 application.Render();
6900 tet_infoline("Check the world position is the same as it would be without a rotation\n");
6901 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6903 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6904 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6905 application.SendNotification();
6906 application.Render();
6907 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
6909 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6910 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6911 application.SendNotification();
6912 application.Render();
6913 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
6918 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6920 TestApplication application;
6921 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6923 Actor actor = Actor::New();
6924 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6925 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6926 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6927 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6928 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6929 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6930 application.GetScene().Add(actor);
6932 application.SendNotification();
6933 application.Render();
6935 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
6936 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6938 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6939 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6940 application.SendNotification();
6941 application.Render();
6942 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
6944 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6945 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6946 application.SendNotification();
6947 application.Render();
6948 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
6953 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6955 TestApplication application;
6956 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6958 Actor parent = Actor::New();
6960 application.GetScene().Add(parent);
6961 Vector2 stageSize(application.GetScene().GetSize());
6963 Actor actor = Actor::New();
6964 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6965 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6966 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6967 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
6968 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
6969 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6972 application.SendNotification();
6973 application.Render();
6975 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
6977 tet_infoline("Check the world position is in the right place\n");
6978 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6980 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
6981 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6982 application.SendNotification();
6983 application.Render();
6984 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6986 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
6987 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6988 application.SendNotification();
6989 application.Render();
6990 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6995 int utcDaliActorVisibilityChangeSignalSelf(void)
6997 TestApplication application;
6998 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7000 Actor actor = Actor::New();
7002 VisibilityChangedFunctorData data;
7003 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7005 actor.SetProperty(Actor::Property::VISIBLE, false);
7007 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7009 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7012 actor.SetProperty(Actor::Property::VISIBLE, false);
7013 data.Check(false /* not called */, TEST_LOCATION);
7015 tet_infoline("Change the visibility using properties, ensure called");
7018 actor.SetProperty(Actor::Property::VISIBLE, true);
7019 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7021 tet_infoline("Set the visibility to current using properties, ensure not called");
7024 actor.SetProperty(Actor::Property::VISIBLE, true);
7025 data.Check(false /* not called */, TEST_LOCATION);
7030 int utcDaliActorVisibilityChangeSignalChildren(void)
7032 TestApplication application;
7033 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7035 Actor parent = Actor::New();
7036 Actor child = Actor::New();
7039 Actor grandChild = Actor::New();
7040 child.Add(grandChild);
7042 VisibilityChangedFunctorData parentData;
7043 VisibilityChangedFunctorData childData;
7044 VisibilityChangedFunctorData grandChildData;
7046 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7047 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7048 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7050 parent.SetProperty(Actor::Property::VISIBLE, false);
7051 parentData.Check(false /* not called */, TEST_LOCATION);
7052 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7053 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7055 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7058 grandChildData.Reset();
7060 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7062 parent.SetProperty(Actor::Property::VISIBLE, true);
7063 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7064 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7065 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7067 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7070 grandChildData.Reset();
7072 parent.SetProperty(Actor::Property::VISIBLE, true);
7073 parentData.Check(false /* not called */, TEST_LOCATION);
7074 childData.Check(false /* not called */, TEST_LOCATION);
7075 grandChildData.Check(false /* not called */, TEST_LOCATION);
7080 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7082 TestApplication application;
7083 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7085 Actor actor = Actor::New();
7086 application.GetScene().Add(actor);
7088 application.SendNotification();
7089 application.Render();
7091 VisibilityChangedFunctorData data;
7092 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7094 Animation animation = Animation::New(1.0f);
7095 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7097 data.Check(false, TEST_LOCATION);
7098 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7099 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7101 tet_infoline("Play the animation and check the property value");
7104 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7105 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7107 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7108 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7110 application.SendNotification();
7111 application.Render(1100); // After the animation
7113 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7118 int utcDaliActorVisibilityChangeSignalByName(void)
7120 TestApplication application;
7121 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7123 Actor actor = Actor::New();
7125 bool signalCalled = false;
7126 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7127 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7128 actor.SetProperty(Actor::Property::VISIBLE, false);
7129 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7131 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7132 signalCalled = false;
7133 actor.SetProperty(Actor::Property::VISIBLE, false);
7134 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7136 tet_infoline("Change the visibility using properties, ensure called");
7137 actor.SetProperty(Actor::Property::VISIBLE, true);
7138 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7140 tet_infoline("Set the visibility to current using properties, ensure not called");
7141 signalCalled = false;
7143 actor.SetProperty(Actor::Property::VISIBLE, true);
7144 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7149 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7151 gLayoutDirectionType = type;
7154 int UtcDaliActorLayoutDirectionProperty(void)
7156 TestApplication application;
7157 tet_infoline("Check layout direction property");
7159 Actor actor0 = Actor::New();
7160 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7161 application.GetScene().Add(actor0);
7163 application.SendNotification();
7164 application.Render();
7166 Actor actor1 = Actor::New();
7167 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7168 Actor actor2 = Actor::New();
7169 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7170 Actor actor3 = Actor::New();
7171 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7172 Actor actor4 = Actor::New();
7173 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7174 Actor actor5 = Actor::New();
7175 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7176 Actor actor6 = Actor::New();
7177 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7178 Actor actor7 = Actor::New();
7179 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7180 Actor actor8 = Actor::New();
7181 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7182 Actor actor9 = Actor::New();
7183 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7186 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7187 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7189 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7190 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7191 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7193 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7194 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7195 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7197 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7199 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7200 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7202 application.GetScene().Add(actor3);
7209 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7210 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7212 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7213 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7214 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7216 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7218 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7219 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7220 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7221 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7222 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7223 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7224 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7226 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7227 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7228 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7230 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7231 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7232 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7233 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7235 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7236 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7237 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7242 struct LayoutDirectionFunctor
7244 LayoutDirectionFunctor(bool& signalCalled)
7245 : mSignalCalled(signalCalled)
7249 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7250 : mSignalCalled(rhs.mSignalCalled)
7256 mSignalCalled = true;
7259 bool& mSignalCalled;
7262 int UtcDaliActorLayoutDirectionSignal(void)
7264 TestApplication application;
7265 tet_infoline("Check changing layout direction property sends a signal");
7267 Actor actor = Actor::New();
7268 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7269 application.GetScene().Add(actor);
7270 bool signalCalled = false;
7271 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7273 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7274 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7276 // Test that writing the same value doesn't send a signal
7277 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7278 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7280 // Test that writing a different value sends the signal
7281 signalCalled = false;
7282 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7283 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7285 signalCalled = false;
7286 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7287 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7292 struct ChildAddedSignalCheck
7294 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7295 : mSignalReceived(signalReceived),
7296 mChildHandle(childHandle)
7300 void operator()(Actor childHandle)
7302 mSignalReceived = true;
7303 mChildHandle = childHandle;
7307 mSignalReceived = true;
7308 mChildHandle = Actor();
7311 bool& mSignalReceived;
7312 Actor& mChildHandle;
7315 int UtcDaliChildAddedSignalP1(void)
7317 TestApplication application;
7318 auto stage = application.GetScene();
7320 bool signalReceived = false;
7323 ChildAddedSignalCheck signal(signalReceived, childActor);
7324 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7325 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7327 auto actorA = Actor::New();
7329 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7330 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7331 signalReceived = false;
7333 auto actorB = Actor::New();
7335 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7336 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7341 int UtcDaliChildAddedSignalP2(void)
7343 TestApplication application;
7344 auto stage = application.GetScene();
7346 bool signalReceived = false;
7349 ChildAddedSignalCheck signal(signalReceived, childActor);
7350 tet_infoline("Connect to childAdded signal by name");
7352 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7353 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7355 auto actorA = Actor::New();
7357 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7359 // Can't test which actor was added; signal signature is void() when connecting via name.
7360 signalReceived = false;
7362 auto actorB = Actor::New();
7364 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7369 int UtcDaliChildAddedSignalN(void)
7371 TestApplication application;
7372 auto stage = application.GetScene();
7374 bool signalReceived = false;
7377 ChildAddedSignalCheck signal(signalReceived, childActor);
7378 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7379 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7381 auto actorA = Actor::New();
7383 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7384 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7385 signalReceived = false;
7387 auto actorB = Actor::New();
7389 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7393 struct ChildRemovedSignalCheck
7395 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7396 : mSignalReceived(signalReceived),
7397 mChildHandle(childHandle)
7401 void operator()(Actor childHandle)
7403 mSignalReceived = true;
7404 mChildHandle = childHandle;
7409 mSignalReceived = true;
7412 bool& mSignalReceived;
7413 Actor& mChildHandle;
7416 int UtcDaliChildRemovedSignalP1(void)
7418 TestApplication application;
7419 auto stage = application.GetScene();
7421 bool signalReceived = false;
7424 ChildRemovedSignalCheck signal(signalReceived, childActor);
7425 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7426 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7428 auto actorA = Actor::New();
7430 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7431 DALI_TEST_CHECK(!childActor);
7433 stage.Remove(actorA);
7434 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7435 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7437 signalReceived = false;
7438 auto actorB = Actor::New();
7440 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7442 stage.Remove(actorB);
7443 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7444 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7449 int UtcDaliChildRemovedSignalP2(void)
7451 TestApplication application;
7452 auto stage = application.GetScene();
7454 bool signalReceived = false;
7457 ChildAddedSignalCheck signal(signalReceived, childActor);
7458 tet_infoline("Connect to childRemoved signal by name");
7460 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7461 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7463 auto actorA = Actor::New();
7465 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7467 stage.Remove(actorA);
7468 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7470 signalReceived = false;
7471 auto actorB = Actor::New();
7473 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7475 stage.Remove(actorB);
7476 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7481 int UtcDaliChildRemovedSignalN(void)
7483 TestApplication application;
7484 auto stage = application.GetScene();
7486 bool signalReceived = false;
7489 ChildRemovedSignalCheck signal(signalReceived, childActor);
7490 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7491 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7493 auto actorA = Actor::New();
7496 auto actorB = Actor::New();
7499 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7500 DALI_TEST_CHECK(!childActor);
7502 actorA.Remove(actorB);
7503 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7507 int UtcDaliChildMovedSignalP(void)
7509 TestApplication application;
7510 auto stage = application.GetScene();
7512 bool addedASignalReceived = false;
7513 bool removedASignalReceived = false;
7514 bool addedBSignalReceived = false;
7515 bool removedBSignalReceived = false;
7518 auto actorA = Actor::New();
7519 auto actorB = Actor::New();
7523 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
7524 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7525 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
7526 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7528 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7529 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7530 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7531 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7533 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7534 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7535 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7536 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7538 // Create a child of A
7540 auto child = Actor::New();
7543 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7544 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7545 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7546 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7547 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7550 addedASignalReceived = false;
7551 addedBSignalReceived = false;
7552 removedASignalReceived = false;
7553 removedBSignalReceived = false;
7555 actorB.Add(child); // Expect this child to be re-parented
7556 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7557 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7558 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7559 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7561 // Move child back to A:
7562 addedASignalReceived = false;
7563 addedBSignalReceived = false;
7564 removedASignalReceived = false;
7565 removedBSignalReceived = false;
7567 actorA.Add(child); // Expect this child to be re-parented
7568 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7569 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7570 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7571 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7576 int utcDaliActorCulled(void)
7578 TestApplication application;
7579 auto stage = application.GetScene();
7581 tet_infoline("Check that the actor is culled if the actor is out of the screen");
7583 Actor actor = Actor::New();
7584 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7586 Geometry geometry = CreateQuadGeometry();
7587 Shader shader = CreateShader();
7588 Renderer renderer = Renderer::New(geometry, shader);
7589 actor.AddRenderer(renderer);
7593 application.SendNotification();
7594 application.Render(0);
7596 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7598 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7599 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7601 // Connect NotifySignal
7602 bool propertyNotificationSignal(false);
7603 PropertyNotification source;
7604 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7605 notification.NotifySignal().Connect(&application, f);
7607 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7609 application.SendNotification();
7610 application.Render();
7612 application.SendNotification();
7614 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7616 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7617 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7618 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7623 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7625 TestApplication application;
7626 auto stage = application.GetScene();
7628 tet_infoline("Ensure we clear the screen when the last actor is removed");
7630 Actor actor = CreateRenderableActor();
7631 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7634 application.SendNotification();
7635 application.Render();
7637 auto& glAbstraction = application.GetGlAbstraction();
7638 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7642 application.SendNotification();
7643 application.Render();
7645 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7650 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7652 TestApplication application;
7653 auto stage = application.GetScene();
7655 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7657 Actor actor = CreateRenderableActor();
7658 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7661 application.SendNotification();
7662 application.Render();
7664 auto& glAbstraction = application.GetGlAbstraction();
7665 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7667 actor.SetProperty(Actor::Property::VISIBLE, false);
7669 application.SendNotification();
7670 application.Render();
7672 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7677 int utcDaliActorGetSizeAfterAnimation(void)
7679 TestApplication application;
7680 tet_infoline("Check the actor size before / after an animation is finished");
7682 Vector3 actorSize(100.0f, 100.0f, 0.0f);
7684 Actor actor = Actor::New();
7685 actor.SetProperty(Actor::Property::SIZE, actorSize);
7686 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7687 application.GetScene().Add(actor);
7689 // Size should be updated without rendering.
7690 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7691 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7693 application.SendNotification();
7694 application.Render();
7696 // Size and current size should be updated.
7697 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7698 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7699 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7700 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7701 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7703 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7704 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7705 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7706 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7707 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7710 actorSize = Vector3(200.0f, 200.0f, 0.0f);
7711 actor.SetProperty(Actor::Property::SIZE, actorSize);
7713 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7714 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7716 Vector3 targetValue(10.0f, 20.0f, 0.0f);
7718 Animation animation = Animation::New(1.0f);
7719 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7722 // Size should be updated without rendering.
7723 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7724 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7726 application.SendNotification();
7727 application.Render(1100); // After the animation
7729 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7730 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7731 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7732 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7733 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7735 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7736 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7737 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7738 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7739 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7741 targetValue.width = 50.0f;
7744 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
7747 application.SendNotification();
7748 application.Render(1100); // After the animation
7750 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7751 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7752 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7753 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7754 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7756 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7757 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7758 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7759 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7760 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7762 targetValue.height = 70.0f;
7765 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
7768 application.SendNotification();
7769 application.Render(1100); // After the animation
7771 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7772 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7773 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7774 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7775 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7777 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7778 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7779 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7780 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7781 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7783 Vector3 offset(10.0f, 20.0f, 0.0f);
7786 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
7789 application.SendNotification();
7790 application.Render(1100); // After the animation
7792 targetValue += offset;
7794 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7795 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7796 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7797 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7798 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7800 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7801 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7802 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7803 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7804 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7806 offset.width = 20.0f;
7809 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
7812 application.SendNotification();
7813 application.Render(1100); // After the animation
7815 targetValue.width += offset.width;
7817 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7818 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7819 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7820 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7821 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7823 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7824 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7825 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7826 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7827 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7829 offset.height = 10.0f;
7832 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
7835 application.SendNotification();
7836 application.Render(1100); // After the animation
7838 targetValue.height += offset.height;
7840 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7841 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7842 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7843 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7844 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7846 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7847 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7848 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7849 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7850 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7853 actorSize = Vector3(300.0f, 300.0f, 0.0f);
7855 actor.SetProperty(Actor::Property::SIZE, actorSize);
7857 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7858 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7860 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7861 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7863 application.SendNotification();
7864 application.Render();
7866 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7867 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7869 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7870 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7875 int utcDaliActorPartialUpdate(void)
7877 TestApplication application(
7878 TestApplication::DEFAULT_SURFACE_WIDTH,
7879 TestApplication::DEFAULT_SURFACE_HEIGHT,
7880 TestApplication::DEFAULT_HORIZONTAL_DPI,
7881 TestApplication::DEFAULT_VERTICAL_DPI,
7885 tet_infoline("Check the damaged area");
7887 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7889 std::vector<Rect<int>> damagedRects;
7890 Rect<int> clippingRect;
7891 application.SendNotification();
7892 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7894 // First render pass, nothing to render, adaptor would just do swap buffer.
7895 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7896 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7898 Actor actor = CreateRenderableActor();
7899 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7900 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7901 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7902 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7903 application.GetScene().Add(actor);
7905 application.SendNotification();
7907 // 1. Actor added, damaged rect is added size of actor
7908 damagedRects.clear();
7909 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7910 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7913 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7914 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7915 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7916 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7917 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7918 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7919 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7922 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7923 application.SendNotification();
7925 damagedRects.clear();
7926 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7927 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7930 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7931 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7932 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7933 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7934 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7935 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7936 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7938 // 3. Set new position
7939 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7940 application.SendNotification();
7942 damagedRects.clear();
7943 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7944 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7947 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7948 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7949 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7950 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7951 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7952 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7953 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7955 application.GetScene().Remove(actor);
7956 application.SendNotification();
7958 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7959 damagedRects.clear();
7960 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7961 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7963 clippingRect = damagedRects[0];
7964 clippingRect.Merge(damagedRects[1]);
7965 clippingRect.Merge(damagedRects[2]);
7967 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7968 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7969 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7971 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7972 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7973 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7974 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7975 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7980 int utcDaliActorPartialUpdateSetColor(void)
7982 TestApplication application(
7983 TestApplication::DEFAULT_SURFACE_WIDTH,
7984 TestApplication::DEFAULT_SURFACE_HEIGHT,
7985 TestApplication::DEFAULT_HORIZONTAL_DPI,
7986 TestApplication::DEFAULT_VERTICAL_DPI,
7990 tet_infoline("Check uniform update");
7992 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7994 std::vector<Rect<int>> damagedRects;
7995 Rect<int> clippingRect;
7996 application.SendNotification();
7997 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7999 // First render pass, nothing to render, adaptor would just do swap buffer.
8000 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8001 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8003 Actor actor = CreateRenderableActor();
8004 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8005 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8006 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8007 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8008 application.GetScene().Add(actor);
8010 application.SendNotification();
8012 // 1. Actor added, damaged rect is added size of actor
8013 damagedRects.clear();
8014 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8015 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8018 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8019 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8020 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8021 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8022 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8023 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8024 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8026 damagedRects.clear();
8027 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8029 damagedRects.clear();
8030 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8033 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8034 application.SendNotification();
8036 damagedRects.clear();
8037 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8038 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8041 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8042 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8043 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8044 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8045 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8046 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8047 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8052 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8053 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8054 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8055 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8056 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8057 " uniform mediump mat4 uLightCameraViewMatrix;\n"
8061 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8062 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
8063 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8066 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8067 "uniform lowp vec4 uShadowColor;\n"
8070 " lowp float alpha;\n"
8071 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8072 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8075 int utcDaliActorPartialUpdateSetProperty(void)
8077 TestApplication application(
8078 TestApplication::DEFAULT_SURFACE_WIDTH,
8079 TestApplication::DEFAULT_SURFACE_HEIGHT,
8080 TestApplication::DEFAULT_HORIZONTAL_DPI,
8081 TestApplication::DEFAULT_VERTICAL_DPI,
8085 tet_infoline("Set/Update property with partial update");
8087 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8089 std::vector<Rect<int>> damagedRects;
8090 Rect<int> clippingRect;
8091 application.SendNotification();
8092 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8094 // First render pass, nothing to render, adaptor would just do swap buffer.
8095 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8096 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8098 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8099 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8100 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8101 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8102 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8103 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8104 application.GetScene().Add(actor);
8106 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8108 damagedRects.clear();
8109 application.SendNotification();
8110 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8111 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8114 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8115 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8116 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8117 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8118 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8119 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8120 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8122 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8123 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8125 damagedRects.clear();
8126 application.SendNotification();
8127 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8128 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8130 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8131 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8132 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8133 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8134 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8135 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8137 // Should be no damage rects, nothing changed
8138 damagedRects.clear();
8139 application.SendNotification();
8140 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8141 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8143 // Should be 1 damage rect due to change in size
8144 damagedRects.clear();
8145 actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8146 application.SendNotification();
8147 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8148 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8150 clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8151 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8152 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8153 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8154 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8155 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8156 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8158 damagedRects.clear();
8159 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8160 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8165 int utcDaliActorPartialUpdateTwoActors(void)
8167 TestApplication application(
8168 TestApplication::DEFAULT_SURFACE_WIDTH,
8169 TestApplication::DEFAULT_SURFACE_HEIGHT,
8170 TestApplication::DEFAULT_HORIZONTAL_DPI,
8171 TestApplication::DEFAULT_VERTICAL_DPI,
8175 tet_infoline("Check the damaged rects with partial update and two actors");
8177 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8179 Actor actor = CreateRenderableActor();
8180 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8181 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8182 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8183 application.GetScene().Add(actor);
8185 Actor actor2 = CreateRenderableActor();
8186 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8187 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8188 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8189 application.GetScene().Add(actor2);
8191 application.SendNotification();
8192 std::vector<Rect<int>> damagedRects;
8193 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8195 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8196 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8197 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8199 // in screen coordinates, adaptor would calculate it using previous frames information
8200 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8201 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8203 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8204 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8205 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8206 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8211 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8213 TestApplication application(
8214 TestApplication::DEFAULT_SURFACE_WIDTH,
8215 TestApplication::DEFAULT_SURFACE_HEIGHT,
8216 TestApplication::DEFAULT_HORIZONTAL_DPI,
8217 TestApplication::DEFAULT_VERTICAL_DPI,
8221 tet_infoline("Check the damaged rect with partial update and actor size hint");
8223 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8225 Actor actor = CreateRenderableActor();
8226 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
8227 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
8228 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f));
8229 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8230 application.GetScene().Add(actor);
8232 application.SendNotification();
8233 std::vector<Rect<int>> damagedRects;
8234 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8236 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8238 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
8239 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8241 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8243 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8244 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8245 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8246 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8251 int utcDaliActorPartialUpdateAnimation(void)
8253 TestApplication application(
8254 TestApplication::DEFAULT_SURFACE_WIDTH,
8255 TestApplication::DEFAULT_SURFACE_HEIGHT,
8256 TestApplication::DEFAULT_HORIZONTAL_DPI,
8257 TestApplication::DEFAULT_VERTICAL_DPI,
8261 tet_infoline("Check the damaged area with partial update and animation");
8263 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8264 drawTrace.Enable(true);
8267 Actor actor1 = CreateRenderableActor();
8268 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8269 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8270 application.GetScene().Add(actor1);
8272 Actor actor2 = CreateRenderableActor();
8273 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8274 actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8275 application.GetScene().Add(actor2);
8277 std::vector<Rect<int>> damagedRects;
8278 Rect<int> clippingRect;
8279 Rect<int> expectedRect1, expectedRect2;
8281 application.SendNotification();
8282 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8284 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8287 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8288 expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
8289 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8290 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
8292 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8294 damagedRects.clear();
8295 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8296 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8298 // Make an animation
8299 Animation animation = Animation::New(1.0f);
8300 animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
8303 application.SendNotification();
8305 damagedRects.clear();
8306 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8307 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8310 damagedRects.clear();
8312 // In animation deley time
8313 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8314 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8317 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8320 damagedRects.clear();
8322 // Also in animation deley time
8323 application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
8324 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8327 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8329 // Unparent 2 actors and make a new actor
8333 Actor actor3 = CreateRenderableActor();
8334 actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8335 actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8336 application.GetScene().Add(actor3);
8338 application.SendNotification();
8340 // Started animation
8341 damagedRects.clear();
8342 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8343 DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION);
8345 // The first dirty rect is actor3's.
8346 // We don't know the exact dirty rect of actor2
8347 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8348 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
8350 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8352 // Finished animation, but the actior was already unparented
8353 damagedRects.clear();
8354 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8356 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8357 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8359 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8364 int utcDaliActorPartialUpdateChangeVisibility(void)
8366 TestApplication application(
8367 TestApplication::DEFAULT_SURFACE_WIDTH,
8368 TestApplication::DEFAULT_SURFACE_HEIGHT,
8369 TestApplication::DEFAULT_HORIZONTAL_DPI,
8370 TestApplication::DEFAULT_VERTICAL_DPI,
8374 tet_infoline("Check the damaged rect with partial update and visibility change");
8376 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8378 Actor actor = CreateRenderableActor();
8379 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8380 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8381 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8382 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8383 application.GetScene().Add(actor);
8385 application.SendNotification();
8387 std::vector<Rect<int>> damagedRects;
8388 Rect<int> clippingRect;
8390 // 1. Actor added, damaged rect is added size of actor
8391 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8392 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8395 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8396 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8397 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8398 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8399 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8400 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8401 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8403 damagedRects.clear();
8404 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8405 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8407 damagedRects.clear();
8408 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8409 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8411 // Ensure the damaged rect is empty
8412 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8414 // 2. Make the Actor invisible
8415 actor.SetProperty(Actor::Property::VISIBLE, false);
8416 application.SendNotification();
8418 damagedRects.clear();
8419 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8420 DALI_TEST_CHECK(damagedRects.size() > 0);
8421 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8423 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8424 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8425 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8426 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8427 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8429 // 3. Make the Actor visible again
8430 actor.SetProperty(Actor::Property::VISIBLE, true);
8431 application.SendNotification();
8433 damagedRects.clear();
8434 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8435 DALI_TEST_CHECK(damagedRects.size() > 0);
8436 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8438 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8439 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8440 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8441 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8442 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8447 int utcDaliActorPartialUpdateOnOffScene(void)
8449 TestApplication application(
8450 TestApplication::DEFAULT_SURFACE_WIDTH,
8451 TestApplication::DEFAULT_SURFACE_HEIGHT,
8452 TestApplication::DEFAULT_HORIZONTAL_DPI,
8453 TestApplication::DEFAULT_VERTICAL_DPI,
8457 tet_infoline("Check the damaged rect with partial update and on/off scene");
8459 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8461 Actor actor = CreateRenderableActor();
8462 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8463 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8464 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8465 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8466 application.GetScene().Add(actor);
8468 application.SendNotification();
8470 std::vector<Rect<int>> damagedRects;
8471 Rect<int> clippingRect;
8473 // 1. Actor added, damaged rect is added size of actor
8474 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8475 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8478 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8479 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8480 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8481 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8482 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8483 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8484 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8486 damagedRects.clear();
8487 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8488 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8490 damagedRects.clear();
8491 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8492 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8494 // Ensure the damaged rect is empty
8495 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8497 // 2. Remove the Actor from the Scene
8499 application.SendNotification();
8501 damagedRects.clear();
8502 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8503 DALI_TEST_CHECK(damagedRects.size() > 0);
8504 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8506 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8507 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8508 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8509 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8510 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8512 // 3. Add the Actor to the Scene again
8513 application.GetScene().Add(actor);
8514 application.SendNotification();
8516 damagedRects.clear();
8517 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8518 DALI_TEST_CHECK(damagedRects.size() > 0);
8519 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8521 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8522 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8523 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8524 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8525 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8530 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
8532 TestApplication application;
8534 Actor actor = Actor::New();
8535 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
8536 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
8537 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
8538 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
8539 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
8540 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8541 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8542 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
8546 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
8548 TestApplication application;
8550 Actor actor = Actor::New();
8552 // Make sure setting invalid types does not cause a crash
8555 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
8556 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
8557 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
8558 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
8559 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
8560 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
8561 tet_result(TET_PASS);
8565 tet_result(TET_FAIL);
8570 int UtcDaliActorTouchAreaPropertyP(void)
8572 TestApplication application;
8574 Actor actor = Actor::New();
8575 Vector2 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
8576 DALI_TEST_EQUALS(touchArea, Vector2::ZERO, TEST_LOCATION);
8577 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(10.f, 10.f));
8578 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
8579 DALI_TEST_EQUALS(touchArea, Vector2(10.f, 10.f), TEST_LOCATION);
8583 int UtcDaliActorTouchAreaPropertyN(void)
8585 TestApplication application;
8587 Actor actor = Actor::New();
8589 // Make sure setting invalid types does not cause a crash
8592 actor.SetProperty(DevelActor::Property::TOUCH_AREA, 1.0f);
8593 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2::ONE);
8594 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector3::ONE);
8595 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector4::ONE);
8596 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Map());
8597 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Array());
8598 tet_result(TET_PASS);
8602 tet_result(TET_FAIL);
8607 int UtcDaliActorLowerBelowNegative(void)
8609 TestApplication application;
8610 Dali::Actor instance;
8614 instance.LowerBelow(arg1);
8615 DALI_TEST_CHECK(false); // Should not get here
8619 DALI_TEST_CHECK(true); // We expect an assert
8624 int UtcDaliActorRaiseAboveNegative(void)
8626 TestApplication application;
8627 Dali::Actor instance;
8631 instance.RaiseAbove(arg1);
8632 DALI_TEST_CHECK(false); // Should not get here
8636 DALI_TEST_CHECK(true); // We expect an assert
8641 int UtcDaliActorRaiseToTopNegative(void)
8643 TestApplication application;
8644 Dali::Actor instance;
8647 instance.RaiseToTop();
8648 DALI_TEST_CHECK(false); // Should not get here
8652 DALI_TEST_CHECK(true); // We expect an assert
8657 int UtcDaliActorAddRendererNegative(void)
8659 TestApplication application;
8660 Dali::Actor instance;
8663 Dali::Renderer arg1;
8664 instance.AddRenderer(arg1);
8665 DALI_TEST_CHECK(false); // Should not get here
8669 DALI_TEST_CHECK(true); // We expect an assert
8674 int UtcDaliActorTouchedSignalNegative(void)
8676 TestApplication application;
8677 Dali::Actor instance;
8680 instance.TouchedSignal();
8681 DALI_TEST_CHECK(false); // Should not get here
8685 DALI_TEST_CHECK(true); // We expect an assert
8690 int UtcDaliActorTranslateByNegative(void)
8692 TestApplication application;
8693 Dali::Actor instance;
8697 instance.TranslateBy(arg1);
8698 DALI_TEST_CHECK(false); // Should not get here
8702 DALI_TEST_CHECK(true); // We expect an assert
8707 int UtcDaliActorFindChildByIdNegative(void)
8709 TestApplication application;
8710 Dali::Actor instance;
8713 unsigned int arg1 = 0u;
8714 instance.FindChildById(arg1);
8715 DALI_TEST_CHECK(false); // Should not get here
8719 DALI_TEST_CHECK(true); // We expect an assert
8724 int UtcDaliActorGetRendererAtNegative(void)
8726 TestApplication application;
8727 Dali::Actor instance;
8730 unsigned int arg1 = 0u;
8731 instance.GetRendererAt(arg1);
8732 DALI_TEST_CHECK(false); // Should not get here
8736 DALI_TEST_CHECK(true); // We expect an assert
8741 int UtcDaliActorHoveredSignalNegative(void)
8743 TestApplication application;
8744 Dali::Actor instance;
8747 instance.HoveredSignal();
8748 DALI_TEST_CHECK(false); // Should not get here
8752 DALI_TEST_CHECK(true); // We expect an assert
8757 int UtcDaliActorLowerToBottomNegative(void)
8759 TestApplication application;
8760 Dali::Actor instance;
8763 instance.LowerToBottom();
8764 DALI_TEST_CHECK(false); // Should not get here
8768 DALI_TEST_CHECK(true); // We expect an assert
8773 int UtcDaliActorOnSceneSignalNegative(void)
8775 TestApplication application;
8776 Dali::Actor instance;
8779 instance.OnSceneSignal();
8780 DALI_TEST_CHECK(false); // Should not get here
8784 DALI_TEST_CHECK(true); // We expect an assert
8789 int UtcDaliActorOffSceneSignalNegative(void)
8791 TestApplication application;
8792 Dali::Actor instance;
8795 instance.OffSceneSignal();
8796 DALI_TEST_CHECK(false); // Should not get here
8800 DALI_TEST_CHECK(true); // We expect an assert
8805 int UtcDaliActorRemoveRendererNegative01(void)
8807 TestApplication application;
8808 Dali::Actor instance;
8811 unsigned int arg1 = 0u;
8812 instance.RemoveRenderer(arg1);
8813 DALI_TEST_CHECK(false); // Should not get here
8817 DALI_TEST_CHECK(true); // We expect an assert
8822 int UtcDaliActorRemoveRendererNegative02(void)
8824 TestApplication application;
8825 Dali::Actor instance;
8828 Dali::Renderer arg1;
8829 instance.RemoveRenderer(arg1);
8830 DALI_TEST_CHECK(false); // Should not get here
8834 DALI_TEST_CHECK(true); // We expect an assert
8839 int UtcDaliActorFindChildByNameNegative(void)
8841 TestApplication application;
8842 Dali::Actor instance;
8846 instance.FindChildByName(arg1);
8847 DALI_TEST_CHECK(false); // Should not get here
8851 DALI_TEST_CHECK(true); // We expect an assert
8856 int UtcDaliActorSetResizePolicyNegative(void)
8858 TestApplication application;
8859 Dali::Actor instance;
8862 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
8863 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
8864 instance.SetResizePolicy(arg1, arg2);
8865 DALI_TEST_CHECK(false); // Should not get here
8869 DALI_TEST_CHECK(true); // We expect an assert
8874 int UtcDaliActorOnRelayoutSignalNegative(void)
8876 TestApplication application;
8877 Dali::Actor instance;
8880 instance.OnRelayoutSignal();
8881 DALI_TEST_CHECK(false); // Should not get here
8885 DALI_TEST_CHECK(true); // We expect an assert
8890 int UtcDaliActorWheelEventSignalNegative(void)
8892 TestApplication application;
8893 Dali::Actor instance;
8896 instance.WheelEventSignal();
8897 DALI_TEST_CHECK(false); // Should not get here
8901 DALI_TEST_CHECK(true); // We expect an assert
8906 int UtcDaliActorGetHeightForWidthNegative(void)
8908 TestApplication application;
8909 Dali::Actor instance;
8913 instance.GetHeightForWidth(arg1);
8914 DALI_TEST_CHECK(false); // Should not get here
8918 DALI_TEST_CHECK(true); // We expect an assert
8923 int UtcDaliActorGetWidthForHeightNegative(void)
8925 TestApplication application;
8926 Dali::Actor instance;
8930 instance.GetWidthForHeight(arg1);
8931 DALI_TEST_CHECK(false); // Should not get here
8935 DALI_TEST_CHECK(true); // We expect an assert
8940 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
8942 TestApplication application;
8943 Dali::Actor instance;
8946 instance.LayoutDirectionChangedSignal();
8947 DALI_TEST_CHECK(false); // Should not get here
8951 DALI_TEST_CHECK(true); // We expect an assert
8956 int UtcDaliActorAddNegative(void)
8958 TestApplication application;
8959 Dali::Actor instance;
8964 DALI_TEST_CHECK(false); // Should not get here
8968 DALI_TEST_CHECK(true); // We expect an assert
8973 int UtcDaliActorLowerNegative(void)
8975 TestApplication application;
8976 Dali::Actor instance;
8980 DALI_TEST_CHECK(false); // Should not get here
8984 DALI_TEST_CHECK(true); // We expect an assert
8989 int UtcDaliActorRaiseNegative(void)
8991 TestApplication application;
8992 Dali::Actor instance;
8996 DALI_TEST_CHECK(false); // Should not get here
9000 DALI_TEST_CHECK(true); // We expect an assert
9005 int UtcDaliActorRemoveNegative(void)
9007 TestApplication application;
9008 Dali::Actor instance;
9012 instance.Remove(arg1);
9013 DALI_TEST_CHECK(false); // Should not get here
9017 DALI_TEST_CHECK(true); // We expect an assert
9022 int UtcDaliActorScaleByNegative(void)
9024 TestApplication application;
9025 Dali::Actor instance;
9029 instance.ScaleBy(arg1);
9030 DALI_TEST_CHECK(false); // Should not get here
9034 DALI_TEST_CHECK(true); // We expect an assert
9039 int UtcDaliActorGetLayerNegative(void)
9041 TestApplication application;
9042 Dali::Actor instance;
9045 instance.GetLayer();
9046 DALI_TEST_CHECK(false); // Should not get here
9050 DALI_TEST_CHECK(true); // We expect an assert
9055 int UtcDaliActorRotateByNegative01(void)
9057 TestApplication application;
9058 Dali::Actor instance;
9061 Dali::Quaternion arg1;
9062 instance.RotateBy(arg1);
9063 DALI_TEST_CHECK(false); // Should not get here
9067 DALI_TEST_CHECK(true); // We expect an assert
9072 int UtcDaliActorRotateByNegative02(void)
9074 TestApplication application;
9075 Dali::Actor instance;
9080 instance.RotateBy(arg1, arg2);
9081 DALI_TEST_CHECK(false); // Should not get here
9085 DALI_TEST_CHECK(true); // We expect an assert
9090 int UtcDaliActorUnparentNegative(void)
9092 TestApplication application;
9093 Dali::Actor instance;
9096 instance.Unparent();
9097 DALI_TEST_CHECK(false); // Should not get here
9101 DALI_TEST_CHECK(true); // We expect an assert
9106 int UtcDaliActorGetChildAtNegative(void)
9108 TestApplication application;
9109 Dali::Actor instance;
9112 unsigned int arg1 = 0u;
9113 instance.GetChildAt(arg1);
9114 DALI_TEST_CHECK(false); // Should not get here
9118 DALI_TEST_CHECK(true); // We expect an assert
9123 int UtcDaliActorGetChildCountNegative(void)
9125 TestApplication application;
9126 Dali::Actor instance;
9129 instance.GetChildCount();
9130 DALI_TEST_CHECK(false); // Should not get here
9134 DALI_TEST_CHECK(true); // We expect an assert
9139 int UtcDaliActorGetTargetSizeNegative(void)
9141 TestApplication application;
9142 Dali::Actor instance;
9145 instance.GetTargetSize();
9146 DALI_TEST_CHECK(false); // Should not get here
9150 DALI_TEST_CHECK(true); // We expect an assert
9155 int UtcDaliActorScreenToLocalNegative(void)
9157 TestApplication application;
9158 Dali::Actor instance;
9165 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
9166 DALI_TEST_CHECK(false); // Should not get here
9170 DALI_TEST_CHECK(true); // We expect an assert
9175 int UtcDaliActorGetNaturalSizeNegative(void)
9177 TestApplication application;
9178 Dali::Actor instance;
9181 instance.GetNaturalSize();
9182 DALI_TEST_CHECK(false); // Should not get here
9186 DALI_TEST_CHECK(true); // We expect an assert
9191 int UtcDaliActorGetRelayoutSizeNegative(void)
9193 TestApplication application;
9194 Dali::Actor instance;
9197 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
9198 instance.GetRelayoutSize(arg1);
9199 DALI_TEST_CHECK(false); // Should not get here
9203 DALI_TEST_CHECK(true); // We expect an assert
9208 int UtcDaliActorGetResizePolicyNegative(void)
9210 TestApplication application;
9211 Dali::Actor instance;
9214 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
9215 instance.GetResizePolicy(arg1);
9216 DALI_TEST_CHECK(false); // Should not get here
9220 DALI_TEST_CHECK(true); // We expect an assert
9225 int UtcDaliActorGetRendererCountNegative(void)
9227 TestApplication application;
9228 Dali::Actor instance;
9231 instance.GetRendererCount();
9232 DALI_TEST_CHECK(false); // Should not get here
9236 DALI_TEST_CHECK(true); // We expect an assert
9241 int UtcDaliActorGetParentNegative(void)
9243 TestApplication application;
9244 Dali::Actor instance;
9247 instance.GetParent();
9248 DALI_TEST_CHECK(false); // Should not get here
9252 DALI_TEST_CHECK(true); // We expect an assert
9257 int UtcDaliActorPropertyBlendEquation(void)
9259 TestApplication application;
9261 tet_infoline("Test SetProperty AdvancedBlendEquation");
9263 Geometry geometry = CreateQuadGeometry();
9264 Shader shader = CreateShader();
9265 Renderer renderer1 = Renderer::New(geometry, shader);
9267 Actor actor = Actor::New();
9268 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
9270 actor.AddRenderer(renderer1);
9271 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
9272 application.GetScene().Add(actor);
9274 if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
9276 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
9277 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
9278 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
9281 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
9283 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
9284 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
9285 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
9288 Renderer renderer2 = Renderer::New(geometry, shader);
9289 actor.AddRenderer(renderer2);
9294 int UtcDaliActorRegisterProperty(void)
9296 tet_infoline("Test property registration and uniform map update\n");
9298 TestApplication application;
9300 Geometry geometry = CreateQuadGeometry();
9301 Shader shader = CreateShader();
9302 Renderer renderer1 = Renderer::New(geometry, shader);
9303 Renderer renderer2 = Renderer::New(geometry, shader);
9305 Actor actor1 = Actor::New();
9306 actor1.AddRenderer(renderer1);
9307 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9308 actor1.RegisterProperty("uCustom", 1);
9309 application.GetScene().Add(actor1);
9311 Actor actor2 = Actor::New();
9312 actor2.AddRenderer(renderer2);
9313 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9314 application.GetScene().Add(actor2);
9316 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
9317 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
9318 glAbstraction.EnableSetUniformCallTrace(true);
9320 application.SendNotification();
9321 application.Render();
9323 std::stringstream out;
9327 // Test uniform value of the custom property
9328 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9329 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
9332 actor1[Actor::Property::VISIBLE] = false;
9334 application.SendNotification();
9335 application.Render();
9337 // Make visible again
9338 actor1[Actor::Property::VISIBLE] = true;
9339 actor1["uCustom"] = 2;
9341 glAbstraction.ResetSetUniformCallStack();
9343 application.SendNotification();
9344 application.Render();
9348 // The uniform value should not be changed
9349 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9350 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);