2 * Copyright (c) 2022 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;
56 bool gHitTestTouchCallBackCalled = false;
58 bool gHoverCallBackCalled = false;
60 static bool gTestConstraintCalled;
62 LayoutDirection::Type gLayoutDirectionType;
66 void operator()(Vector4& color, const PropertyInputContainer& /* inputs */)
68 gTestConstraintCalled = true;
73 * TestConstraint reference.
74 * When constraint is called, the resultRef is updated
75 * with the value supplied.
78 struct TestConstraintRef
80 TestConstraintRef(unsigned int& resultRef, unsigned int value)
81 : mResultRef(resultRef),
86 void operator()(T& current, const PropertyInputContainer& /* inputs */)
91 unsigned int& mResultRef;
95 static bool TestTouchCallback(Actor, const TouchEvent&)
97 gTouchCallBackCalled = true;
102 static bool TestTouchCallback2(Actor, const TouchEvent&)
104 gTouchCallBackCalled2 = true;
109 static bool TestTouchCallback3(Actor, const TouchEvent&)
111 gTouchCallBackCalled3 = true;
116 static bool TestHitTestTouchCallback(Actor, const TouchEvent&)
118 gHitTestTouchCallBackCalled = true;
123 static void ResetTouchCallbacks()
125 gTouchCallBackCalled = false;
126 gTouchCallBackCalled2 = false;
127 gTouchCallBackCalled3 = false;
130 static bool TestCallback3(Actor actor, const HoverEvent& event)
132 gHoverCallBackCalled = true;
137 // validation stuff for onstage & offstage signals
138 static std::vector<std::string> gActorNamesOnOffScene;
139 static int gOnSceneCallBackCalled;
140 void OnSceneCallback(Actor actor)
142 ++gOnSceneCallBackCalled;
143 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
144 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
146 static int gOffSceneCallBackCalled;
147 void OffSceneCallback(Actor actor)
149 ++gOffSceneCallBackCalled;
150 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
151 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
154 struct PositionComponentConstraint
156 PositionComponentConstraint()
160 void operator()(Vector3& pos, const PropertyInputContainer& inputs)
162 const Matrix& m = inputs[0]->GetMatrix();
165 m.GetTransformComponents(pos, rot, scale);
169 struct OrientationComponentConstraint
171 OrientationComponentConstraint()
175 void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
177 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
180 orientation = parentOrientation;
185 static bool gOnRelayoutCallBackCalled = false;
186 static std::vector<std::string> gActorNamesRelayout;
188 void OnRelayoutCallback(Actor actor)
190 gOnRelayoutCallBackCalled = true;
191 gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
194 struct VisibilityChangedFunctorData
196 VisibilityChangedFunctorData()
199 type(DevelActor::VisibilityChange::SELF),
208 type = DevelActor::VisibilityChange::SELF;
212 void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
214 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
215 DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
216 DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
217 DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
220 void Check(bool compareCalled, const std::string& location)
222 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
227 DevelActor::VisibilityChange::Type type;
231 struct VisibilityChangedFunctor
233 VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
238 void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
241 data.visible = visible;
246 VisibilityChangedFunctorData& data;
249 struct VisibilityChangedVoidFunctor
251 VisibilityChangedVoidFunctor(bool& signalCalled)
252 : mSignalCalled(signalCalled)
258 mSignalCalled = true;
264 struct ChildOrderChangedFunctor
266 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
267 : mSignalCalled(signalCalled),
272 void operator()(Actor actor)
274 mSignalCalled = true;
282 struct CulledPropertyNotificationFunctor
284 CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
285 : mSignalCalled(signalCalled),
286 mPropertyNotification(propertyNotification)
290 void operator()(PropertyNotification& source)
292 mSignalCalled = true;
293 mPropertyNotification = source;
297 PropertyNotification& mPropertyNotification;
300 } // anonymous namespace
302 //& purpose: Testing New API
303 int UtcDaliActorNew(void)
305 TestApplication application;
307 Actor actor = Actor::New();
309 DALI_TEST_CHECK(actor);
313 //& purpose: Testing Dali::Actor::DownCast()
314 int UtcDaliActorDownCastP(void)
316 TestApplication application;
317 tet_infoline("Testing Dali::Actor::DownCast()");
319 Actor actor = Actor::New();
320 BaseHandle object(actor);
321 Actor actor2 = Actor::DownCast(object);
322 DALI_TEST_CHECK(actor2);
326 //& purpose: Testing Dali::Actor::DownCast()
327 int UtcDaliActorDownCastN(void)
329 TestApplication application;
330 tet_infoline("Testing Dali::Actor::DownCast()");
332 BaseHandle unInitializedObject;
333 Actor actor = Actor::DownCast(unInitializedObject);
334 DALI_TEST_CHECK(!actor);
338 int UtcDaliActorMoveConstructor(void)
340 TestApplication application;
342 Actor actor = Actor::New();
343 DALI_TEST_CHECK(actor);
345 int id = actor.GetProperty<int>(Actor::Property::ID);
347 Actor moved = std::move(actor);
348 DALI_TEST_CHECK(moved);
349 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
350 DALI_TEST_CHECK(!actor);
355 int UtcDaliActorMoveAssignment(void)
357 TestApplication application;
359 Actor actor = Actor::New();
360 DALI_TEST_CHECK(actor);
362 int id = actor.GetProperty<int>(Actor::Property::ID);
365 moved = std::move(actor);
366 DALI_TEST_CHECK(moved);
367 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
368 DALI_TEST_CHECK(!actor);
373 //& purpose: Testing Dali::Actor::GetName()
374 int UtcDaliActorGetName(void)
376 TestApplication application;
378 Actor actor = Actor::New();
380 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
384 //& purpose: Testing Dali::Actor::SetName()
385 int UtcDaliActorSetName(void)
387 TestApplication application;
389 string str("ActorName");
390 Actor actor = Actor::New();
392 actor.SetProperty(Actor::Property::NAME, str);
393 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
397 int UtcDaliActorGetId(void)
399 tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
400 TestApplication application;
402 Actor first = Actor::New();
403 Actor second = Actor::New();
404 Actor third = Actor::New();
406 DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
407 DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
411 int UtcDaliActorIsRoot(void)
413 TestApplication application;
415 Actor actor = Actor::New();
416 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
418 // get the root layer
419 actor = application.GetScene().GetLayer(0);
420 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
424 int UtcDaliActorOnScene(void)
426 TestApplication application;
428 Actor actor = Actor::New();
429 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
431 // get the root layer
432 actor = application.GetScene().GetLayer(0);
433 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
437 int UtcDaliActorIsLayer(void)
439 TestApplication application;
441 Actor actor = Actor::New();
442 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
444 // get the root layer
445 actor = application.GetScene().GetLayer(0);
446 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
450 int UtcDaliActorGetLayer(void)
452 TestApplication application;
454 Actor actor = Actor::New();
455 application.GetScene().Add(actor);
456 Layer layer = actor.GetLayer();
458 DALI_TEST_CHECK(layer);
460 // get the root layers layer
461 actor = application.GetScene().GetLayer(0);
462 DALI_TEST_CHECK(actor.GetLayer());
466 int UtcDaliActorAddP(void)
468 tet_infoline("Testing Actor::Add");
469 TestApplication application;
471 Actor parent = Actor::New();
472 Actor child = Actor::New();
474 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
478 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
480 Actor parent2 = Actor::New();
483 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
484 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
486 // try Adding to same parent again, works
488 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
490 // try reparenting an orphaned child
492 Actor temporaryParent = Actor::New();
493 temporaryParent.Add(child);
494 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
496 // temporaryParent has now died, reparent the orphaned child
498 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
503 int UtcDaliActorAddN(void)
505 tet_infoline("Testing Actor::Add");
506 TestApplication application;
508 Actor child = Actor::New();
510 Actor parent2 = Actor::New();
516 parent2.Add(parent2);
517 tet_printf("Assertion test failed - no Exception\n");
518 tet_result(TET_FAIL);
520 catch(Dali::DaliException& e)
522 DALI_TEST_PRINT_ASSERT(e);
523 DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
524 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
528 tet_printf("Assertion test failed - wrong Exception\n");
529 tet_result(TET_FAIL);
532 // try reparenting root
535 parent2.Add(application.GetScene().GetLayer(0));
536 tet_printf("Assertion test failed - no Exception\n");
537 tet_result(TET_FAIL);
539 catch(Dali::DaliException& e)
541 DALI_TEST_PRINT_ASSERT(e);
542 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
543 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
547 tet_printf("Assertion test failed - wrong Exception\n");
548 tet_result(TET_FAIL);
556 tet_printf("Assertion test failed - no Exception\n");
557 tet_result(TET_FAIL);
559 catch(Dali::DaliException& e)
561 DALI_TEST_PRINT_ASSERT(e);
562 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
563 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
567 tet_printf("Assertion test failed - wrong Exception\n");
568 tet_result(TET_FAIL);
574 int UtcDaliActorRemoveN(void)
576 tet_infoline("Testing Actor::Remove");
577 TestApplication application;
579 Actor parent = Actor::New();
580 Actor child = Actor::New();
581 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
584 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
586 parent.Remove(child);
587 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
589 // remove again, no problem
590 parent.Remove(child);
591 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
595 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
596 // try Remove self, its a no-op
597 parent.Remove(parent);
598 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
604 parent.Remove(empty);
605 tet_printf("Assertion test failed - no Exception\n");
606 tet_result(TET_FAIL);
608 catch(Dali::DaliException& e)
610 DALI_TEST_PRINT_ASSERT(e);
611 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
612 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
616 tet_printf("Assertion test failed - wrong Exception\n");
617 tet_result(TET_FAIL);
622 int UtcDaliActorRemoveP(void)
624 TestApplication application;
626 Actor parent = Actor::New();
627 Actor child = Actor::New();
628 Actor random = Actor::New();
630 application.GetScene().Add(parent);
632 DALI_TEST_CHECK(parent.GetChildCount() == 0);
636 DALI_TEST_CHECK(parent.GetChildCount() == 1);
638 parent.Remove(random);
640 DALI_TEST_CHECK(parent.GetChildCount() == 1);
642 application.GetScene().Remove(parent);
644 DALI_TEST_CHECK(parent.GetChildCount() == 1);
648 int UtcDaliActorSwitchParentN(void)
650 tet_infoline("Testing Actor::UtcDaliActorSwitchParentN");
651 TestApplication application;
653 Actor parent1 = Actor::New();
654 Actor child = Actor::New();
656 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
660 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
662 Actor parent2 = Actor::New();
664 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
666 // Try switch parent with that both of parent1 and parent2 are off scene.
667 DevelActor::SwitchParent(child, parent2);
669 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
670 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
674 int UtcDaliActorGetChildCount(void)
676 TestApplication application;
678 Actor parent = Actor::New();
679 Actor child = Actor::New();
681 DALI_TEST_CHECK(parent.GetChildCount() == 0);
685 DALI_TEST_CHECK(parent.GetChildCount() == 1);
689 int UtcDaliActorGetChildren01(void)
691 TestApplication application;
693 Actor parent = Actor::New();
694 Actor first = Actor::New();
695 Actor second = Actor::New();
696 Actor third = Actor::New();
702 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
703 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
704 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
708 int UtcDaliActorGetChildren02(void)
710 TestApplication application;
712 Actor parent = Actor::New();
713 Actor first = Actor::New();
714 Actor second = Actor::New();
715 Actor third = Actor::New();
721 const Actor& constParent = parent;
723 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
724 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
725 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
729 int UtcDaliActorGetParent01(void)
731 TestApplication application;
733 Actor parent = Actor::New();
734 Actor child = Actor::New();
738 DALI_TEST_CHECK(child.GetParent() == parent);
742 int UtcDaliActorGetParent02(void)
744 TestApplication application;
746 Actor actor = Actor::New();
748 DALI_TEST_CHECK(!actor.GetParent());
752 int UtcDaliActorCustomProperty(void)
754 TestApplication application;
756 Actor actor = Actor::New();
757 application.GetScene().Add(actor);
759 float startValue(1.0f);
760 Property::Index index = actor.RegisterProperty("testProperty", startValue);
761 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
763 application.SendNotification();
764 application.Render(0);
765 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
767 actor.SetProperty(index, 5.0f);
769 application.SendNotification();
770 application.Render(0);
771 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
775 int UtcDaliActorCustomPropertyIntToFloat(void)
777 TestApplication application;
779 Actor actor = Actor::New();
780 application.GetScene().Add(actor);
782 float startValue(5.0f);
783 Property::Index index = actor.RegisterProperty("testProperty", startValue);
784 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
786 application.SendNotification();
787 application.Render(0);
788 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
790 actor.SetProperty(index, int(1));
792 application.SendNotification();
793 application.Render(0);
794 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
798 int UtcDaliActorCustomPropertyFloatToInt(void)
800 TestApplication application;
802 Actor actor = Actor::New();
803 application.GetScene().Add(actor);
806 Property::Index index = actor.RegisterProperty("testProperty", startValue);
807 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
809 application.SendNotification();
810 application.Render(0);
811 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
813 actor.SetProperty(index, float(1.5));
815 application.SendNotification();
816 application.Render(0);
817 DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
821 int UtcDaliActorSetParentOrigin(void)
823 TestApplication application;
825 Actor actor = Actor::New();
827 Vector3 vector(0.7f, 0.8f, 0.9f);
828 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
830 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
832 // flush the queue and render once
833 application.SendNotification();
834 application.Render();
836 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
838 application.GetScene().Add(actor);
840 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
842 // flush the queue and render once
843 application.SendNotification();
844 application.Render();
846 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
848 application.GetScene().Remove(actor);
852 int UtcDaliActorSetParentOriginIndividual(void)
854 TestApplication application;
856 Actor actor = Actor::New();
858 Vector3 vector(0.7f, 0.8f, 0.9f);
859 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
861 actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
863 // flush the queue and render once
864 application.SendNotification();
865 application.Render();
867 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
869 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
871 // flush the queue and render once
872 application.SendNotification();
873 application.Render();
875 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
877 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
879 // flush the queue and render once
880 application.SendNotification();
881 application.Render();
883 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
888 int UtcDaliActorGetCurrentParentOrigin(void)
890 TestApplication application;
892 Actor actor = Actor::New();
894 Vector3 vector(0.7f, 0.8f, 0.9f);
895 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
897 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
899 // flush the queue and render once
900 application.SendNotification();
901 application.Render();
903 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
907 int UtcDaliActorSetAnchorPoint(void)
909 TestApplication application;
911 Actor actor = Actor::New();
913 Vector3 vector(0.7f, 0.8f, 0.9f);
914 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
916 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
918 // flush the queue and render once
919 application.SendNotification();
920 application.Render();
922 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
924 application.GetScene().Add(actor);
926 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
927 // flush the queue and render once
928 application.SendNotification();
929 application.Render();
931 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
933 application.GetScene().Remove(actor);
937 int UtcDaliActorSetAnchorPointIndividual(void)
939 TestApplication application;
941 Actor actor = Actor::New();
943 Vector3 vector(0.7f, 0.8f, 0.9f);
944 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
946 actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
948 // flush the queue and render once
949 application.SendNotification();
950 application.Render();
952 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
954 actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
956 // flush the queue and render once
957 application.SendNotification();
958 application.Render();
960 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
962 actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
964 // flush the queue and render once
965 application.SendNotification();
966 application.Render();
968 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
973 int UtcDaliActorGetCurrentAnchorPoint(void)
975 TestApplication application;
977 Actor actor = Actor::New();
979 Vector3 vector(0.7f, 0.8f, 0.9f);
980 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
982 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
984 // flush the queue and render once
985 application.SendNotification();
986 application.Render();
988 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
992 int UtcDaliActorSetSize01(void)
994 TestApplication application;
996 Actor actor = Actor::New();
997 Vector3 vector(100.0f, 100.0f, 0.0f);
999 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1001 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1003 // Immediately retrieve the size after setting
1004 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1005 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1006 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1007 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1008 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1010 // Flush the queue and render once
1011 application.SendNotification();
1012 application.Render();
1014 // Check the size in the new frame
1015 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1017 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1018 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1019 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1020 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1021 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1023 // Check async behaviour
1024 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
1025 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1026 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1027 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1028 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1030 // Change the resize policy and check whether the size stays the same
1031 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1033 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1034 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1036 // Set a new size after resize policy is changed and check the new size
1037 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1039 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1040 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1042 // Change the resize policy again and check whether the new size stays the same
1043 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1045 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1046 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1048 // Set another new size after resize policy is changed and check the new size
1049 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1051 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1052 DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1057 int UtcDaliActorSetSize02(void)
1059 TestApplication application;
1061 Actor actor = Actor::New();
1062 Vector3 vector(100.0f, 100.0f, 100.0f);
1064 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1066 actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1068 // Immediately check the size after setting
1069 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1070 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1072 // flush the queue and render once
1073 application.SendNotification();
1074 application.Render();
1076 // Check the size in the new frame
1077 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1079 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1080 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1085 // SetSize(Vector2 size)
1086 int UtcDaliActorSetSize03(void)
1088 TestApplication application;
1090 Actor actor = Actor::New();
1091 Vector3 vector(100.0f, 100.0f, 0.0f);
1093 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1095 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1097 // Immediately check the size after setting
1098 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1099 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1101 // flush the queue and render once
1102 application.SendNotification();
1103 application.Render();
1105 // Check the size in the new frame
1106 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1108 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1109 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1114 // SetSize(Vector3 size)
1115 int UtcDaliActorSetSize04(void)
1117 TestApplication application;
1119 Actor actor = Actor::New();
1120 Vector3 vector(100.0f, 100.0f, 100.0f);
1122 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1124 actor.SetProperty(Actor::Property::SIZE, vector);
1126 // Immediately check the size after setting
1127 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1128 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1130 // flush the queue and render once
1131 application.SendNotification();
1132 application.Render();
1134 // Check the size in the new frame
1135 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1137 application.GetScene().Add(actor);
1138 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1140 // Immediately check the size after setting
1141 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1142 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1144 // flush the queue and render once
1145 application.SendNotification();
1146 application.Render();
1148 // Check the size in the new frame
1149 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1151 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1152 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1154 application.GetScene().Remove(actor);
1158 int UtcDaliActorSetSize05(void)
1160 TestApplication application;
1162 Actor parent = Actor::New();
1163 Vector2 vector(200.0f, 200.0f);
1164 DALI_TEST_CHECK(vector != parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1166 parent.SetProperty(Actor::Property::SIZE, vector);
1167 Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1168 DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1170 Actor child = Actor::New();
1171 DALI_TEST_CHECK(vector != child.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1172 child.SetProperty(Actor::Property::SIZE, vector);
1173 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
1174 DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1176 // flush the queue and render once
1177 application.SendNotification();
1178 application.Render();
1180 DALI_TEST_CHECK(vector == parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
1185 int UtcDaliActorSetSizeIndividual(void)
1187 TestApplication application;
1189 Actor actor = Actor::New();
1191 Vector3 vector(0.7f, 0.8f, 0.9f);
1192 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1194 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1196 // Immediately check the width after setting
1197 float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1198 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1200 // flush the queue and render once
1201 application.SendNotification();
1202 application.Render();
1204 // Check the width in the new frame
1205 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1207 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1208 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1210 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1212 // Immediately check the height after setting
1213 float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1214 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1216 // flush the queue and render once
1217 application.SendNotification();
1218 application.Render();
1220 // Check the height in the new frame
1221 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1223 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1224 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1226 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1228 // Immediately check the depth after setting
1229 float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1230 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1232 // flush the queue and render once
1233 application.SendNotification();
1234 application.Render();
1236 // Check the depth in the new frame
1237 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1239 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1240 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1242 // Change the resize policy and check whether the size stays the same
1243 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1245 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1246 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1248 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1249 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1251 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1252 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1254 // Change the resize policy again and check whether the size stays the same
1255 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1257 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1258 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1260 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1261 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1263 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1264 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1269 int UtcDaliActorSetSizeIndividual02(void)
1271 TestApplication application;
1273 Actor actor = Actor::New();
1274 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1275 application.GetScene().Add(actor);
1277 Vector3 vector(100.0f, 200.0f, 400.0f);
1278 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1280 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1281 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1283 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1284 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1286 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1287 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1289 // flush the queue and render once
1290 application.SendNotification();
1291 application.Render();
1293 // Check the width in the new frame
1294 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1295 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1300 int UtcDaliActorGetCurrentSize(void)
1302 TestApplication application;
1304 Actor actor = Actor::New();
1305 Vector3 vector(100.0f, 100.0f, 20.0f);
1307 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1309 actor.SetProperty(Actor::Property::SIZE, vector);
1311 // flush the queue and render once
1312 application.SendNotification();
1313 application.Render();
1315 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1319 int UtcDaliActorGetNaturalSize(void)
1321 TestApplication application;
1323 Actor actor = Actor::New();
1324 Vector3 vector(0.0f, 0.0f, 0.0f);
1326 DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1331 int UtcDaliActorGetCurrentSizeImmediate(void)
1333 TestApplication application;
1335 Actor actor = Actor::New();
1336 Vector3 vector(100.0f, 100.0f, 20.0f);
1338 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1339 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1341 actor.SetProperty(Actor::Property::SIZE, vector);
1343 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1344 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1346 // flush the queue and render once
1347 application.SendNotification();
1348 application.Render();
1350 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1351 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1354 // Build the animation
1355 const float durationSeconds = 2.0f;
1356 Animation animation = Animation::New(durationSeconds);
1357 const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1358 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1360 DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1362 application.GetScene().Add(actor);
1364 // Start the animation
1367 application.SendNotification();
1368 application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1370 DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1375 int UtcDaliActorCalculateScreenExtents(void)
1377 TestApplication application;
1379 Actor actor = Actor::New();
1381 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1382 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1384 application.GetScene().Add(actor);
1386 application.SendNotification();
1387 application.Render();
1389 auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1390 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1391 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1392 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1393 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1394 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1396 application.GetScene().Remove(actor);
1400 int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void)
1402 TestApplication application;
1403 Integration::Scene scene = application.GetScene();
1406 Layer layer = Layer::New();
1407 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1408 layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1409 layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1413 // Build custom camera with top-view
1414 CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
1416 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1417 Vector3 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1418 Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1421 std::ostringstream oss;
1422 oss << cameraPos << "\n";
1423 oss << cameraOrient << "\n";
1424 tet_printf("%s\n", oss.str().c_str());
1427 cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1428 cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1430 // Now, upside : -Z, leftside : -X, foward : +Y
1432 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1433 cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1435 std::ostringstream oss;
1436 oss << cameraPos << "\n";
1437 oss << cameraOrient << "\n";
1438 tet_printf("%s\n", oss.str().c_str());
1442 Actor actor = Actor::New();
1443 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1444 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1445 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f));
1446 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f});
1450 application.SendNotification();
1451 application.Render();
1453 Vector2 sceneSize = scene.GetSize();
1455 auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f};
1456 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1458 std::ostringstream oss;
1459 oss << expectedExtent << "\n";
1460 oss << actualExtent << "\n";
1461 tet_printf("%s\n", oss.str().c_str());
1464 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1465 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1466 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1467 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1472 int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void)
1474 // TODO : Need to make it works well
1475 TestApplication application;
1476 Integration::Scene scene = application.GetScene();
1477 Vector2 sceneSize = scene.GetSize();
1480 Layer layer = Layer::New();
1481 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1482 layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1483 layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1484 layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1485 layer.SetProperty(Actor::Property::SIZE, sceneSize);
1489 // Build custom camera with top-view
1490 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1492 offscreenCameraActor.SetPerspectiveProjection(sceneSize);
1493 offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1494 offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1496 scene.Add(offscreenCameraActor);
1498 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1499 Vector3 cameraPos = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1500 Quaternion cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1503 std::ostringstream oss;
1504 oss << cameraPos << "\n";
1505 oss << cameraOrient << "\n";
1506 tet_printf("%s\n", oss.str().c_str());
1509 offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1510 offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1512 // Now, upside : -Z, leftside : -X, foward : +Y
1514 cameraPos = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1515 cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1517 std::ostringstream oss;
1518 oss << cameraPos << "\n";
1519 oss << cameraOrient << "\n";
1520 tet_printf("%s\n", oss.str().c_str());
1523 Vector3 sourcePosition{2.0f, 0.0f, 16.0f};
1524 Vector3 sourceSize{1.0f, 0.0f, 3.0f};
1526 Actor sourceActor = Actor::New();
1527 sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1528 sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1529 sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition);
1530 sourceActor.SetProperty(Actor::Property::SIZE, sourceSize);
1532 layer.Add(sourceActor);
1534 // Create framebuffer
1535 unsigned int width(64);
1536 unsigned int height(64);
1537 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1538 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
1539 frameBuffer.AttachColorTexture(texture);
1541 Actor rootActor = Actor::New();
1542 rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1543 rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1544 rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1545 rootActor.SetProperty(Actor::Property::SIZE, sceneSize);
1546 scene.Add(rootActor);
1548 RenderTaskList taskList = scene.GetRenderTaskList();
1549 RenderTask newTask = taskList.CreateTask();
1550 newTask.SetCameraActor(offscreenCameraActor);
1551 newTask.SetSourceActor(layer);
1552 newTask.SetInputEnabled(false);
1553 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1554 newTask.SetClearEnabled(true);
1555 newTask.SetExclusive(true);
1556 newTask.SetFrameBuffer(frameBuffer);
1557 newTask.SetScreenToFrameBufferMappingActor(rootActor);
1559 application.SendNotification();
1560 application.Render(16u);
1562 auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f,
1563 sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f,
1566 auto actualExtent = DevelActor::CalculateScreenExtents(sourceActor);
1568 std::ostringstream oss;
1569 oss << expectedExtent << "\n";
1570 oss << actualExtent << "\n";
1571 tet_printf("%s\n", oss.str().c_str());
1574 auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z};
1575 auto actualScreen = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1577 std::ostringstream oss;
1578 oss << expectedScreen << "\n";
1579 oss << actualScreen << "\n";
1580 tet_printf("%s\n", oss.str().c_str());
1583 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1584 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1585 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1586 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1588 DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1589 DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1591 // Change rootActor's size and position
1593 Vector3 rootPosition{100.0f, 200.0f, 0.0f};
1594 Vector3 rootSize{200.0f, 100.0f, 0.0f};
1596 rootActor.SetProperty(Actor::Property::POSITION, rootPosition);
1597 rootActor.SetProperty(Actor::Property::SIZE, rootSize);
1599 application.SendNotification();
1600 application.Render(16u);
1602 expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x,
1603 sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y,
1604 sourceSize.x * rootSize.x / sceneSize.x,
1605 sourceSize.z * rootSize.y / sceneSize.y};
1606 actualExtent = DevelActor::CalculateScreenExtents(sourceActor);
1608 std::ostringstream oss;
1609 oss << expectedExtent << "\n";
1610 oss << actualExtent << "\n";
1611 tet_printf("%s\n", oss.str().c_str());
1614 expectedScreen = Vector2{sceneSize.x * 0.5f + rootPosition.x + sourcePosition.x * rootSize.x / sceneSize.x, sceneSize.y * 0.5f + rootPosition.y + sourcePosition.z * rootSize.y / sceneSize.y};
1615 actualScreen = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1617 std::ostringstream oss;
1618 oss << expectedScreen << "\n";
1619 oss << actualScreen << "\n";
1620 tet_printf("%s\n", oss.str().c_str());
1623 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1624 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1625 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1626 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1628 DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1629 DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1634 // SetPosition(float x, float y)
1635 int UtcDaliActorSetPosition01(void)
1637 TestApplication application;
1639 Actor actor = Actor::New();
1641 // Set to random to start off with
1642 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1644 Vector3 vector(100.0f, 100.0f, 0.0f);
1646 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1648 actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1649 // flush the queue and render once
1650 application.SendNotification();
1651 application.Render();
1652 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1654 application.GetScene().Add(actor);
1655 actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1656 // flush the queue and render once
1657 application.SendNotification();
1658 application.Render();
1659 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1661 actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1662 actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1663 actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1664 // flush the queue and render once
1665 application.SendNotification();
1666 application.Render();
1667 DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1669 actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1670 // flush the queue and render once
1671 application.SendNotification();
1672 application.Render();
1673 DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1675 application.GetScene().Remove(actor);
1679 // SetPosition(float x, float y, float z)
1680 int UtcDaliActorSetPosition02(void)
1682 TestApplication application;
1684 Actor actor = Actor::New();
1686 // Set to random to start off with
1687 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1689 Vector3 vector(100.0f, 100.0f, 100.0f);
1691 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1693 actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1695 // flush the queue and render once
1696 application.SendNotification();
1697 application.Render();
1699 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1703 // SetPosition(Vector3 position)
1704 int UtcDaliActorSetPosition03(void)
1706 TestApplication application;
1708 Actor actor = Actor::New();
1710 // Set to random to start off with
1711 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1713 Vector3 vector(100.0f, 100.0f, 100.0f);
1715 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1717 actor.SetProperty(Actor::Property::POSITION, vector);
1719 // flush the queue and render once
1720 application.SendNotification();
1721 application.Render();
1723 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1727 int UtcDaliActorSetX(void)
1729 TestApplication application;
1731 Actor actor = Actor::New();
1733 Vector3 vector(100.0f, 0.0f, 0.0f);
1735 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1737 actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1739 // flush the queue and render once
1740 application.SendNotification();
1741 application.Render();
1743 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1747 int UtcDaliActorSetY(void)
1749 TestApplication application;
1751 Actor actor = Actor::New();
1753 Vector3 vector(0.0f, 100.0f, 0.0f);
1755 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1757 actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1759 // flush the queue and render once
1760 application.SendNotification();
1761 application.Render();
1763 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1767 int UtcDaliActorSetZ(void)
1769 TestApplication application;
1771 Actor actor = Actor::New();
1773 Vector3 vector(0.0f, 0.0f, 100.0f);
1775 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1777 actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1779 // flush the queue and render once
1780 application.SendNotification();
1781 application.Render();
1783 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1787 int UtcDaliActorSetPositionProperties(void)
1789 TestApplication application;
1791 Actor actor = Actor::New();
1793 Vector3 vector(0.7f, 0.8f, 0.9f);
1794 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1796 actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1797 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1798 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1800 // flush the queue and render once
1801 application.SendNotification();
1802 application.Render();
1804 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1805 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1806 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1807 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1808 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1810 actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1811 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1812 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1814 // flush the queue and render once
1815 application.SendNotification();
1816 application.Render();
1818 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1819 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1820 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1821 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1822 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1824 actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1825 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1826 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1828 // flush the queue and render once
1829 application.SendNotification();
1830 application.Render();
1832 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1833 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1834 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1835 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1836 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1841 int UtcDaliActorTranslateBy(void)
1843 TestApplication application;
1845 Actor actor = Actor::New();
1846 Vector3 vector(100.0f, 100.0f, 100.0f);
1848 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1850 actor.SetProperty(Actor::Property::POSITION, vector);
1852 // flush the queue and render once
1853 application.SendNotification();
1854 application.Render();
1856 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1858 actor.TranslateBy(vector);
1860 // flush the queue and render once
1861 application.SendNotification();
1862 application.Render();
1864 DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1868 int UtcDaliActorGetCurrentPosition(void)
1870 TestApplication application;
1872 Actor actor = Actor::New();
1873 Vector3 setVector(100.0f, 100.0f, 0.0f);
1874 actor.SetProperty(Actor::Property::POSITION, setVector);
1876 // flush the queue and render once
1877 application.SendNotification();
1878 application.Render();
1880 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1884 int UtcDaliActorGetCurrentWorldPosition(void)
1886 TestApplication application;
1888 Actor parent = Actor::New();
1889 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1890 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1891 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1892 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1893 application.GetScene().Add(parent);
1895 Actor child = Actor::New();
1896 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1897 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1898 Vector3 childPosition(6.0f, 6.0f, 6.0f);
1899 child.SetProperty(Actor::Property::POSITION, childPosition);
1902 // The actors should not have a world position yet
1903 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1904 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1906 application.SendNotification();
1907 application.Render(0);
1909 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1910 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1912 // The actors should have a world position now
1913 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1914 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1918 int UtcDaliActorSetInheritPosition(void)
1920 tet_infoline("Testing Actor::SetInheritPosition");
1921 TestApplication application;
1923 Actor parent = Actor::New();
1924 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1925 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1926 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1927 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1928 application.GetScene().Add(parent);
1930 Actor child = Actor::New();
1931 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1932 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1933 Vector3 childPosition(10.0f, 11.0f, 12.0f);
1934 child.SetProperty(Actor::Property::POSITION, childPosition);
1937 // The actors should not have a world position yet
1938 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1939 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1941 // first test default, which is to inherit position
1942 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1943 application.SendNotification();
1944 application.Render(0); // should only really call Update as Render is not required to update scene
1945 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1946 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1947 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1948 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1950 //Change child position
1951 Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1952 child.SetProperty(Actor::Property::POSITION, childOffset);
1954 // Use local position as world postion
1955 child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1956 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1957 application.SendNotification();
1958 application.Render(0); // should only really call Update as Render is not required to update scene
1959 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1960 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1961 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1962 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1964 //Change back to inherit position from parent
1965 child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1966 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1967 application.SendNotification();
1968 application.Render(0); // should only really call Update as Render is not required to update scene
1969 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1970 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1971 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1972 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1976 int UtcDaliActorInheritOpacity(void)
1978 tet_infoline("Testing Actor::Inherit Opacity");
1979 TestApplication application;
1981 Actor parent = Actor::New();
1982 Actor child = Actor::New();
1984 application.GetScene().Add(parent);
1986 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1987 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1989 // flush the queue and render once
1990 application.SendNotification();
1991 application.Render();
1993 parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1995 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1996 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1998 application.SendNotification();
1999 application.Render();
2001 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2002 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
2003 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2004 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2005 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
2006 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
2011 // SetOrientation(float angleRadians, Vector3 axis)
2012 int UtcDaliActorSetOrientation01(void)
2014 TestApplication application;
2016 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2017 Actor actor = Actor::New();
2019 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2021 // flush the queue and render once
2022 application.SendNotification();
2023 application.Render();
2025 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2029 int UtcDaliActorSetOrientation02(void)
2031 TestApplication application;
2033 Actor actor = Actor::New();
2035 Radian angle(0.785f);
2036 Vector3 axis(1.0f, 1.0f, 0.0f);
2038 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2039 Quaternion rotation(angle, axis);
2040 // flush the queue and render once
2041 application.SendNotification();
2042 application.Render();
2043 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2045 application.GetScene().Add(actor);
2046 actor.RotateBy(Degree(360), axis);
2047 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2049 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
2050 Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
2051 // flush the queue and render once
2052 application.SendNotification();
2053 application.Render();
2054 DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2056 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2057 // flush the queue and render once
2058 application.SendNotification();
2059 application.Render();
2060 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2062 application.GetScene().Remove(actor);
2066 // SetOrientation(float angleRadians, Vector3 axis)
2067 int UtcDaliActorSetOrientationProperty(void)
2069 TestApplication application;
2071 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2072 Actor actor = Actor::New();
2074 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2075 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2077 // flush the queue and render once
2078 application.SendNotification();
2079 application.Render();
2081 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2082 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2083 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2087 // RotateBy(float angleRadians, Vector3 axis)
2088 int UtcDaliActorRotateBy01(void)
2090 TestApplication application;
2092 Actor actor = Actor::New();
2094 Radian angle(M_PI * 0.25f);
2095 actor.RotateBy((angle), Vector3::ZAXIS);
2096 // flush the queue and render once
2097 application.SendNotification();
2098 application.Render();
2099 DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2101 application.GetScene().Add(actor);
2103 actor.RotateBy(angle, Vector3::ZAXIS);
2104 // flush the queue and render once
2105 application.SendNotification();
2106 application.Render();
2107 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2109 application.GetScene().Remove(actor);
2113 // RotateBy(Quaternion relativeRotation)
2114 int UtcDaliActorRotateBy02(void)
2116 TestApplication application;
2118 Actor actor = Actor::New();
2120 Radian angle(M_PI * 0.25f);
2121 Quaternion rotation(angle, Vector3::ZAXIS);
2122 actor.RotateBy(rotation);
2123 // flush the queue and render once
2124 application.SendNotification();
2125 application.Render();
2126 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2128 actor.RotateBy(rotation);
2129 // flush the queue and render once
2130 application.SendNotification();
2131 application.Render();
2132 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2136 int UtcDaliActorGetCurrentOrientation(void)
2138 TestApplication application;
2139 Actor actor = Actor::New();
2141 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2142 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2143 // flush the queue and render once
2144 application.SendNotification();
2145 application.Render();
2146 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2150 int UtcDaliActorGetCurrentWorldOrientation(void)
2152 tet_infoline("Testing Actor::GetCurrentWorldRotation");
2153 TestApplication application;
2155 Actor parent = Actor::New();
2156 Radian rotationAngle(Degree(90.0f));
2157 Quaternion rotation(rotationAngle, Vector3::YAXIS);
2158 parent.SetProperty(Actor::Property::ORIENTATION, rotation);
2159 application.GetScene().Add(parent);
2161 Actor child = Actor::New();
2162 child.SetProperty(Actor::Property::ORIENTATION, rotation);
2165 // The actors should not have a world rotation yet
2166 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2167 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2169 application.SendNotification();
2170 application.Render(0);
2172 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2173 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2175 // The actors should have a world rotation now
2176 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2177 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
2179 // turn off child rotation inheritance
2180 child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
2181 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
2182 application.SendNotification();
2183 application.Render(0);
2185 // The actors should have a world rotation now
2186 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2187 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
2191 // SetScale(float scale)
2192 int UtcDaliActorSetScale01(void)
2194 TestApplication application;
2196 Actor actor = Actor::New();
2198 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2199 actor.SetProperty(Actor::Property::SCALE, 0.25f);
2201 Vector3 scale(10.0f, 10.0f, 10.0f);
2202 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2204 actor.SetProperty(Actor::Property::SCALE, scale.x);
2206 // flush the queue and render once
2207 application.SendNotification();
2208 application.Render();
2210 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2214 // SetScale(float scaleX, float scaleY, float scaleZ)
2215 int UtcDaliActorSetScale02(void)
2217 TestApplication application;
2218 Vector3 scale(10.0f, 10.0f, 10.0f);
2220 Actor actor = Actor::New();
2222 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2223 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2225 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2227 actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
2228 // flush the queue and render once
2229 application.SendNotification();
2230 application.Render();
2231 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2233 // add to stage and test
2234 application.GetScene().Add(actor);
2235 actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
2236 // flush the queue and render once
2237 application.SendNotification();
2238 application.Render();
2239 DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
2241 application.GetScene().Remove(actor);
2246 // SetScale(Vector3 scale)
2247 int UtcDaliActorSetScale03(void)
2249 TestApplication application;
2250 Vector3 scale(10.0f, 10.0f, 10.0f);
2252 Actor actor = Actor::New();
2254 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2255 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2257 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2259 actor.SetProperty(Actor::Property::SCALE, scale);
2261 // flush the queue and render once
2262 application.SendNotification();
2263 application.Render();
2265 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2269 int UtcDaliActorSetScaleIndividual(void)
2271 TestApplication application;
2273 Actor actor = Actor::New();
2275 Vector3 vector(0.7f, 0.8f, 0.9f);
2276 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2278 actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2279 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2281 // flush the queue and render once
2282 application.SendNotification();
2283 application.Render();
2285 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2286 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2287 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2289 actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2290 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2292 // flush the queue and render once
2293 application.SendNotification();
2294 application.Render();
2296 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2297 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2298 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2300 actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2301 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2303 // flush the queue and render once
2304 application.SendNotification();
2305 application.Render();
2307 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2308 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2309 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2311 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2312 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2317 int UtcDaliActorScaleBy(void)
2319 TestApplication application;
2320 Actor actor = Actor::New();
2321 Vector3 vector(100.0f, 100.0f, 100.0f);
2323 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2325 actor.SetProperty(Actor::Property::SCALE, vector);
2327 // flush the queue and render once
2328 application.SendNotification();
2329 application.Render();
2331 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2333 actor.ScaleBy(vector);
2335 // flush the queue and render once
2336 application.SendNotification();
2337 application.Render();
2339 DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2343 int UtcDaliActorGetCurrentScale(void)
2345 TestApplication application;
2346 Vector3 scale(12.0f, 1.0f, 2.0f);
2348 Actor actor = Actor::New();
2350 actor.SetProperty(Actor::Property::SCALE, scale);
2352 // flush the queue and render once
2353 application.SendNotification();
2354 application.Render();
2356 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2360 int UtcDaliActorGetCurrentWorldScale(void)
2362 TestApplication application;
2364 Actor parent = Actor::New();
2365 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2366 parent.SetProperty(Actor::Property::SCALE, parentScale);
2367 application.GetScene().Add(parent);
2369 Actor child = Actor::New();
2370 Vector3 childScale(2.0f, 2.0f, 2.0f);
2371 child.SetProperty(Actor::Property::SCALE, childScale);
2374 // The actors should not have a scale yet
2375 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2376 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2378 // The actors should not have a world scale yet
2379 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2380 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2382 application.SendNotification();
2383 application.Render(0);
2385 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2386 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2388 // The actors should have a world scale now
2389 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2390 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2394 int UtcDaliActorInheritScale(void)
2396 tet_infoline("Testing Actor::SetInheritScale");
2397 TestApplication application;
2399 Actor parent = Actor::New();
2400 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2401 parent.SetProperty(Actor::Property::SCALE, parentScale);
2402 application.GetScene().Add(parent);
2404 Actor child = Actor::New();
2405 Vector3 childScale(2.0f, 2.0f, 2.0f);
2406 child.SetProperty(Actor::Property::SCALE, childScale);
2409 application.SendNotification();
2410 application.Render(0);
2412 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2413 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2415 child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2416 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2418 application.SendNotification();
2419 application.Render(0);
2421 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2425 int UtcDaliActorSetVisible(void)
2427 TestApplication application;
2429 Actor actor = Actor::New();
2430 actor.SetProperty(Actor::Property::VISIBLE, false);
2431 // flush the queue and render once
2432 application.SendNotification();
2433 application.Render();
2434 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2436 actor.SetProperty(Actor::Property::VISIBLE, true);
2437 // flush the queue and render once
2438 application.SendNotification();
2439 application.Render();
2440 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2442 // put actor on stage
2443 application.GetScene().Add(actor);
2444 actor.SetProperty(Actor::Property::VISIBLE, false);
2445 // flush the queue and render once
2446 application.SendNotification();
2447 application.Render();
2448 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2452 int UtcDaliActorIsVisible(void)
2454 TestApplication application;
2456 Actor actor = Actor::New();
2458 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2462 int UtcDaliActorSetOpacity(void)
2464 TestApplication application;
2466 Actor actor = Actor::New();
2467 // initial opacity is 1
2468 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2470 actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2471 // flush the queue and render once
2472 application.SendNotification();
2473 application.Render();
2474 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2476 // change opacity, actor is on stage to change is not immediate
2477 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2478 // flush the queue and render once
2479 application.SendNotification();
2480 application.Render();
2481 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2483 // put actor on stage
2484 application.GetScene().Add(actor);
2486 // change opacity, actor is on stage to change is not immediate
2487 actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2488 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2489 // flush the queue and render once
2490 application.SendNotification();
2491 application.Render();
2492 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2494 // change opacity, actor is on stage to change is not immediate
2495 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2496 // flush the queue and render once
2497 application.SendNotification();
2498 application.Render();
2499 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2503 int UtcDaliActorGetCurrentOpacity(void)
2505 TestApplication application;
2507 Actor actor = Actor::New();
2508 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2510 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2511 // flush the queue and render once
2512 application.SendNotification();
2513 application.Render();
2514 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2518 int UtcDaliActorSetSensitive(void)
2520 TestApplication application;
2521 Actor actor = Actor::New();
2523 bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2525 actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2527 DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2531 int UtcDaliActorIsSensitive(void)
2533 TestApplication application;
2534 Actor actor = Actor::New();
2535 actor.SetProperty(Actor::Property::SENSITIVE, false);
2537 DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2541 int UtcDaliActorSetColor(void)
2543 TestApplication application;
2544 Actor actor = Actor::New();
2545 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2547 DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2549 actor.SetProperty(Actor::Property::COLOR, color);
2550 // flush the queue and render once
2551 application.SendNotification();
2552 application.Render();
2553 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2555 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2556 // flush the queue and render once
2557 application.SendNotification();
2558 application.Render();
2559 DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2561 application.GetScene().Add(actor);
2562 actor.SetProperty(Actor::Property::COLOR, color);
2563 // flush the queue and render once
2564 application.SendNotification();
2565 application.Render();
2566 DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2568 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2569 // flush the queue and render once
2570 application.SendNotification();
2571 application.Render();
2572 // Actor color is not clamped
2573 DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2574 // world color is clamped
2575 DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2577 actor.SetProperty(Actor::Property::COLOR, color);
2578 DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2580 Vector3 newColor(1.0f, 0.0f, 0.0f);
2581 actor.SetProperty(Actor::Property::COLOR, newColor);
2582 DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2584 application.GetScene().Remove(actor);
2588 int UtcDaliActorSetColorIndividual(void)
2590 TestApplication application;
2592 Actor actor = Actor::New();
2594 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2595 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2597 actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2598 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2600 // flush the queue and render once
2601 application.SendNotification();
2602 application.Render();
2604 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2605 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2606 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2608 actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2609 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2611 // flush the queue and render once
2612 application.SendNotification();
2613 application.Render();
2615 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2616 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2617 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2619 actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2620 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2622 // flush the queue and render once
2623 application.SendNotification();
2624 application.Render();
2626 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2627 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2628 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2630 actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2631 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2633 // flush the queue and render once
2634 application.SendNotification();
2635 application.Render();
2637 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2638 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2639 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2641 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2642 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2644 actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2646 // flush the queue and render once
2647 application.SendNotification();
2648 application.Render();
2650 DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2655 int UtcDaliActorGetCurrentColor(void)
2657 TestApplication application;
2658 Actor actor = Actor::New();
2659 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2661 actor.SetProperty(Actor::Property::COLOR, color);
2662 // flush the queue and render once
2663 application.SendNotification();
2664 application.Render();
2665 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2669 int UtcDaliActorGetCurrentWorldColor(void)
2671 tet_infoline("Actor::GetCurrentWorldColor");
2672 TestApplication application;
2674 Actor parent = Actor::New();
2675 Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2676 parent.SetProperty(Actor::Property::COLOR, parentColor);
2677 application.GetScene().Add(parent);
2679 Actor child = Actor::New();
2680 Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2681 child.SetProperty(Actor::Property::COLOR, childColor);
2684 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2685 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2687 // verify the default color mode
2688 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2690 // The actors should not have a world color yet
2691 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2692 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2694 application.SendNotification();
2695 application.Render(0);
2697 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2698 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2700 // The actors should have a world color now
2701 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2702 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2705 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2706 application.SendNotification();
2707 application.Render(0);
2708 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2711 child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2712 application.SendNotification();
2713 application.Render(0);
2714 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2715 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2718 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2719 application.SendNotification();
2720 application.Render(0);
2721 Vector4 expectedColor(childColor);
2722 expectedColor.a *= parentColor.a;
2723 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2724 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2728 int UtcDaliActorSetColorMode(void)
2730 tet_infoline("Actor::SetColorMode");
2731 TestApplication application;
2732 Actor actor = Actor::New();
2733 Actor child = Actor::New();
2736 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2737 DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2739 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2740 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2742 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2743 DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2745 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2746 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2750 int UtcDaliActorScreenToLocal(void)
2752 TestApplication application;
2753 Actor actor = Actor::New();
2754 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2755 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2756 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2757 application.GetScene().Add(actor);
2759 // flush the queue and render once
2760 application.SendNotification();
2761 application.Render();
2766 application.SendNotification();
2767 application.Render();
2769 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2771 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2772 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2776 int UtcDaliActorSetLeaveRequired(void)
2778 TestApplication application;
2780 Actor actor = Actor::New();
2782 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2783 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2785 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2786 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2790 int UtcDaliActorGetLeaveRequired(void)
2792 TestApplication application;
2794 Actor actor = Actor::New();
2796 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2800 int UtcDaliActorSetKeyboardFocusable(void)
2802 TestApplication application;
2804 Actor actor = Actor::New();
2806 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2807 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2809 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2810 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2814 int UtcDaliActorIsKeyboardFocusable(void)
2816 TestApplication application;
2818 Actor actor = Actor::New();
2820 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2824 int UtcDaliActorSetKeyboardFocusableChildren(void)
2826 TestApplication application;
2828 Actor actor = Actor::New();
2830 actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2831 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2833 actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2834 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
2838 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
2840 TestApplication application;
2842 Actor actor = Actor::New();
2844 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2848 int UtcDaliActorSetTouchFocusable(void)
2850 TestApplication application;
2852 Actor actor = Actor::New();
2854 actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2855 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2857 actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2858 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2862 int UtcDaliActorIsTouchFocusable(void)
2864 TestApplication application;
2866 Actor actor = Actor::New();
2868 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2872 int UtcDaliActorSetUserInteractionEnabled(void)
2874 TestApplication application;
2875 Actor actor = Actor::New();
2877 bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
2879 actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
2881 DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2885 int UtcDaliActorIsUserInteractionEnabled(void)
2887 TestApplication application;
2888 Actor actor = Actor::New();
2889 actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
2891 DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2895 int UtcDaliActorRemoveConstraints(void)
2897 tet_infoline(" UtcDaliActorRemoveConstraints");
2898 TestApplication application;
2900 gTestConstraintCalled = false;
2902 Actor actor = Actor::New();
2904 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2906 actor.RemoveConstraints();
2908 DALI_TEST_CHECK(gTestConstraintCalled == false);
2910 application.GetScene().Add(actor);
2913 // flush the queue and render once
2914 application.SendNotification();
2915 application.Render();
2917 actor.RemoveConstraints();
2919 DALI_TEST_CHECK(gTestConstraintCalled == true);
2923 int UtcDaliActorRemoveConstraintTag(void)
2925 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2926 TestApplication application;
2928 Actor actor = Actor::New();
2930 // 1. Apply Constraint1 and Constraint2, and test...
2931 unsigned int result1 = 0u;
2932 unsigned int result2 = 0u;
2934 unsigned constraint1Tag = 1u;
2935 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2936 constraint1.SetTag(constraint1Tag);
2937 constraint1.Apply();
2939 unsigned constraint2Tag = 2u;
2940 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2941 constraint2.SetTag(constraint2Tag);
2942 constraint2.Apply();
2944 application.GetScene().Add(actor);
2945 // flush the queue and render once
2946 application.SendNotification();
2947 application.Render();
2949 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2950 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2952 // 2. Remove Constraint1 and test...
2955 actor.RemoveConstraints(constraint1Tag);
2956 // make color property dirty, which will trigger constraints to be reapplied.
2957 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2958 // flush the queue and render once
2959 application.SendNotification();
2960 application.Render();
2962 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2963 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2965 // 3. Re-Apply Constraint1 and test...
2968 constraint1.Apply();
2969 // make color property dirty, which will trigger constraints to be reapplied.
2970 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2971 // flush the queue and render once
2972 application.SendNotification();
2973 application.Render();
2975 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2976 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2978 // 2. Remove Constraint2 and test...
2981 actor.RemoveConstraints(constraint2Tag);
2982 // make color property dirty, which will trigger constraints to be reapplied.
2983 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2984 // flush the queue and render once
2985 application.SendNotification();
2986 application.Render();
2988 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2989 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2991 // 2. Remove Constraint1 as well and test...
2994 actor.RemoveConstraints(constraint1Tag);
2995 // make color property dirty, which will trigger constraints to be reapplied.
2996 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2997 // flush the queue and render once
2998 application.SendNotification();
2999 application.Render();
3001 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
3002 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
3006 int UtcDaliActorTouchedSignal(void)
3008 TestApplication application;
3010 ResetTouchCallbacks();
3012 // get the root layer
3013 Actor actor = application.GetScene().GetRootLayer();
3014 DALI_TEST_CHECK(gTouchCallBackCalled == false);
3016 application.SendNotification();
3017 application.Render();
3019 // connect to its touch signal
3020 actor.TouchedSignal().Connect(TestTouchCallback);
3022 // simulate a touch event in the middle of the screen
3023 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
3024 Dali::Integration::Point point;
3025 point.SetDeviceId(1);
3026 point.SetState(PointState::DOWN);
3027 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3028 Dali::Integration::TouchEvent touchEvent;
3029 touchEvent.AddPoint(point);
3030 application.ProcessEvent(touchEvent);
3032 DALI_TEST_CHECK(gTouchCallBackCalled == true);
3036 int UtcDaliActorHoveredSignal(void)
3038 TestApplication application;
3040 gHoverCallBackCalled = false;
3042 // get the root layer
3043 Actor actor = application.GetScene().GetRootLayer();
3044 DALI_TEST_CHECK(gHoverCallBackCalled == false);
3046 application.SendNotification();
3047 application.Render();
3049 // connect to its hover signal
3050 actor.HoveredSignal().Connect(TestCallback3);
3052 // simulate a hover event in the middle of the screen
3053 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
3054 Dali::Integration::Point point;
3055 point.SetDeviceId(1);
3056 point.SetState(PointState::MOTION);
3057 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3058 Dali::Integration::HoverEvent hoverEvent;
3059 hoverEvent.AddPoint(point);
3060 application.ProcessEvent(hoverEvent);
3062 DALI_TEST_CHECK(gHoverCallBackCalled == true);
3066 int UtcDaliActorOnOffSceneSignal(void)
3068 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
3070 TestApplication application;
3073 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3074 gActorNamesOnOffScene.clear();
3076 Actor parent = Actor::New();
3077 parent.SetProperty(Actor::Property::NAME, "parent");
3078 parent.OnSceneSignal().Connect(OnSceneCallback);
3079 parent.OffSceneSignal().Connect(OffSceneCallback);
3081 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
3082 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
3084 // add parent to the scene
3085 application.GetScene().Add(parent);
3086 // onstage emitted, offstage not
3087 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3088 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3089 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3091 // test adding a child, should get onstage emitted
3093 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3094 gActorNamesOnOffScene.clear();
3096 Actor child = Actor::New();
3097 child.SetProperty(Actor::Property::NAME, "child");
3098 child.OnSceneSignal().Connect(OnSceneCallback);
3099 child.OffSceneSignal().Connect(OffSceneCallback);
3100 parent.Add(child); // add child
3101 // onscene emitted, offscene not
3102 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3103 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3104 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3106 // test removing parent from the scene
3108 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3109 gActorNamesOnOffScene.clear();
3111 application.GetScene().Remove(parent);
3112 // onscene not emitted, offscene is
3113 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3114 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
3115 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3116 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
3118 // test adding parent back to the scene
3120 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3121 gActorNamesOnOffScene.clear();
3123 application.GetScene().Add(parent);
3124 // onscene emitted, offscene not
3125 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
3126 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3127 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3128 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
3130 // test removing child
3132 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3133 gActorNamesOnOffScene.clear();
3135 parent.Remove(child);
3136 // onscene not emitted, offscene is
3137 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3138 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3139 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3141 // test removing parent
3143 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3144 gActorNamesOnOffScene.clear();
3146 application.GetScene().Remove(parent);
3147 // onscene not emitted, offscene is
3148 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3149 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3150 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3154 int UtcDaliActorFindChildByName(void)
3156 tet_infoline("Testing Dali::Actor::FindChildByName()");
3157 TestApplication application;
3159 Actor parent = Actor::New();
3160 parent.SetProperty(Actor::Property::NAME, "parent");
3161 Actor first = Actor::New();
3162 first.SetProperty(Actor::Property::NAME, "first");
3163 Actor second = Actor::New();
3164 second.SetProperty(Actor::Property::NAME, "second");
3169 Actor found = parent.FindChildByName("foo");
3170 DALI_TEST_CHECK(!found);
3172 found = parent.FindChildByName("parent");
3173 DALI_TEST_CHECK(found == parent);
3175 found = parent.FindChildByName("first");
3176 DALI_TEST_CHECK(found == first);
3178 found = parent.FindChildByName("second");
3179 DALI_TEST_CHECK(found == second);
3183 int UtcDaliActorFindChildById(void)
3185 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
3186 TestApplication application;
3188 Actor parent = Actor::New();
3189 Actor first = Actor::New();
3190 Actor second = Actor::New();
3195 Actor found = parent.FindChildById(100000);
3196 DALI_TEST_CHECK(!found);
3198 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
3199 DALI_TEST_CHECK(found == parent);
3201 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
3202 DALI_TEST_CHECK(found == first);
3204 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
3205 DALI_TEST_CHECK(found == second);
3209 int UtcDaliActorHitTest(void)
3214 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3216 mTouchPoint(touchPoint),
3222 Vector2 mTouchPoint;
3226 TestApplication application;
3227 tet_infoline(" UtcDaliActorHitTest");
3229 // Fill a vector with different hit tests.
3230 struct HitTestData* hitTestData[] = {
3231 // scale touch point result
3232 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
3233 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3234 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.
3235 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3236 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.
3240 // get the root layer
3241 Actor actor = Actor::New();
3242 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3243 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3245 application.GetScene().Add(actor);
3247 ResetTouchCallbacks();
3249 unsigned int index = 0;
3250 while(NULL != hitTestData[index])
3252 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3253 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3255 // flush the queue and render once
3256 application.SendNotification();
3257 application.Render();
3259 DALI_TEST_CHECK(!gTouchCallBackCalled);
3261 // connect to its touch signal
3262 actor.TouchedSignal().Connect(TestTouchCallback);
3264 Dali::Integration::Point point;
3265 point.SetState(PointState::DOWN);
3266 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3267 Dali::Integration::TouchEvent event;
3268 event.AddPoint(point);
3270 // flush the queue and render once
3271 application.SendNotification();
3272 application.Render();
3273 application.ProcessEvent(event);
3275 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3277 if(gTouchCallBackCalled != hitTestData[index]->mResult)
3278 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3279 hitTestData[index]->mScale.x,
3280 hitTestData[index]->mScale.y,
3281 hitTestData[index]->mScale.z,
3282 hitTestData[index]->mTouchPoint.x,
3283 hitTestData[index]->mTouchPoint.y,
3284 hitTestData[index]->mResult);
3286 ResetTouchCallbacks();
3292 int UtcDaliActorSetDrawMode(void)
3294 TestApplication application;
3295 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3297 Actor a = Actor::New();
3299 application.GetScene().Add(a);
3300 application.SendNotification();
3301 application.Render(0);
3302 application.SendNotification();
3303 application.Render(1);
3305 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3307 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3308 application.SendNotification();
3309 application.Render(1);
3311 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3313 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3314 application.SendNotification();
3315 application.Render(1);
3317 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3321 int UtcDaliActorSetDrawModeOverlayRender(void)
3323 TestApplication application;
3324 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3326 application.SendNotification();
3327 application.Render(1);
3329 std::vector<GLuint> ids;
3330 ids.push_back(8); // first rendered actor
3331 ids.push_back(9); // second rendered actor
3332 ids.push_back(10); // third rendered actor
3333 application.GetGlAbstraction().SetNextTextureIds(ids);
3335 Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3336 Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3337 Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3338 Actor a = CreateRenderableActor(imageA);
3339 Actor b = CreateRenderableActor(imageB);
3340 Actor c = CreateRenderableActor(imageC);
3342 application.SendNotification();
3343 application.Render(1);
3345 //Textures are bound when first created. Clear bound textures vector
3346 application.GetGlAbstraction().ClearBoundTextures();
3348 // Render a,b,c as regular non-overlays. so order will be:
3352 application.GetScene().Add(a);
3353 application.GetScene().Add(b);
3354 application.GetScene().Add(c);
3356 application.SendNotification();
3357 application.Render(1);
3359 // Should be 3 textures changes.
3360 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3361 typedef std::vector<GLuint>::size_type TextureSize;
3362 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3363 if(boundTextures.size() == 3)
3365 DALI_TEST_CHECK(boundTextures[0] == 8u);
3366 DALI_TEST_CHECK(boundTextures[1] == 9u);
3367 DALI_TEST_CHECK(boundTextures[2] == 10u);
3370 // Now texture ids have been set, we can monitor their render order.
3371 // render a as an overlay (last), so order will be:
3375 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3376 application.GetGlAbstraction().ClearBoundTextures();
3378 application.SendNotification();
3379 application.Render(1);
3381 // Should be 3 texture changes.
3382 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3383 if(boundTextures.size() == 3)
3385 DALI_TEST_CHECK(boundTextures[0] == 9u);
3386 DALI_TEST_CHECK(boundTextures[1] == 10u);
3387 DALI_TEST_CHECK(boundTextures[2] == 8u);
3392 int UtcDaliActorGetCurrentWorldMatrix(void)
3394 TestApplication application;
3395 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3397 Actor parent = Actor::New();
3398 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3399 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3400 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3401 Radian rotationAngle(Degree(85.0f));
3402 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3403 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3404 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3405 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3406 parent.SetProperty(Actor::Property::SCALE, parentScale);
3407 application.GetScene().Add(parent);
3409 Actor child = Actor::New();
3410 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3411 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3412 Radian childRotationAngle(Degree(23.0f));
3413 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3414 Vector3 childScale(2.0f, 2.0f, 2.0f);
3415 child.SetProperty(Actor::Property::POSITION, childPosition);
3416 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3417 child.SetProperty(Actor::Property::SCALE, childScale);
3420 application.SendNotification();
3421 application.Render(0);
3422 application.Render();
3423 application.SendNotification();
3425 Matrix parentMatrix(false);
3426 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3428 Matrix childMatrix(false);
3429 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3431 //Child matrix should be the composition of child and parent
3432 Matrix childWorldMatrix(false);
3433 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3435 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3436 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3440 int UtcDaliActorConstrainedToWorldMatrix(void)
3442 TestApplication application;
3443 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3445 Actor parent = Actor::New();
3446 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3447 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3448 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3449 Radian rotationAngle(Degree(85.0f));
3450 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3451 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3452 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3453 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3454 parent.SetProperty(Actor::Property::SCALE, parentScale);
3455 application.GetScene().Add(parent);
3457 Actor child = Actor::New();
3458 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3459 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3460 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3461 posConstraint.Apply();
3463 application.GetScene().Add(child);
3465 application.SendNotification();
3466 application.Render(0);
3467 application.Render();
3468 application.SendNotification();
3470 Matrix parentMatrix(false);
3471 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3473 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3474 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3478 int UtcDaliActorConstrainedToOrientation(void)
3480 TestApplication application;
3481 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3483 Actor parent = Actor::New();
3484 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3485 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3486 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3487 Radian rotationAngle(Degree(85.0f));
3488 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3489 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3490 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3491 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3492 parent.SetProperty(Actor::Property::SCALE, parentScale);
3493 application.GetScene().Add(parent);
3495 Actor child = Actor::New();
3496 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3497 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3498 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3499 posConstraint.Apply();
3501 application.GetScene().Add(child);
3503 application.SendNotification();
3504 application.Render(0);
3505 application.Render();
3506 application.SendNotification();
3508 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3512 int UtcDaliActorConstrainedToOpacity(void)
3514 TestApplication application;
3515 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3517 Actor parent = Actor::New();
3518 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3519 application.GetScene().Add(parent);
3521 Actor child = Actor::New();
3522 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3523 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3524 opacityConstraint.Apply();
3526 application.GetScene().Add(child);
3528 application.SendNotification();
3529 application.Render(0);
3530 application.Render();
3531 application.SendNotification();
3533 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3535 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3537 application.SendNotification();
3538 application.Render(0);
3539 application.Render();
3540 application.SendNotification();
3542 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3547 int UtcDaliActorUnparent(void)
3549 TestApplication application;
3550 tet_infoline(" UtcDaliActorUnparent");
3552 Actor parent = Actor::New();
3553 application.GetScene().Add(parent);
3555 Actor child = Actor::New();
3557 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3558 DALI_TEST_CHECK(!child.GetParent());
3560 // Test that calling Unparent with no parent is a NOOP
3563 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3564 DALI_TEST_CHECK(!child.GetParent());
3566 // Test that Unparent works
3569 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3570 DALI_TEST_CHECK(parent == child.GetParent());
3574 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3575 DALI_TEST_CHECK(!child.GetParent());
3577 // Test that UnparentAndReset works
3580 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3581 DALI_TEST_CHECK(parent == child.GetParent());
3583 UnparentAndReset(child);
3585 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3586 DALI_TEST_CHECK(!child);
3588 // Test that UnparentAndReset is a NOOP with empty handle
3589 UnparentAndReset(child);
3591 DALI_TEST_CHECK(!child);
3595 int UtcDaliActorGetChildAt(void)
3597 TestApplication application;
3598 tet_infoline(" UtcDaliActorGetChildAt");
3600 Actor parent = Actor::New();
3601 application.GetScene().Add(parent);
3603 Actor child0 = Actor::New();
3606 Actor child1 = Actor::New();
3609 Actor child2 = Actor::New();
3612 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3613 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3614 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3618 int UtcDaliActorSetGetOverlay(void)
3620 TestApplication application;
3621 tet_infoline(" UtcDaliActorSetGetOverlay");
3623 Actor parent = Actor::New();
3624 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3625 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3629 int UtcDaliActorCreateDestroy(void)
3631 Actor* actor = new Actor;
3632 DALI_TEST_CHECK(actor);
3639 struct PropertyStringIndex
3641 const char* const name;
3642 const Property::Index index;
3643 const Property::Type type;
3646 const PropertyStringIndex PROPERTY_TABLE[] =
3648 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3649 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3650 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3651 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3652 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3653 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3654 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3655 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3656 {"size", Actor::Property::SIZE, Property::VECTOR3},
3657 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3658 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3659 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3660 {"position", Actor::Property::POSITION, Property::VECTOR3},
3661 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3662 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3663 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3664 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3665 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3666 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3667 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3668 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3669 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3670 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3671 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3672 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3673 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3674 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3675 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3676 {"color", Actor::Property::COLOR, Property::VECTOR4},
3677 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3678 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3679 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3680 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3681 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3682 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3683 {"name", Actor::Property::NAME, Property::STRING},
3684 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3685 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3686 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3687 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3688 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3689 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3690 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3691 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3692 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3693 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3694 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3695 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3696 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3697 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3698 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3699 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3700 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3701 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3703 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3704 } // unnamed namespace
3706 int UtcDaliActorProperties(void)
3708 TestApplication application;
3710 Actor actor = Actor::New();
3712 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3714 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3715 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3716 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3717 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3722 int UtcDaliRelayoutProperties_ResizePolicies(void)
3724 TestApplication application;
3726 Actor actor = Actor::New();
3729 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3730 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3732 // Set resize policy for all dimensions
3733 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3734 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3736 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3739 // Set individual dimensions
3740 const char* const widthPolicy = "FILL_TO_PARENT";
3741 const char* const heightPolicy = "FIXED";
3743 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3744 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3746 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3747 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3749 // Set individual dimensions using enums
3750 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3751 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3753 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3754 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3756 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3757 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3762 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3764 TestApplication application;
3766 Actor actor = Actor::New();
3769 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3771 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3772 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3773 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3776 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3777 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3779 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3780 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3782 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3783 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3788 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3790 TestApplication application;
3792 Actor actor = Actor::New();
3795 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3796 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3798 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3799 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3800 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3803 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3805 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3806 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3811 int UtcDaliRelayoutProperties_DimensionDependency(void)
3813 TestApplication application;
3815 Actor actor = Actor::New();
3818 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3819 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3822 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3823 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3825 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3826 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3828 // Test setting another resize policy
3829 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3830 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3835 int UtcDaliRelayoutProperties_Padding(void)
3837 TestApplication application;
3839 Actor actor = Actor::New();
3842 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3845 actor.SetProperty(Actor::Property::PADDING, padding);
3846 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3848 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3853 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3855 TestApplication application;
3857 Actor actor = Actor::New();
3860 Vector2 minSize(1.0f, 2.0f);
3862 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3863 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3865 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3867 Vector2 maxSize(3.0f, 4.0f);
3869 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3870 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3872 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3877 int UtcDaliActorGetHeightForWidth(void)
3879 TestApplication application;
3881 Actor actor = Actor::New();
3883 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3888 int UtcDaliActorGetWidthForHeight(void)
3890 TestApplication application;
3892 Actor actor = Actor::New();
3894 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3899 int UtcDaliActorGetRelayoutSize(void)
3901 TestApplication application;
3903 Actor actor = Actor::New();
3905 // Add actor to stage
3906 application.GetScene().Add(actor);
3908 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3910 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3911 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3913 // Flush the queue and render once
3914 application.SendNotification();
3915 application.Render();
3917 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3922 int UtcDaliActorSetPadding(void)
3924 TestApplication application;
3926 Actor actor = Actor::New();
3929 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3931 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3932 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3933 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3934 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3936 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3937 actor.SetProperty(Actor::Property::PADDING, padding2);
3939 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3941 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3942 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3943 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3944 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3949 int UtcDaliActorSetMinimumSize(void)
3951 TestApplication application;
3953 Actor actor = Actor::New();
3955 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3957 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3958 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3960 Vector2 size2(1.0f, 2.0f);
3961 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3963 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3965 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3966 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3971 int UtcDaliActorSetMaximumSize(void)
3973 TestApplication application;
3975 Actor actor = Actor::New();
3977 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3979 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3980 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3982 Vector2 size2(1.0f, 2.0f);
3983 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3985 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3987 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3988 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3993 int UtcDaliActorOnRelayoutSignal(void)
3995 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3997 TestApplication application;
4000 gOnRelayoutCallBackCalled = false;
4001 gActorNamesRelayout.clear();
4003 Actor actor = Actor::New();
4004 actor.SetProperty(Actor::Property::NAME, "actor");
4005 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
4008 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
4010 // Add actor to stage
4011 application.GetScene().Add(actor);
4013 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4014 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
4016 // Flush the queue and render once
4017 application.SendNotification();
4018 application.Render();
4020 // OnRelayout emitted
4021 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
4022 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
4027 int UtcDaliActorGetHierachyDepth(void)
4029 TestApplication application;
4030 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
4032 /* Build tree of actors:
4042 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
4044 Integration::Scene stage(application.GetScene());
4046 Actor actorA = Actor::New();
4047 Actor actorB = Actor::New();
4048 Actor actorC = Actor::New();
4049 Actor actorD = Actor::New();
4050 Actor actorE = Actor::New();
4051 Actor actorF = Actor::New();
4053 //Test that root actor has depth equal 0
4054 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4056 //Test actors return depth -1 when not connected to the tree
4057 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4058 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4059 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4060 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4061 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4062 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4064 //Create the hierarchy
4072 //Test actors return correct depth
4073 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4074 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4075 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4076 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4077 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4078 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4080 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
4081 actorA.Remove(actorB);
4083 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4084 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4085 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4087 //Removing actorA from the stage. All actors should have depth equal -1
4088 stage.Remove(actorA);
4090 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4091 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4092 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4093 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4094 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4095 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4100 int UtcDaliActorAnchorPointPropertyAsString(void)
4102 TestApplication application;
4104 Actor actor = Actor::New();
4106 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
4107 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4109 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
4110 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4112 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
4113 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4115 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
4116 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4118 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
4119 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
4121 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
4122 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4124 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
4125 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4127 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
4128 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4130 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
4131 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4133 // Invalid should not change anything
4134 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
4135 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4140 int UtcDaliActorParentOriginPropertyAsString(void)
4142 TestApplication application;
4144 Actor actor = Actor::New();
4146 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
4147 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4149 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
4150 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4152 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
4153 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4155 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
4156 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4158 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
4159 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
4161 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
4162 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4164 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
4165 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4167 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
4168 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4170 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
4171 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4173 // Invalid should not change anything
4174 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
4175 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4180 int UtcDaliActorColorModePropertyAsString(void)
4182 TestApplication application;
4184 Actor actor = Actor::New();
4186 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
4187 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4189 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
4190 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4192 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
4193 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4195 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
4196 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4198 // Invalid should not change anything
4199 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
4200 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4205 int UtcDaliActorDrawModePropertyAsString(void)
4207 TestApplication application;
4209 Actor actor = Actor::New();
4211 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
4212 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4214 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
4215 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4217 // Invalid should not change anything
4218 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
4219 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4224 int UtcDaliActorColorModePropertyAsEnum(void)
4226 TestApplication application;
4228 Actor actor = Actor::New();
4230 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
4231 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4233 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
4234 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4236 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
4237 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4239 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
4240 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4245 int UtcDaliActorDrawModePropertyAsEnum(void)
4247 TestApplication application;
4249 Actor actor = Actor::New();
4251 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
4252 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4254 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
4255 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4260 int UtcDaliActorAddRendererP(void)
4262 tet_infoline("Testing Actor::AddRenderer");
4263 TestApplication application;
4265 Actor actor = Actor::New();
4267 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4269 Geometry geometry = CreateQuadGeometry();
4270 Shader shader = CreateShader();
4271 Renderer renderer = Renderer::New(geometry, shader);
4273 actor.AddRenderer(renderer);
4274 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4275 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4280 int UtcDaliActorAddRendererN01(void)
4282 tet_infoline("Testing Actor::AddRenderer");
4283 TestApplication application;
4285 Actor actor = Actor::New();
4291 actor.AddRenderer(renderer);
4292 tet_printf("Assertion test failed - no Exception\n");
4293 tet_result(TET_FAIL);
4295 catch(Dali::DaliException& e)
4297 DALI_TEST_PRINT_ASSERT(e);
4298 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4299 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4303 tet_printf("Assertion test failed - wrong Exception\n");
4304 tet_result(TET_FAIL);
4310 int UtcDaliActorAddRendererN02(void)
4312 tet_infoline("UtcDaliActorAddRendererN02");
4318 TestApplication application;
4320 Geometry geometry = CreateQuadGeometry();
4321 Shader shader = CreateShader();
4322 renderer = Renderer::New(geometry, shader);
4324 actor = Actor::New();
4327 // try illegal AddRenderer
4330 actor.AddRenderer(renderer);
4331 tet_printf("Assertion test failed - no Exception\n");
4332 tet_result(TET_FAIL);
4334 catch(Dali::DaliException& e)
4336 DALI_TEST_PRINT_ASSERT(e);
4337 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4341 tet_printf("Assertion test failed - wrong Exception\n");
4342 tet_result(TET_FAIL);
4348 int UtcDaliActorAddRendererOnScene(void)
4350 tet_infoline("Testing Actor::AddRenderer");
4351 TestApplication application;
4353 Actor actor = Actor::New();
4354 application.GetScene().Add(actor);
4356 application.SendNotification();
4357 application.Render(0);
4359 Geometry geometry = CreateQuadGeometry();
4360 Shader shader = CreateShader();
4361 Renderer renderer = Renderer::New(geometry, shader);
4363 application.SendNotification();
4364 application.Render(0);
4368 actor.AddRenderer(renderer);
4369 tet_result(TET_PASS);
4373 tet_result(TET_FAIL);
4379 int UtcDaliActorRemoveRendererP1(void)
4381 tet_infoline("Testing Actor::RemoveRenderer");
4382 TestApplication application;
4384 Actor actor = Actor::New();
4386 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4389 Geometry geometry = CreateQuadGeometry();
4390 Shader shader = CreateShader();
4391 Renderer renderer = Renderer::New(geometry, shader);
4393 actor.AddRenderer(renderer);
4394 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4395 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4397 application.SendNotification();
4398 application.Render();
4402 Renderer renderer = actor.GetRendererAt(0);
4403 actor.RemoveRenderer(renderer);
4404 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4406 application.SendNotification();
4407 application.Render();
4410 // Call one final time to ensure that the renderer is actually removed after
4411 // the handle goes out of scope, and excercises the deletion code path in
4412 // scene graph and render.
4413 application.SendNotification();
4414 application.Render();
4419 int UtcDaliActorRemoveRendererP2(void)
4421 tet_infoline("Testing Actor::RemoveRenderer");
4422 TestApplication application;
4424 Actor actor = Actor::New();
4426 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4428 Geometry geometry = CreateQuadGeometry();
4429 Shader shader = CreateShader();
4430 Renderer renderer = Renderer::New(geometry, shader);
4432 actor.AddRenderer(renderer);
4433 application.SendNotification();
4434 application.Render();
4436 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4437 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4439 actor.RemoveRenderer(0);
4440 application.SendNotification();
4441 application.Render();
4443 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4445 // Shut down whilst holding onto the renderer handle.
4449 int UtcDaliActorRemoveRendererN(void)
4451 tet_infoline("Testing Actor::RemoveRenderer");
4452 TestApplication application;
4454 Actor actor = Actor::New();
4456 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4458 Geometry geometry = CreateQuadGeometry();
4459 Shader shader = CreateShader();
4460 Renderer renderer = Renderer::New(geometry, shader);
4462 actor.AddRenderer(renderer);
4463 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4464 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4466 actor.RemoveRenderer(10);
4467 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4468 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4473 // Clipping test helper functions:
4474 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4476 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4477 Actor actor = CreateRenderableActor(image);
4479 // Setup dimensions and position so actor is not skipped by culling.
4480 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4481 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4482 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4483 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4488 Actor CreateActorWithContent16x16()
4490 return CreateActorWithContent(16, 16);
4493 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4495 enabledDisableTrace.Reset();
4496 stencilTrace.Reset();
4497 enabledDisableTrace.Enable(true);
4498 stencilTrace.Enable(true);
4500 application.SendNotification();
4501 application.Render();
4503 enabledDisableTrace.Enable(false);
4504 stencilTrace.Enable(false);
4507 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4509 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4511 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4512 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4513 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4515 // @todo only test alpha if the framebuffer has an alpha channel
4516 //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4519 int UtcDaliActorPropertyClippingP(void)
4521 // This test checks the clippingMode property.
4522 tet_infoline("Testing Actor::Property::ClippingMode: P");
4523 TestApplication application;
4525 Actor actor = Actor::New();
4527 // Check default clippingEnabled value.
4528 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4531 bool getValueResult = getValue.Get(value);
4532 DALI_TEST_CHECK(getValueResult);
4536 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4539 // Check setting the property to the stencil mode.
4540 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4542 // Check the new value was set.
4543 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4544 getValueResult = getValue.Get(value);
4545 DALI_TEST_CHECK(getValueResult);
4549 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4552 // Check setting the property to the scissor mode.
4553 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4555 // Check the new value was set.
4556 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4557 getValueResult = getValue.Get(value);
4558 DALI_TEST_CHECK(getValueResult);
4562 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4567 int UtcDaliActorPropertyClippingN(void)
4569 // Negative test case for Clipping.
4570 tet_infoline("Testing Actor::Property::ClippingMode: N");
4571 TestApplication application;
4573 Actor actor = Actor::New();
4575 // Check default clippingEnabled value.
4576 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4579 bool getValueResult = getValue.Get(value);
4580 DALI_TEST_CHECK(getValueResult);
4584 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4587 // Check setting an invalid property value won't change the current property value.
4588 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4590 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4591 getValueResult = getValue.Get(value);
4592 DALI_TEST_CHECK(getValueResult);
4596 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4602 int UtcDaliActorPropertyClippingActor(void)
4604 // This test checks that an actor is correctly setup for clipping.
4605 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4606 TestApplication application;
4608 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4609 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4610 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4611 size_t startIndex = 0u;
4613 // Create a clipping actor.
4614 Actor actorDepth1Clip = CreateActorWithContent16x16();
4615 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4616 application.GetScene().Add(actorDepth1Clip);
4618 // Gather the call trace.
4619 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4621 // Check we are writing to the color buffer.
4622 CheckColorMask(glAbstraction, true);
4624 // Check the stencil buffer was enabled.
4625 std::ostringstream oss;
4626 oss << std::hex << GL_STENCIL_TEST;
4627 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4629 // Check the stencil buffer was cleared.
4630 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4632 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4633 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4634 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4635 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4640 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4642 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4643 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4644 TestApplication application;
4646 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4647 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4648 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4649 size_t startIndex = 0u;
4651 // Create a clipping actor.
4652 Actor actorDepth1Clip = CreateActorWithContent16x16();
4653 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4654 application.GetScene().Add(actorDepth1Clip);
4656 // Gather the call trace.
4657 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4659 // Check we are writing to the color buffer.
4660 CheckColorMask(glAbstraction, true);
4662 // Check the stencil buffer was enabled.
4663 std::ostringstream oss;
4664 oss << std::hex << GL_STENCIL_TEST;
4665 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4667 // Check the stencil buffer was cleared.
4668 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4670 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4671 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4672 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4673 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4675 // Now disable the clipping
4676 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4678 // Gather the call trace.
4679 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4681 // Check the stencil buffer was disabled.
4682 std::ostringstream stencil;
4683 stencil << std::hex << GL_STENCIL_TEST;
4684 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4686 // Ensure all values in stencil-mask are set to 1.
4688 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4693 int UtcDaliActorPropertyClippingNestedChildren(void)
4695 // This test checks that a hierarchy of actors are clipped correctly by
4696 // writing to and reading from the correct bit-planes of the stencil buffer.
4697 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4698 TestApplication application;
4699 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4700 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4701 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4703 // Create a clipping actor.
4704 Actor actorDepth1Clip = CreateActorWithContent16x16();
4705 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4706 application.GetScene().Add(actorDepth1Clip);
4708 // Create a child actor.
4709 Actor childDepth2 = CreateActorWithContent16x16();
4710 actorDepth1Clip.Add(childDepth2);
4712 // Create another clipping actor.
4713 Actor childDepth2Clip = CreateActorWithContent16x16();
4714 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4715 childDepth2.Add(childDepth2Clip);
4717 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4718 // This tests the sort algorithm.
4719 Actor childDepth3 = CreateActorWithContent16x16();
4720 childDepth2Clip.Add(childDepth3);
4721 Actor childDepth4 = CreateActorWithContent16x16();
4722 childDepth3.Add(childDepth4);
4724 // Gather the call trace.
4725 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4727 // Check we are writing to the color buffer.
4728 CheckColorMask(glAbstraction, true);
4730 // Check the stencil buffer was enabled.
4731 std::ostringstream oss;
4732 oss << std::hex << GL_STENCIL_TEST;
4733 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4735 // Perform the test twice, once for 2D layer, and once for 3D.
4736 for(unsigned int i = 0u; i < 2u; ++i)
4738 size_t startIndex = 0u;
4740 // Check the stencil buffer was cleared.
4741 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4743 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4744 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4745 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4746 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4748 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4749 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
4750 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4752 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4753 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4754 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4755 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4757 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4758 // (Both must be set to pass the check).
4759 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4760 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4762 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4765 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4766 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4773 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4775 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4776 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4777 TestApplication application;
4778 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4779 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4781 /* We create a small tree of actors as follows:
4785 Clipping enabled -> B D
4789 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4792 for(int i = 0; i < 5; ++i)
4794 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4795 Actor actor = CreateRenderableActor(image);
4797 // Setup dimensions and position so actor is not skipped by culling.
4798 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4799 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4803 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4807 float b = i > 2 ? 1.0f : -1.0f;
4808 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4814 // Enable clipping on the actor at the top of the left branch.
4815 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4817 // Build the scene graph.
4818 application.GetScene().Add(actors[0]);
4821 actors[0].Add(actors[1]);
4822 actors[1].Add(actors[2]);
4825 actors[0].Add(actors[3]);
4826 actors[3].Add(actors[4]);
4828 // Gather the call trace.
4829 enabledDisableTrace.Reset();
4830 enabledDisableTrace.Enable(true);
4831 application.SendNotification();
4832 application.Render();
4833 enabledDisableTrace.Enable(false);
4835 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4837 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
4838 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4840 size_t startIndex = 0u;
4841 std::ostringstream blend;
4842 blend << std::hex << GL_BLEND;
4843 std::ostringstream stencil;
4844 stencil << std::hex << GL_STENCIL_TEST;
4846 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4847 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4848 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4850 // Swap the clipping actor from top of left branch to top of right branch.
4851 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4852 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4854 // Gather the call trace.
4855 enabledDisableTrace.Reset();
4856 enabledDisableTrace.Enable(true);
4857 application.SendNotification();
4858 application.Render();
4859 enabledDisableTrace.Enable(false);
4861 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4862 // This proves the draw order has remained the same.
4864 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4865 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4870 int UtcDaliActorPropertyScissorClippingActor01(void)
4872 // This test checks that an actor is correctly setup for clipping.
4873 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4874 TestApplication application;
4876 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4877 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4878 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4880 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4881 const Vector2 imageSize(16.0f, 16.0f);
4883 // Create a clipping actor.
4884 Actor clippingActorA = CreateActorWithContent16x16();
4885 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4886 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4887 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4888 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4889 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4890 application.GetScene().Add(clippingActorA);
4892 // Gather the call trace.
4893 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4895 // Check we are writing to the color buffer.
4896 CheckColorMask(glAbstraction, true);
4898 // Check scissor test was enabled.
4900 std::ostringstream scissor;
4901 scissor << std::hex << GL_SCISSOR_TEST;
4902 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4904 // Check the scissor was set, and the coordinates are correct.
4905 std::stringstream compareParametersString;
4906 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4907 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4909 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4910 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4912 // Gather the call trace.
4913 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4915 // Check the scissor was set, and the coordinates are correct.
4916 compareParametersString.str(std::string());
4917 compareParametersString.clear();
4918 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4919 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4924 int UtcDaliActorPropertyScissorClippingActor02(void)
4926 // This test checks that an actor is correctly setup for clipping.
4927 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4928 TestApplication application;
4930 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4931 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4932 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4934 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4935 const Vector2 actorSize(16.0f, 16.0f);
4937 // Create a clipping actor.
4938 Actor clippingActorA = CreateRenderableActor();
4939 clippingActorA[Actor::Property::SIZE] = actorSize;
4941 Renderer renderer = clippingActorA.GetRendererAt(0);
4942 DALI_TEST_CHECK(renderer);
4944 // Make Renderer opacity 0.
4945 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4947 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4948 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4949 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4950 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4951 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4952 application.GetScene().Add(clippingActorA);
4954 // Gather the call trace.
4955 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4957 // Check we are writing to the color buffer.
4958 CheckColorMask(glAbstraction, true);
4960 // Check scissor test was enabled.
4962 std::ostringstream scissor;
4963 scissor << std::hex << GL_SCISSOR_TEST;
4964 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4966 // Check the scissor was set, and the coordinates are correct.
4967 std::stringstream compareParametersString;
4968 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
4969 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4971 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4972 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4974 // Gather the call trace.
4975 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4977 // Check the scissor was set, and the coordinates are correct.
4978 compareParametersString.str(std::string());
4979 compareParametersString.clear();
4980 compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
4981 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4986 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4988 // This test checks that an actor is correctly setup for clipping.
4989 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4990 TestApplication application;
4992 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4993 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4994 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4996 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4997 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4998 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5000 // Create a clipping actors.
5001 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5002 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5004 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5005 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5006 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5008 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5009 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5010 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5012 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5013 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5015 application.GetScene().Add(clippingActorA);
5016 application.GetScene().Add(clippingActorB);
5018 // Gather the call trace.
5019 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5021 // Check we are writing to the color buffer.
5022 CheckColorMask(glAbstraction, true);
5024 // Check scissor test was enabled.
5025 std::ostringstream scissor;
5026 scissor << std::hex << GL_SCISSOR_TEST;
5027 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5029 // Check the scissor was set, and the coordinates are correct.
5030 std::stringstream compareParametersString;
5032 std::string clipA("0, 500, 480, 200");
5033 std::string clipB("0, 380, 480, 40");
5035 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5036 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5041 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5043 // This test checks that an actor is correctly setup for clipping.
5044 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5045 TestApplication application;
5047 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5048 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5049 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5051 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5052 const Vector2 imageSize(16.0f, 16.0f);
5054 /* Create a nest of 2 scissors to test nesting (intersecting clips).
5056 A is drawn first - with scissor clipping on
5057 B is drawn second - also with scissor clipping on
5058 C is the generated clipping region, the intersection ( A ∩ B )
5062 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
5063 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
5064 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
5068 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5071 // Create a clipping actor.
5072 Actor clippingActorA = CreateActorWithContent16x16();
5073 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5074 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5075 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5076 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5077 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5078 application.GetScene().Add(clippingActorA);
5080 // Create a child clipping actor.
5081 Actor clippingActorB = CreateActorWithContent16x16();
5082 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5083 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5084 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5085 clippingActorA.Add(clippingActorB);
5087 // positionModifiers is an array of positions to position B around.
5088 // expect is an array of expected scissor clip coordinate results.
5089 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5090 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5092 // Loop through each overlap combination.
5093 for(unsigned int test = 0u; test < 4u; ++test)
5095 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5096 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5097 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5099 // Gather the call trace.
5100 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5102 // Check we are writing to the color buffer.
5103 CheckColorMask(glAbstraction, true);
5105 // Check scissor test was enabled.
5106 std::ostringstream scissor;
5107 scissor << std::hex << GL_SCISSOR_TEST;
5108 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5110 // Check the scissor was set, and the coordinates are correct.
5111 const Vector4& expectResults(expect[test]);
5112 std::stringstream compareParametersString;
5113 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5114 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5120 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5122 // This test checks that an actor is correctly setup for clipping.
5123 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5124 TestApplication application;
5126 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5127 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5128 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5130 /* Create a nest of 2 scissors and siblings of the parent.
5140 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5141 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5142 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5143 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5144 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5145 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5147 // Create a clipping actors.
5148 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5149 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5150 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5151 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5152 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5154 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5155 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5156 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5158 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5159 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5160 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5162 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5163 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5164 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5166 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5167 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5168 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5170 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5171 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5173 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5174 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5175 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5176 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5177 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5179 application.GetScene().Add(clippingActorA);
5180 clippingActorA.Add(clippingActorB);
5181 application.GetScene().Add(clippingActorC);
5182 application.GetScene().Add(clippingActorD);
5183 clippingActorD.Add(clippingActorE);
5185 // Gather the call trace.
5186 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5188 // Check we are writing to the color buffer.
5189 CheckColorMask(glAbstraction, true);
5191 // Check scissor test was enabled.
5192 std::ostringstream scissor;
5193 scissor << std::hex << GL_SCISSOR_TEST;
5194 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5196 // Check the scissor was set, and the coordinates are correct.
5197 std::string clipA("0, 500, 480, 200");
5198 std::string clipB("0, 580, 480, 40");
5199 std::string clipC("0, 200, 480, 200");
5200 std::string clipD("0, 300, 480, 200");
5202 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5203 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5204 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5205 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5206 DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5211 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5213 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5214 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5215 TestApplication application;
5217 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5218 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
5219 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5221 // Create a clipping actor.
5222 Actor actorDepth1Clip = CreateActorWithContent16x16();
5223 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5224 application.GetScene().Add(actorDepth1Clip);
5226 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5227 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5229 // Gather the call trace.
5230 GenerateTrace(application, enabledDisableTrace, stencilTrace);
5232 // Check we are writing to the color buffer.
5233 CheckColorMask(glAbstraction, true);
5235 // Check the stencil buffer was not enabled.
5236 std::ostringstream stencil;
5237 stencil << std::hex << GL_STENCIL_TEST;
5238 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5240 // Check stencil functions are not called.
5241 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5242 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5244 // Check that scissor clipping is overriden by the renderer properties.
5245 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5247 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5249 // Gather the call trace.
5250 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5252 // Check the stencil buffer was not enabled.
5253 std::ostringstream scissor;
5254 scissor << std::hex << GL_SCISSOR_TEST;
5255 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5257 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5262 int UtcDaliActorPropertyClippingActorCulled(void)
5264 // This test checks that child actors are clipped by an culled parent actor.
5265 tet_infoline("Testing child actors are clipped by an culled parent actor");
5266 TestApplication application;
5268 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5269 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5270 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5272 const Vector2 actorSize(160.0f, 160.0f);
5274 // Create a clipping actor.
5275 Actor clippingActorA = CreateRenderableActor();
5276 clippingActorA[Actor::Property::SIZE] = actorSize;
5278 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5279 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5280 clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5281 clippingActorA[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5282 clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5283 application.GetScene().Add(clippingActorA);
5285 // Create a child actor
5286 Actor childActor = CreateRenderableActor();
5287 childActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5288 childActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5289 childActor[Actor::Property::SIZE] = Vector2(50.0f, 50.0f);
5290 childActor[Actor::Property::INHERIT_POSITION] = false;
5292 // Gather the call trace.
5293 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5295 // Check scissor test was enabled.
5296 std::ostringstream scissor;
5297 scissor << std::hex << GL_SCISSOR_TEST;
5298 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5300 // Check the scissor was set, and the coordinates are correct.
5301 std::stringstream compareParametersString;
5302 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5303 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5305 // Move the clipping actor out of screen
5306 clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5308 // Gather the call trace.
5309 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5311 // Check the scissor was set, and the coordinates are correct.
5312 compareParametersString.str(std::string());
5313 compareParametersString.clear();
5314 compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5315 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5320 int UtcDaliGetPropertyN(void)
5322 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5323 TestApplication application;
5325 Actor actor = Actor::New();
5327 unsigned int propertyCount = actor.GetPropertyCount();
5328 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5332 int UtcDaliActorRaiseLower(void)
5334 tet_infoline("UtcDaliActor Raise and Lower test\n");
5336 TestApplication application;
5338 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5340 Integration::Scene stage(application.GetScene());
5342 Actor actorA = Actor::New();
5343 Actor actorB = Actor::New();
5344 Actor actorC = Actor::New();
5346 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5347 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5349 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5350 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5352 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5353 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5355 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5356 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5358 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5359 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5361 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5362 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5368 ResetTouchCallbacks();
5370 application.SendNotification();
5371 application.Render();
5373 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5374 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5375 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5377 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5378 // Only top actor will get touched.
5379 actorA.TouchedSignal().Connect(TestTouchCallback);
5380 actorB.TouchedSignal().Connect(TestTouchCallback2);
5381 actorC.TouchedSignal().Connect(TestTouchCallback3);
5383 // Connect ChildOrderChangedSignal
5384 bool orderChangedSignal(false);
5385 Actor orderChangedActor;
5386 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5387 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5389 Dali::Integration::Point point;
5390 point.SetDeviceId(1);
5391 point.SetState(PointState::DOWN);
5392 point.SetScreenPosition(Vector2(10.f, 10.f));
5393 Dali::Integration::TouchEvent touchEvent;
5394 touchEvent.AddPoint(point);
5396 application.ProcessEvent(touchEvent);
5398 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5399 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5400 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5402 ResetTouchCallbacks();
5404 tet_printf("Testing Raising of Actor\n");
5406 int preActorOrder(0);
5407 int postActorOrder(0);
5409 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5410 value.Get(preActorOrder);
5412 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5414 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5415 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5417 // Ensure sort order is calculated before next touch event
5418 application.SendNotification();
5420 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5421 value.Get(postActorOrder);
5423 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5425 application.ProcessEvent(touchEvent);
5427 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5428 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5429 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5431 ResetTouchCallbacks();
5433 tet_printf("Testing Lowering of Actor\n");
5435 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5436 value.Get(preActorOrder);
5438 orderChangedSignal = false;
5440 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5442 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5443 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5445 application.SendNotification(); // ensure sort order calculated before next touch event
5447 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5448 value.Get(postActorOrder);
5450 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5452 application.ProcessEvent(touchEvent);
5454 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5455 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5456 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5458 ResetTouchCallbacks();
5460 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5465 int UtcDaliActorRaiseToTopLowerToBottom(void)
5467 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5469 TestApplication application;
5471 Integration::Scene stage(application.GetScene());
5473 Actor actorA = Actor::New();
5474 Actor actorB = Actor::New();
5475 Actor actorC = Actor::New();
5477 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5478 // enables checking of which actor the uniform is assigned too
5479 Shader shaderA = CreateShader();
5480 shaderA.RegisterProperty("uRendererColor", 1.f);
5482 Shader shaderB = CreateShader();
5483 shaderB.RegisterProperty("uRendererColor", 2.f);
5485 Shader shaderC = CreateShader();
5486 shaderC.RegisterProperty("uRendererColor", 3.f);
5488 Geometry geometry = CreateQuadGeometry();
5490 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5491 Renderer rendererA = Renderer::New(geometry, shaderA);
5492 actorA.AddRenderer(rendererA);
5494 Renderer rendererB = Renderer::New(geometry, shaderB);
5495 actorB.AddRenderer(rendererB);
5497 Renderer rendererC = Renderer::New(geometry, shaderC);
5498 actorC.AddRenderer(rendererC);
5500 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5501 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5503 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5504 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5506 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5507 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5509 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5510 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5512 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5513 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5515 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5516 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5522 ResetTouchCallbacks();
5524 // Connect ChildOrderChangedSignal
5525 bool orderChangedSignal(false);
5526 Actor orderChangedActor;
5527 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5528 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5530 // Set up gl abstraction trace so can query the set uniform order
5531 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5532 glAbstraction.EnableSetUniformCallTrace(true);
5533 glAbstraction.ResetSetUniformCallStack();
5535 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5537 application.SendNotification();
5538 application.Render();
5540 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5542 // Test order of uniforms in stack
5543 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5544 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5545 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5547 bool CBA = (indexC > indexB) && (indexB > indexA);
5549 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5551 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5552 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5553 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5555 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5556 // Only top actor will get touched.
5557 actorA.TouchedSignal().Connect(TestTouchCallback);
5558 actorB.TouchedSignal().Connect(TestTouchCallback2);
5559 actorC.TouchedSignal().Connect(TestTouchCallback3);
5561 Dali::Integration::Point point;
5562 point.SetDeviceId(1);
5563 point.SetState(PointState::DOWN);
5564 point.SetScreenPosition(Vector2(10.f, 10.f));
5565 Dali::Integration::TouchEvent touchEvent;
5566 touchEvent.AddPoint(point);
5568 application.ProcessEvent(touchEvent);
5570 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5571 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5572 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5574 ResetTouchCallbacks();
5576 tet_printf("RaiseToTop ActorA\n");
5578 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5579 actorA.RaiseToTop();
5580 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5581 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5583 application.SendNotification(); // ensure sorting order is calculated before next touch event
5585 application.ProcessEvent(touchEvent);
5587 glSetUniformStack.Reset();
5589 application.SendNotification();
5590 application.Render();
5592 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5594 // Test order of uniforms in stack
5595 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5596 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5597 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5599 tet_infoline("Testing A above C and B at bottom\n");
5600 bool ACB = (indexA > indexC) && (indexC > indexB);
5602 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5604 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5605 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5606 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5608 ResetTouchCallbacks();
5610 tet_printf("RaiseToTop ActorB\n");
5612 orderChangedSignal = false;
5614 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5615 actorB.RaiseToTop();
5616 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5617 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5619 application.SendNotification(); // Ensure sort order is calculated before next touch event
5621 application.ProcessEvent(touchEvent);
5623 glSetUniformStack.Reset();
5625 application.SendNotification();
5626 application.Render();
5628 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5630 // Test order of uniforms in stack
5631 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5632 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5633 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5635 tet_infoline("Testing B above A and C at bottom\n");
5636 bool BAC = (indexB > indexA) && (indexA > indexC);
5638 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5640 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5641 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5642 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5644 ResetTouchCallbacks();
5646 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5648 orderChangedSignal = false;
5650 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5651 actorA.LowerToBottom();
5652 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5653 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5655 application.SendNotification();
5656 application.Render();
5658 orderChangedSignal = false;
5660 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5661 actorB.LowerToBottom();
5662 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5663 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5665 application.SendNotification();
5666 application.Render();
5668 application.ProcessEvent(touchEvent);
5670 glSetUniformStack.Reset();
5672 application.SendNotification();
5673 application.Render();
5675 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5677 // Test order of uniforms in stack
5678 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5679 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5680 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5682 tet_infoline("Testing C above A and B at bottom\n");
5683 bool CAB = (indexC > indexA) && (indexA > indexB);
5685 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5687 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5688 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5689 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5691 ResetTouchCallbacks();
5696 int UtcDaliActorRaiseAbove(void)
5698 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5700 TestApplication application;
5702 Integration::Scene stage(application.GetScene());
5704 Actor actorA = Actor::New();
5705 Actor actorB = Actor::New();
5706 Actor actorC = Actor::New();
5708 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5709 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5711 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5712 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5714 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5715 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5717 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5718 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5720 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5721 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5723 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5724 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5730 ResetTouchCallbacks();
5732 application.SendNotification();
5733 application.Render();
5735 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5736 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5737 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5739 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5740 // Only top actor will get touched.
5741 actorA.TouchedSignal().Connect(TestTouchCallback);
5742 actorB.TouchedSignal().Connect(TestTouchCallback2);
5743 actorC.TouchedSignal().Connect(TestTouchCallback3);
5745 bool orderChangedSignal(false);
5746 Actor orderChangedActor;
5747 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5748 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5750 Dali::Integration::Point point;
5751 point.SetDeviceId(1);
5752 point.SetState(PointState::DOWN);
5753 point.SetScreenPosition(Vector2(10.f, 10.f));
5754 Dali::Integration::TouchEvent touchEvent;
5755 touchEvent.AddPoint(point);
5757 application.ProcessEvent(touchEvent);
5759 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5760 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5761 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5763 ResetTouchCallbacks();
5765 tet_printf("Raise actor B Above Actor C\n");
5767 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5768 actorB.RaiseAbove(actorC);
5769 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5770 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5772 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5773 application.SendNotification();
5774 application.ProcessEvent(touchEvent);
5776 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5777 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5778 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5780 ResetTouchCallbacks();
5782 tet_printf("Raise actor A Above Actor B\n");
5784 orderChangedSignal = false;
5786 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5787 actorA.RaiseAbove(actorB);
5788 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5789 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5791 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5792 application.SendNotification();
5794 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5796 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5797 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5798 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5800 ResetTouchCallbacks();
5805 int UtcDaliActorRaiseAbove2(void)
5807 tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5809 TestApplication application;
5811 Integration::Scene stage(application.GetScene());
5813 Actor actorA = Actor::New();
5814 Actor actorB = Actor::New();
5815 Actor actorC = Actor::New();
5817 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5818 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5820 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5821 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5823 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5824 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5826 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5827 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5829 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5830 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5832 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5833 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5839 ResetTouchCallbacks();
5841 application.SendNotification();
5842 application.Render();
5844 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5845 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5846 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5848 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5849 // Only top actor will get touched.
5850 actorA.TouchedSignal().Connect(TestTouchCallback);
5851 actorB.TouchedSignal().Connect(TestTouchCallback2);
5852 actorC.TouchedSignal().Connect(TestTouchCallback3);
5854 bool orderChangedSignal(false);
5855 Actor orderChangedActor;
5856 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5857 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5859 Dali::Integration::Point point;
5860 point.SetDeviceId(1);
5861 point.SetState(PointState::DOWN);
5862 point.SetScreenPosition(Vector2(10.f, 10.f));
5863 Dali::Integration::TouchEvent touchEvent;
5864 touchEvent.AddPoint(point);
5866 application.ProcessEvent(touchEvent);
5868 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5869 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5870 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5872 ResetTouchCallbacks();
5874 tet_printf("Raise actor B Above Actor C\n");
5876 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5877 int newOrder = actorC[DevelActor::Property::SIBLING_ORDER];
5878 actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5879 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5880 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5882 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5883 application.SendNotification();
5884 application.ProcessEvent(touchEvent);
5886 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5887 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5888 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5890 ResetTouchCallbacks();
5892 tet_printf("Raise actor A Above Actor B\n");
5894 orderChangedSignal = false;
5896 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5897 newOrder = actorB[DevelActor::Property::SIBLING_ORDER];
5898 actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5899 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5900 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5902 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5903 application.SendNotification();
5905 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5907 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5908 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5909 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5911 ResetTouchCallbacks();
5916 int UtcDaliActorLowerBelow(void)
5918 tet_infoline("UtcDaliActor LowerBelow test \n");
5920 TestApplication application;
5922 Integration::Scene stage(application.GetScene());
5924 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5925 // enables checking of which actor the uniform is assigned too
5926 Shader shaderA = CreateShader();
5927 shaderA.RegisterProperty("uRendererColor", 1.f);
5929 Shader shaderB = CreateShader();
5930 shaderB.RegisterProperty("uRendererColor", 2.f);
5932 Shader shaderC = CreateShader();
5933 shaderC.RegisterProperty("uRendererColor", 3.f);
5935 Actor actorA = Actor::New();
5936 Actor actorB = Actor::New();
5937 Actor actorC = Actor::New();
5939 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5940 Geometry geometry = CreateQuadGeometry();
5942 Renderer rendererA = Renderer::New(geometry, shaderA);
5943 actorA.AddRenderer(rendererA);
5945 Renderer rendererB = Renderer::New(geometry, shaderB);
5946 actorB.AddRenderer(rendererB);
5948 Renderer rendererC = Renderer::New(geometry, shaderC);
5949 actorC.AddRenderer(rendererC);
5951 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5952 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5954 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5955 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5957 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5958 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5960 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5961 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5963 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5964 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5966 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5967 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5969 Actor container = Actor::New();
5970 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5971 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5972 stage.Add(container);
5974 container.Add(actorA);
5975 container.Add(actorB);
5976 container.Add(actorC);
5978 ResetTouchCallbacks();
5980 // Connect ChildOrderChangedSignal
5981 bool orderChangedSignal(false);
5982 Actor orderChangedActor;
5983 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5984 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5986 // Set up gl abstraction trace so can query the set uniform order
5987 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5988 glAbstraction.EnableSetUniformCallTrace(true);
5989 glAbstraction.ResetSetUniformCallStack();
5990 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5992 glAbstraction.ResetSetUniformCallStack();
5994 application.SendNotification();
5995 application.Render();
5997 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5999 // Test order of uniforms in stack
6000 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6001 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6002 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6004 tet_infoline("Testing C above B and A at bottom\n");
6005 bool CBA = (indexC > indexB) && (indexB > indexA);
6007 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6009 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6010 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6011 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6013 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6014 // Only top actor will get touched.
6015 actorA.TouchedSignal().Connect(TestTouchCallback);
6016 actorB.TouchedSignal().Connect(TestTouchCallback2);
6017 actorC.TouchedSignal().Connect(TestTouchCallback3);
6019 Dali::Integration::Point point;
6020 point.SetDeviceId(1);
6021 point.SetState(PointState::DOWN);
6022 point.SetScreenPosition(Vector2(10.f, 10.f));
6023 Dali::Integration::TouchEvent touchEvent;
6024 touchEvent.AddPoint(point);
6026 tet_infoline("UtcDaliActor Test Set up completed \n");
6028 application.ProcessEvent(touchEvent);
6030 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6031 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6032 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6034 ResetTouchCallbacks();
6036 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");
6038 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6039 actorC.LowerBelow(actorB);
6040 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6041 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6043 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6044 application.SendNotification();
6045 application.Render();
6047 application.ProcessEvent(touchEvent); // touch event
6049 glSetUniformStack.Reset();
6051 application.SendNotification();
6052 application.Render();
6054 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6056 // Test order of uniforms in stack
6057 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6058 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6059 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6061 tet_infoline("Testing render order is A, C, B");
6062 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6063 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6065 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6066 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6067 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6069 ResetTouchCallbacks();
6071 tet_printf("Lower actor C below Actor A leaving B on top\n");
6073 orderChangedSignal = false;
6075 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6076 actorC.LowerBelow(actorA);
6077 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6078 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6080 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6081 application.SendNotification();
6082 application.Render();
6084 application.ProcessEvent(touchEvent);
6086 glSetUniformStack.Reset();
6088 application.Render();
6089 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6091 // Test order of uniforms in stack
6092 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6093 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6094 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6096 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6097 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6099 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6100 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6101 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6103 ResetTouchCallbacks();
6105 tet_printf("Lower actor B below Actor C leaving A on top\n");
6107 orderChangedSignal = false;
6109 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6110 actorB.LowerBelow(actorC);
6111 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6112 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6114 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6115 application.SendNotification();
6116 application.Render();
6118 application.ProcessEvent(touchEvent);
6120 glSetUniformStack.Reset();
6122 application.Render();
6123 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6125 // Test order of uniforms in stack
6126 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6127 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6128 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6130 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6131 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6136 int UtcDaliActorLowerBelow2(void)
6138 tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
6140 TestApplication application;
6142 Integration::Scene stage(application.GetScene());
6144 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6145 // enables checking of which actor the uniform is assigned too
6146 Shader shaderA = CreateShader();
6147 shaderA.RegisterProperty("uRendererColor", 1.f);
6149 Shader shaderB = CreateShader();
6150 shaderB.RegisterProperty("uRendererColor", 2.f);
6152 Shader shaderC = CreateShader();
6153 shaderC.RegisterProperty("uRendererColor", 3.f);
6155 Actor actorA = Actor::New();
6156 Actor actorB = Actor::New();
6157 Actor actorC = Actor::New();
6159 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6160 Geometry geometry = CreateQuadGeometry();
6162 Renderer rendererA = Renderer::New(geometry, shaderA);
6163 actorA.AddRenderer(rendererA);
6165 Renderer rendererB = Renderer::New(geometry, shaderB);
6166 actorB.AddRenderer(rendererB);
6168 Renderer rendererC = Renderer::New(geometry, shaderC);
6169 actorC.AddRenderer(rendererC);
6171 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6172 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6174 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6175 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6177 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6178 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6180 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6181 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6183 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6184 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6186 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6187 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6189 Actor container = Actor::New();
6190 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6191 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6192 stage.Add(container);
6194 container.Add(actorA);
6195 container.Add(actorB);
6196 container.Add(actorC);
6198 ResetTouchCallbacks();
6200 // Connect ChildOrderChangedSignal
6201 bool orderChangedSignal(false);
6202 Actor orderChangedActor;
6203 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6204 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6206 // Set up gl abstraction trace so can query the set uniform order
6207 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6208 glAbstraction.EnableSetUniformCallTrace(true);
6209 glAbstraction.ResetSetUniformCallStack();
6210 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6212 glAbstraction.ResetSetUniformCallStack();
6214 application.SendNotification();
6215 application.Render();
6217 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6219 // Test order of uniforms in stack
6220 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6221 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6222 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6224 tet_infoline("Testing C above B and A at bottom\n");
6225 bool CBA = (indexC > indexB) && (indexB > indexA);
6227 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6229 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6230 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6231 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6233 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6234 // Only top actor will get touched.
6235 actorA.TouchedSignal().Connect(TestTouchCallback);
6236 actorB.TouchedSignal().Connect(TestTouchCallback2);
6237 actorC.TouchedSignal().Connect(TestTouchCallback3);
6239 Dali::Integration::Point point;
6240 point.SetDeviceId(1);
6241 point.SetState(PointState::DOWN);
6242 point.SetScreenPosition(Vector2(10.f, 10.f));
6243 Dali::Integration::TouchEvent touchEvent;
6244 touchEvent.AddPoint(point);
6246 tet_infoline("UtcDaliActor Test Set up completed \n");
6248 application.ProcessEvent(touchEvent);
6250 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6251 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6252 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6254 ResetTouchCallbacks();
6256 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");
6258 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6259 actorC[DevelActor::Property::SIBLING_ORDER] = 1;
6260 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6261 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6263 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6264 application.SendNotification();
6265 application.Render();
6267 application.ProcessEvent(touchEvent); // touch event
6269 glSetUniformStack.Reset();
6271 application.SendNotification();
6272 application.Render();
6274 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6276 // Test order of uniforms in stack
6277 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6278 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6279 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6281 tet_infoline("Testing render order is A, C, B");
6282 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6283 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6285 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6286 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6287 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6289 ResetTouchCallbacks();
6291 tet_printf("Lower actor C below Actor A leaving B on top\n");
6293 orderChangedSignal = false;
6295 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6296 actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6297 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6298 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6300 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6301 application.SendNotification();
6302 application.Render();
6304 application.ProcessEvent(touchEvent);
6306 glSetUniformStack.Reset();
6308 application.Render();
6309 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6311 // Test order of uniforms in stack
6312 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6313 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6314 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6316 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6317 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6319 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6320 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6321 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6323 ResetTouchCallbacks();
6325 tet_printf("Lower actor B below Actor C leaving A on top\n");
6327 orderChangedSignal = false;
6329 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6330 actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6331 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6332 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6334 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6335 application.SendNotification();
6336 application.Render();
6338 application.ProcessEvent(touchEvent);
6340 glSetUniformStack.Reset();
6342 application.Render();
6343 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6345 // Test order of uniforms in stack
6346 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6347 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6348 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6350 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6351 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6356 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6358 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6360 TestApplication application;
6362 Integration::Scene stage(application.GetScene());
6364 Actor parentA = Actor::New();
6365 Actor parentB = Actor::New();
6366 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6367 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6368 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6369 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6371 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6372 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6374 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6375 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6380 Actor actorA = Actor::New();
6381 Actor actorB = Actor::New();
6382 Actor actorC = Actor::New();
6384 parentA.Add(actorA);
6385 parentA.Add(actorB);
6387 tet_printf("Actor C added to different parent from A and B \n");
6388 parentB.Add(actorC);
6390 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6391 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6393 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6394 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6396 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6397 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6399 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6400 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6402 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6403 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6405 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6406 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6408 ResetTouchCallbacks();
6410 // Connect ChildOrderChangedSignal
6411 bool orderChangedSignal(false);
6412 Actor orderChangedActor;
6413 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6414 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6416 application.SendNotification();
6417 application.Render();
6419 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6420 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6421 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6423 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6424 // Only top actor will get touched.
6425 actorA.TouchedSignal().Connect(TestTouchCallback);
6426 actorB.TouchedSignal().Connect(TestTouchCallback2);
6427 actorC.TouchedSignal().Connect(TestTouchCallback3);
6429 Dali::Integration::Point point;
6430 point.SetDeviceId(1);
6431 point.SetState(PointState::DOWN);
6432 point.SetScreenPosition(Vector2(10.f, 10.f));
6433 Dali::Integration::TouchEvent touchEvent;
6434 touchEvent.AddPoint(point);
6436 application.ProcessEvent(touchEvent);
6438 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6439 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6440 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6442 ResetTouchCallbacks();
6444 tet_printf("Raise actor A Above Actor C which have different parents\n");
6446 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6447 actorA.RaiseAbove(actorC);
6448 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6450 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6451 application.SendNotification();
6453 application.ProcessEvent(touchEvent); // touch event
6455 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6456 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6457 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6459 ResetTouchCallbacks();
6464 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6466 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
6468 TestApplication application;
6470 Integration::Scene stage(application.GetScene());
6472 Actor actorA = Actor::New();
6473 Actor actorB = Actor::New();
6474 Actor actorC = Actor::New();
6476 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6477 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6479 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6480 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6482 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6483 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6485 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6486 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6488 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6489 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6491 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6492 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6494 ResetTouchCallbacks();
6496 // Connect ChildOrderChangedSignal
6497 bool orderChangedSignal(false);
6498 Actor orderChangedActor;
6499 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6500 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6502 application.SendNotification();
6503 application.Render();
6505 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6506 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6507 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6509 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6510 // Only top actor will get touched.
6511 actorA.TouchedSignal().Connect(TestTouchCallback);
6512 actorB.TouchedSignal().Connect(TestTouchCallback2);
6513 actorC.TouchedSignal().Connect(TestTouchCallback3);
6515 Dali::Integration::Point point;
6516 point.SetDeviceId(1);
6517 point.SetState(PointState::DOWN);
6518 point.SetScreenPosition(Vector2(10.f, 10.f));
6519 Dali::Integration::TouchEvent touchEvent;
6520 touchEvent.AddPoint(point);
6522 tet_printf("Raise actor A Above Actor C which have no parents\n");
6524 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6525 actorA.RaiseAbove(actorC);
6526 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6528 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6529 application.SendNotification();
6531 application.ProcessEvent(touchEvent);
6533 tet_printf("Not parented so RaiseAbove should show no effect\n");
6535 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6536 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6537 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6539 ResetTouchCallbacks();
6541 orderChangedSignal = false;
6544 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6546 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6547 actorA.LowerBelow(actorC);
6548 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6550 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6551 application.SendNotification();
6552 application.Render();
6554 application.ProcessEvent(touchEvent);
6556 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6557 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6558 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6559 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6561 ResetTouchCallbacks();
6563 orderChangedSignal = false;
6565 tet_printf("Adding Actor A to stage, will be on top\n");
6568 application.SendNotification();
6569 application.Render();
6571 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6573 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6574 actorB.RaiseAbove(actorC);
6575 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6577 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6578 application.SendNotification();
6580 application.ProcessEvent(touchEvent);
6582 tet_printf("C not parented so RaiseAbove should show no effect\n");
6583 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6584 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6585 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6587 ResetTouchCallbacks();
6589 orderChangedSignal = false;
6591 tet_printf("Lower actor A below Actor C when only A has a parent\n");
6593 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6594 actorA.LowerBelow(actorC);
6595 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6597 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6598 application.SendNotification();
6600 application.ProcessEvent(touchEvent);
6602 tet_printf("C not parented so LowerBelow should show no effect\n");
6603 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6604 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6605 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6607 ResetTouchCallbacks();
6609 orderChangedSignal = false;
6613 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6614 actorA.RaiseAbove(actorC);
6615 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6616 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6618 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6619 application.SendNotification();
6620 application.Render();
6622 application.ProcessEvent(touchEvent);
6624 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6625 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6626 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6627 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6632 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6634 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6636 TestApplication application;
6638 Integration::Scene stage(application.GetScene());
6640 Actor actorA = Actor::New();
6641 Actor actorB = Actor::New();
6642 Actor actorC = Actor::New();
6644 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6645 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6647 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6648 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6650 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6651 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6653 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6654 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6656 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6657 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6659 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6660 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6662 ResetTouchCallbacks();
6664 // Connect ChildOrderChangedSignal
6665 bool orderChangedSignal(false);
6666 Actor orderChangedActor;
6667 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6668 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6670 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6671 // Only top actor will get touched.
6672 actorA.TouchedSignal().Connect(TestTouchCallback);
6673 actorB.TouchedSignal().Connect(TestTouchCallback2);
6674 actorC.TouchedSignal().Connect(TestTouchCallback3);
6676 Dali::Integration::Point point;
6677 point.SetDeviceId(1);
6678 point.SetState(PointState::DOWN);
6679 point.SetScreenPosition(Vector2(10.f, 10.f));
6680 Dali::Integration::TouchEvent touchEvent;
6681 touchEvent.AddPoint(point);
6684 tet_printf("Raise actor B Above Actor C but B not parented\n");
6686 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6688 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6690 application.SendNotification();
6691 application.Render();
6693 application.ProcessEvent(touchEvent);
6695 tet_printf("Not parented so RaiseAbove should show no effect\n");
6697 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6698 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6699 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6701 tet_printf("Raise actor B Above Actor C but B not parented\n");
6702 ResetTouchCallbacks();
6704 orderChangedSignal = false;
6706 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6708 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6710 // Sort actor tree before next touch event
6711 application.SendNotification();
6712 application.Render();
6714 application.ProcessEvent(touchEvent);
6716 tet_printf("Not parented so RaiseAbove should show no effect\n");
6718 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6719 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6720 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6721 ResetTouchCallbacks();
6723 orderChangedSignal = false;
6725 tet_printf("Lower actor C below B but C not parented\n");
6727 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6729 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6731 // Sort actor tree before next touch event
6732 application.SendNotification();
6733 application.Render();
6735 application.ProcessEvent(touchEvent);
6737 tet_printf("Not parented so Lower should show no effect\n");
6739 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6740 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6741 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6742 ResetTouchCallbacks();
6744 orderChangedSignal = false;
6746 tet_printf("Raise actor B to top\n");
6748 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6749 actorB.RaiseToTop();
6750 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6752 // Sort actor tree before next touch event
6753 application.SendNotification();
6754 application.Render();
6756 application.ProcessEvent(touchEvent);
6758 tet_printf("Not parented so RaiseToTop should show no effect\n");
6760 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6761 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6762 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6763 ResetTouchCallbacks();
6765 orderChangedSignal = false;
6767 tet_printf("Add ActorB to stage so only Actor C not parented\n");
6771 tet_printf("Lower actor C to Bottom, B stays at top\n");
6773 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6774 actorC.LowerToBottom();
6775 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6777 application.SendNotification();
6778 application.Render();
6780 application.ProcessEvent(touchEvent);
6782 tet_printf("Not parented so LowerToBottom should show no effect\n");
6784 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6785 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6786 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6787 ResetTouchCallbacks();
6792 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6794 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
6796 TestApplication application;
6798 Integration::Scene stage(application.GetScene());
6800 Actor actorA = Actor::New();
6801 Actor actorB = Actor::New();
6802 Actor actorC = Actor::New();
6804 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6805 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6807 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6808 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6810 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6811 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6813 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6814 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6816 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6817 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6819 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6820 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6826 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6827 // Only top actor will get touched.
6828 actorA.TouchedSignal().Connect(TestTouchCallback);
6829 actorB.TouchedSignal().Connect(TestTouchCallback2);
6830 actorC.TouchedSignal().Connect(TestTouchCallback3);
6832 ResetTouchCallbacks();
6834 // Connect ChildOrderChangedSignal
6835 bool orderChangedSignal(false);
6836 Actor orderChangedActor;
6837 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6838 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6840 application.SendNotification();
6841 application.Render();
6843 Dali::Integration::Point point;
6844 point.SetDeviceId(1);
6845 point.SetState(PointState::DOWN);
6846 point.SetScreenPosition(Vector2(10.f, 10.f));
6847 Dali::Integration::TouchEvent touchEvent;
6848 touchEvent.AddPoint(point);
6850 application.ProcessEvent(touchEvent);
6852 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6853 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6854 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6856 ResetTouchCallbacks();
6858 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6860 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6861 actorA.RaiseAbove(actorA);
6862 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6863 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6865 application.SendNotification();
6866 application.Render();
6868 application.ProcessEvent(touchEvent);
6870 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6872 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6873 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6874 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6876 ResetTouchCallbacks();
6878 orderChangedSignal = false;
6880 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6881 actorA.RaiseAbove(actorC);
6882 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6883 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6885 application.SendNotification();
6886 application.Render();
6888 application.ProcessEvent(touchEvent);
6890 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6891 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6892 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6893 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6898 int UtcDaliActorGetScreenPosition(void)
6900 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6902 TestApplication application;
6904 Integration::Scene stage(application.GetScene());
6906 Actor actorA = Actor::New();
6907 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6909 Vector2 size2(10.0f, 20.0f);
6910 actorA.SetProperty(Actor::Property::SIZE, size2);
6912 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6914 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6918 application.SendNotification();
6919 application.Render();
6921 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6922 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6924 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6925 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6927 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6928 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6930 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6932 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6934 application.SendNotification();
6935 application.Render();
6937 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6938 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6940 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6941 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6943 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6944 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6946 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6948 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6950 application.SendNotification();
6951 application.Render();
6953 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6954 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6956 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6957 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6959 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6960 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6962 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6964 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6966 application.SendNotification();
6967 application.Render();
6969 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6970 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6972 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6973 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6975 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6976 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6978 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6980 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6982 application.SendNotification();
6983 application.Render();
6985 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6986 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6988 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6989 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6991 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6992 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6994 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6996 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6997 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6999 Actor actorB = Actor::New();
7000 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7001 actorB.SetProperty(Actor::Property::SIZE, size2);
7002 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
7005 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7007 application.SendNotification();
7008 application.Render();
7010 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7012 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
7013 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
7018 int UtcDaliActorGetScreenPositionAfterScaling(void)
7020 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
7022 TestApplication application;
7024 Integration::Scene stage(application.GetScene());
7026 Actor actorA = Actor::New();
7027 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7029 Vector2 size2(10.0f, 20.0f);
7030 actorA.SetProperty(Actor::Property::SIZE, size2);
7031 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
7032 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7034 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
7038 application.SendNotification();
7039 application.Render();
7041 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7042 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7044 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7045 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7047 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7048 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7050 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
7052 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7054 application.SendNotification();
7055 application.Render();
7057 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7058 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7060 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7061 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7063 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
7064 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7069 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
7071 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
7073 TestApplication application;
7075 Integration::Scene stage(application.GetScene());
7077 Actor actorA = Actor::New();
7078 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7079 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7080 Vector2 size2(10.0f, 20.0f);
7081 actorA.SetProperty(Actor::Property::SIZE, size2);
7082 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7084 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7088 application.SendNotification();
7089 application.Render();
7091 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7092 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7094 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7095 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7097 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
7098 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
7100 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
7102 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
7103 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7105 application.SendNotification();
7106 application.Render();
7108 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7109 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7111 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7112 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7114 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
7115 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7121 int UtcDaliActorGetScreenPositionWithChildActors(void)
7123 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
7125 TestApplication application;
7127 Integration::Scene stage(application.GetScene());
7129 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7131 Actor actorA = Actor::New();
7132 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7133 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7134 Vector2 size1(10.0f, 20.0f);
7135 actorA.SetProperty(Actor::Property::SIZE, size1);
7136 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7138 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7140 Actor parentActorA = Actor::New();
7141 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7142 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7143 Vector2 size2(30.0f, 60.0f);
7144 parentActorA.SetProperty(Actor::Property::SIZE, size2);
7145 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7147 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7149 stage.Add(parentActorA);
7150 parentActorA.Add(actorA);
7152 application.SendNotification();
7153 application.Render();
7155 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7156 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7158 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7159 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7161 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
7162 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
7164 tet_infoline("Test 2\n");
7166 tet_infoline("change parent anchor point and parent origin then check screen position \n");
7168 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7169 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
7171 application.SendNotification();
7172 application.Render();
7174 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7175 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7177 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7178 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7180 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
7181 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
7186 int UtcDaliActorGetScreenPositionWithChildActors02(void)
7188 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
7190 TestApplication application;
7192 Integration::Scene stage(application.GetScene());
7194 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7196 Actor actorA = Actor::New();
7197 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7198 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7199 Vector2 size1(10.0f, 20.0f);
7200 actorA.SetProperty(Actor::Property::SIZE, size1);
7201 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7203 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7205 Actor parentActorA = Actor::New();
7206 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7207 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7208 Vector2 size2(30.0f, 60.0f);
7209 parentActorA.SetProperty(Actor::Property::SIZE, size2);
7210 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7212 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
7214 Actor grandParentActorA = Actor::New();
7215 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7216 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
7217 Vector2 size3(60.0f, 120.0f);
7218 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
7219 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7221 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
7223 stage.Add(grandParentActorA);
7224 grandParentActorA.Add(parentActorA);
7226 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7228 parentActorA.Add(actorA);
7230 application.SendNotification();
7231 application.Render();
7233 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7234 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7236 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7237 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7239 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
7240 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
7245 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
7247 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
7249 TestApplication application;
7251 Integration::Scene stage(application.GetScene());
7253 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7255 Actor actorA = Actor::New();
7256 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7257 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7258 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7259 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
7262 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7264 Actor actorB = Actor::New();
7265 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7266 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7267 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7268 Vector2 actorBSize(30.0f, 60.0f);
7269 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7272 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7274 Actor actorC = Actor::New();
7275 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7276 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7277 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7278 Vector2 actorCSize(60.0f, 120.0f);
7279 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7282 application.SendNotification();
7283 application.Render();
7285 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7287 Vector2 center(stage.GetSize() * 0.5f);
7289 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7290 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7291 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7293 tet_infoline("Add scale to all actors");
7295 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7296 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7297 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7299 application.SendNotification();
7300 application.Render();
7302 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7303 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7304 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7309 int UtcDaliActorGetScreenPositionResizeScene(void)
7311 tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
7313 TestApplication application;
7314 Integration::Scene scene = application.GetScene();
7316 Actor actorA = Actor::New();
7317 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7318 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7319 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7323 application.SendNotification();
7324 application.Render();
7326 Vector2 sceneSize = scene.GetSize();
7327 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7329 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7332 Vector2 newSize(1000.0f, 2000.0f);
7333 DALI_TEST_CHECK(scene.GetSize() != newSize);
7335 scene.SurfaceResized(newSize.width, newSize.height);
7337 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7339 // The screen position should not be updated yet
7340 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7342 application.SendNotification();
7343 application.Render();
7345 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7347 // The screen position should be updated
7348 sceneSize = scene.GetSize();
7349 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7354 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
7356 tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
7358 TestApplication application;
7359 Integration::Scene scene = application.GetScene();
7362 Layer layer = scene.GetRootLayer();
7363 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
7365 // Build custom camera with top-view
7366 CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
7368 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
7369 Vector3 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7370 Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7373 std::ostringstream oss;
7374 oss << cameraPos << "\n";
7375 oss << cameraOrient << "\n";
7376 tet_printf("%s\n", oss.str().c_str());
7379 cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
7380 cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
7382 // Now, upside : -Z, leftside : -X, foward : +Y
7384 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7385 cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7387 std::ostringstream oss;
7388 oss << cameraPos << "\n";
7389 oss << cameraOrient << "\n";
7390 tet_printf("%s\n", oss.str().c_str());
7394 Actor actorA = Actor::New();
7395 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7396 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7397 actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7398 actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
7400 Actor actorB = Actor::New();
7401 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7402 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7403 actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7404 actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
7409 application.SendNotification();
7410 application.Render();
7412 Vector2 sceneSize = scene.GetSize();
7413 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7415 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
7417 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7419 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
7424 int utcDaliActorPositionUsesAnchorPoint(void)
7426 TestApplication application;
7427 tet_infoline("Check default behaviour\n");
7429 Actor actor = Actor::New();
7430 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7431 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7432 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7433 application.GetScene().Add(actor);
7435 application.SendNotification();
7436 application.Render();
7438 tet_infoline("Check that the world position is in the center\n");
7439 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7441 tet_infoline("Set the position uses anchor point property to false\n");
7442 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7444 application.SendNotification();
7445 application.Render();
7447 tet_infoline("Check that the world position has changed appropriately\n");
7448 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7453 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7455 TestApplication application;
7456 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7458 Actor actor = Actor::New();
7459 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7460 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7461 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7462 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7463 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7464 application.GetScene().Add(actor);
7466 application.SendNotification();
7467 application.Render();
7469 tet_infoline("Check the world position is the same as it would be without a scale\n");
7470 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7472 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7473 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7474 application.SendNotification();
7475 application.Render();
7476 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7478 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7479 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7480 application.SendNotification();
7481 application.Render();
7482 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7487 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7489 TestApplication application;
7490 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7492 Actor actor = Actor::New();
7493 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7494 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7495 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7496 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7497 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7498 application.GetScene().Add(actor);
7500 application.SendNotification();
7501 application.Render();
7503 tet_infoline("Check the world position is the same as it would be without a rotation\n");
7504 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7506 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7507 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7508 application.SendNotification();
7509 application.Render();
7510 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7512 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7513 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7514 application.SendNotification();
7515 application.Render();
7516 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7521 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7523 TestApplication application;
7524 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7526 Actor actor = Actor::New();
7527 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7528 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7529 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7530 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7531 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7532 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7533 application.GetScene().Add(actor);
7535 application.SendNotification();
7536 application.Render();
7538 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7539 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7541 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7542 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7543 application.SendNotification();
7544 application.Render();
7545 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7547 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7548 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7549 application.SendNotification();
7550 application.Render();
7551 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7556 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7558 TestApplication application;
7559 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7561 Actor parent = Actor::New();
7563 application.GetScene().Add(parent);
7564 Vector2 stageSize(application.GetScene().GetSize());
7566 Actor actor = Actor::New();
7567 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7568 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7569 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7570 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7571 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7572 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7575 application.SendNotification();
7576 application.Render();
7578 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7580 tet_infoline("Check the world position is in the right place\n");
7581 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7583 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7584 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7585 application.SendNotification();
7586 application.Render();
7587 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7589 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7590 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7591 application.SendNotification();
7592 application.Render();
7593 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7598 int utcDaliActorVisibilityChangeSignalSelf(void)
7600 TestApplication application;
7601 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7603 Actor actor = Actor::New();
7605 VisibilityChangedFunctorData data;
7606 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7608 actor.SetProperty(Actor::Property::VISIBLE, false);
7610 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7612 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7615 actor.SetProperty(Actor::Property::VISIBLE, false);
7616 data.Check(false /* not called */, TEST_LOCATION);
7618 tet_infoline("Change the visibility using properties, ensure called");
7621 actor.SetProperty(Actor::Property::VISIBLE, true);
7622 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7624 tet_infoline("Set the visibility to current using properties, ensure not called");
7627 actor.SetProperty(Actor::Property::VISIBLE, true);
7628 data.Check(false /* not called */, TEST_LOCATION);
7633 int utcDaliActorVisibilityChangeSignalChildren(void)
7635 TestApplication application;
7636 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7638 Actor parent = Actor::New();
7639 Actor child = Actor::New();
7642 Actor grandChild = Actor::New();
7643 child.Add(grandChild);
7645 VisibilityChangedFunctorData parentData;
7646 VisibilityChangedFunctorData childData;
7647 VisibilityChangedFunctorData grandChildData;
7649 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7650 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7651 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7653 parent.SetProperty(Actor::Property::VISIBLE, false);
7654 parentData.Check(false /* not called */, TEST_LOCATION);
7655 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7656 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7658 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7661 grandChildData.Reset();
7663 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7665 parent.SetProperty(Actor::Property::VISIBLE, true);
7666 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7667 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7668 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7670 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7673 grandChildData.Reset();
7675 parent.SetProperty(Actor::Property::VISIBLE, true);
7676 parentData.Check(false /* not called */, TEST_LOCATION);
7677 childData.Check(false /* not called */, TEST_LOCATION);
7678 grandChildData.Check(false /* not called */, TEST_LOCATION);
7683 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7685 TestApplication application;
7686 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7688 Actor actor = Actor::New();
7689 application.GetScene().Add(actor);
7691 application.SendNotification();
7692 application.Render();
7694 VisibilityChangedFunctorData data;
7695 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7697 Animation animation = Animation::New(1.0f);
7698 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7700 data.Check(false, TEST_LOCATION);
7701 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7702 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7704 tet_infoline("Play the animation and check the property value");
7707 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7708 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7710 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7711 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7713 application.SendNotification();
7714 application.Render(1100); // After the animation
7716 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7721 int utcDaliActorVisibilityChangeSignalByName(void)
7723 TestApplication application;
7724 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7726 Actor actor = Actor::New();
7728 bool signalCalled = false;
7729 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7730 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7731 actor.SetProperty(Actor::Property::VISIBLE, false);
7732 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7734 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7735 signalCalled = false;
7736 actor.SetProperty(Actor::Property::VISIBLE, false);
7737 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7739 tet_infoline("Change the visibility using properties, ensure called");
7740 actor.SetProperty(Actor::Property::VISIBLE, true);
7741 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7743 tet_infoline("Set the visibility to current using properties, ensure not called");
7744 signalCalled = false;
7746 actor.SetProperty(Actor::Property::VISIBLE, true);
7747 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7752 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7754 gLayoutDirectionType = type;
7757 int UtcDaliActorLayoutDirectionProperty(void)
7759 TestApplication application;
7760 tet_infoline("Check layout direction property");
7762 Actor actor0 = Actor::New();
7763 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7764 application.GetScene().Add(actor0);
7766 application.SendNotification();
7767 application.Render();
7769 Actor actor1 = Actor::New();
7770 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7771 Actor actor2 = Actor::New();
7772 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7773 Actor actor3 = Actor::New();
7774 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7775 Actor actor4 = Actor::New();
7776 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7777 Actor actor5 = Actor::New();
7778 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7779 Actor actor6 = Actor::New();
7780 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7781 Actor actor7 = Actor::New();
7782 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7783 Actor actor8 = Actor::New();
7784 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7785 Actor actor9 = Actor::New();
7786 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7789 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7790 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7792 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7793 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7794 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7796 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7797 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7798 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7800 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7802 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7803 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7805 application.GetScene().Add(actor3);
7812 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7813 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7815 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7816 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7817 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7819 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7821 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7822 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7823 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7824 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7825 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7826 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7827 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7829 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7830 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7831 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7833 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7834 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7835 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7836 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7838 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7839 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7840 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7845 struct LayoutDirectionFunctor
7847 LayoutDirectionFunctor(bool& signalCalled)
7848 : mSignalCalled(signalCalled)
7852 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7853 : mSignalCalled(rhs.mSignalCalled)
7859 mSignalCalled = true;
7862 bool& mSignalCalled;
7865 int UtcDaliActorLayoutDirectionSignal(void)
7867 TestApplication application;
7868 tet_infoline("Check changing layout direction property sends a signal");
7870 Actor actor = Actor::New();
7871 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7872 application.GetScene().Add(actor);
7873 bool signalCalled = false;
7874 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7876 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7877 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7879 // Test that writing the same value doesn't send a signal
7880 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7881 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7883 // Test that writing a different value sends the signal
7884 signalCalled = false;
7885 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7886 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7888 signalCalled = false;
7889 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7890 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7895 struct ChildAddedSignalCheck
7897 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7898 : mSignalReceived(signalReceived),
7899 mChildHandle(childHandle)
7903 void operator()(Actor childHandle)
7905 mSignalReceived = true;
7906 mChildHandle = childHandle;
7910 mSignalReceived = true;
7911 mChildHandle = Actor();
7914 bool& mSignalReceived;
7915 Actor& mChildHandle;
7918 int UtcDaliChildAddedSignalP1(void)
7920 TestApplication application;
7921 auto stage = application.GetScene();
7923 bool signalReceived = false;
7926 ChildAddedSignalCheck signal(signalReceived, childActor);
7927 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7928 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7930 auto actorA = Actor::New();
7932 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7933 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7934 signalReceived = false;
7936 auto actorB = Actor::New();
7938 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7939 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7944 int UtcDaliChildAddedSignalP2(void)
7946 TestApplication application;
7947 auto stage = application.GetScene();
7949 bool signalReceived = false;
7952 ChildAddedSignalCheck signal(signalReceived, childActor);
7953 tet_infoline("Connect to childAdded signal by name");
7955 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7956 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7958 auto actorA = Actor::New();
7960 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7962 // Can't test which actor was added; signal signature is void() when connecting via name.
7963 signalReceived = false;
7965 auto actorB = Actor::New();
7967 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7972 int UtcDaliChildAddedSignalN(void)
7974 TestApplication application;
7975 auto stage = application.GetScene();
7977 bool signalReceived = false;
7980 ChildAddedSignalCheck signal(signalReceived, childActor);
7981 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7982 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7984 auto actorA = Actor::New();
7986 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7987 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7988 signalReceived = false;
7990 auto actorB = Actor::New();
7992 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7996 struct ChildRemovedSignalCheck
7998 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7999 : mSignalReceived(signalReceived),
8000 mChildHandle(childHandle)
8004 void operator()(Actor childHandle)
8006 mSignalReceived = true;
8007 mChildHandle = childHandle;
8012 mSignalReceived = true;
8015 bool& mSignalReceived;
8016 Actor& mChildHandle;
8019 int UtcDaliChildRemovedSignalP1(void)
8021 TestApplication application;
8022 auto stage = application.GetScene();
8024 bool signalReceived = false;
8027 ChildRemovedSignalCheck signal(signalReceived, childActor);
8028 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8029 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8031 auto actorA = Actor::New();
8033 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8034 DALI_TEST_CHECK(!childActor);
8036 stage.Remove(actorA);
8037 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8038 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8040 signalReceived = false;
8041 auto actorB = Actor::New();
8043 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8045 stage.Remove(actorB);
8046 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8047 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8052 int UtcDaliChildRemovedSignalP2(void)
8054 TestApplication application;
8055 auto stage = application.GetScene();
8057 bool signalReceived = false;
8060 ChildAddedSignalCheck signal(signalReceived, childActor);
8061 tet_infoline("Connect to childRemoved signal by name");
8063 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
8064 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8066 auto actorA = Actor::New();
8068 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8070 stage.Remove(actorA);
8071 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8073 signalReceived = false;
8074 auto actorB = Actor::New();
8076 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8078 stage.Remove(actorB);
8079 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8084 int UtcDaliChildRemovedSignalN(void)
8086 TestApplication application;
8087 auto stage = application.GetScene();
8089 bool signalReceived = false;
8092 ChildRemovedSignalCheck signal(signalReceived, childActor);
8093 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8094 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8096 auto actorA = Actor::New();
8099 auto actorB = Actor::New();
8102 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8103 DALI_TEST_CHECK(!childActor);
8105 actorA.Remove(actorB);
8106 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8110 int UtcDaliChildMovedSignalP(void)
8112 TestApplication application;
8113 auto stage = application.GetScene();
8115 bool addedASignalReceived = false;
8116 bool removedASignalReceived = false;
8117 bool addedBSignalReceived = false;
8118 bool removedBSignalReceived = false;
8121 auto actorA = Actor::New();
8122 auto actorB = Actor::New();
8126 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
8127 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
8128 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
8129 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
8131 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
8132 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
8133 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
8134 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
8136 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8137 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8138 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8139 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8141 // Create a child of A
8143 auto child = Actor::New();
8146 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8147 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8148 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8149 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8150 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
8153 addedASignalReceived = false;
8154 addedBSignalReceived = false;
8155 removedASignalReceived = false;
8156 removedBSignalReceived = false;
8158 actorB.Add(child); // Expect this child to be re-parented
8159 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8160 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
8161 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
8162 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8164 // Move child back to A:
8165 addedASignalReceived = false;
8166 addedBSignalReceived = false;
8167 removedASignalReceived = false;
8168 removedBSignalReceived = false;
8170 actorA.Add(child); // Expect this child to be re-parented
8171 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8172 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8173 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8174 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
8179 int UtcDaliActorSwitchParentP(void)
8181 tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
8182 TestApplication application;
8184 Actor parent1 = Actor::New();
8185 Actor child = Actor::New();
8187 application.GetScene().Add(parent1);
8189 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8191 child.OnSceneSignal().Connect(OnSceneCallback);
8192 child.OffSceneSignal().Connect(OffSceneCallback);
8195 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
8196 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8200 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
8202 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8203 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8205 Actor parent2 = Actor::New();
8206 application.GetScene().Add(parent2);
8208 bool addSignalReceived = false;
8209 ChildAddedSignalCheck addedSignal(addSignalReceived, child);
8210 DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
8211 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8213 bool removedSignalReceived = false;
8214 ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
8215 DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
8216 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8218 DevelActor::SwitchParent(child, parent2);
8220 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8221 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8223 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8224 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
8226 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8227 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8228 DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
8229 DALI_TEST_CHECK(child.GetParent() == parent2);
8234 int utcDaliActorCulled(void)
8236 TestApplication application;
8237 auto stage = application.GetScene();
8239 tet_infoline("Check that the actor is culled if the actor is out of the screen");
8241 Actor actor = Actor::New();
8242 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
8244 Geometry geometry = CreateQuadGeometry();
8245 Shader shader = CreateShader();
8246 Renderer renderer = Renderer::New(geometry, shader);
8247 actor.AddRenderer(renderer);
8251 application.SendNotification();
8252 application.Render(0);
8254 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
8256 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
8257 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
8259 // Connect NotifySignal
8260 bool propertyNotificationSignal(false);
8261 PropertyNotification source;
8262 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
8263 notification.NotifySignal().Connect(&application, f);
8265 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
8267 application.SendNotification();
8268 application.Render();
8270 application.SendNotification();
8272 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
8274 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
8275 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
8276 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
8281 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
8283 TestApplication application;
8284 auto stage = application.GetScene();
8286 tet_infoline("Ensure we clear the screen when the last actor is removed");
8288 Actor actor = CreateRenderableActor();
8289 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8292 application.SendNotification();
8293 application.Render();
8295 auto& glAbstraction = application.GetGlAbstraction();
8296 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8300 application.SendNotification();
8301 application.Render();
8303 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8308 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
8310 TestApplication application;
8311 auto stage = application.GetScene();
8313 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
8315 Actor actor = CreateRenderableActor();
8316 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8319 application.SendNotification();
8320 application.Render();
8322 auto& glAbstraction = application.GetGlAbstraction();
8323 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8325 actor.SetProperty(Actor::Property::VISIBLE, false);
8327 application.SendNotification();
8328 application.Render();
8330 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8335 int utcDaliActorGetSizeAfterAnimation(void)
8337 TestApplication application;
8338 tet_infoline("Check the actor size before / after an animation is finished");
8340 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8342 Actor actor = Actor::New();
8343 actor.SetProperty(Actor::Property::SIZE, actorSize);
8344 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8345 application.GetScene().Add(actor);
8347 // Size should be updated without rendering.
8348 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8349 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8351 application.SendNotification();
8352 application.Render();
8354 // Size and current size should be updated.
8355 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8356 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8357 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8358 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8359 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8361 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8362 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8363 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8364 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8365 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8368 actorSize = Vector3(200.0f, 200.0f, 0.0f);
8369 actor.SetProperty(Actor::Property::SIZE, actorSize);
8371 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8372 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8374 Vector3 targetValue(10.0f, 20.0f, 0.0f);
8376 Animation animation = Animation::New(1.0f);
8377 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8380 // Size should be updated without rendering.
8381 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8382 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8384 application.SendNotification();
8385 application.Render(1100); // After the animation
8387 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8388 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8389 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8390 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8391 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8393 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8394 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8395 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8396 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8397 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8399 targetValue.width = 50.0f;
8402 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8405 application.SendNotification();
8406 application.Render(1100); // After the animation
8408 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8409 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8410 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8411 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8412 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8414 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8415 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8416 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8417 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8418 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8420 targetValue.height = 70.0f;
8423 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8426 application.SendNotification();
8427 application.Render(1100); // After the animation
8429 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8430 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8431 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8432 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8433 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8435 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8436 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8437 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8438 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8439 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8441 Vector3 offset(10.0f, 20.0f, 0.0f);
8444 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8447 application.SendNotification();
8448 application.Render(1100); // After the animation
8450 targetValue += offset;
8452 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8453 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8454 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8455 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8456 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8458 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8459 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8460 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8461 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8462 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8464 offset.width = 20.0f;
8467 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8470 application.SendNotification();
8471 application.Render(1100); // After the animation
8473 targetValue.width += offset.width;
8475 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8476 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8477 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8478 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8479 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8481 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8482 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8483 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8484 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8485 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8487 offset.height = 10.0f;
8490 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8493 application.SendNotification();
8494 application.Render(1100); // After the animation
8496 targetValue.height += offset.height;
8498 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8499 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8500 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8501 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8502 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8504 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8505 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8506 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8507 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8508 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8511 actorSize = Vector3(300.0f, 300.0f, 0.0f);
8513 actor.SetProperty(Actor::Property::SIZE, actorSize);
8515 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8516 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8518 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8519 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8521 application.SendNotification();
8522 application.Render();
8524 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8525 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8527 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8528 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8533 int utcDaliActorRelayoutAndAnimation(void)
8535 TestApplication application;
8536 tet_infoline("Check the actor size when relayoutting and playing animation");
8538 Vector3 parentSize(300.0f, 300.0f, 0.0f);
8539 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8542 Actor parentA = Actor::New();
8543 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8544 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8545 application.GetScene().Add(parentA);
8547 Actor parentB = Actor::New();
8548 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8549 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8550 application.GetScene().Add(parentB);
8552 Actor actor = Actor::New();
8553 actor.SetProperty(Actor::Property::SIZE, actorSize);
8554 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8557 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8558 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8560 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8562 Animation animation = Animation::New(1.0f);
8563 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8566 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8567 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8569 application.SendNotification();
8570 application.Render(1100); // After the animation
8572 // Size and current size should be updated.
8573 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8574 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8576 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8577 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8582 application.SendNotification();
8583 application.Render();
8585 // Size and current size should be same.
8586 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8587 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8589 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8590 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8598 Actor parentA = Actor::New();
8599 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8600 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8601 application.GetScene().Add(parentA);
8603 Actor parentB = Actor::New();
8604 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8605 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8606 application.GetScene().Add(parentB);
8608 Actor actor = Actor::New();
8609 actor.SetProperty(Actor::Property::SIZE, actorSize);
8610 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8613 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8614 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8616 application.SendNotification();
8617 application.Render();
8619 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8620 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8622 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8623 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8625 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8627 // Make an animation
8628 Animation animation = Animation::New(1.0f);
8629 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8632 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8633 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8635 application.SendNotification();
8636 application.Render(1100); // After the animation
8638 // Size and current size should be updated.
8639 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8640 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8642 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8643 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8648 application.SendNotification();
8649 application.Render();
8651 // Size and current size should be same.
8652 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8653 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8655 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8656 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8666 int utcDaliActorPartialUpdate(void)
8668 TestApplication application(
8669 TestApplication::DEFAULT_SURFACE_WIDTH,
8670 TestApplication::DEFAULT_SURFACE_HEIGHT,
8671 TestApplication::DEFAULT_HORIZONTAL_DPI,
8672 TestApplication::DEFAULT_VERTICAL_DPI,
8676 tet_infoline("Check the damaged area");
8678 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8680 std::vector<Rect<int>> damagedRects;
8681 Rect<int> clippingRect;
8682 application.SendNotification();
8683 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8685 // First render pass, nothing to render, adaptor would just do swap buffer.
8686 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8688 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8689 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8691 Actor actor = CreateRenderableActor();
8692 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8693 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8694 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8695 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8696 application.GetScene().Add(actor);
8698 application.SendNotification();
8700 // 1. Actor added, damaged rect is added size of actor
8701 damagedRects.clear();
8702 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8703 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8706 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8707 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8708 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8709 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8710 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8711 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8712 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8715 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8716 application.SendNotification();
8718 damagedRects.clear();
8719 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8720 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8723 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
8724 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8725 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8726 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8727 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8728 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8729 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8731 // 3. Set new position
8732 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8733 application.SendNotification();
8735 damagedRects.clear();
8736 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8737 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8740 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
8741 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8742 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8743 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8744 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8745 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8746 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8748 application.GetScene().Remove(actor);
8749 application.SendNotification();
8751 // Actor removed, last a dirty rect is reported.
8752 damagedRects.clear();
8753 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8754 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8756 clippingRect = damagedRects[0];
8758 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8759 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
8761 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8762 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8763 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8764 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8765 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8770 int utcDaliActorPartialUpdateSetColor(void)
8772 TestApplication application(
8773 TestApplication::DEFAULT_SURFACE_WIDTH,
8774 TestApplication::DEFAULT_SURFACE_HEIGHT,
8775 TestApplication::DEFAULT_HORIZONTAL_DPI,
8776 TestApplication::DEFAULT_VERTICAL_DPI,
8780 tet_infoline("Check uniform update");
8782 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8784 std::vector<Rect<int>> damagedRects;
8785 Rect<int> clippingRect;
8786 application.SendNotification();
8787 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8789 // First render pass, nothing to render, adaptor would just do swap buffer.
8790 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8792 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8793 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8795 Actor actor = CreateRenderableActor();
8796 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8797 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8798 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8799 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8800 application.GetScene().Add(actor);
8802 application.SendNotification();
8804 // 1. Actor added, damaged rect is added size of actor
8805 damagedRects.clear();
8806 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8807 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8810 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8811 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8812 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8813 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8814 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8815 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8816 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8818 damagedRects.clear();
8819 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8820 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8822 damagedRects.clear();
8823 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8824 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8827 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8828 application.SendNotification();
8830 damagedRects.clear();
8831 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8832 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8835 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8836 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8837 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8838 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8839 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8840 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8841 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8846 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8847 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8848 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8849 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8850 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8851 " uniform mediump mat4 uLightCameraViewMatrix;\n"
8855 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8856 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
8857 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8860 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8861 "uniform lowp vec4 uShadowColor;\n"
8864 " lowp float alpha;\n"
8865 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8866 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8869 int utcDaliActorPartialUpdateSetProperty(void)
8871 TestApplication application(
8872 TestApplication::DEFAULT_SURFACE_WIDTH,
8873 TestApplication::DEFAULT_SURFACE_HEIGHT,
8874 TestApplication::DEFAULT_HORIZONTAL_DPI,
8875 TestApplication::DEFAULT_VERTICAL_DPI,
8879 tet_infoline("Set/Update property with partial update");
8881 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8883 std::vector<Rect<int>> damagedRects;
8884 Rect<int> clippingRect;
8885 application.SendNotification();
8886 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8888 // First render pass, nothing to render, adaptor would just do swap buffer.
8889 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8891 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8892 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8894 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8895 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8896 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8897 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8898 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8899 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8900 application.GetScene().Add(actor);
8902 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8904 damagedRects.clear();
8905 application.SendNotification();
8906 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8907 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8910 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8911 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8912 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8913 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8914 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8915 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8916 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8918 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8919 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8921 damagedRects.clear();
8922 application.SendNotification();
8923 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8924 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8926 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8927 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8928 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8929 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8930 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8931 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8933 // Should be no damage rects, nothing changed
8934 damagedRects.clear();
8935 application.SendNotification();
8936 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8937 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8939 // Should be 1 damage rect due to change in size
8940 damagedRects.clear();
8941 actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8942 application.SendNotification();
8943 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8944 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8946 clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8947 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8948 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8949 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8950 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8951 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8952 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8954 damagedRects.clear();
8955 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8956 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8961 int utcDaliActorPartialUpdateTwoActors(void)
8963 TestApplication application(
8964 TestApplication::DEFAULT_SURFACE_WIDTH,
8965 TestApplication::DEFAULT_SURFACE_HEIGHT,
8966 TestApplication::DEFAULT_HORIZONTAL_DPI,
8967 TestApplication::DEFAULT_VERTICAL_DPI,
8971 tet_infoline("Check the damaged rects with partial update and two actors");
8973 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8975 Actor actor = CreateRenderableActor();
8976 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8977 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8978 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8979 application.GetScene().Add(actor);
8981 Actor actor2 = CreateRenderableActor();
8982 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8983 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8984 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8985 application.GetScene().Add(actor2);
8987 application.SendNotification();
8988 std::vector<Rect<int>> damagedRects;
8989 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8991 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8992 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8993 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8995 // in screen coordinates, adaptor would calculate it using previous frames information
8996 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8997 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8999 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9000 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9001 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9002 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9004 // Change a Renderer of actor1
9005 Geometry geometry = CreateQuadGeometry();
9006 Shader shader = CreateShader();
9007 Renderer newRenderer = Renderer::New(geometry, shader);
9008 Renderer renderer = actor.GetRendererAt(0);
9010 actor.RemoveRenderer(renderer);
9011 actor.AddRenderer(newRenderer);
9013 damagedRects.clear();
9015 application.SendNotification();
9016 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9018 DALI_TEST_CHECK(damagedRects.size() > 0);
9019 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
9021 // in screen coordinates, adaptor would calculate it using previous frames information
9022 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9024 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9025 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9026 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9027 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9032 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
9034 TestApplication application(
9035 TestApplication::DEFAULT_SURFACE_WIDTH,
9036 TestApplication::DEFAULT_SURFACE_HEIGHT,
9037 TestApplication::DEFAULT_HORIZONTAL_DPI,
9038 TestApplication::DEFAULT_VERTICAL_DPI,
9042 tet_infoline("Check the damaged rect with partial update and actor size hint");
9044 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9046 Actor actor = CreateRenderableActor();
9047 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9048 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9049 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9050 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9051 application.GetScene().Add(actor);
9053 application.SendNotification();
9054 std::vector<Rect<int>> damagedRects;
9055 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9057 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9059 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9060 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9062 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9064 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9065 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9066 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9067 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9072 damagedRects.clear();
9073 application.SendNotification();
9074 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9076 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9077 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9079 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9081 damagedRects.clear();
9082 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9083 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9085 // Ensure the damaged rect is empty
9086 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9088 // Chnage UPDATE_AREA_HINT
9089 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
9090 application.GetScene().Add(actor);
9092 application.SendNotification();
9093 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9095 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9097 clippingRect = Rect<int>(64, 704, 48, 48);
9098 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9100 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9102 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9103 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9104 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9105 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9110 damagedRects.clear();
9111 application.SendNotification();
9112 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9114 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9115 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9117 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9119 damagedRects.clear();
9120 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9121 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9123 // Ensure the damaged rect is empty
9124 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9126 // Chnage UPDATE_AREA_HINT
9127 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
9128 application.GetScene().Add(actor);
9130 application.SendNotification();
9131 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9133 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9135 clippingRect = Rect<int>(0, 720, 80, 80);
9136 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9138 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9140 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9141 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9142 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9143 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9148 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
9150 TestApplication application(
9151 TestApplication::DEFAULT_SURFACE_WIDTH,
9152 TestApplication::DEFAULT_SURFACE_HEIGHT,
9153 TestApplication::DEFAULT_HORIZONTAL_DPI,
9154 TestApplication::DEFAULT_VERTICAL_DPI,
9158 tet_infoline("Check the damaged rect with partial update and actor size hint");
9160 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9162 Actor actor = CreateRenderableActor();
9163 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9164 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9165 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9166 application.GetScene().Add(actor);
9168 application.SendNotification();
9169 std::vector<Rect<int>> damagedRects;
9170 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9172 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9174 Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
9175 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9177 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9179 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9180 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9181 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9182 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9184 damagedRects.clear();
9185 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9186 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9188 // Ensure the damaged rect is empty
9189 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9191 // Chnage UPDATE_AREA_HINT
9192 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9194 application.SendNotification();
9195 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9197 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9199 clippingRect = Rect<int>(32, 704, 80, 80);
9200 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9202 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9204 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9205 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9206 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9207 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9209 damagedRects.clear();
9210 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9211 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9213 // Ensure the damaged rect is empty
9214 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9216 // Chnage UPDATE_AREA_HINT
9217 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
9218 application.GetScene().Add(actor);
9220 application.SendNotification();
9221 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9223 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9225 clippingRect = Rect<int>(32, 688, 96, 96);
9226 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9228 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9230 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9231 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9232 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9233 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9238 int utcDaliActorPartialUpdateAnimation(void)
9240 TestApplication application(
9241 TestApplication::DEFAULT_SURFACE_WIDTH,
9242 TestApplication::DEFAULT_SURFACE_HEIGHT,
9243 TestApplication::DEFAULT_HORIZONTAL_DPI,
9244 TestApplication::DEFAULT_VERTICAL_DPI,
9248 tet_infoline("Check the damaged area with partial update and animation");
9250 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9251 drawTrace.Enable(true);
9254 Actor actor1 = CreateRenderableActor();
9255 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9256 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9257 application.GetScene().Add(actor1);
9259 Actor actor2 = CreateRenderableActor();
9260 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9261 actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9262 application.GetScene().Add(actor2);
9264 std::vector<Rect<int>> damagedRects;
9265 Rect<int> clippingRect;
9266 Rect<int> expectedRect1, expectedRect2;
9268 application.SendNotification();
9269 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9271 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9274 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
9275 expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
9276 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9277 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
9279 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9280 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9282 // Make an animation
9283 Animation animation = Animation::New(1.0f);
9284 animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
9287 application.SendNotification();
9289 damagedRects.clear();
9290 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9291 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9292 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9295 damagedRects.clear();
9297 // In animation deley time
9298 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9299 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9300 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9303 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9306 damagedRects.clear();
9308 // Also in animation deley time
9309 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9310 application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
9311 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9314 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9316 // Unparent 2 actors and make a new actor
9320 Actor actor3 = CreateRenderableActor();
9321 actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9322 actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9323 application.GetScene().Add(actor3);
9325 application.SendNotification();
9327 // Started animation
9328 damagedRects.clear();
9329 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9330 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
9332 // The first dirty rect is actor3's.
9333 // We don't know the exact dirty rect of actor2
9334 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
9335 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
9337 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9338 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9340 // Finished animation, but the actor was already unparented
9341 damagedRects.clear();
9342 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9344 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9346 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9347 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9352 int utcDaliActorPartialUpdateChangeVisibility(void)
9354 TestApplication application(
9355 TestApplication::DEFAULT_SURFACE_WIDTH,
9356 TestApplication::DEFAULT_SURFACE_HEIGHT,
9357 TestApplication::DEFAULT_HORIZONTAL_DPI,
9358 TestApplication::DEFAULT_VERTICAL_DPI,
9362 tet_infoline("Check the damaged rect with partial update and visibility change");
9364 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9366 Actor actor = CreateRenderableActor();
9367 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9368 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9369 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9370 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9371 application.GetScene().Add(actor);
9373 application.SendNotification();
9375 std::vector<Rect<int>> damagedRects;
9376 Rect<int> clippingRect;
9378 // 1. Actor added, damaged rect is added size of actor
9379 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9380 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9383 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9384 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9385 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9386 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9387 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9388 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9389 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9391 damagedRects.clear();
9392 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9393 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9395 // Ensure the damaged rect is empty
9396 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9398 // 2. Make the Actor invisible
9399 actor.SetProperty(Actor::Property::VISIBLE, false);
9400 application.SendNotification();
9402 damagedRects.clear();
9403 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9404 DALI_TEST_CHECK(damagedRects.size() > 0);
9405 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9407 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9408 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9409 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9410 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9411 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9413 // 3. Make the Actor visible again
9414 actor.SetProperty(Actor::Property::VISIBLE, true);
9415 application.SendNotification();
9417 damagedRects.clear();
9418 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9419 DALI_TEST_CHECK(damagedRects.size() > 0);
9420 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9422 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9423 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9424 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9425 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9426 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9431 int utcDaliActorPartialUpdateOnOffScene(void)
9433 TestApplication application(
9434 TestApplication::DEFAULT_SURFACE_WIDTH,
9435 TestApplication::DEFAULT_SURFACE_HEIGHT,
9436 TestApplication::DEFAULT_HORIZONTAL_DPI,
9437 TestApplication::DEFAULT_VERTICAL_DPI,
9441 tet_infoline("Check the damaged rect with partial update and on/off scene");
9443 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9445 Actor actor = CreateRenderableActor();
9446 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9447 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9448 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9449 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9450 application.GetScene().Add(actor);
9452 application.SendNotification();
9454 std::vector<Rect<int>> damagedRects;
9455 Rect<int> clippingRect;
9457 // 1. Actor added, damaged rect is added size of actor
9458 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9459 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9462 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9463 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9464 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9465 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9466 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9467 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9468 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9470 damagedRects.clear();
9471 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9472 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9474 damagedRects.clear();
9475 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9476 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9478 // Ensure the damaged rect is empty
9479 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9481 // 2. Remove the Actor from the Scene
9483 application.SendNotification();
9485 damagedRects.clear();
9486 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9487 DALI_TEST_CHECK(damagedRects.size() > 0);
9488 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9490 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9491 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9492 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9493 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9494 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9496 // 3. Add the Actor to the Scene again
9497 application.GetScene().Add(actor);
9498 application.SendNotification();
9500 damagedRects.clear();
9501 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9502 DALI_TEST_CHECK(damagedRects.size() > 0);
9503 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9505 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9506 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9507 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9508 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9509 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9514 int utcDaliActorPartialUpdateSkipRendering(void)
9516 TestApplication application(
9517 TestApplication::DEFAULT_SURFACE_WIDTH,
9518 TestApplication::DEFAULT_SURFACE_HEIGHT,
9519 TestApplication::DEFAULT_HORIZONTAL_DPI,
9520 TestApplication::DEFAULT_VERTICAL_DPI,
9524 tet_infoline("Check to skip rendering in case of the empty damaged rect");
9526 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9527 drawTrace.Enable(true);
9530 Actor actor1 = CreateRenderableActor();
9531 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9532 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9533 application.GetScene().Add(actor1);
9535 std::vector<Rect<int>> damagedRects;
9536 Rect<int> clippingRect;
9537 Rect<int> expectedRect1;
9539 application.SendNotification();
9540 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9542 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9545 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
9546 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9548 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9549 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9551 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9553 damagedRects.clear();
9554 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9555 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9556 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9561 application.SendNotification();
9563 damagedRects.clear();
9564 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9566 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9568 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9569 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9571 // Render again without any change
9572 damagedRects.clear();
9574 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9576 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9578 clippingRect = Rect<int>();
9579 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9582 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9584 // Add the actor again
9585 application.GetScene().Add(actor1);
9587 application.SendNotification();
9589 damagedRects.clear();
9591 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9593 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9595 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9596 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9598 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9603 int utcDaliActorPartialUpdate3DNode(void)
9605 TestApplication application(
9606 TestApplication::DEFAULT_SURFACE_WIDTH,
9607 TestApplication::DEFAULT_SURFACE_HEIGHT,
9608 TestApplication::DEFAULT_HORIZONTAL_DPI,
9609 TestApplication::DEFAULT_VERTICAL_DPI,
9613 tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9615 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9616 drawTrace.Enable(true);
9619 Actor actor1 = CreateRenderableActor();
9620 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9621 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9622 application.GetScene().Add(actor1);
9624 std::vector<Rect<int>> damagedRects;
9625 Rect<int> clippingRect;
9627 application.SendNotification();
9628 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9630 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9632 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9633 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9635 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9637 // Change the layer to 3D
9638 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9640 application.SendNotification();
9642 damagedRects.clear();
9643 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9645 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9646 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9648 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9650 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9652 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9654 // Change the layer to 2D
9655 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9657 application.SendNotification();
9659 damagedRects.clear();
9660 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9662 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9664 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9665 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9667 // Make 3D transform
9668 actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9670 application.SendNotification();
9672 damagedRects.clear();
9673 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9675 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9676 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9678 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9680 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9682 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9687 int utcDaliActorPartialUpdateNotRenderableActor(void)
9689 TestApplication application(
9690 TestApplication::DEFAULT_SURFACE_WIDTH,
9691 TestApplication::DEFAULT_SURFACE_HEIGHT,
9692 TestApplication::DEFAULT_HORIZONTAL_DPI,
9693 TestApplication::DEFAULT_VERTICAL_DPI,
9697 tet_infoline("Check the damaged rect with not renderable parent actor");
9699 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9701 Actor parent = Actor::New();
9702 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9703 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9704 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9705 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9706 application.GetScene().Add(parent);
9708 Actor child = CreateRenderableActor();
9709 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9710 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9711 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9714 application.SendNotification();
9716 std::vector<Rect<int>> damagedRects;
9718 // 1. Actor added, damaged rect is added size of actor
9719 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9720 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9723 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9724 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9726 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9727 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9728 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9729 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9730 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9732 damagedRects.clear();
9733 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9734 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9736 damagedRects.clear();
9737 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9738 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9740 // Ensure the damaged rect is empty
9741 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9746 int utcDaliActorPartialUpdateChangeTransparency(void)
9748 TestApplication application(
9749 TestApplication::DEFAULT_SURFACE_WIDTH,
9750 TestApplication::DEFAULT_SURFACE_HEIGHT,
9751 TestApplication::DEFAULT_HORIZONTAL_DPI,
9752 TestApplication::DEFAULT_VERTICAL_DPI,
9756 tet_infoline("Check the damaged rect with changing transparency");
9758 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9760 Actor actor = CreateRenderableActor();
9761 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9762 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9763 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9764 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9765 application.GetScene().Add(actor);
9767 application.SendNotification();
9769 std::vector<Rect<int>> damagedRects;
9771 // Actor added, damaged rect is added size of actor
9772 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9773 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9776 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9777 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9779 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9780 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9781 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9782 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9783 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9785 damagedRects.clear();
9786 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9787 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9789 // Ensure the damaged rect is empty
9790 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9792 // Make the actor transparent by changing opacity of the Renderer
9793 // It changes a uniform value
9794 Renderer renderer = actor.GetRendererAt(0);
9795 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9797 application.SendNotification();
9799 // The damaged rect should be same
9800 damagedRects.clear();
9801 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9802 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9803 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9804 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9806 damagedRects.clear();
9807 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9808 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9810 // Ensure the damaged rect is empty
9811 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9813 // Make the actor opaque again
9814 renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9816 application.SendNotification();
9818 // The damaged rect should not be empty
9819 damagedRects.clear();
9820 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9821 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9822 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9823 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9825 damagedRects.clear();
9826 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9827 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9829 // Ensure the damaged rect is empty
9830 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9832 // Make the actor translucent
9833 renderer[DevelRenderer::Property::OPACITY] = 0.5f;
9835 application.SendNotification();
9837 // The damaged rect should not be empty
9838 damagedRects.clear();
9839 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9840 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9841 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9842 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9844 damagedRects.clear();
9845 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9846 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9848 // Ensure the damaged rect is empty
9849 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9851 // Change Renderer opacity - also translucent
9852 renderer[DevelRenderer::Property::OPACITY] = 0.2f;
9854 application.SendNotification();
9856 // The damaged rect should not be empty
9857 damagedRects.clear();
9858 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9859 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9860 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9861 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9863 damagedRects.clear();
9864 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9865 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9867 // Ensure the damaged rect is empty
9868 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9870 // Make the actor culled
9871 actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9873 application.SendNotification();
9875 // The damaged rect should be same
9876 damagedRects.clear();
9877 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9878 DALI_TEST_CHECK(damagedRects.size() > 0);
9879 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9880 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9882 damagedRects.clear();
9883 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9884 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9886 // Ensure the damaged rect is empty
9887 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9889 // Make the actor not culled again
9890 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
9892 application.SendNotification();
9894 // The damaged rect should not be empty
9895 damagedRects.clear();
9896 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9897 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9898 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9899 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9904 int utcDaliActorPartialUpdateChangeParentOpacity(void)
9906 TestApplication application(
9907 TestApplication::DEFAULT_SURFACE_WIDTH,
9908 TestApplication::DEFAULT_SURFACE_HEIGHT,
9909 TestApplication::DEFAULT_HORIZONTAL_DPI,
9910 TestApplication::DEFAULT_VERTICAL_DPI,
9914 tet_infoline("Check the damaged rect with changing parent's opacity");
9916 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9918 Actor parent = Actor::New();
9919 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9920 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9921 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9922 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9923 application.GetScene().Add(parent);
9925 Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
9926 Actor child = CreateRenderableActor(texture);
9927 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9928 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9929 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9932 application.SendNotification();
9934 std::vector<Rect<int>> damagedRects;
9936 // Actor added, damaged rect is added size of actor
9937 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9938 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9941 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9942 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9944 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9945 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9946 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9947 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9948 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9950 damagedRects.clear();
9951 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9952 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9954 damagedRects.clear();
9955 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9956 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9958 // Ensure the damaged rect is empty
9959 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9961 // Change the parent's opacity
9962 parent[Actor::Property::OPACITY] = 0.5f;
9964 application.SendNotification();
9966 // The damaged rect should be same
9967 damagedRects.clear();
9968 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9969 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9970 DALI_TEST_CHECK(damagedRects.size() > 0);
9971 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9976 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
9978 TestApplication application(
9979 TestApplication::DEFAULT_SURFACE_WIDTH,
9980 TestApplication::DEFAULT_SURFACE_HEIGHT,
9981 TestApplication::DEFAULT_HORIZONTAL_DPI,
9982 TestApplication::DEFAULT_VERTICAL_DPI,
9986 tet_infoline("Check the damaged rect with adding / removing renderer");
9988 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9990 Actor actor = CreateRenderableActor();
9991 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9992 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9993 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9994 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9995 application.GetScene().Add(actor);
9997 application.SendNotification();
9999 std::vector<Rect<int>> damagedRects;
10001 // Actor added, damaged rect is added size of actor
10002 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10003 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10006 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
10007 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10009 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10010 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10011 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10012 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10013 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10015 damagedRects.clear();
10016 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10017 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10019 damagedRects.clear();
10020 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10021 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10023 // Remove the Renderer
10024 Renderer renderer = actor.GetRendererAt(0);
10025 actor.RemoveRenderer(renderer);
10027 application.SendNotification();
10029 // The damaged rect should be the actor area
10030 damagedRects.clear();
10031 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10032 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10033 DALI_TEST_CHECK(damagedRects.size() > 0);
10034 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10036 damagedRects.clear();
10037 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10038 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10040 // Ensure the damaged rect is empty
10041 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10043 // Add the Renderer again
10044 actor.AddRenderer(renderer);
10046 application.SendNotification();
10048 // The damaged rect should be the actor area
10049 damagedRects.clear();
10050 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10051 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10052 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10053 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10058 int utcDaliActorPartialUpdate3DTransform(void)
10060 TestApplication application(
10061 TestApplication::DEFAULT_SURFACE_WIDTH,
10062 TestApplication::DEFAULT_SURFACE_HEIGHT,
10063 TestApplication::DEFAULT_HORIZONTAL_DPI,
10064 TestApplication::DEFAULT_VERTICAL_DPI,
10068 tet_infoline("Check the damaged rect with 3D transformed actors");
10070 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10072 Actor actor1 = CreateRenderableActor();
10073 actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10074 actor1[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10075 actor1[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10076 actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10077 application.GetScene().Add(actor1);
10080 Actor actor2 = CreateRenderableActor();
10081 actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10082 actor2[Actor::Property::POSITION] = Vector3(160.0f, 160.0f, 0.0f);
10083 actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10084 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10085 application.GetScene().Add(actor2);
10087 application.SendNotification();
10089 std::vector<Rect<int>> damagedRects;
10091 // Actor added, damaged rect is added size of actor
10092 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10093 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10096 Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
10097 Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
10098 DALI_TEST_EQUALS<Rect<int>>(clippingRect1, damagedRects[0], TEST_LOCATION);
10099 DALI_TEST_EQUALS<Rect<int>>(clippingRect2, damagedRects[1], TEST_LOCATION);
10101 Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10102 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10104 damagedRects.clear();
10105 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10106 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10107 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10109 damagedRects.clear();
10110 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10111 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10112 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10114 // Rotate actor1 on y axis
10115 actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10120 application.SendNotification();
10122 damagedRects.clear();
10123 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10125 // Should update full area
10126 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10127 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10128 DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10129 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10131 // Add actor2 again
10132 application.GetScene().Add(actor2);
10134 application.SendNotification();
10136 damagedRects.clear();
10137 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10139 // Should update full area
10140 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10141 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10142 DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10143 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10145 // Reset the orientation of actor1
10146 actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
10148 application.SendNotification();
10150 damagedRects.clear();
10151 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10153 // Should update full area
10154 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10155 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10156 DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10157 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10159 // Make actor2 dirty
10160 actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
10162 application.SendNotification();
10164 damagedRects.clear();
10165 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10167 clippingRect2 = Rect<int>(160, 608, 48, 48);
10168 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10169 DALI_TEST_EQUALS<Rect<int>>(clippingRect2, damagedRects[0], TEST_LOCATION);
10171 application.RenderWithPartialUpdate(damagedRects, clippingRect2);
10172 DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
10173 DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
10174 DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
10175 DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
10180 application.SendNotification();
10182 damagedRects.clear();
10183 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10184 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10185 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10187 // Rotate actor1 on y axis
10188 actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10190 // Add actor1 again
10191 application.GetScene().Add(actor1);
10193 application.SendNotification();
10195 damagedRects.clear();
10196 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10198 // Should update full area
10199 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10200 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10201 DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10202 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10207 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
10209 TestApplication application(
10210 TestApplication::DEFAULT_SURFACE_WIDTH,
10211 TestApplication::DEFAULT_SURFACE_HEIGHT,
10212 TestApplication::DEFAULT_HORIZONTAL_DPI,
10213 TestApplication::DEFAULT_VERTICAL_DPI,
10217 tet_infoline("Check the damaged rect with one actor which has multiple renderers");
10219 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10221 Actor actor = CreateRenderableActor();
10223 // Create another renderer
10224 Geometry geometry = CreateQuadGeometry();
10225 Shader shader = CreateShader();
10226 Renderer renderer2 = Renderer::New(geometry, shader);
10227 actor.AddRenderer(renderer2);
10229 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10230 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10231 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10232 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10233 application.GetScene().Add(actor);
10235 application.SendNotification();
10237 DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
10239 std::vector<Rect<int>> damagedRects;
10241 // Actor added, damaged rect is added size of actor
10242 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10243 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10246 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10247 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10248 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[1], TEST_LOCATION);
10250 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10251 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10252 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10253 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10254 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10256 damagedRects.clear();
10257 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10258 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10260 // Ensure the damaged rect is empty
10261 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10263 // Make renderer2 dirty
10264 renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
10266 application.SendNotification();
10268 // The damaged rect should be the actor area
10269 damagedRects.clear();
10270 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10272 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10273 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10274 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10276 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10278 damagedRects.clear();
10279 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10280 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10282 // Ensure the damaged rect is empty
10283 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10285 // Make renderer2 dirty
10286 renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
10288 application.SendNotification();
10290 // The damaged rect should be the actor area
10291 damagedRects.clear();
10292 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10294 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10295 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10296 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10298 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10300 damagedRects.clear();
10301 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10302 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10304 // Ensure the damaged rect is empty
10305 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10310 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
10312 TestApplication application(
10313 TestApplication::DEFAULT_SURFACE_WIDTH,
10314 TestApplication::DEFAULT_SURFACE_HEIGHT,
10315 TestApplication::DEFAULT_HORIZONTAL_DPI,
10316 TestApplication::DEFAULT_VERTICAL_DPI,
10320 tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
10322 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10324 Actor actor = CreateRenderableActor();
10325 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10326 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10327 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10328 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10329 application.GetScene().Add(actor);
10331 // Create another actor which has the same renderer with actor1
10332 Actor actor2 = Actor::New();
10333 Renderer renderer = actor.GetRendererAt(0);
10334 actor2.AddRenderer(renderer);
10335 actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10336 actor2[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10337 actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10338 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10339 application.GetScene().Add(actor2);
10341 application.SendNotification();
10343 std::vector<Rect<int>> damagedRects;
10345 // Actor added, damaged rect is added size of actor
10346 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10347 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10350 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10351 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10352 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[1], TEST_LOCATION);
10354 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10355 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10356 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10357 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10358 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10360 damagedRects.clear();
10361 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10362 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10364 // Ensure the damaged rect is empty
10365 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10367 // Make renderer dirty
10368 renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10370 application.SendNotification();
10372 // The damaged rect should be the actor area
10373 damagedRects.clear();
10374 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10376 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10377 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10378 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10379 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[1], TEST_LOCATION);
10381 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10383 damagedRects.clear();
10384 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10385 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10387 // Ensure the damaged rect is empty
10388 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10393 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
10395 TestApplication application;
10397 Actor actor = Actor::New();
10398 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
10399 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
10400 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
10401 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
10402 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
10403 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10404 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10405 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
10409 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
10411 TestApplication application;
10413 Actor actor = Actor::New();
10415 // Make sure setting invalid types does not cause a crash
10418 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
10419 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
10420 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
10421 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
10422 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
10423 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
10424 tet_result(TET_PASS);
10428 tet_result(TET_FAIL);
10433 int UtcDaliActorTouchAreaOffsetPropertyP(void)
10435 TestApplication application;
10437 Actor actor = Actor::New();
10438 Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10439 DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
10440 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
10441 touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10442 DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
10446 int UtcDaliActorTouchAreaOffsetPropertyN(void)
10448 TestApplication application;
10450 Actor actor = Actor::New();
10452 // Make sure setting invalid types does not cause a crash
10455 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
10456 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
10457 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
10458 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
10459 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
10460 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
10461 tet_result(TET_PASS);
10465 tet_result(TET_FAIL);
10470 int UtcDaliActorLowerBelowNegative(void)
10472 TestApplication application;
10473 Dali::Actor instance;
10477 instance.LowerBelow(arg1);
10478 DALI_TEST_CHECK(false); // Should not get here
10482 DALI_TEST_CHECK(true); // We expect an assert
10487 int UtcDaliActorRaiseAboveNegative(void)
10489 TestApplication application;
10490 Dali::Actor instance;
10494 instance.RaiseAbove(arg1);
10495 DALI_TEST_CHECK(false); // Should not get here
10499 DALI_TEST_CHECK(true); // We expect an assert
10504 int UtcDaliActorRaiseToTopNegative(void)
10506 TestApplication application;
10507 Dali::Actor instance;
10510 instance.RaiseToTop();
10511 DALI_TEST_CHECK(false); // Should not get here
10515 DALI_TEST_CHECK(true); // We expect an assert
10520 int UtcDaliActorAddRendererNegative(void)
10522 TestApplication application;
10523 Dali::Actor instance;
10526 Dali::Renderer arg1;
10527 instance.AddRenderer(arg1);
10528 DALI_TEST_CHECK(false); // Should not get here
10532 DALI_TEST_CHECK(true); // We expect an assert
10537 int UtcDaliActorTouchedSignalNegative(void)
10539 TestApplication application;
10540 Dali::Actor instance;
10543 instance.TouchedSignal();
10544 DALI_TEST_CHECK(false); // Should not get here
10548 DALI_TEST_CHECK(true); // We expect an assert
10553 int UtcDaliActorTranslateByNegative(void)
10555 TestApplication application;
10556 Dali::Actor instance;
10559 Dali::Vector3 arg1;
10560 instance.TranslateBy(arg1);
10561 DALI_TEST_CHECK(false); // Should not get here
10565 DALI_TEST_CHECK(true); // We expect an assert
10570 int UtcDaliActorFindChildByIdNegative(void)
10572 TestApplication application;
10573 Dali::Actor instance;
10576 unsigned int arg1 = 0u;
10577 instance.FindChildById(arg1);
10578 DALI_TEST_CHECK(false); // Should not get here
10582 DALI_TEST_CHECK(true); // We expect an assert
10587 int UtcDaliActorGetRendererAtNegative(void)
10589 TestApplication application;
10590 Dali::Actor instance;
10593 unsigned int arg1 = 0u;
10594 instance.GetRendererAt(arg1);
10595 DALI_TEST_CHECK(false); // Should not get here
10599 DALI_TEST_CHECK(true); // We expect an assert
10604 int UtcDaliActorHoveredSignalNegative(void)
10606 TestApplication application;
10607 Dali::Actor instance;
10610 instance.HoveredSignal();
10611 DALI_TEST_CHECK(false); // Should not get here
10615 DALI_TEST_CHECK(true); // We expect an assert
10620 int UtcDaliActorLowerToBottomNegative(void)
10622 TestApplication application;
10623 Dali::Actor instance;
10626 instance.LowerToBottom();
10627 DALI_TEST_CHECK(false); // Should not get here
10631 DALI_TEST_CHECK(true); // We expect an assert
10636 int UtcDaliActorOnSceneSignalNegative(void)
10638 TestApplication application;
10639 Dali::Actor instance;
10642 instance.OnSceneSignal();
10643 DALI_TEST_CHECK(false); // Should not get here
10647 DALI_TEST_CHECK(true); // We expect an assert
10652 int UtcDaliActorOffSceneSignalNegative(void)
10654 TestApplication application;
10655 Dali::Actor instance;
10658 instance.OffSceneSignal();
10659 DALI_TEST_CHECK(false); // Should not get here
10663 DALI_TEST_CHECK(true); // We expect an assert
10668 int UtcDaliActorRemoveRendererNegative01(void)
10670 TestApplication application;
10671 Dali::Actor instance;
10674 unsigned int arg1 = 0u;
10675 instance.RemoveRenderer(arg1);
10676 DALI_TEST_CHECK(false); // Should not get here
10680 DALI_TEST_CHECK(true); // We expect an assert
10685 int UtcDaliActorRemoveRendererNegative02(void)
10687 TestApplication application;
10688 Dali::Actor instance;
10691 Dali::Renderer arg1;
10692 instance.RemoveRenderer(arg1);
10693 DALI_TEST_CHECK(false); // Should not get here
10697 DALI_TEST_CHECK(true); // We expect an assert
10702 int UtcDaliActorFindChildByNameNegative(void)
10704 TestApplication application;
10705 Dali::Actor instance;
10709 instance.FindChildByName(arg1);
10710 DALI_TEST_CHECK(false); // Should not get here
10714 DALI_TEST_CHECK(true); // We expect an assert
10719 int UtcDaliActorSetResizePolicyNegative(void)
10721 TestApplication application;
10722 Dali::Actor instance;
10725 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
10726 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
10727 instance.SetResizePolicy(arg1, arg2);
10728 DALI_TEST_CHECK(false); // Should not get here
10732 DALI_TEST_CHECK(true); // We expect an assert
10737 int UtcDaliActorOnRelayoutSignalNegative(void)
10739 TestApplication application;
10740 Dali::Actor instance;
10743 instance.OnRelayoutSignal();
10744 DALI_TEST_CHECK(false); // Should not get here
10748 DALI_TEST_CHECK(true); // We expect an assert
10753 int UtcDaliActorWheelEventSignalNegative(void)
10755 TestApplication application;
10756 Dali::Actor instance;
10759 instance.WheelEventSignal();
10760 DALI_TEST_CHECK(false); // Should not get here
10764 DALI_TEST_CHECK(true); // We expect an assert
10769 int UtcDaliActorGetHeightForWidthNegative(void)
10771 TestApplication application;
10772 Dali::Actor instance;
10776 instance.GetHeightForWidth(arg1);
10777 DALI_TEST_CHECK(false); // Should not get here
10781 DALI_TEST_CHECK(true); // We expect an assert
10786 int UtcDaliActorGetWidthForHeightNegative(void)
10788 TestApplication application;
10789 Dali::Actor instance;
10793 instance.GetWidthForHeight(arg1);
10794 DALI_TEST_CHECK(false); // Should not get here
10798 DALI_TEST_CHECK(true); // We expect an assert
10803 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
10805 TestApplication application;
10806 Dali::Actor instance;
10809 instance.LayoutDirectionChangedSignal();
10810 DALI_TEST_CHECK(false); // Should not get here
10814 DALI_TEST_CHECK(true); // We expect an assert
10819 int UtcDaliActorAddNegative(void)
10821 TestApplication application;
10822 Dali::Actor instance;
10826 instance.Add(arg1);
10827 DALI_TEST_CHECK(false); // Should not get here
10831 DALI_TEST_CHECK(true); // We expect an assert
10836 int UtcDaliActorLowerNegative(void)
10838 TestApplication application;
10839 Dali::Actor instance;
10843 DALI_TEST_CHECK(false); // Should not get here
10847 DALI_TEST_CHECK(true); // We expect an assert
10852 int UtcDaliActorRaiseNegative(void)
10854 TestApplication application;
10855 Dali::Actor instance;
10859 DALI_TEST_CHECK(false); // Should not get here
10863 DALI_TEST_CHECK(true); // We expect an assert
10868 int UtcDaliActorRemoveNegative(void)
10870 TestApplication application;
10871 Dali::Actor instance;
10875 instance.Remove(arg1);
10876 DALI_TEST_CHECK(false); // Should not get here
10880 DALI_TEST_CHECK(true); // We expect an assert
10885 int UtcDaliActorScaleByNegative(void)
10887 TestApplication application;
10888 Dali::Actor instance;
10891 Dali::Vector3 arg1;
10892 instance.ScaleBy(arg1);
10893 DALI_TEST_CHECK(false); // Should not get here
10897 DALI_TEST_CHECK(true); // We expect an assert
10902 int UtcDaliActorGetLayerNegative(void)
10904 TestApplication application;
10905 Dali::Actor instance;
10908 instance.GetLayer();
10909 DALI_TEST_CHECK(false); // Should not get here
10913 DALI_TEST_CHECK(true); // We expect an assert
10918 int UtcDaliActorRotateByNegative01(void)
10920 TestApplication application;
10921 Dali::Actor instance;
10924 Dali::Quaternion arg1;
10925 instance.RotateBy(arg1);
10926 DALI_TEST_CHECK(false); // Should not get here
10930 DALI_TEST_CHECK(true); // We expect an assert
10935 int UtcDaliActorRotateByNegative02(void)
10937 TestApplication application;
10938 Dali::Actor instance;
10942 Dali::Vector3 arg2;
10943 instance.RotateBy(arg1, arg2);
10944 DALI_TEST_CHECK(false); // Should not get here
10948 DALI_TEST_CHECK(true); // We expect an assert
10953 int UtcDaliActorUnparentNegative(void)
10955 TestApplication application;
10956 Dali::Actor instance;
10959 instance.Unparent();
10960 DALI_TEST_CHECK(false); // Should not get here
10964 DALI_TEST_CHECK(true); // We expect an assert
10969 int UtcDaliActorGetChildAtNegative(void)
10971 TestApplication application;
10972 Dali::Actor instance;
10975 unsigned int arg1 = 0u;
10976 instance.GetChildAt(arg1);
10977 DALI_TEST_CHECK(false); // Should not get here
10981 DALI_TEST_CHECK(true); // We expect an assert
10986 int UtcDaliActorGetChildCountNegative(void)
10988 TestApplication application;
10989 Dali::Actor instance;
10992 instance.GetChildCount();
10993 DALI_TEST_CHECK(false); // Should not get here
10997 DALI_TEST_CHECK(true); // We expect an assert
11002 int UtcDaliActorGetTargetSizeNegative(void)
11004 TestApplication application;
11005 Dali::Actor instance;
11008 instance.GetTargetSize();
11009 DALI_TEST_CHECK(false); // Should not get here
11013 DALI_TEST_CHECK(true); // We expect an assert
11018 int UtcDaliActorScreenToLocalNegative(void)
11020 TestApplication application;
11021 Dali::Actor instance;
11028 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
11029 DALI_TEST_CHECK(false); // Should not get here
11033 DALI_TEST_CHECK(true); // We expect an assert
11038 int UtcDaliActorGetNaturalSizeNegative(void)
11040 TestApplication application;
11041 Dali::Actor instance;
11044 instance.GetNaturalSize();
11045 DALI_TEST_CHECK(false); // Should not get here
11049 DALI_TEST_CHECK(true); // We expect an assert
11054 int UtcDaliActorGetRelayoutSizeNegative(void)
11056 TestApplication application;
11057 Dali::Actor instance;
11060 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
11061 instance.GetRelayoutSize(arg1);
11062 DALI_TEST_CHECK(false); // Should not get here
11066 DALI_TEST_CHECK(true); // We expect an assert
11071 int UtcDaliActorGetResizePolicyNegative(void)
11073 TestApplication application;
11074 Dali::Actor instance;
11077 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
11078 instance.GetResizePolicy(arg1);
11079 DALI_TEST_CHECK(false); // Should not get here
11083 DALI_TEST_CHECK(true); // We expect an assert
11088 int UtcDaliActorGetRendererCountNegative(void)
11090 TestApplication application;
11091 Dali::Actor instance;
11094 instance.GetRendererCount();
11095 DALI_TEST_CHECK(false); // Should not get here
11099 DALI_TEST_CHECK(true); // We expect an assert
11104 int UtcDaliActorGetParentNegative(void)
11106 TestApplication application;
11107 Dali::Actor instance;
11110 instance.GetParent();
11111 DALI_TEST_CHECK(false); // Should not get here
11115 DALI_TEST_CHECK(true); // We expect an assert
11120 int UtcDaliActorPropertyBlendEquation(void)
11122 TestApplication application;
11124 tet_infoline("Test SetProperty AdvancedBlendEquation");
11126 Geometry geometry = CreateQuadGeometry();
11127 Shader shader = CreateShader();
11128 Renderer renderer1 = Renderer::New(geometry, shader);
11130 Actor actor = Actor::New();
11131 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
11133 actor.AddRenderer(renderer1);
11134 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
11135 application.GetScene().Add(actor);
11137 if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11139 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11140 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11141 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
11144 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11146 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11147 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11148 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
11151 Renderer renderer2 = Renderer::New(geometry, shader);
11152 actor.AddRenderer(renderer2);
11157 int UtcDaliActorRegisterProperty(void)
11159 tet_infoline("Test property registration and uniform map update\n");
11161 TestApplication application;
11163 Geometry geometry = CreateQuadGeometry();
11164 Shader shader = CreateShader();
11165 Renderer renderer1 = Renderer::New(geometry, shader);
11166 Renderer renderer2 = Renderer::New(geometry, shader);
11168 Actor actor1 = Actor::New();
11169 actor1.AddRenderer(renderer1);
11170 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11171 actor1.RegisterProperty("uCustom", 1);
11172 application.GetScene().Add(actor1);
11174 Actor actor2 = Actor::New();
11175 actor2.AddRenderer(renderer2);
11176 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11177 application.GetScene().Add(actor2);
11179 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
11180 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
11181 glAbstraction.EnableSetUniformCallTrace(true);
11183 application.SendNotification();
11184 application.Render();
11186 std::stringstream out;
11188 std::string params;
11190 // Test uniform value of the custom property
11191 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11192 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11195 actor1[Actor::Property::VISIBLE] = false;
11197 application.SendNotification();
11198 application.Render();
11200 // Make visible again
11201 actor1[Actor::Property::VISIBLE] = true;
11202 actor1["uCustom"] = 2;
11204 glAbstraction.ResetSetUniformCallStack();
11206 application.SendNotification();
11207 application.Render();
11211 // The uniform value should not be changed
11212 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11213 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11218 int UtcDaliActorDoesWantedHitTest(void)
11223 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
11225 mTouchPoint(touchPoint),
11231 Vector2 mTouchPoint;
11235 TestApplication application;
11236 tet_infoline(" UtcDaliActorDoesWantedHitTest");
11238 // Fill a vector with different hit tests.
11239 struct HitTestData* hitTestData[] = {
11240 // scale touch point result
11241 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
11242 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
11243 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.
11244 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
11245 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.
11249 // get the root layer
11250 Actor actor = Actor::New();
11251 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11252 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11254 Actor lowerActor = Actor::New();
11255 lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11256 lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11258 // actor and lowerActor have no relationship.
11259 application.GetScene().Add(lowerActor);
11260 application.GetScene().Add(actor);
11262 ResetTouchCallbacks();
11263 gHitTestTouchCallBackCalled = false;
11265 unsigned int index = 0;
11266 while(NULL != hitTestData[index])
11268 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11269 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11271 lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11272 lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11274 // flush the queue and render once
11275 application.SendNotification();
11276 application.Render();
11278 DALI_TEST_CHECK(!gTouchCallBackCalled);
11279 DALI_TEST_CHECK(!gTouchCallBackCalled2);
11280 DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
11282 // connect to its touch signal
11283 actor.TouchedSignal().Connect(TestTouchCallback);
11284 lowerActor.TouchedSignal().Connect(TestTouchCallback2);
11286 // connect to its hit-test signal
11287 Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
11289 Dali::Integration::Point point;
11290 point.SetState(PointState::DOWN);
11291 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
11292 Dali::Integration::TouchEvent event;
11293 event.AddPoint(point);
11295 // flush the queue and render once
11296 application.SendNotification();
11297 application.Render();
11298 application.ProcessEvent(event);
11300 // check hit-test events
11301 DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
11302 // Passed all hit-tests of actor.
11303 DALI_TEST_CHECK(gTouchCallBackCalled == false);
11304 // The lowerActor was hit-tested.
11305 DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
11307 if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
11308 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
11309 hitTestData[index]->mScale.x,
11310 hitTestData[index]->mScale.y,
11311 hitTestData[index]->mScale.z,
11312 hitTestData[index]->mTouchPoint.x,
11313 hitTestData[index]->mTouchPoint.y,
11314 hitTestData[index]->mResult);
11316 ResetTouchCallbacks();
11317 gHitTestTouchCallBackCalled = false;
11323 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
11325 TestApplication application;
11327 Actor actor = Actor::New();
11328 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
11329 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
11330 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
11331 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
11332 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
11333 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11334 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11335 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
11339 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
11341 TestApplication application;
11343 Actor actor = Actor::New();
11345 // Make sure setting invalid types does not cause a crash
11348 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
11349 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
11350 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
11351 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
11352 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
11353 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
11354 tet_result(TET_PASS);
11358 tet_result(TET_FAIL);
11363 int UtcDaliActorCalculateWorldTransform01(void)
11365 TestApplication application;
11367 tet_infoline("Test that actor position inheritance produces right transform matrix");
11369 Actor rootActor = Actor::New();
11370 Actor branchActor = Actor::New();
11371 Actor leafActor = Actor::New();
11373 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11374 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11375 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11377 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11378 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11379 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11381 // Set anchor point to the same value as parent origin
11382 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11383 branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11384 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11386 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11387 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11388 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11390 application.GetScene().Add(rootActor);
11391 rootActor.Add(branchActor);
11392 branchActor.Add(leafActor);
11394 application.SendNotification();
11395 application.Render(0);
11396 application.SendNotification();
11397 application.Render(0);
11399 Matrix m = DevelActor::GetWorldTransform(leafActor);
11401 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11402 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11405 Vector3 worldScale;
11406 Quaternion worldRotation;
11407 m.GetTransformComponents(worldPos, worldRotation, worldScale);
11408 DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
11413 int UtcDaliActorCalculateWorldTransform02(void)
11415 TestApplication application;
11417 tet_infoline("Test that actor position produces right transform matrix");
11419 Actor rootActor = Actor::New();
11420 Actor branchActor = Actor::New();
11421 Actor leafActor = Actor::New();
11423 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11424 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11425 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11427 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11428 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11429 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11431 // Set anchor point to the same value as parent origin
11432 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11433 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11434 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11436 application.GetScene().Add(rootActor);
11437 rootActor.Add(branchActor);
11438 branchActor.Add(leafActor);
11440 leafActor[Actor::Property::INHERIT_POSITION] = false;
11441 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11442 leafActor[Actor::Property::INHERIT_SCALE] = false;
11444 application.SendNotification();
11445 application.Render(0);
11446 application.SendNotification();
11447 application.Render(0);
11449 Matrix m = DevelActor::GetWorldTransform(leafActor);
11451 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11452 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11457 int UtcDaliActorCalculateWorldTransform03(void)
11459 TestApplication application;
11461 tet_infoline("Test that actor position produces right transform matrix");
11463 Actor rootActor = Actor::New();
11464 Actor branchActor = Actor::New();
11465 Actor leafActor = Actor::New();
11467 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11468 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11469 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11471 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11472 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11473 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11475 // Set anchor point to the same value as parent origin
11476 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11477 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11478 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11480 application.GetScene().Add(rootActor);
11481 rootActor.Add(branchActor);
11482 branchActor.Add(leafActor);
11484 leafActor[Actor::Property::INHERIT_POSITION] = true;
11485 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11486 leafActor[Actor::Property::INHERIT_SCALE] = false;
11488 application.SendNotification();
11489 application.Render(0);
11490 application.SendNotification();
11491 application.Render(0);
11493 Matrix m = DevelActor::GetWorldTransform(leafActor);
11495 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11496 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11501 int UtcDaliActorCalculateWorldTransform04(void)
11503 TestApplication application;
11505 tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
11507 Actor rootActor = Actor::New();
11508 Actor branchActor = Actor::New();
11509 Actor leafActor = Actor::New();
11511 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11512 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11513 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11515 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11516 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11517 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11519 // Set anchor point to the same value as parent origin
11520 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11521 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11522 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11523 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11525 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11526 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11528 application.GetScene().Add(rootActor);
11529 rootActor.Add(branchActor);
11530 branchActor.Add(leafActor);
11532 application.SendNotification();
11533 application.Render(0);
11534 application.SendNotification();
11535 application.Render(0);
11537 Matrix m = DevelActor::GetWorldTransform(leafActor);
11539 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11540 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11545 int UtcDaliActorCalculateWorldTransform05(void)
11547 TestApplication application;
11549 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11551 Actor rootActor = Actor::New();
11552 Actor branchActor = Actor::New();
11553 Actor leafActor = Actor::New();
11555 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11556 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11557 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11559 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11560 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11561 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11563 // Set anchor point to the same value as parent origin
11564 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11565 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11566 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11567 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11569 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11570 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11572 leafActor[Actor::Property::INHERIT_POSITION] = false;
11573 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11575 application.GetScene().Add(rootActor);
11576 rootActor.Add(branchActor);
11577 branchActor.Add(leafActor);
11579 application.SendNotification();
11580 application.Render(0);
11581 application.SendNotification();
11582 application.Render(0);
11584 Matrix m = DevelActor::GetWorldTransform(leafActor);
11586 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11587 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11592 int UtcDaliActorCalculateWorldTransform06(void)
11594 TestApplication application;
11596 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11598 Actor rootActor = Actor::New();
11599 Actor branchActor = Actor::New();
11600 Actor leafActor = Actor::New();
11602 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11603 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11604 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11606 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11607 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11608 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11610 // Set anchor point to the same value as parent origin
11611 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11612 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11613 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11614 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11616 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
11617 branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11618 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11620 leafActor[Actor::Property::INHERIT_POSITION] = false;
11621 leafActor[Actor::Property::INHERIT_SCALE] = false;
11623 application.GetScene().Add(rootActor);
11624 rootActor.Add(branchActor);
11625 branchActor.Add(leafActor);
11627 application.SendNotification();
11628 application.Render(0);
11629 application.SendNotification();
11630 application.Render(0);
11632 Matrix m = DevelActor::GetWorldTransform(leafActor);
11634 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11635 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11640 int UtcDaliActorCalculateWorldTransform07(void)
11642 TestApplication application;
11644 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11646 Actor rootActor = Actor::New();
11647 Actor branchActor = Actor::New();
11648 Actor leafActor = Actor::New();
11650 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11651 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11652 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11654 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11655 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11656 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11658 // Set anchor point to the same value as parent origin
11659 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11660 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11661 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11663 // This should be ignored.
11664 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11665 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11667 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
11668 branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11669 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11671 leafActor[Actor::Property::INHERIT_POSITION] = false;
11672 leafActor[Actor::Property::INHERIT_SCALE] = false;
11673 leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
11675 application.GetScene().Add(rootActor);
11676 rootActor.Add(branchActor);
11677 branchActor.Add(leafActor);
11679 application.SendNotification();
11680 application.Render(0);
11681 application.SendNotification();
11682 application.Render(0);
11684 Matrix m = DevelActor::GetWorldTransform(leafActor);
11686 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11687 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11692 int UtcDaliActorCalculateWorldTransform08(void)
11694 TestApplication application;
11696 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11698 Vector3 solutions[] = {Vector3(250, 0, 0), Vector3(0, 250, 0), Vector3(650, 0, 0), Vector3(0, 250, 0), Vector3(650, 0, 0), Vector3(400, 250, 0), Vector3(200, -50, 0), Vector3(500, 200, 0)};
11706 TestCase testCases[] = {
11707 {false, false, true},
11708 {false, true, false},
11709 {true, false, false},
11710 {false, true, true},
11711 {true, false, true},
11712 {true, true, false},
11713 {false, false, false},
11714 {true, true, true},
11717 Actor rootActor = Actor::New();
11718 Actor leafActor = Actor::New();
11720 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11721 rootActor[Actor::Property::SCALE] = Vector3(1.0f, 2.0f, 1.0f);
11722 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11723 rootActor[Actor::Property::SIZE] = Vector2(200, 400);
11724 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11725 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11727 leafActor[Actor::Property::POSITION] = Vector3(0.0f, -50.0f, 0.0f);
11728 leafActor[Actor::Property::SCALE] = Vector3(1.0f, 1.0f, 1.0f);
11729 leafActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11730 leafActor[Actor::Property::SIZE] = Vector2(200, 400);
11731 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_CENTER;
11732 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_CENTER;
11733 leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
11735 application.GetScene().Add(rootActor);
11736 rootActor.Add(leafActor);
11738 for(uint32_t i = 0; i< 8; ++i)
11740 leafActor[Actor::Property::INHERIT_POSITION] = testCases[i].translation;
11741 leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation;
11742 leafActor[Actor::Property::INHERIT_SCALE] = testCases[i].scaling;
11744 application.SendNotification();
11745 application.Render(0);
11746 application.SendNotification();
11747 application.Render(0);
11749 Matrix m = DevelActor::GetWorldTransform(leafActor);
11750 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11752 Vector3 worldPosition1 = Vector3(m.GetTranslation());
11753 Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation());
11755 DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION);
11756 DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION);
11762 int UtcDaliActorCalculateWorldColor01(void)
11764 TestApplication application;
11766 tet_infoline("Test that actor inheritance of color produces right final color");
11768 Actor rootActor = Actor::New();
11769 Actor branchActor = Actor::New();
11770 Actor leafActor = Actor::New();
11772 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11773 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11774 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11776 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11777 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11778 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11780 rootActor[Actor::Property::COLOR] = Color::WHITE;
11781 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11782 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11784 // Default is to inherit:
11785 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
11787 application.GetScene().Add(rootActor);
11788 rootActor.Add(branchActor);
11789 branchActor.Add(leafActor);
11791 application.SendNotification();
11792 application.Render(0);
11794 Vector4 color = DevelActor::GetWorldColor(leafActor);
11796 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11797 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11802 int UtcDaliActorCalculateWorldColor02(void)
11804 TestApplication application;
11806 tet_infoline("Test that actor uses own color");
11808 Actor rootActor = Actor::New();
11809 Actor branchActor = Actor::New();
11810 Actor leafActor = Actor::New();
11812 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11813 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11814 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11816 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11817 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11818 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11820 rootActor[Actor::Property::COLOR] = Color::WHITE;
11821 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11822 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11824 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
11826 application.GetScene().Add(rootActor);
11827 rootActor.Add(branchActor);
11828 branchActor.Add(leafActor);
11830 application.SendNotification();
11831 application.Render(0);
11833 Vector4 color = DevelActor::GetWorldColor(leafActor);
11835 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11836 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11837 DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
11841 int UtcDaliActorCalculateWorldColor03(void)
11843 TestApplication application;
11845 tet_infoline("Test that actor uses parent color");
11847 Actor rootActor = Actor::New();
11848 Actor branchActor = Actor::New();
11849 Actor leafActor = Actor::New();
11851 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11852 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11853 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11855 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11856 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11857 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11859 rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
11860 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11861 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11863 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
11865 application.GetScene().Add(rootActor);
11866 rootActor.Add(branchActor);
11867 branchActor.Add(leafActor);
11869 application.SendNotification();
11870 application.Render(0);
11872 Vector4 color = DevelActor::GetWorldColor(leafActor);
11874 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11875 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11876 DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
11880 int UtcDaliActorCalculateWorldColor04(void)
11882 TestApplication application;
11884 tet_infoline("Test that actor blends with parent color");
11886 Actor rootActor = Actor::New();
11887 Actor branchActor = Actor::New();
11888 Actor leafActor = Actor::New();
11890 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11891 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11892 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11894 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11895 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11896 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11898 rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
11899 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11900 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11902 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
11904 application.GetScene().Add(rootActor);
11905 rootActor.Add(branchActor);
11906 branchActor.Add(leafActor);
11908 application.SendNotification();
11909 application.Render(0);
11911 Vector4 color = DevelActor::GetWorldColor(leafActor);
11913 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11914 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);