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 UtcDaliActorSetSizeIndividual(void)
1160 TestApplication application;
1162 Actor actor = Actor::New();
1164 Vector3 vector(0.7f, 0.8f, 0.9f);
1165 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1167 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1169 // Immediately check the width after setting
1170 float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1171 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1173 // flush the queue and render once
1174 application.SendNotification();
1175 application.Render();
1177 // Check the width in the new frame
1178 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1180 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1181 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1183 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1185 // Immediately check the height after setting
1186 float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1187 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1189 // flush the queue and render once
1190 application.SendNotification();
1191 application.Render();
1193 // Check the height in the new frame
1194 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1196 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1197 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1199 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1201 // Immediately check the depth after setting
1202 float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1203 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1205 // flush the queue and render once
1206 application.SendNotification();
1207 application.Render();
1209 // Check the depth in the new frame
1210 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1212 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1213 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1215 // Change the resize policy and check whether the size stays the same
1216 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1218 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1219 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1221 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1222 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1224 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1225 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1227 // Change the resize policy again and check whether the size stays the same
1228 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1230 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1231 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1233 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1234 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1236 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1237 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1242 int UtcDaliActorSetSizeIndividual02(void)
1244 TestApplication application;
1246 Actor actor = Actor::New();
1247 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1248 application.GetScene().Add(actor);
1250 Vector3 vector(100.0f, 200.0f, 400.0f);
1251 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1253 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1254 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1256 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1257 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1259 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1260 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1262 // flush the queue and render once
1263 application.SendNotification();
1264 application.Render();
1266 // Check the width in the new frame
1267 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1268 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1273 int UtcDaliActorGetCurrentSize(void)
1275 TestApplication application;
1277 Actor actor = Actor::New();
1278 Vector3 vector(100.0f, 100.0f, 20.0f);
1280 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1282 actor.SetProperty(Actor::Property::SIZE, vector);
1284 // flush the queue and render once
1285 application.SendNotification();
1286 application.Render();
1288 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1292 int UtcDaliActorGetNaturalSize(void)
1294 TestApplication application;
1296 Actor actor = Actor::New();
1297 Vector3 vector(0.0f, 0.0f, 0.0f);
1299 DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1304 int UtcDaliActorGetCurrentSizeImmediate(void)
1306 TestApplication application;
1308 Actor actor = Actor::New();
1309 Vector3 vector(100.0f, 100.0f, 20.0f);
1311 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1312 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1314 actor.SetProperty(Actor::Property::SIZE, vector);
1316 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1317 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1319 // flush the queue and render once
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1324 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1327 // Build the animation
1328 const float durationSeconds = 2.0f;
1329 Animation animation = Animation::New(durationSeconds);
1330 const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1331 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1333 DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1335 application.GetScene().Add(actor);
1337 // Start the animation
1340 application.SendNotification();
1341 application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1343 DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1348 int UtcDaliActorCalculateScreenExtents(void)
1350 TestApplication application;
1352 Actor actor = Actor::New();
1354 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1355 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1357 application.GetScene().Add(actor);
1359 application.SendNotification();
1360 application.Render();
1362 auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f};
1363 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1364 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1365 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1366 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1367 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1369 application.GetScene().Remove(actor);
1373 int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void)
1375 TestApplication application;
1376 Integration::Scene scene = application.GetScene();
1379 Layer layer = Layer::New();
1380 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1381 layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1382 layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1386 // Build custom camera with top-view
1387 CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
1389 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1390 Vector3 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1391 Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1394 std::ostringstream oss;
1395 oss << cameraPos << "\n";
1396 oss << cameraOrient << "\n";
1397 tet_printf("%s\n", oss.str().c_str());
1400 cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1401 cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1403 // Now, upside : -Z, leftside : -X, foward : +Y
1405 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1406 cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1408 std::ostringstream oss;
1409 oss << cameraPos << "\n";
1410 oss << cameraOrient << "\n";
1411 tet_printf("%s\n", oss.str().c_str());
1415 Actor actor = Actor::New();
1416 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1417 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1418 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f));
1419 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f});
1423 application.SendNotification();
1424 application.Render();
1426 Vector2 sceneSize = scene.GetSize();
1428 auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f};
1429 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1431 std::ostringstream oss;
1432 oss << expectedExtent << "\n";
1433 oss << actualExtent << "\n";
1434 tet_printf("%s\n", oss.str().c_str());
1437 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1438 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1439 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1440 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1445 int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void)
1447 // TODO : Need to make it works well
1448 TestApplication application;
1449 Integration::Scene scene = application.GetScene();
1450 Vector2 sceneSize = scene.GetSize();
1453 Layer layer = Layer::New();
1454 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
1455 layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1456 layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1457 layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1458 layer.SetProperty(Actor::Property::SIZE, sceneSize);
1462 // Build custom camera with top-view
1463 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
1465 offscreenCameraActor.SetPerspectiveProjection(sceneSize);
1466 offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1467 offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1469 scene.Add(offscreenCameraActor);
1471 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
1472 Vector3 cameraPos = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1473 Quaternion cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1476 std::ostringstream oss;
1477 oss << cameraPos << "\n";
1478 oss << cameraOrient << "\n";
1479 tet_printf("%s\n", oss.str().c_str());
1482 offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
1483 offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
1485 // Now, upside : -Z, leftside : -X, foward : +Y
1487 cameraPos = offscreenCameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
1488 cameraOrient = offscreenCameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
1490 std::ostringstream oss;
1491 oss << cameraPos << "\n";
1492 oss << cameraOrient << "\n";
1493 tet_printf("%s\n", oss.str().c_str());
1496 Vector3 sourcePosition{2.0f, 0.0f, 16.0f};
1497 Vector3 sourceSize{1.0f, 0.0f, 3.0f};
1499 Actor sourceActor = Actor::New();
1500 sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1501 sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1502 sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition);
1503 sourceActor.SetProperty(Actor::Property::SIZE, sourceSize);
1505 layer.Add(sourceActor);
1507 // Create framebuffer
1508 unsigned int width(64);
1509 unsigned int height(64);
1510 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1511 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
1512 frameBuffer.AttachColorTexture(texture);
1514 Actor rootActor = Actor::New();
1515 rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1516 rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1517 rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
1518 rootActor.SetProperty(Actor::Property::SIZE, sceneSize);
1519 scene.Add(rootActor);
1521 RenderTaskList taskList = scene.GetRenderTaskList();
1522 RenderTask newTask = taskList.CreateTask();
1523 newTask.SetCameraActor(offscreenCameraActor);
1524 newTask.SetSourceActor(layer);
1525 newTask.SetInputEnabled(false);
1526 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
1527 newTask.SetClearEnabled(true);
1528 newTask.SetExclusive(true);
1529 newTask.SetFrameBuffer(frameBuffer);
1530 newTask.SetScreenToFrameBufferMappingActor(rootActor);
1532 application.SendNotification();
1533 application.Render(16u);
1535 auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f,
1536 sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f,
1539 auto actualExtent = DevelActor::CalculateScreenExtents(sourceActor);
1541 std::ostringstream oss;
1542 oss << expectedExtent << "\n";
1543 oss << actualExtent << "\n";
1544 tet_printf("%s\n", oss.str().c_str());
1547 auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z};
1548 auto actualScreen = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1550 std::ostringstream oss;
1551 oss << expectedScreen << "\n";
1552 oss << actualScreen << "\n";
1553 tet_printf("%s\n", oss.str().c_str());
1556 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1557 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1558 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1559 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1561 DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1562 DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1564 // Change rootActor's size and position
1566 Vector3 rootPosition{100.0f, 200.0f, 0.0f};
1567 Vector3 rootSize{200.0f, 100.0f, 0.0f};
1569 rootActor.SetProperty(Actor::Property::POSITION, rootPosition);
1570 rootActor.SetProperty(Actor::Property::SIZE, rootSize);
1572 application.SendNotification();
1573 application.Render(16u);
1575 expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x,
1576 sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y,
1577 sourceSize.x * rootSize.x / sceneSize.x,
1578 sourceSize.z * rootSize.y / sceneSize.y};
1579 actualExtent = DevelActor::CalculateScreenExtents(sourceActor);
1581 std::ostringstream oss;
1582 oss << expectedExtent << "\n";
1583 oss << actualExtent << "\n";
1584 tet_printf("%s\n", oss.str().c_str());
1587 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};
1588 actualScreen = sourceActor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
1590 std::ostringstream oss;
1591 oss << expectedScreen << "\n";
1592 oss << actualScreen << "\n";
1593 tet_printf("%s\n", oss.str().c_str());
1596 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1597 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1598 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1599 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1601 DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1602 DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1607 // SetPosition(float x, float y)
1608 int UtcDaliActorSetPosition01(void)
1610 TestApplication application;
1612 Actor actor = Actor::New();
1614 // Set to random to start off with
1615 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1617 Vector3 vector(100.0f, 100.0f, 0.0f);
1619 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1621 actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1622 // flush the queue and render once
1623 application.SendNotification();
1624 application.Render();
1625 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1627 application.GetScene().Add(actor);
1628 actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1629 // flush the queue and render once
1630 application.SendNotification();
1631 application.Render();
1632 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1634 actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1635 actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1636 actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1637 // flush the queue and render once
1638 application.SendNotification();
1639 application.Render();
1640 DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1642 actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1643 // flush the queue and render once
1644 application.SendNotification();
1645 application.Render();
1646 DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1648 application.GetScene().Remove(actor);
1652 // SetPosition(float x, float y, float z)
1653 int UtcDaliActorSetPosition02(void)
1655 TestApplication application;
1657 Actor actor = Actor::New();
1659 // Set to random to start off with
1660 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1662 Vector3 vector(100.0f, 100.0f, 100.0f);
1664 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1666 actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1668 // flush the queue and render once
1669 application.SendNotification();
1670 application.Render();
1672 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1676 // SetPosition(Vector3 position)
1677 int UtcDaliActorSetPosition03(void)
1679 TestApplication application;
1681 Actor actor = Actor::New();
1683 // Set to random to start off with
1684 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1686 Vector3 vector(100.0f, 100.0f, 100.0f);
1688 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1690 actor.SetProperty(Actor::Property::POSITION, vector);
1692 // flush the queue and render once
1693 application.SendNotification();
1694 application.Render();
1696 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1700 int UtcDaliActorSetX(void)
1702 TestApplication application;
1704 Actor actor = Actor::New();
1706 Vector3 vector(100.0f, 0.0f, 0.0f);
1708 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1710 actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1712 // flush the queue and render once
1713 application.SendNotification();
1714 application.Render();
1716 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1720 int UtcDaliActorSetY(void)
1722 TestApplication application;
1724 Actor actor = Actor::New();
1726 Vector3 vector(0.0f, 100.0f, 0.0f);
1728 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1730 actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1732 // flush the queue and render once
1733 application.SendNotification();
1734 application.Render();
1736 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1740 int UtcDaliActorSetZ(void)
1742 TestApplication application;
1744 Actor actor = Actor::New();
1746 Vector3 vector(0.0f, 0.0f, 100.0f);
1748 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1750 actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1752 // flush the queue and render once
1753 application.SendNotification();
1754 application.Render();
1756 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1760 int UtcDaliActorSetPositionProperties(void)
1762 TestApplication application;
1764 Actor actor = Actor::New();
1766 Vector3 vector(0.7f, 0.8f, 0.9f);
1767 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1769 actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1770 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1771 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1773 // flush the queue and render once
1774 application.SendNotification();
1775 application.Render();
1777 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1778 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1779 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1780 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1781 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1783 actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1784 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1785 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1787 // flush the queue and render once
1788 application.SendNotification();
1789 application.Render();
1791 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1792 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1793 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1794 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1795 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1797 actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1798 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1799 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1801 // flush the queue and render once
1802 application.SendNotification();
1803 application.Render();
1805 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1806 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1807 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1808 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1809 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1814 int UtcDaliActorTranslateBy(void)
1816 TestApplication application;
1818 Actor actor = Actor::New();
1819 Vector3 vector(100.0f, 100.0f, 100.0f);
1821 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1823 actor.SetProperty(Actor::Property::POSITION, vector);
1825 // flush the queue and render once
1826 application.SendNotification();
1827 application.Render();
1829 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1831 actor.TranslateBy(vector);
1833 // flush the queue and render once
1834 application.SendNotification();
1835 application.Render();
1837 DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1841 int UtcDaliActorGetCurrentPosition(void)
1843 TestApplication application;
1845 Actor actor = Actor::New();
1846 Vector3 setVector(100.0f, 100.0f, 0.0f);
1847 actor.SetProperty(Actor::Property::POSITION, setVector);
1849 // flush the queue and render once
1850 application.SendNotification();
1851 application.Render();
1853 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1857 int UtcDaliActorGetCurrentWorldPosition(void)
1859 TestApplication application;
1861 Actor parent = Actor::New();
1862 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1863 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1864 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1865 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1866 application.GetScene().Add(parent);
1868 Actor child = Actor::New();
1869 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1870 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1871 Vector3 childPosition(6.0f, 6.0f, 6.0f);
1872 child.SetProperty(Actor::Property::POSITION, childPosition);
1875 // The actors should not have a world position yet
1876 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1877 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1879 application.SendNotification();
1880 application.Render(0);
1882 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1883 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1885 // The actors should have a world position now
1886 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1887 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1891 int UtcDaliActorSetInheritPosition(void)
1893 tet_infoline("Testing Actor::SetInheritPosition");
1894 TestApplication application;
1896 Actor parent = Actor::New();
1897 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1898 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1899 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1900 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1901 application.GetScene().Add(parent);
1903 Actor child = Actor::New();
1904 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1905 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1906 Vector3 childPosition(10.0f, 11.0f, 12.0f);
1907 child.SetProperty(Actor::Property::POSITION, childPosition);
1910 // The actors should not have a world position yet
1911 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1912 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1914 // first test default, which is to inherit position
1915 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1916 application.SendNotification();
1917 application.Render(0); // should only really call Update as Render is not required to update scene
1918 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1919 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1920 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1921 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1923 //Change child position
1924 Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1925 child.SetProperty(Actor::Property::POSITION, childOffset);
1927 // Use local position as world postion
1928 child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1929 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1930 application.SendNotification();
1931 application.Render(0); // should only really call Update as Render is not required to update scene
1932 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1933 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1934 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1935 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1937 //Change back to inherit position from parent
1938 child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1939 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1940 application.SendNotification();
1941 application.Render(0); // should only really call Update as Render is not required to update scene
1942 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1943 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1944 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1945 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1949 int UtcDaliActorInheritOpacity(void)
1951 tet_infoline("Testing Actor::Inherit Opacity");
1952 TestApplication application;
1954 Actor parent = Actor::New();
1955 Actor child = Actor::New();
1957 application.GetScene().Add(parent);
1959 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1960 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1962 // flush the queue and render once
1963 application.SendNotification();
1964 application.Render();
1966 parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1968 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1969 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1971 application.SendNotification();
1972 application.Render();
1974 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1975 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1976 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1977 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1978 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1979 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1984 // SetOrientation(float angleRadians, Vector3 axis)
1985 int UtcDaliActorSetOrientation01(void)
1987 TestApplication application;
1989 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1990 Actor actor = Actor::New();
1992 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1994 // flush the queue and render once
1995 application.SendNotification();
1996 application.Render();
1998 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2002 int UtcDaliActorSetOrientation02(void)
2004 TestApplication application;
2006 Actor actor = Actor::New();
2008 Radian angle(0.785f);
2009 Vector3 axis(1.0f, 1.0f, 0.0f);
2011 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2012 Quaternion rotation(angle, axis);
2013 // flush the queue and render once
2014 application.SendNotification();
2015 application.Render();
2016 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2018 application.GetScene().Add(actor);
2019 actor.RotateBy(Degree(360), axis);
2020 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2022 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
2023 Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
2024 // flush the queue and render once
2025 application.SendNotification();
2026 application.Render();
2027 DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2029 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
2030 // flush the queue and render once
2031 application.SendNotification();
2032 application.Render();
2033 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2035 application.GetScene().Remove(actor);
2039 // SetOrientation(float angleRadians, Vector3 axis)
2040 int UtcDaliActorSetOrientationProperty(void)
2042 TestApplication application;
2044 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2045 Actor actor = Actor::New();
2047 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2048 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2050 // flush the queue and render once
2051 application.SendNotification();
2052 application.Render();
2054 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2055 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2056 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2060 // RotateBy(float angleRadians, Vector3 axis)
2061 int UtcDaliActorRotateBy01(void)
2063 TestApplication application;
2065 Actor actor = Actor::New();
2067 Radian angle(M_PI * 0.25f);
2068 actor.RotateBy((angle), Vector3::ZAXIS);
2069 // flush the queue and render once
2070 application.SendNotification();
2071 application.Render();
2072 DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2074 application.GetScene().Add(actor);
2076 actor.RotateBy(angle, Vector3::ZAXIS);
2077 // flush the queue and render once
2078 application.SendNotification();
2079 application.Render();
2080 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2082 application.GetScene().Remove(actor);
2086 // RotateBy(Quaternion relativeRotation)
2087 int UtcDaliActorRotateBy02(void)
2089 TestApplication application;
2091 Actor actor = Actor::New();
2093 Radian angle(M_PI * 0.25f);
2094 Quaternion rotation(angle, Vector3::ZAXIS);
2095 actor.RotateBy(rotation);
2096 // flush the queue and render once
2097 application.SendNotification();
2098 application.Render();
2099 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2101 actor.RotateBy(rotation);
2102 // flush the queue and render once
2103 application.SendNotification();
2104 application.Render();
2105 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2109 int UtcDaliActorGetCurrentOrientation(void)
2111 TestApplication application;
2112 Actor actor = Actor::New();
2114 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
2115 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
2116 // flush the queue and render once
2117 application.SendNotification();
2118 application.Render();
2119 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
2123 int UtcDaliActorGetCurrentWorldOrientation(void)
2125 tet_infoline("Testing Actor::GetCurrentWorldRotation");
2126 TestApplication application;
2128 Actor parent = Actor::New();
2129 Radian rotationAngle(Degree(90.0f));
2130 Quaternion rotation(rotationAngle, Vector3::YAXIS);
2131 parent.SetProperty(Actor::Property::ORIENTATION, rotation);
2132 application.GetScene().Add(parent);
2134 Actor child = Actor::New();
2135 child.SetProperty(Actor::Property::ORIENTATION, rotation);
2138 // The actors should not have a world rotation yet
2139 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2140 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
2142 application.SendNotification();
2143 application.Render(0);
2145 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2146 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
2148 // The actors should have a world rotation now
2149 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2150 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
2152 // turn off child rotation inheritance
2153 child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
2154 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
2155 application.SendNotification();
2156 application.Render(0);
2158 // The actors should have a world rotation now
2159 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
2160 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
2164 // SetScale(float scale)
2165 int UtcDaliActorSetScale01(void)
2167 TestApplication application;
2169 Actor actor = Actor::New();
2171 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2172 actor.SetProperty(Actor::Property::SCALE, 0.25f);
2174 Vector3 scale(10.0f, 10.0f, 10.0f);
2175 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2177 actor.SetProperty(Actor::Property::SCALE, scale.x);
2179 // flush the queue and render once
2180 application.SendNotification();
2181 application.Render();
2183 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2187 // SetScale(float scaleX, float scaleY, float scaleZ)
2188 int UtcDaliActorSetScale02(void)
2190 TestApplication application;
2191 Vector3 scale(10.0f, 10.0f, 10.0f);
2193 Actor actor = Actor::New();
2195 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2196 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2198 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2200 actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
2201 // flush the queue and render once
2202 application.SendNotification();
2203 application.Render();
2204 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2206 // add to stage and test
2207 application.GetScene().Add(actor);
2208 actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
2209 // flush the queue and render once
2210 application.SendNotification();
2211 application.Render();
2212 DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
2214 application.GetScene().Remove(actor);
2219 // SetScale(Vector3 scale)
2220 int UtcDaliActorSetScale03(void)
2222 TestApplication application;
2223 Vector3 scale(10.0f, 10.0f, 10.0f);
2225 Actor actor = Actor::New();
2227 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
2228 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
2230 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
2232 actor.SetProperty(Actor::Property::SCALE, scale);
2234 // flush the queue and render once
2235 application.SendNotification();
2236 application.Render();
2238 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2242 int UtcDaliActorSetScaleIndividual(void)
2244 TestApplication application;
2246 Actor actor = Actor::New();
2248 Vector3 vector(0.7f, 0.8f, 0.9f);
2249 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2251 actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2252 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2254 // flush the queue and render once
2255 application.SendNotification();
2256 application.Render();
2258 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2259 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2260 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2262 actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2263 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2265 // flush the queue and render once
2266 application.SendNotification();
2267 application.Render();
2269 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2270 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2271 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2273 actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2274 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2276 // flush the queue and render once
2277 application.SendNotification();
2278 application.Render();
2280 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2281 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2282 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2284 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2285 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2290 int UtcDaliActorScaleBy(void)
2292 TestApplication application;
2293 Actor actor = Actor::New();
2294 Vector3 vector(100.0f, 100.0f, 100.0f);
2296 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2298 actor.SetProperty(Actor::Property::SCALE, vector);
2300 // flush the queue and render once
2301 application.SendNotification();
2302 application.Render();
2304 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2306 actor.ScaleBy(vector);
2308 // flush the queue and render once
2309 application.SendNotification();
2310 application.Render();
2312 DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2316 int UtcDaliActorGetCurrentScale(void)
2318 TestApplication application;
2319 Vector3 scale(12.0f, 1.0f, 2.0f);
2321 Actor actor = Actor::New();
2323 actor.SetProperty(Actor::Property::SCALE, scale);
2325 // flush the queue and render once
2326 application.SendNotification();
2327 application.Render();
2329 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2333 int UtcDaliActorGetCurrentWorldScale(void)
2335 TestApplication application;
2337 Actor parent = Actor::New();
2338 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2339 parent.SetProperty(Actor::Property::SCALE, parentScale);
2340 application.GetScene().Add(parent);
2342 Actor child = Actor::New();
2343 Vector3 childScale(2.0f, 2.0f, 2.0f);
2344 child.SetProperty(Actor::Property::SCALE, childScale);
2347 // The actors should not have a scale yet
2348 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2349 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2351 // The actors should not have a world scale yet
2352 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2353 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2355 application.SendNotification();
2356 application.Render(0);
2358 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2359 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2361 // The actors should have a world scale now
2362 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2363 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2367 int UtcDaliActorInheritScale(void)
2369 tet_infoline("Testing Actor::SetInheritScale");
2370 TestApplication application;
2372 Actor parent = Actor::New();
2373 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2374 parent.SetProperty(Actor::Property::SCALE, parentScale);
2375 application.GetScene().Add(parent);
2377 Actor child = Actor::New();
2378 Vector3 childScale(2.0f, 2.0f, 2.0f);
2379 child.SetProperty(Actor::Property::SCALE, childScale);
2382 application.SendNotification();
2383 application.Render(0);
2385 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2386 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2388 child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2389 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2391 application.SendNotification();
2392 application.Render(0);
2394 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2398 int UtcDaliActorSetVisible(void)
2400 TestApplication application;
2402 Actor actor = Actor::New();
2403 actor.SetProperty(Actor::Property::VISIBLE, false);
2404 // flush the queue and render once
2405 application.SendNotification();
2406 application.Render();
2407 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2409 actor.SetProperty(Actor::Property::VISIBLE, true);
2410 // flush the queue and render once
2411 application.SendNotification();
2412 application.Render();
2413 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2415 // put actor on stage
2416 application.GetScene().Add(actor);
2417 actor.SetProperty(Actor::Property::VISIBLE, false);
2418 // flush the queue and render once
2419 application.SendNotification();
2420 application.Render();
2421 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2425 int UtcDaliActorIsVisible(void)
2427 TestApplication application;
2429 Actor actor = Actor::New();
2431 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2435 int UtcDaliActorSetOpacity(void)
2437 TestApplication application;
2439 Actor actor = Actor::New();
2440 // initial opacity is 1
2441 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2443 actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2444 // flush the queue and render once
2445 application.SendNotification();
2446 application.Render();
2447 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2449 // change opacity, actor is on stage to change is not immediate
2450 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2451 // flush the queue and render once
2452 application.SendNotification();
2453 application.Render();
2454 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2456 // put actor on stage
2457 application.GetScene().Add(actor);
2459 // change opacity, actor is on stage to change is not immediate
2460 actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2461 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2462 // flush the queue and render once
2463 application.SendNotification();
2464 application.Render();
2465 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2467 // change opacity, actor is on stage to change is not immediate
2468 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2469 // flush the queue and render once
2470 application.SendNotification();
2471 application.Render();
2472 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2476 int UtcDaliActorGetCurrentOpacity(void)
2478 TestApplication application;
2480 Actor actor = Actor::New();
2481 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2483 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2484 // flush the queue and render once
2485 application.SendNotification();
2486 application.Render();
2487 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2491 int UtcDaliActorSetSensitive(void)
2493 TestApplication application;
2494 Actor actor = Actor::New();
2496 bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2498 actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2500 DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2504 int UtcDaliActorIsSensitive(void)
2506 TestApplication application;
2507 Actor actor = Actor::New();
2508 actor.SetProperty(Actor::Property::SENSITIVE, false);
2510 DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2514 int UtcDaliActorSetColor(void)
2516 TestApplication application;
2517 Actor actor = Actor::New();
2518 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2520 DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2522 actor.SetProperty(Actor::Property::COLOR, color);
2523 // flush the queue and render once
2524 application.SendNotification();
2525 application.Render();
2526 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2528 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2529 // flush the queue and render once
2530 application.SendNotification();
2531 application.Render();
2532 DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2534 application.GetScene().Add(actor);
2535 actor.SetProperty(Actor::Property::COLOR, color);
2536 // flush the queue and render once
2537 application.SendNotification();
2538 application.Render();
2539 DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2541 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2542 // flush the queue and render once
2543 application.SendNotification();
2544 application.Render();
2545 // Actor color is not clamped
2546 DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2547 // world color is clamped
2548 DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2550 actor.SetProperty(Actor::Property::COLOR, color);
2551 DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2553 Vector3 newColor(1.0f, 0.0f, 0.0f);
2554 actor.SetProperty(Actor::Property::COLOR, newColor);
2555 DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2557 application.GetScene().Remove(actor);
2561 int UtcDaliActorSetColorIndividual(void)
2563 TestApplication application;
2565 Actor actor = Actor::New();
2567 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2568 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2570 actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2571 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2573 // flush the queue and render once
2574 application.SendNotification();
2575 application.Render();
2577 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2578 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2579 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2581 actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2582 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2584 // flush the queue and render once
2585 application.SendNotification();
2586 application.Render();
2588 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2589 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2590 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2592 actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2593 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2595 // flush the queue and render once
2596 application.SendNotification();
2597 application.Render();
2599 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2600 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2601 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2603 actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2604 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2606 // flush the queue and render once
2607 application.SendNotification();
2608 application.Render();
2610 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2611 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2612 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2614 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2615 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2617 actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2619 // flush the queue and render once
2620 application.SendNotification();
2621 application.Render();
2623 DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2628 int UtcDaliActorGetCurrentColor(void)
2630 TestApplication application;
2631 Actor actor = Actor::New();
2632 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2634 actor.SetProperty(Actor::Property::COLOR, color);
2635 // flush the queue and render once
2636 application.SendNotification();
2637 application.Render();
2638 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2642 int UtcDaliActorGetCurrentWorldColor(void)
2644 tet_infoline("Actor::GetCurrentWorldColor");
2645 TestApplication application;
2647 Actor parent = Actor::New();
2648 Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2649 parent.SetProperty(Actor::Property::COLOR, parentColor);
2650 application.GetScene().Add(parent);
2652 Actor child = Actor::New();
2653 Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2654 child.SetProperty(Actor::Property::COLOR, childColor);
2657 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2658 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2660 // verify the default color mode
2661 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2663 // The actors should not have a world color yet
2664 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2665 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2667 application.SendNotification();
2668 application.Render(0);
2670 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2671 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2673 // The actors should have a world color now
2674 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2675 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2678 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2679 application.SendNotification();
2680 application.Render(0);
2681 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2684 child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2685 application.SendNotification();
2686 application.Render(0);
2687 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2688 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2691 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2692 application.SendNotification();
2693 application.Render(0);
2694 Vector4 expectedColor(childColor);
2695 expectedColor.a *= parentColor.a;
2696 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2697 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2701 int UtcDaliActorSetColorMode(void)
2703 tet_infoline("Actor::SetColorMode");
2704 TestApplication application;
2705 Actor actor = Actor::New();
2706 Actor child = Actor::New();
2709 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2710 DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2712 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2713 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2715 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2716 DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2718 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2719 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2723 int UtcDaliActorScreenToLocal(void)
2725 TestApplication application;
2726 Actor actor = Actor::New();
2727 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2728 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2729 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2730 application.GetScene().Add(actor);
2732 // flush the queue and render once
2733 application.SendNotification();
2734 application.Render();
2739 application.SendNotification();
2740 application.Render();
2742 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2744 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2745 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2749 int UtcDaliActorSetLeaveRequired(void)
2751 TestApplication application;
2753 Actor actor = Actor::New();
2755 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2756 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2758 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2759 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2763 int UtcDaliActorGetLeaveRequired(void)
2765 TestApplication application;
2767 Actor actor = Actor::New();
2769 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2773 int UtcDaliActorSetKeyboardFocusable(void)
2775 TestApplication application;
2777 Actor actor = Actor::New();
2779 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2780 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2782 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2783 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2787 int UtcDaliActorIsKeyboardFocusable(void)
2789 TestApplication application;
2791 Actor actor = Actor::New();
2793 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2797 int UtcDaliActorSetKeyboardFocusableChildren(void)
2799 TestApplication application;
2801 Actor actor = Actor::New();
2803 actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2804 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2806 actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2807 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
2811 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
2813 TestApplication application;
2815 Actor actor = Actor::New();
2817 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2821 int UtcDaliActorSetTouchFocusable(void)
2823 TestApplication application;
2825 Actor actor = Actor::New();
2827 actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2828 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2830 actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2831 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2835 int UtcDaliActorIsTouchFocusable(void)
2837 TestApplication application;
2839 Actor actor = Actor::New();
2841 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2845 int UtcDaliActorSetUserInteractionEnabled(void)
2847 TestApplication application;
2848 Actor actor = Actor::New();
2850 bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
2852 actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
2854 DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2858 int UtcDaliActorIsUserInteractionEnabled(void)
2860 TestApplication application;
2861 Actor actor = Actor::New();
2862 actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
2864 DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2868 int UtcDaliActorRemoveConstraints(void)
2870 tet_infoline(" UtcDaliActorRemoveConstraints");
2871 TestApplication application;
2873 gTestConstraintCalled = false;
2875 Actor actor = Actor::New();
2877 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2879 actor.RemoveConstraints();
2881 DALI_TEST_CHECK(gTestConstraintCalled == false);
2883 application.GetScene().Add(actor);
2886 // flush the queue and render once
2887 application.SendNotification();
2888 application.Render();
2890 actor.RemoveConstraints();
2892 DALI_TEST_CHECK(gTestConstraintCalled == true);
2896 int UtcDaliActorRemoveConstraintTag(void)
2898 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2899 TestApplication application;
2901 Actor actor = Actor::New();
2903 // 1. Apply Constraint1 and Constraint2, and test...
2904 unsigned int result1 = 0u;
2905 unsigned int result2 = 0u;
2907 unsigned constraint1Tag = 1u;
2908 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2909 constraint1.SetTag(constraint1Tag);
2910 constraint1.Apply();
2912 unsigned constraint2Tag = 2u;
2913 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2914 constraint2.SetTag(constraint2Tag);
2915 constraint2.Apply();
2917 application.GetScene().Add(actor);
2918 // flush the queue and render once
2919 application.SendNotification();
2920 application.Render();
2922 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2923 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2925 // 2. Remove Constraint1 and test...
2928 actor.RemoveConstraints(constraint1Tag);
2929 // make color property dirty, which will trigger constraints to be reapplied.
2930 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2931 // flush the queue and render once
2932 application.SendNotification();
2933 application.Render();
2935 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2936 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2938 // 3. Re-Apply Constraint1 and test...
2941 constraint1.Apply();
2942 // make color property dirty, which will trigger constraints to be reapplied.
2943 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2944 // flush the queue and render once
2945 application.SendNotification();
2946 application.Render();
2948 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2949 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2951 // 2. Remove Constraint2 and test...
2954 actor.RemoveConstraints(constraint2Tag);
2955 // make color property dirty, which will trigger constraints to be reapplied.
2956 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2957 // flush the queue and render once
2958 application.SendNotification();
2959 application.Render();
2961 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2962 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2964 // 2. Remove Constraint1 as well and test...
2967 actor.RemoveConstraints(constraint1Tag);
2968 // make color property dirty, which will trigger constraints to be reapplied.
2969 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2970 // flush the queue and render once
2971 application.SendNotification();
2972 application.Render();
2974 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2975 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2979 int UtcDaliActorTouchedSignal(void)
2981 TestApplication application;
2983 ResetTouchCallbacks();
2985 // get the root layer
2986 Actor actor = application.GetScene().GetRootLayer();
2987 DALI_TEST_CHECK(gTouchCallBackCalled == false);
2989 application.SendNotification();
2990 application.Render();
2992 // connect to its touch signal
2993 actor.TouchedSignal().Connect(TestTouchCallback);
2995 // simulate a touch event in the middle of the screen
2996 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2997 Dali::Integration::Point point;
2998 point.SetDeviceId(1);
2999 point.SetState(PointState::DOWN);
3000 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3001 Dali::Integration::TouchEvent touchEvent;
3002 touchEvent.AddPoint(point);
3003 application.ProcessEvent(touchEvent);
3005 DALI_TEST_CHECK(gTouchCallBackCalled == true);
3009 int UtcDaliActorHoveredSignal(void)
3011 TestApplication application;
3013 gHoverCallBackCalled = false;
3015 // get the root layer
3016 Actor actor = application.GetScene().GetRootLayer();
3017 DALI_TEST_CHECK(gHoverCallBackCalled == false);
3019 application.SendNotification();
3020 application.Render();
3022 // connect to its hover signal
3023 actor.HoveredSignal().Connect(TestCallback3);
3025 // simulate a hover event in the middle of the screen
3026 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
3027 Dali::Integration::Point point;
3028 point.SetDeviceId(1);
3029 point.SetState(PointState::MOTION);
3030 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
3031 Dali::Integration::HoverEvent hoverEvent;
3032 hoverEvent.AddPoint(point);
3033 application.ProcessEvent(hoverEvent);
3035 DALI_TEST_CHECK(gHoverCallBackCalled == true);
3039 int UtcDaliActorOnOffSceneSignal(void)
3041 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
3043 TestApplication application;
3046 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3047 gActorNamesOnOffScene.clear();
3049 Actor parent = Actor::New();
3050 parent.SetProperty(Actor::Property::NAME, "parent");
3051 parent.OnSceneSignal().Connect(OnSceneCallback);
3052 parent.OffSceneSignal().Connect(OffSceneCallback);
3054 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
3055 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
3057 // add parent to the scene
3058 application.GetScene().Add(parent);
3059 // onstage emitted, offstage not
3060 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3061 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3062 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3064 // test adding a child, should get onstage emitted
3066 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3067 gActorNamesOnOffScene.clear();
3069 Actor child = Actor::New();
3070 child.SetProperty(Actor::Property::NAME, "child");
3071 child.OnSceneSignal().Connect(OnSceneCallback);
3072 child.OffSceneSignal().Connect(OffSceneCallback);
3073 parent.Add(child); // add child
3074 // onscene emitted, offscene not
3075 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
3076 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3077 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3079 // test removing parent from the scene
3081 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3082 gActorNamesOnOffScene.clear();
3084 application.GetScene().Remove(parent);
3085 // onscene not emitted, offscene is
3086 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3087 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
3088 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3089 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
3091 // test adding parent back to the scene
3093 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3094 gActorNamesOnOffScene.clear();
3096 application.GetScene().Add(parent);
3097 // onscene emitted, offscene not
3098 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
3099 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
3100 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3101 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
3103 // test removing child
3105 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3106 gActorNamesOnOffScene.clear();
3108 parent.Remove(child);
3109 // onscene not emitted, offscene is
3110 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3111 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3112 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
3114 // test removing parent
3116 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
3117 gActorNamesOnOffScene.clear();
3119 application.GetScene().Remove(parent);
3120 // onscene not emitted, offscene is
3121 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
3122 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
3123 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
3127 int UtcDaliActorFindChildByName(void)
3129 tet_infoline("Testing Dali::Actor::FindChildByName()");
3130 TestApplication application;
3132 Actor parent = Actor::New();
3133 parent.SetProperty(Actor::Property::NAME, "parent");
3134 Actor first = Actor::New();
3135 first.SetProperty(Actor::Property::NAME, "first");
3136 Actor second = Actor::New();
3137 second.SetProperty(Actor::Property::NAME, "second");
3142 Actor found = parent.FindChildByName("foo");
3143 DALI_TEST_CHECK(!found);
3145 found = parent.FindChildByName("parent");
3146 DALI_TEST_CHECK(found == parent);
3148 found = parent.FindChildByName("first");
3149 DALI_TEST_CHECK(found == first);
3151 found = parent.FindChildByName("second");
3152 DALI_TEST_CHECK(found == second);
3156 int UtcDaliActorFindChildById(void)
3158 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
3159 TestApplication application;
3161 Actor parent = Actor::New();
3162 Actor first = Actor::New();
3163 Actor second = Actor::New();
3168 Actor found = parent.FindChildById(100000);
3169 DALI_TEST_CHECK(!found);
3171 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
3172 DALI_TEST_CHECK(found == parent);
3174 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
3175 DALI_TEST_CHECK(found == first);
3177 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
3178 DALI_TEST_CHECK(found == second);
3182 int UtcDaliActorHitTest(void)
3187 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
3189 mTouchPoint(touchPoint),
3195 Vector2 mTouchPoint;
3199 TestApplication application;
3200 tet_infoline(" UtcDaliActorHitTest");
3202 // Fill a vector with different hit tests.
3203 struct HitTestData* hitTestData[] = {
3204 // scale touch point result
3205 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
3206 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
3207 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.
3208 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
3209 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.
3213 // get the root layer
3214 Actor actor = Actor::New();
3215 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3216 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3218 application.GetScene().Add(actor);
3220 ResetTouchCallbacks();
3222 unsigned int index = 0;
3223 while(NULL != hitTestData[index])
3225 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
3226 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
3228 // flush the queue and render once
3229 application.SendNotification();
3230 application.Render();
3232 DALI_TEST_CHECK(!gTouchCallBackCalled);
3234 // connect to its touch signal
3235 actor.TouchedSignal().Connect(TestTouchCallback);
3237 Dali::Integration::Point point;
3238 point.SetState(PointState::DOWN);
3239 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3240 Dali::Integration::TouchEvent event;
3241 event.AddPoint(point);
3243 // flush the queue and render once
3244 application.SendNotification();
3245 application.Render();
3246 application.ProcessEvent(event);
3248 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3250 if(gTouchCallBackCalled != hitTestData[index]->mResult)
3251 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3252 hitTestData[index]->mScale.x,
3253 hitTestData[index]->mScale.y,
3254 hitTestData[index]->mScale.z,
3255 hitTestData[index]->mTouchPoint.x,
3256 hitTestData[index]->mTouchPoint.y,
3257 hitTestData[index]->mResult);
3259 ResetTouchCallbacks();
3265 int UtcDaliActorSetDrawMode(void)
3267 TestApplication application;
3268 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3270 Actor a = Actor::New();
3272 application.GetScene().Add(a);
3273 application.SendNotification();
3274 application.Render(0);
3275 application.SendNotification();
3276 application.Render(1);
3278 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3280 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3281 application.SendNotification();
3282 application.Render(1);
3284 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3286 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3287 application.SendNotification();
3288 application.Render(1);
3290 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3294 int UtcDaliActorSetDrawModeOverlayRender(void)
3296 TestApplication application;
3297 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3299 application.SendNotification();
3300 application.Render(1);
3302 std::vector<GLuint> ids;
3303 ids.push_back(8); // first rendered actor
3304 ids.push_back(9); // second rendered actor
3305 ids.push_back(10); // third rendered actor
3306 application.GetGlAbstraction().SetNextTextureIds(ids);
3308 Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3309 Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3310 Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3311 Actor a = CreateRenderableActor(imageA);
3312 Actor b = CreateRenderableActor(imageB);
3313 Actor c = CreateRenderableActor(imageC);
3315 application.SendNotification();
3316 application.Render(1);
3318 //Textures are bound when first created. Clear bound textures vector
3319 application.GetGlAbstraction().ClearBoundTextures();
3321 // Render a,b,c as regular non-overlays. so order will be:
3325 application.GetScene().Add(a);
3326 application.GetScene().Add(b);
3327 application.GetScene().Add(c);
3329 application.SendNotification();
3330 application.Render(1);
3332 // Should be 3 textures changes.
3333 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3334 typedef std::vector<GLuint>::size_type TextureSize;
3335 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3336 if(boundTextures.size() == 3)
3338 DALI_TEST_CHECK(boundTextures[0] == 8u);
3339 DALI_TEST_CHECK(boundTextures[1] == 9u);
3340 DALI_TEST_CHECK(boundTextures[2] == 10u);
3343 // Now texture ids have been set, we can monitor their render order.
3344 // render a as an overlay (last), so order will be:
3348 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3349 application.GetGlAbstraction().ClearBoundTextures();
3351 application.SendNotification();
3352 application.Render(1);
3354 // Should be 3 texture changes.
3355 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3356 if(boundTextures.size() == 3)
3358 DALI_TEST_CHECK(boundTextures[0] == 9u);
3359 DALI_TEST_CHECK(boundTextures[1] == 10u);
3360 DALI_TEST_CHECK(boundTextures[2] == 8u);
3365 int UtcDaliActorGetCurrentWorldMatrix(void)
3367 TestApplication application;
3368 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3370 Actor parent = Actor::New();
3371 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3372 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3373 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3374 Radian rotationAngle(Degree(85.0f));
3375 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3376 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3377 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3378 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3379 parent.SetProperty(Actor::Property::SCALE, parentScale);
3380 application.GetScene().Add(parent);
3382 Actor child = Actor::New();
3383 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3384 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3385 Radian childRotationAngle(Degree(23.0f));
3386 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3387 Vector3 childScale(2.0f, 2.0f, 2.0f);
3388 child.SetProperty(Actor::Property::POSITION, childPosition);
3389 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3390 child.SetProperty(Actor::Property::SCALE, childScale);
3393 application.SendNotification();
3394 application.Render(0);
3395 application.Render();
3396 application.SendNotification();
3398 Matrix parentMatrix(false);
3399 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3401 Matrix childMatrix(false);
3402 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3404 //Child matrix should be the composition of child and parent
3405 Matrix childWorldMatrix(false);
3406 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3408 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3409 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3413 int UtcDaliActorConstrainedToWorldMatrix(void)
3415 TestApplication application;
3416 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3418 Actor parent = Actor::New();
3419 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3420 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3421 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3422 Radian rotationAngle(Degree(85.0f));
3423 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3424 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3425 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3426 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3427 parent.SetProperty(Actor::Property::SCALE, parentScale);
3428 application.GetScene().Add(parent);
3430 Actor child = Actor::New();
3431 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3432 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3433 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3434 posConstraint.Apply();
3436 application.GetScene().Add(child);
3438 application.SendNotification();
3439 application.Render(0);
3440 application.Render();
3441 application.SendNotification();
3443 Matrix parentMatrix(false);
3444 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3446 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3447 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3451 int UtcDaliActorConstrainedToOrientation(void)
3453 TestApplication application;
3454 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3456 Actor parent = Actor::New();
3457 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3458 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3459 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3460 Radian rotationAngle(Degree(85.0f));
3461 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3462 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3463 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3464 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3465 parent.SetProperty(Actor::Property::SCALE, parentScale);
3466 application.GetScene().Add(parent);
3468 Actor child = Actor::New();
3469 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3470 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3471 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3472 posConstraint.Apply();
3474 application.GetScene().Add(child);
3476 application.SendNotification();
3477 application.Render(0);
3478 application.Render();
3479 application.SendNotification();
3481 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3485 int UtcDaliActorConstrainedToOpacity(void)
3487 TestApplication application;
3488 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3490 Actor parent = Actor::New();
3491 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3492 application.GetScene().Add(parent);
3494 Actor child = Actor::New();
3495 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3496 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3497 opacityConstraint.Apply();
3499 application.GetScene().Add(child);
3501 application.SendNotification();
3502 application.Render(0);
3503 application.Render();
3504 application.SendNotification();
3506 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3508 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3510 application.SendNotification();
3511 application.Render(0);
3512 application.Render();
3513 application.SendNotification();
3515 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3520 int UtcDaliActorUnparent(void)
3522 TestApplication application;
3523 tet_infoline(" UtcDaliActorUnparent");
3525 Actor parent = Actor::New();
3526 application.GetScene().Add(parent);
3528 Actor child = Actor::New();
3530 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3531 DALI_TEST_CHECK(!child.GetParent());
3533 // Test that calling Unparent with no parent is a NOOP
3536 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3537 DALI_TEST_CHECK(!child.GetParent());
3539 // Test that Unparent works
3542 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3543 DALI_TEST_CHECK(parent == child.GetParent());
3547 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3548 DALI_TEST_CHECK(!child.GetParent());
3550 // Test that UnparentAndReset works
3553 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3554 DALI_TEST_CHECK(parent == child.GetParent());
3556 UnparentAndReset(child);
3558 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3559 DALI_TEST_CHECK(!child);
3561 // Test that UnparentAndReset is a NOOP with empty handle
3562 UnparentAndReset(child);
3564 DALI_TEST_CHECK(!child);
3568 int UtcDaliActorGetChildAt(void)
3570 TestApplication application;
3571 tet_infoline(" UtcDaliActorGetChildAt");
3573 Actor parent = Actor::New();
3574 application.GetScene().Add(parent);
3576 Actor child0 = Actor::New();
3579 Actor child1 = Actor::New();
3582 Actor child2 = Actor::New();
3585 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3586 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3587 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3591 int UtcDaliActorSetGetOverlay(void)
3593 TestApplication application;
3594 tet_infoline(" UtcDaliActorSetGetOverlay");
3596 Actor parent = Actor::New();
3597 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3598 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3602 int UtcDaliActorCreateDestroy(void)
3604 Actor* actor = new Actor;
3605 DALI_TEST_CHECK(actor);
3612 struct PropertyStringIndex
3614 const char* const name;
3615 const Property::Index index;
3616 const Property::Type type;
3619 const PropertyStringIndex PROPERTY_TABLE[] =
3621 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3622 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3623 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3624 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3625 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3626 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3627 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3628 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3629 {"size", Actor::Property::SIZE, Property::VECTOR3},
3630 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3631 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3632 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3633 {"position", Actor::Property::POSITION, Property::VECTOR3},
3634 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3635 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3636 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3637 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3638 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3639 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3640 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3641 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3642 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3643 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3644 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3645 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3646 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3647 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3648 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3649 {"color", Actor::Property::COLOR, Property::VECTOR4},
3650 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3651 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3652 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3653 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3654 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3655 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3656 {"name", Actor::Property::NAME, Property::STRING},
3657 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3658 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3659 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3660 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3661 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3662 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3663 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3664 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3665 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3666 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3667 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3668 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3669 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3670 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3671 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3672 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3673 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3674 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3676 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3677 } // unnamed namespace
3679 int UtcDaliActorProperties(void)
3681 TestApplication application;
3683 Actor actor = Actor::New();
3685 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3687 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3688 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3689 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3690 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3695 int UtcDaliRelayoutProperties_ResizePolicies(void)
3697 TestApplication application;
3699 Actor actor = Actor::New();
3702 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3703 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3705 // Set resize policy for all dimensions
3706 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3707 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3709 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3712 // Set individual dimensions
3713 const char* const widthPolicy = "FILL_TO_PARENT";
3714 const char* const heightPolicy = "FIXED";
3716 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3717 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3719 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3720 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3722 // Set individual dimensions using enums
3723 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3724 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3726 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3727 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3729 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3730 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3735 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3737 TestApplication application;
3739 Actor actor = Actor::New();
3742 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3744 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3745 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3746 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3749 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3750 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3752 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3753 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3755 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3756 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3761 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3763 TestApplication application;
3765 Actor actor = Actor::New();
3768 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3769 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3771 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3772 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3773 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3776 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3778 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3779 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3784 int UtcDaliRelayoutProperties_DimensionDependency(void)
3786 TestApplication application;
3788 Actor actor = Actor::New();
3791 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3792 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3795 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3796 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3798 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3799 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3801 // Test setting another resize policy
3802 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3803 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3808 int UtcDaliRelayoutProperties_Padding(void)
3810 TestApplication application;
3812 Actor actor = Actor::New();
3815 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3818 actor.SetProperty(Actor::Property::PADDING, padding);
3819 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3821 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3826 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3828 TestApplication application;
3830 Actor actor = Actor::New();
3833 Vector2 minSize(1.0f, 2.0f);
3835 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3836 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3838 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3840 Vector2 maxSize(3.0f, 4.0f);
3842 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3843 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3845 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3850 int UtcDaliActorGetHeightForWidth(void)
3852 TestApplication application;
3854 Actor actor = Actor::New();
3856 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3861 int UtcDaliActorGetWidthForHeight(void)
3863 TestApplication application;
3865 Actor actor = Actor::New();
3867 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3872 int UtcDaliActorGetRelayoutSize(void)
3874 TestApplication application;
3876 Actor actor = Actor::New();
3878 // Add actor to stage
3879 application.GetScene().Add(actor);
3881 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3883 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3884 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3886 // Flush the queue and render once
3887 application.SendNotification();
3888 application.Render();
3890 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3895 int UtcDaliActorSetPadding(void)
3897 TestApplication application;
3899 Actor actor = Actor::New();
3902 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3904 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3905 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3906 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3907 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3909 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3910 actor.SetProperty(Actor::Property::PADDING, padding2);
3912 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3914 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3915 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3916 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3917 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3922 int UtcDaliActorSetMinimumSize(void)
3924 TestApplication application;
3926 Actor actor = Actor::New();
3928 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3930 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3931 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3933 Vector2 size2(1.0f, 2.0f);
3934 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3936 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3938 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3939 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3944 int UtcDaliActorSetMaximumSize(void)
3946 TestApplication application;
3948 Actor actor = Actor::New();
3950 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3952 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3953 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3955 Vector2 size2(1.0f, 2.0f);
3956 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3958 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3960 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3961 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3966 int UtcDaliActorOnRelayoutSignal(void)
3968 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3970 TestApplication application;
3973 gOnRelayoutCallBackCalled = false;
3974 gActorNamesRelayout.clear();
3976 Actor actor = Actor::New();
3977 actor.SetProperty(Actor::Property::NAME, "actor");
3978 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3981 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3983 // Add actor to stage
3984 application.GetScene().Add(actor);
3986 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3987 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3989 // Flush the queue and render once
3990 application.SendNotification();
3991 application.Render();
3993 // OnRelayout emitted
3994 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3995 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
4000 int UtcDaliActorGetHierachyDepth(void)
4002 TestApplication application;
4003 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
4005 /* Build tree of actors:
4015 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
4017 Integration::Scene stage(application.GetScene());
4019 Actor actorA = Actor::New();
4020 Actor actorB = Actor::New();
4021 Actor actorC = Actor::New();
4022 Actor actorD = Actor::New();
4023 Actor actorE = Actor::New();
4024 Actor actorF = Actor::New();
4026 //Test that root actor has depth equal 0
4027 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4029 //Test actors return depth -1 when not connected to the tree
4030 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4031 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4032 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4033 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4034 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4035 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4037 //Create the hierarchy
4045 //Test actors return correct depth
4046 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4047 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4048 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4049 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4050 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4051 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4053 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
4054 actorA.Remove(actorB);
4056 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4057 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4058 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4060 //Removing actorA from the stage. All actors should have depth equal -1
4061 stage.Remove(actorA);
4063 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4064 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4065 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4066 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4067 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4068 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
4073 int UtcDaliActorAnchorPointPropertyAsString(void)
4075 TestApplication application;
4077 Actor actor = Actor::New();
4079 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
4080 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4082 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
4083 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4085 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
4086 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4088 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
4089 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4091 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
4092 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
4094 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
4095 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4097 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
4098 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4100 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
4101 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4103 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
4104 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4106 // Invalid should not change anything
4107 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
4108 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4113 int UtcDaliActorParentOriginPropertyAsString(void)
4115 TestApplication application;
4117 Actor actor = Actor::New();
4119 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
4120 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
4122 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
4123 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
4125 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
4126 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
4128 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
4129 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
4131 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
4132 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
4134 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
4135 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
4137 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
4138 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
4140 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
4141 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
4143 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
4144 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4146 // Invalid should not change anything
4147 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
4148 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
4153 int UtcDaliActorColorModePropertyAsString(void)
4155 TestApplication application;
4157 Actor actor = Actor::New();
4159 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
4160 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4162 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
4163 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4165 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
4166 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4168 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
4169 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4171 // Invalid should not change anything
4172 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
4173 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4178 int UtcDaliActorDrawModePropertyAsString(void)
4180 TestApplication application;
4182 Actor actor = Actor::New();
4184 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
4185 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4187 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
4188 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4190 // Invalid should not change anything
4191 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
4192 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4197 int UtcDaliActorColorModePropertyAsEnum(void)
4199 TestApplication application;
4201 Actor actor = Actor::New();
4203 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
4204 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
4206 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
4207 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
4209 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
4210 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
4212 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
4213 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
4218 int UtcDaliActorDrawModePropertyAsEnum(void)
4220 TestApplication application;
4222 Actor actor = Actor::New();
4224 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
4225 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
4227 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
4228 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
4233 int UtcDaliActorAddRendererP(void)
4235 tet_infoline("Testing Actor::AddRenderer");
4236 TestApplication application;
4238 Actor actor = Actor::New();
4240 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4242 Geometry geometry = CreateQuadGeometry();
4243 Shader shader = CreateShader();
4244 Renderer renderer = Renderer::New(geometry, shader);
4246 actor.AddRenderer(renderer);
4247 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4248 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4253 int UtcDaliActorAddRendererN01(void)
4255 tet_infoline("Testing Actor::AddRenderer");
4256 TestApplication application;
4258 Actor actor = Actor::New();
4264 actor.AddRenderer(renderer);
4265 tet_printf("Assertion test failed - no Exception\n");
4266 tet_result(TET_FAIL);
4268 catch(Dali::DaliException& e)
4270 DALI_TEST_PRINT_ASSERT(e);
4271 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4272 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4276 tet_printf("Assertion test failed - wrong Exception\n");
4277 tet_result(TET_FAIL);
4283 int UtcDaliActorAddRendererN02(void)
4285 tet_infoline("UtcDaliActorAddRendererN02");
4291 TestApplication application;
4293 Geometry geometry = CreateQuadGeometry();
4294 Shader shader = CreateShader();
4295 renderer = Renderer::New(geometry, shader);
4297 actor = Actor::New();
4300 // try illegal AddRenderer
4303 actor.AddRenderer(renderer);
4304 tet_printf("Assertion test failed - no Exception\n");
4305 tet_result(TET_FAIL);
4307 catch(Dali::DaliException& e)
4309 DALI_TEST_PRINT_ASSERT(e);
4310 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4314 tet_printf("Assertion test failed - wrong Exception\n");
4315 tet_result(TET_FAIL);
4321 int UtcDaliActorAddRendererOnScene(void)
4323 tet_infoline("Testing Actor::AddRenderer");
4324 TestApplication application;
4326 Actor actor = Actor::New();
4327 application.GetScene().Add(actor);
4329 application.SendNotification();
4330 application.Render(0);
4332 Geometry geometry = CreateQuadGeometry();
4333 Shader shader = CreateShader();
4334 Renderer renderer = Renderer::New(geometry, shader);
4336 application.SendNotification();
4337 application.Render(0);
4341 actor.AddRenderer(renderer);
4342 tet_result(TET_PASS);
4346 tet_result(TET_FAIL);
4352 int UtcDaliActorRemoveRendererP1(void)
4354 tet_infoline("Testing Actor::RemoveRenderer");
4355 TestApplication application;
4357 Actor actor = Actor::New();
4359 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4362 Geometry geometry = CreateQuadGeometry();
4363 Shader shader = CreateShader();
4364 Renderer renderer = Renderer::New(geometry, shader);
4366 actor.AddRenderer(renderer);
4367 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4368 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4370 application.SendNotification();
4371 application.Render();
4375 Renderer renderer = actor.GetRendererAt(0);
4376 actor.RemoveRenderer(renderer);
4377 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4379 application.SendNotification();
4380 application.Render();
4383 // Call one final time to ensure that the renderer is actually removed after
4384 // the handle goes out of scope, and excercises the deletion code path in
4385 // scene graph and render.
4386 application.SendNotification();
4387 application.Render();
4392 int UtcDaliActorRemoveRendererP2(void)
4394 tet_infoline("Testing Actor::RemoveRenderer");
4395 TestApplication application;
4397 Actor actor = Actor::New();
4399 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4401 Geometry geometry = CreateQuadGeometry();
4402 Shader shader = CreateShader();
4403 Renderer renderer = Renderer::New(geometry, shader);
4405 actor.AddRenderer(renderer);
4406 application.SendNotification();
4407 application.Render();
4409 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4410 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4412 actor.RemoveRenderer(0);
4413 application.SendNotification();
4414 application.Render();
4416 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4418 // Shut down whilst holding onto the renderer handle.
4422 int UtcDaliActorRemoveRendererN(void)
4424 tet_infoline("Testing Actor::RemoveRenderer");
4425 TestApplication application;
4427 Actor actor = Actor::New();
4429 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4431 Geometry geometry = CreateQuadGeometry();
4432 Shader shader = CreateShader();
4433 Renderer renderer = Renderer::New(geometry, shader);
4435 actor.AddRenderer(renderer);
4436 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4437 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4439 actor.RemoveRenderer(10);
4440 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4441 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4446 // Clipping test helper functions:
4447 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4449 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4450 Actor actor = CreateRenderableActor(image);
4452 // Setup dimensions and position so actor is not skipped by culling.
4453 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4454 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4455 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4456 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4461 Actor CreateActorWithContent16x16()
4463 return CreateActorWithContent(16, 16);
4466 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4468 enabledDisableTrace.Reset();
4469 stencilTrace.Reset();
4470 enabledDisableTrace.Enable(true);
4471 stencilTrace.Enable(true);
4473 application.SendNotification();
4474 application.Render();
4476 enabledDisableTrace.Enable(false);
4477 stencilTrace.Enable(false);
4480 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4482 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4484 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4485 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4486 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4488 // @todo only test alpha if the framebuffer has an alpha channel
4489 //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4492 int UtcDaliActorPropertyClippingP(void)
4494 // This test checks the clippingMode property.
4495 tet_infoline("Testing Actor::Property::ClippingMode: P");
4496 TestApplication application;
4498 Actor actor = Actor::New();
4500 // Check default clippingEnabled value.
4501 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4504 bool getValueResult = getValue.Get(value);
4505 DALI_TEST_CHECK(getValueResult);
4509 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4512 // Check setting the property to the stencil mode.
4513 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4515 // Check the new value was set.
4516 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4517 getValueResult = getValue.Get(value);
4518 DALI_TEST_CHECK(getValueResult);
4522 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4525 // Check setting the property to the scissor mode.
4526 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4528 // Check the new value was set.
4529 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4530 getValueResult = getValue.Get(value);
4531 DALI_TEST_CHECK(getValueResult);
4535 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4540 int UtcDaliActorPropertyClippingN(void)
4542 // Negative test case for Clipping.
4543 tet_infoline("Testing Actor::Property::ClippingMode: N");
4544 TestApplication application;
4546 Actor actor = Actor::New();
4548 // Check default clippingEnabled value.
4549 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4552 bool getValueResult = getValue.Get(value);
4553 DALI_TEST_CHECK(getValueResult);
4557 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4560 // Check setting an invalid property value won't change the current property value.
4561 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4563 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4564 getValueResult = getValue.Get(value);
4565 DALI_TEST_CHECK(getValueResult);
4569 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4575 int UtcDaliActorPropertyClippingActor(void)
4577 // This test checks that an actor is correctly setup for clipping.
4578 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4579 TestApplication application;
4581 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4582 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4583 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4584 size_t startIndex = 0u;
4586 // Create a clipping actor.
4587 Actor actorDepth1Clip = CreateActorWithContent16x16();
4588 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4589 application.GetScene().Add(actorDepth1Clip);
4591 // Gather the call trace.
4592 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4594 // Check we are writing to the color buffer.
4595 CheckColorMask(glAbstraction, true);
4597 // Check the stencil buffer was enabled.
4598 std::ostringstream oss;
4599 oss << std::hex << GL_STENCIL_TEST;
4600 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4602 // Check the stencil buffer was cleared.
4603 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4605 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4606 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4607 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4608 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4613 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4615 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4616 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4617 TestApplication application;
4619 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4620 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4621 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4622 size_t startIndex = 0u;
4624 // Create a clipping actor.
4625 Actor actorDepth1Clip = CreateActorWithContent16x16();
4626 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4627 application.GetScene().Add(actorDepth1Clip);
4629 // Gather the call trace.
4630 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4632 // Check we are writing to the color buffer.
4633 CheckColorMask(glAbstraction, true);
4635 // Check the stencil buffer was enabled.
4636 std::ostringstream oss;
4637 oss << std::hex << GL_STENCIL_TEST;
4638 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4640 // Check the stencil buffer was cleared.
4641 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4643 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4644 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4645 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4646 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4648 // Now disable the clipping
4649 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4651 // Gather the call trace.
4652 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4654 // Check the stencil buffer was disabled.
4655 std::ostringstream stencil;
4656 stencil << std::hex << GL_STENCIL_TEST;
4657 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4659 // Ensure all values in stencil-mask are set to 1.
4661 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4666 int UtcDaliActorPropertyClippingNestedChildren(void)
4668 // This test checks that a hierarchy of actors are clipped correctly by
4669 // writing to and reading from the correct bit-planes of the stencil buffer.
4670 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4671 TestApplication application;
4672 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4673 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4674 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4676 // Create a clipping actor.
4677 Actor actorDepth1Clip = CreateActorWithContent16x16();
4678 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4679 application.GetScene().Add(actorDepth1Clip);
4681 // Create a child actor.
4682 Actor childDepth2 = CreateActorWithContent16x16();
4683 actorDepth1Clip.Add(childDepth2);
4685 // Create another clipping actor.
4686 Actor childDepth2Clip = CreateActorWithContent16x16();
4687 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4688 childDepth2.Add(childDepth2Clip);
4690 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4691 // This tests the sort algorithm.
4692 Actor childDepth3 = CreateActorWithContent16x16();
4693 childDepth2Clip.Add(childDepth3);
4694 Actor childDepth4 = CreateActorWithContent16x16();
4695 childDepth3.Add(childDepth4);
4697 // Gather the call trace.
4698 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4700 // Check we are writing to the color buffer.
4701 CheckColorMask(glAbstraction, true);
4703 // Check the stencil buffer was enabled.
4704 std::ostringstream oss;
4705 oss << std::hex << GL_STENCIL_TEST;
4706 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4708 // Perform the test twice, once for 2D layer, and once for 3D.
4709 for(unsigned int i = 0u; i < 2u; ++i)
4711 size_t startIndex = 0u;
4713 // Check the stencil buffer was cleared.
4714 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4716 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4717 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4718 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4719 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4721 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4722 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
4723 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4725 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4726 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4727 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4728 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4730 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4731 // (Both must be set to pass the check).
4732 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4733 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4735 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4738 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4739 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4746 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4748 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4749 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4750 TestApplication application;
4751 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4752 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4754 /* We create a small tree of actors as follows:
4758 Clipping enabled -> B D
4762 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4765 for(int i = 0; i < 5; ++i)
4767 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4768 Actor actor = CreateRenderableActor(image);
4770 // Setup dimensions and position so actor is not skipped by culling.
4771 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4772 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4776 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4780 float b = i > 2 ? 1.0f : -1.0f;
4781 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4787 // Enable clipping on the actor at the top of the left branch.
4788 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4790 // Build the scene graph.
4791 application.GetScene().Add(actors[0]);
4794 actors[0].Add(actors[1]);
4795 actors[1].Add(actors[2]);
4798 actors[0].Add(actors[3]);
4799 actors[3].Add(actors[4]);
4801 // Gather the call trace.
4802 enabledDisableTrace.Reset();
4803 enabledDisableTrace.Enable(true);
4804 application.SendNotification();
4805 application.Render();
4806 enabledDisableTrace.Enable(false);
4808 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4810 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
4811 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4813 size_t startIndex = 0u;
4814 std::ostringstream blend;
4815 blend << std::hex << GL_BLEND;
4816 std::ostringstream stencil;
4817 stencil << std::hex << GL_STENCIL_TEST;
4819 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4820 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4821 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4823 // Swap the clipping actor from top of left branch to top of right branch.
4824 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4825 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4827 // Gather the call trace.
4828 enabledDisableTrace.Reset();
4829 enabledDisableTrace.Enable(true);
4830 application.SendNotification();
4831 application.Render();
4832 enabledDisableTrace.Enable(false);
4834 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4835 // This proves the draw order has remained the same.
4837 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4838 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4843 int UtcDaliActorPropertyScissorClippingActor01(void)
4845 // This test checks that an actor is correctly setup for clipping.
4846 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4847 TestApplication application;
4849 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4850 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4851 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4853 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4854 const Vector2 imageSize(16.0f, 16.0f);
4856 // Create a clipping actor.
4857 Actor clippingActorA = CreateActorWithContent16x16();
4858 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4859 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4860 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4861 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4862 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4863 application.GetScene().Add(clippingActorA);
4865 // Gather the call trace.
4866 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4868 // Check we are writing to the color buffer.
4869 CheckColorMask(glAbstraction, true);
4871 // Check scissor test was enabled.
4873 std::ostringstream scissor;
4874 scissor << std::hex << GL_SCISSOR_TEST;
4875 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4877 // Check the scissor was set, and the coordinates are correct.
4878 std::stringstream compareParametersString;
4879 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4880 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4882 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4883 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4885 // Gather the call trace.
4886 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4888 // Check the scissor was set, and the coordinates are correct.
4889 compareParametersString.str(std::string());
4890 compareParametersString.clear();
4891 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4892 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4897 int UtcDaliActorPropertyScissorClippingActor02(void)
4899 // This test checks that an actor is correctly setup for clipping.
4900 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4901 TestApplication application;
4903 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4904 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4905 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4907 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4908 const Vector2 actorSize(16.0f, 16.0f);
4910 // Create a clipping actor.
4911 Actor clippingActorA = CreateRenderableActor();
4912 clippingActorA[Actor::Property::SIZE] = actorSize;
4914 Renderer renderer = clippingActorA.GetRendererAt(0);
4915 DALI_TEST_CHECK(renderer);
4917 // Make Renderer opacity 0.
4918 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4920 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4921 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4922 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4923 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4924 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4925 application.GetScene().Add(clippingActorA);
4927 // Gather the call trace.
4928 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4930 // Check we are writing to the color buffer.
4931 CheckColorMask(glAbstraction, true);
4933 // Check scissor test was enabled.
4935 std::ostringstream scissor;
4936 scissor << std::hex << GL_SCISSOR_TEST;
4937 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4939 // Check the scissor was set, and the coordinates are correct.
4940 std::stringstream compareParametersString;
4941 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
4942 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4944 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4945 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4947 // Gather the call trace.
4948 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4950 // Check the scissor was set, and the coordinates are correct.
4951 compareParametersString.str(std::string());
4952 compareParametersString.clear();
4953 compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
4954 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4959 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4961 // This test checks that an actor is correctly setup for clipping.
4962 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4963 TestApplication application;
4965 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4966 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4967 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4969 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4970 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4971 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4973 // Create a clipping actors.
4974 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4975 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4977 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4978 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4979 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4981 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4982 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4983 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4985 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4986 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4988 application.GetScene().Add(clippingActorA);
4989 application.GetScene().Add(clippingActorB);
4991 // Gather the call trace.
4992 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4994 // Check we are writing to the color buffer.
4995 CheckColorMask(glAbstraction, true);
4997 // Check scissor test was enabled.
4998 std::ostringstream scissor;
4999 scissor << std::hex << GL_SCISSOR_TEST;
5000 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5002 // Check the scissor was set, and the coordinates are correct.
5003 std::stringstream compareParametersString;
5005 std::string clipA("0, 500, 480, 200");
5006 std::string clipB("0, 380, 480, 40");
5008 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5009 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5014 int UtcDaliActorPropertyScissorClippingActorNested01(void)
5016 // This test checks that an actor is correctly setup for clipping.
5017 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5018 TestApplication application;
5020 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5021 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5022 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5024 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5025 const Vector2 imageSize(16.0f, 16.0f);
5027 /* Create a nest of 2 scissors to test nesting (intersecting clips).
5029 A is drawn first - with scissor clipping on
5030 B is drawn second - also with scissor clipping on
5031 C is the generated clipping region, the intersection ( A ∩ B )
5035 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
5036 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
5037 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
5041 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
5044 // Create a clipping actor.
5045 Actor clippingActorA = CreateActorWithContent16x16();
5046 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5047 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5048 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5049 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5050 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5051 application.GetScene().Add(clippingActorA);
5053 // Create a child clipping actor.
5054 Actor clippingActorB = CreateActorWithContent16x16();
5055 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5056 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5057 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5058 clippingActorA.Add(clippingActorB);
5060 // positionModifiers is an array of positions to position B around.
5061 // expect is an array of expected scissor clip coordinate results.
5062 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
5063 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
5065 // Loop through each overlap combination.
5066 for(unsigned int test = 0u; test < 4u; ++test)
5068 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
5069 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
5070 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
5072 // Gather the call trace.
5073 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5075 // Check we are writing to the color buffer.
5076 CheckColorMask(glAbstraction, true);
5078 // Check scissor test was enabled.
5079 std::ostringstream scissor;
5080 scissor << std::hex << GL_SCISSOR_TEST;
5081 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5083 // Check the scissor was set, and the coordinates are correct.
5084 const Vector4& expectResults(expect[test]);
5085 std::stringstream compareParametersString;
5086 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
5087 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
5093 int UtcDaliActorPropertyScissorClippingActorNested02(void)
5095 // This test checks that an actor is correctly setup for clipping.
5096 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
5097 TestApplication application;
5099 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5100 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5101 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5103 /* Create a nest of 2 scissors and siblings of the parent.
5113 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
5114 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
5115 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
5116 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
5117 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
5118 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
5120 // Create a clipping actors.
5121 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
5122 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
5123 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
5124 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
5125 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
5127 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5128 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5129 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5131 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5132 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5133 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5135 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5136 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5137 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5139 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5140 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5141 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5143 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
5144 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
5146 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
5147 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5148 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
5149 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5150 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
5152 application.GetScene().Add(clippingActorA);
5153 clippingActorA.Add(clippingActorB);
5154 application.GetScene().Add(clippingActorC);
5155 application.GetScene().Add(clippingActorD);
5156 clippingActorD.Add(clippingActorE);
5158 // Gather the call trace.
5159 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5161 // Check we are writing to the color buffer.
5162 CheckColorMask(glAbstraction, true);
5164 // Check scissor test was enabled.
5165 std::ostringstream scissor;
5166 scissor << std::hex << GL_SCISSOR_TEST;
5167 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5169 // Check the scissor was set, and the coordinates are correct.
5170 std::string clipA("0, 500, 480, 200");
5171 std::string clipB("0, 580, 480, 40");
5172 std::string clipC("0, 200, 480, 200");
5173 std::string clipD("0, 300, 480, 200");
5175 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
5176 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
5177 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
5178 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
5179 DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
5184 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
5186 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
5187 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
5188 TestApplication application;
5190 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5191 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
5192 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5194 // Create a clipping actor.
5195 Actor actorDepth1Clip = CreateActorWithContent16x16();
5196 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
5197 application.GetScene().Add(actorDepth1Clip);
5199 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
5200 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
5202 // Gather the call trace.
5203 GenerateTrace(application, enabledDisableTrace, stencilTrace);
5205 // Check we are writing to the color buffer.
5206 CheckColorMask(glAbstraction, true);
5208 // Check the stencil buffer was not enabled.
5209 std::ostringstream stencil;
5210 stencil << std::hex << GL_STENCIL_TEST;
5211 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
5213 // Check stencil functions are not called.
5214 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
5215 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
5217 // Check that scissor clipping is overriden by the renderer properties.
5218 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5220 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
5222 // Gather the call trace.
5223 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5225 // Check the stencil buffer was not enabled.
5226 std::ostringstream scissor;
5227 scissor << std::hex << GL_SCISSOR_TEST;
5228 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5230 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
5235 int UtcDaliActorPropertyClippingActorCulled(void)
5237 // This test checks that child actors are clipped by an culled parent actor.
5238 tet_infoline("Testing child actors are clipped by an culled parent actor");
5239 TestApplication application;
5241 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5242 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5243 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5245 const Vector2 actorSize(160.0f, 160.0f);
5247 // Create a clipping actor.
5248 Actor clippingActorA = CreateRenderableActor();
5249 clippingActorA[Actor::Property::SIZE] = actorSize;
5251 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5252 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5253 clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5254 clippingActorA[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5255 clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5256 application.GetScene().Add(clippingActorA);
5258 // Create a child actor
5259 Actor childActor = CreateRenderableActor();
5260 childActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5261 childActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5262 childActor[Actor::Property::SIZE] = Vector2(50.0f, 50.0f);
5263 childActor[Actor::Property::INHERIT_POSITION] = false;
5265 // Gather the call trace.
5266 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5268 // Check scissor test was enabled.
5269 std::ostringstream scissor;
5270 scissor << std::hex << GL_SCISSOR_TEST;
5271 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5273 // Check the scissor was set, and the coordinates are correct.
5274 std::stringstream compareParametersString;
5275 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5276 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5278 // Move the clipping actor out of screen
5279 clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5281 // Gather the call trace.
5282 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5284 // Check the scissor was set, and the coordinates are correct.
5285 compareParametersString.str(std::string());
5286 compareParametersString.clear();
5287 compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5288 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5293 int UtcDaliGetPropertyN(void)
5295 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5296 TestApplication application;
5298 Actor actor = Actor::New();
5300 unsigned int propertyCount = actor.GetPropertyCount();
5301 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5305 int UtcDaliActorRaiseLower(void)
5307 tet_infoline("UtcDaliActor Raise and Lower test\n");
5309 TestApplication application;
5311 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5313 Integration::Scene stage(application.GetScene());
5315 Actor actorA = Actor::New();
5316 Actor actorB = Actor::New();
5317 Actor actorC = Actor::New();
5319 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5320 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5322 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5323 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5325 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5326 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5328 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5329 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5331 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5332 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5334 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5335 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5341 ResetTouchCallbacks();
5343 application.SendNotification();
5344 application.Render();
5346 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5347 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5348 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5350 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5351 // Only top actor will get touched.
5352 actorA.TouchedSignal().Connect(TestTouchCallback);
5353 actorB.TouchedSignal().Connect(TestTouchCallback2);
5354 actorC.TouchedSignal().Connect(TestTouchCallback3);
5356 // Connect ChildOrderChangedSignal
5357 bool orderChangedSignal(false);
5358 Actor orderChangedActor;
5359 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5360 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5362 Dali::Integration::Point point;
5363 point.SetDeviceId(1);
5364 point.SetState(PointState::DOWN);
5365 point.SetScreenPosition(Vector2(10.f, 10.f));
5366 Dali::Integration::TouchEvent touchEvent;
5367 touchEvent.AddPoint(point);
5369 application.ProcessEvent(touchEvent);
5371 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5372 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5373 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5375 ResetTouchCallbacks();
5377 tet_printf("Testing Raising of Actor\n");
5379 int preActorOrder(0);
5380 int postActorOrder(0);
5382 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5383 value.Get(preActorOrder);
5385 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5387 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5388 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5390 // Ensure sort order is calculated before next touch event
5391 application.SendNotification();
5393 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5394 value.Get(postActorOrder);
5396 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5398 application.ProcessEvent(touchEvent);
5400 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5401 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5402 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5404 ResetTouchCallbacks();
5406 tet_printf("Testing Lowering of Actor\n");
5408 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5409 value.Get(preActorOrder);
5411 orderChangedSignal = false;
5413 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5415 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5416 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5418 application.SendNotification(); // ensure sort order calculated before next touch event
5420 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5421 value.Get(postActorOrder);
5423 tet_printf("Lowered 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, false, TEST_LOCATION);
5429 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5431 ResetTouchCallbacks();
5433 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5438 int UtcDaliActorRaiseToTopLowerToBottom(void)
5440 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5442 TestApplication application;
5444 Integration::Scene stage(application.GetScene());
5446 Actor actorA = Actor::New();
5447 Actor actorB = Actor::New();
5448 Actor actorC = Actor::New();
5450 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5451 // enables checking of which actor the uniform is assigned too
5452 Shader shaderA = CreateShader();
5453 shaderA.RegisterProperty("uRendererColor", 1.f);
5455 Shader shaderB = CreateShader();
5456 shaderB.RegisterProperty("uRendererColor", 2.f);
5458 Shader shaderC = CreateShader();
5459 shaderC.RegisterProperty("uRendererColor", 3.f);
5461 Geometry geometry = CreateQuadGeometry();
5463 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5464 Renderer rendererA = Renderer::New(geometry, shaderA);
5465 actorA.AddRenderer(rendererA);
5467 Renderer rendererB = Renderer::New(geometry, shaderB);
5468 actorB.AddRenderer(rendererB);
5470 Renderer rendererC = Renderer::New(geometry, shaderC);
5471 actorC.AddRenderer(rendererC);
5473 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5474 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5476 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5477 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5479 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5480 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5482 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5483 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5485 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5486 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5488 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5489 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5495 ResetTouchCallbacks();
5497 // Connect ChildOrderChangedSignal
5498 bool orderChangedSignal(false);
5499 Actor orderChangedActor;
5500 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5501 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5503 // Set up gl abstraction trace so can query the set uniform order
5504 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5505 glAbstraction.EnableSetUniformCallTrace(true);
5506 glAbstraction.ResetSetUniformCallStack();
5508 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5510 application.SendNotification();
5511 application.Render();
5513 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5515 // Test order of uniforms in stack
5516 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5517 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5518 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5520 bool CBA = (indexC > indexB) && (indexB > indexA);
5522 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5524 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5525 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5526 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5528 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5529 // Only top actor will get touched.
5530 actorA.TouchedSignal().Connect(TestTouchCallback);
5531 actorB.TouchedSignal().Connect(TestTouchCallback2);
5532 actorC.TouchedSignal().Connect(TestTouchCallback3);
5534 Dali::Integration::Point point;
5535 point.SetDeviceId(1);
5536 point.SetState(PointState::DOWN);
5537 point.SetScreenPosition(Vector2(10.f, 10.f));
5538 Dali::Integration::TouchEvent touchEvent;
5539 touchEvent.AddPoint(point);
5541 application.ProcessEvent(touchEvent);
5543 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5544 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5545 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5547 ResetTouchCallbacks();
5549 tet_printf("RaiseToTop ActorA\n");
5551 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5552 actorA.RaiseToTop();
5553 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5554 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5556 application.SendNotification(); // ensure sorting order is calculated before next touch event
5558 application.ProcessEvent(touchEvent);
5560 glSetUniformStack.Reset();
5562 application.SendNotification();
5563 application.Render();
5565 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5567 // Test order of uniforms in stack
5568 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5569 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5570 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5572 tet_infoline("Testing A above C and B at bottom\n");
5573 bool ACB = (indexA > indexC) && (indexC > indexB);
5575 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5577 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5578 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5579 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5581 ResetTouchCallbacks();
5583 tet_printf("RaiseToTop ActorB\n");
5585 orderChangedSignal = false;
5587 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5588 actorB.RaiseToTop();
5589 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5590 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5592 application.SendNotification(); // Ensure sort order is calculated before next touch event
5594 application.ProcessEvent(touchEvent);
5596 glSetUniformStack.Reset();
5598 application.SendNotification();
5599 application.Render();
5601 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5603 // Test order of uniforms in stack
5604 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5605 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5606 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5608 tet_infoline("Testing B above A and C at bottom\n");
5609 bool BAC = (indexB > indexA) && (indexA > indexC);
5611 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5613 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5614 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5615 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5617 ResetTouchCallbacks();
5619 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5621 orderChangedSignal = false;
5623 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5624 actorA.LowerToBottom();
5625 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5626 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5628 application.SendNotification();
5629 application.Render();
5631 orderChangedSignal = false;
5633 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5634 actorB.LowerToBottom();
5635 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5636 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5638 application.SendNotification();
5639 application.Render();
5641 application.ProcessEvent(touchEvent);
5643 glSetUniformStack.Reset();
5645 application.SendNotification();
5646 application.Render();
5648 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5650 // Test order of uniforms in stack
5651 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5652 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5653 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5655 tet_infoline("Testing C above A and B at bottom\n");
5656 bool CAB = (indexC > indexA) && (indexA > indexB);
5658 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5660 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5661 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5662 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5664 ResetTouchCallbacks();
5669 int UtcDaliActorRaiseAbove(void)
5671 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5673 TestApplication application;
5675 Integration::Scene stage(application.GetScene());
5677 Actor actorA = Actor::New();
5678 Actor actorB = Actor::New();
5679 Actor actorC = Actor::New();
5681 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5682 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5684 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5685 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5687 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5688 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5690 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5691 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5693 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5694 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5696 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5697 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5703 ResetTouchCallbacks();
5705 application.SendNotification();
5706 application.Render();
5708 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5709 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5710 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5712 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5713 // Only top actor will get touched.
5714 actorA.TouchedSignal().Connect(TestTouchCallback);
5715 actorB.TouchedSignal().Connect(TestTouchCallback2);
5716 actorC.TouchedSignal().Connect(TestTouchCallback3);
5718 bool orderChangedSignal(false);
5719 Actor orderChangedActor;
5720 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5721 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5723 Dali::Integration::Point point;
5724 point.SetDeviceId(1);
5725 point.SetState(PointState::DOWN);
5726 point.SetScreenPosition(Vector2(10.f, 10.f));
5727 Dali::Integration::TouchEvent touchEvent;
5728 touchEvent.AddPoint(point);
5730 application.ProcessEvent(touchEvent);
5732 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5733 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5734 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5736 ResetTouchCallbacks();
5738 tet_printf("Raise actor B Above Actor C\n");
5740 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5741 actorB.RaiseAbove(actorC);
5742 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5743 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5745 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5746 application.SendNotification();
5747 application.ProcessEvent(touchEvent);
5749 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5750 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5751 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5753 ResetTouchCallbacks();
5755 tet_printf("Raise actor A Above Actor B\n");
5757 orderChangedSignal = false;
5759 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5760 actorA.RaiseAbove(actorB);
5761 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5762 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5764 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5765 application.SendNotification();
5767 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5769 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5770 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5771 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5773 ResetTouchCallbacks();
5778 int UtcDaliActorRaiseAbove2(void)
5780 tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5782 TestApplication application;
5784 Integration::Scene stage(application.GetScene());
5786 Actor actorA = Actor::New();
5787 Actor actorB = Actor::New();
5788 Actor actorC = Actor::New();
5790 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5791 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5793 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5794 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5796 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5797 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5799 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5800 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5802 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5803 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5805 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5806 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5812 ResetTouchCallbacks();
5814 application.SendNotification();
5815 application.Render();
5817 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5818 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5819 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5821 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5822 // Only top actor will get touched.
5823 actorA.TouchedSignal().Connect(TestTouchCallback);
5824 actorB.TouchedSignal().Connect(TestTouchCallback2);
5825 actorC.TouchedSignal().Connect(TestTouchCallback3);
5827 bool orderChangedSignal(false);
5828 Actor orderChangedActor;
5829 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5830 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5832 Dali::Integration::Point point;
5833 point.SetDeviceId(1);
5834 point.SetState(PointState::DOWN);
5835 point.SetScreenPosition(Vector2(10.f, 10.f));
5836 Dali::Integration::TouchEvent touchEvent;
5837 touchEvent.AddPoint(point);
5839 application.ProcessEvent(touchEvent);
5841 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5842 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5843 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5845 ResetTouchCallbacks();
5847 tet_printf("Raise actor B Above Actor C\n");
5849 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5850 int newOrder = actorC[DevelActor::Property::SIBLING_ORDER];
5851 actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5852 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5853 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5855 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5856 application.SendNotification();
5857 application.ProcessEvent(touchEvent);
5859 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5860 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5861 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5863 ResetTouchCallbacks();
5865 tet_printf("Raise actor A Above Actor B\n");
5867 orderChangedSignal = false;
5869 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5870 newOrder = actorB[DevelActor::Property::SIBLING_ORDER];
5871 actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5872 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5873 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5875 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5876 application.SendNotification();
5878 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5880 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5881 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5882 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5884 ResetTouchCallbacks();
5889 int UtcDaliActorLowerBelow(void)
5891 tet_infoline("UtcDaliActor LowerBelow test \n");
5893 TestApplication application;
5895 Integration::Scene stage(application.GetScene());
5897 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5898 // enables checking of which actor the uniform is assigned too
5899 Shader shaderA = CreateShader();
5900 shaderA.RegisterProperty("uRendererColor", 1.f);
5902 Shader shaderB = CreateShader();
5903 shaderB.RegisterProperty("uRendererColor", 2.f);
5905 Shader shaderC = CreateShader();
5906 shaderC.RegisterProperty("uRendererColor", 3.f);
5908 Actor actorA = Actor::New();
5909 Actor actorB = Actor::New();
5910 Actor actorC = Actor::New();
5912 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5913 Geometry geometry = CreateQuadGeometry();
5915 Renderer rendererA = Renderer::New(geometry, shaderA);
5916 actorA.AddRenderer(rendererA);
5918 Renderer rendererB = Renderer::New(geometry, shaderB);
5919 actorB.AddRenderer(rendererB);
5921 Renderer rendererC = Renderer::New(geometry, shaderC);
5922 actorC.AddRenderer(rendererC);
5924 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5925 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5927 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5928 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5930 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5931 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5933 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5934 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5936 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5937 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5939 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5940 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5942 Actor container = Actor::New();
5943 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5944 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5945 stage.Add(container);
5947 container.Add(actorA);
5948 container.Add(actorB);
5949 container.Add(actorC);
5951 ResetTouchCallbacks();
5953 // Connect ChildOrderChangedSignal
5954 bool orderChangedSignal(false);
5955 Actor orderChangedActor;
5956 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5957 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5959 // Set up gl abstraction trace so can query the set uniform order
5960 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5961 glAbstraction.EnableSetUniformCallTrace(true);
5962 glAbstraction.ResetSetUniformCallStack();
5963 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5965 glAbstraction.ResetSetUniformCallStack();
5967 application.SendNotification();
5968 application.Render();
5970 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5972 // Test order of uniforms in stack
5973 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5974 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5975 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5977 tet_infoline("Testing C above B and A at bottom\n");
5978 bool CBA = (indexC > indexB) && (indexB > indexA);
5980 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5982 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5983 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5984 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5986 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5987 // Only top actor will get touched.
5988 actorA.TouchedSignal().Connect(TestTouchCallback);
5989 actorB.TouchedSignal().Connect(TestTouchCallback2);
5990 actorC.TouchedSignal().Connect(TestTouchCallback3);
5992 Dali::Integration::Point point;
5993 point.SetDeviceId(1);
5994 point.SetState(PointState::DOWN);
5995 point.SetScreenPosition(Vector2(10.f, 10.f));
5996 Dali::Integration::TouchEvent touchEvent;
5997 touchEvent.AddPoint(point);
5999 tet_infoline("UtcDaliActor Test Set up completed \n");
6001 application.ProcessEvent(touchEvent);
6003 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6004 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6005 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6007 ResetTouchCallbacks();
6009 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");
6011 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6012 actorC.LowerBelow(actorB);
6013 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6014 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6016 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6017 application.SendNotification();
6018 application.Render();
6020 application.ProcessEvent(touchEvent); // touch event
6022 glSetUniformStack.Reset();
6024 application.SendNotification();
6025 application.Render();
6027 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6029 // Test order of uniforms in stack
6030 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6031 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6032 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6034 tet_infoline("Testing render order is A, C, B");
6035 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6036 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6038 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6039 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6040 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6042 ResetTouchCallbacks();
6044 tet_printf("Lower actor C below Actor A leaving B on top\n");
6046 orderChangedSignal = false;
6048 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6049 actorC.LowerBelow(actorA);
6050 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6051 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6053 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6054 application.SendNotification();
6055 application.Render();
6057 application.ProcessEvent(touchEvent);
6059 glSetUniformStack.Reset();
6061 application.Render();
6062 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6064 // Test order of uniforms in stack
6065 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6066 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6067 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6069 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6070 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6072 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6073 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6074 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6076 ResetTouchCallbacks();
6078 tet_printf("Lower actor B below Actor C leaving A on top\n");
6080 orderChangedSignal = false;
6082 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6083 actorB.LowerBelow(actorC);
6084 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6085 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6087 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6088 application.SendNotification();
6089 application.Render();
6091 application.ProcessEvent(touchEvent);
6093 glSetUniformStack.Reset();
6095 application.Render();
6096 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6098 // Test order of uniforms in stack
6099 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6100 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6101 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6103 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6104 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6109 int UtcDaliActorLowerBelow2(void)
6111 tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
6113 TestApplication application;
6115 Integration::Scene stage(application.GetScene());
6117 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
6118 // enables checking of which actor the uniform is assigned too
6119 Shader shaderA = CreateShader();
6120 shaderA.RegisterProperty("uRendererColor", 1.f);
6122 Shader shaderB = CreateShader();
6123 shaderB.RegisterProperty("uRendererColor", 2.f);
6125 Shader shaderC = CreateShader();
6126 shaderC.RegisterProperty("uRendererColor", 3.f);
6128 Actor actorA = Actor::New();
6129 Actor actorB = Actor::New();
6130 Actor actorC = Actor::New();
6132 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
6133 Geometry geometry = CreateQuadGeometry();
6135 Renderer rendererA = Renderer::New(geometry, shaderA);
6136 actorA.AddRenderer(rendererA);
6138 Renderer rendererB = Renderer::New(geometry, shaderB);
6139 actorB.AddRenderer(rendererB);
6141 Renderer rendererC = Renderer::New(geometry, shaderC);
6142 actorC.AddRenderer(rendererC);
6144 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6145 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6147 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6148 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6150 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6151 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6153 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6154 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6156 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6157 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6159 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6160 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6162 Actor container = Actor::New();
6163 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6164 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
6165 stage.Add(container);
6167 container.Add(actorA);
6168 container.Add(actorB);
6169 container.Add(actorC);
6171 ResetTouchCallbacks();
6173 // Connect ChildOrderChangedSignal
6174 bool orderChangedSignal(false);
6175 Actor orderChangedActor;
6176 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6177 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
6179 // Set up gl abstraction trace so can query the set uniform order
6180 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
6181 glAbstraction.EnableSetUniformCallTrace(true);
6182 glAbstraction.ResetSetUniformCallStack();
6183 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
6185 glAbstraction.ResetSetUniformCallStack();
6187 application.SendNotification();
6188 application.Render();
6190 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6192 // Test order of uniforms in stack
6193 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6194 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6195 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6197 tet_infoline("Testing C above B and A at bottom\n");
6198 bool CBA = (indexC > indexB) && (indexB > indexA);
6200 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
6202 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6203 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6204 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6206 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6207 // Only top actor will get touched.
6208 actorA.TouchedSignal().Connect(TestTouchCallback);
6209 actorB.TouchedSignal().Connect(TestTouchCallback2);
6210 actorC.TouchedSignal().Connect(TestTouchCallback3);
6212 Dali::Integration::Point point;
6213 point.SetDeviceId(1);
6214 point.SetState(PointState::DOWN);
6215 point.SetScreenPosition(Vector2(10.f, 10.f));
6216 Dali::Integration::TouchEvent touchEvent;
6217 touchEvent.AddPoint(point);
6219 tet_infoline("UtcDaliActor Test Set up completed \n");
6221 application.ProcessEvent(touchEvent);
6223 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6224 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6225 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6227 ResetTouchCallbacks();
6229 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");
6231 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6232 actorC[DevelActor::Property::SIBLING_ORDER] = 1;
6233 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6234 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6236 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6237 application.SendNotification();
6238 application.Render();
6240 application.ProcessEvent(touchEvent); // touch event
6242 glSetUniformStack.Reset();
6244 application.SendNotification();
6245 application.Render();
6247 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6249 // Test order of uniforms in stack
6250 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6251 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6252 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6254 tet_infoline("Testing render order is A, C, B");
6255 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6256 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6258 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6259 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6260 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6262 ResetTouchCallbacks();
6264 tet_printf("Lower actor C below Actor A leaving B on top\n");
6266 orderChangedSignal = false;
6268 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6269 actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6270 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6271 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6273 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6274 application.SendNotification();
6275 application.Render();
6277 application.ProcessEvent(touchEvent);
6279 glSetUniformStack.Reset();
6281 application.Render();
6282 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6284 // Test order of uniforms in stack
6285 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6286 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6287 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6289 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6290 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6292 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6293 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6294 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6296 ResetTouchCallbacks();
6298 tet_printf("Lower actor B below Actor C leaving A on top\n");
6300 orderChangedSignal = false;
6302 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6303 actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6304 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6305 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6307 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6308 application.SendNotification();
6309 application.Render();
6311 application.ProcessEvent(touchEvent);
6313 glSetUniformStack.Reset();
6315 application.Render();
6316 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6318 // Test order of uniforms in stack
6319 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6320 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6321 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6323 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6324 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6329 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6331 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6333 TestApplication application;
6335 Integration::Scene stage(application.GetScene());
6337 Actor parentA = Actor::New();
6338 Actor parentB = Actor::New();
6339 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6340 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6341 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6342 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6344 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6345 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6347 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6348 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6353 Actor actorA = Actor::New();
6354 Actor actorB = Actor::New();
6355 Actor actorC = Actor::New();
6357 parentA.Add(actorA);
6358 parentA.Add(actorB);
6360 tet_printf("Actor C added to different parent from A and B \n");
6361 parentB.Add(actorC);
6363 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6364 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6366 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6367 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6369 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6370 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6372 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6373 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6375 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6376 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6378 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6379 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6381 ResetTouchCallbacks();
6383 // Connect ChildOrderChangedSignal
6384 bool orderChangedSignal(false);
6385 Actor orderChangedActor;
6386 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6387 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6389 application.SendNotification();
6390 application.Render();
6392 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6393 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6394 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6396 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6397 // Only top actor will get touched.
6398 actorA.TouchedSignal().Connect(TestTouchCallback);
6399 actorB.TouchedSignal().Connect(TestTouchCallback2);
6400 actorC.TouchedSignal().Connect(TestTouchCallback3);
6402 Dali::Integration::Point point;
6403 point.SetDeviceId(1);
6404 point.SetState(PointState::DOWN);
6405 point.SetScreenPosition(Vector2(10.f, 10.f));
6406 Dali::Integration::TouchEvent touchEvent;
6407 touchEvent.AddPoint(point);
6409 application.ProcessEvent(touchEvent);
6411 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6412 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6413 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6415 ResetTouchCallbacks();
6417 tet_printf("Raise actor A Above Actor C which have different parents\n");
6419 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6420 actorA.RaiseAbove(actorC);
6421 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6423 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6424 application.SendNotification();
6426 application.ProcessEvent(touchEvent); // touch event
6428 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6429 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6430 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6432 ResetTouchCallbacks();
6437 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6439 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
6441 TestApplication application;
6443 Integration::Scene stage(application.GetScene());
6445 Actor actorA = Actor::New();
6446 Actor actorB = Actor::New();
6447 Actor actorC = Actor::New();
6449 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6450 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6452 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6453 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6455 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6456 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6458 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6459 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6461 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6462 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6464 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6465 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6467 ResetTouchCallbacks();
6469 // Connect ChildOrderChangedSignal
6470 bool orderChangedSignal(false);
6471 Actor orderChangedActor;
6472 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6473 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6475 application.SendNotification();
6476 application.Render();
6478 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6479 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6480 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6482 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6483 // Only top actor will get touched.
6484 actorA.TouchedSignal().Connect(TestTouchCallback);
6485 actorB.TouchedSignal().Connect(TestTouchCallback2);
6486 actorC.TouchedSignal().Connect(TestTouchCallback3);
6488 Dali::Integration::Point point;
6489 point.SetDeviceId(1);
6490 point.SetState(PointState::DOWN);
6491 point.SetScreenPosition(Vector2(10.f, 10.f));
6492 Dali::Integration::TouchEvent touchEvent;
6493 touchEvent.AddPoint(point);
6495 tet_printf("Raise actor A Above Actor C which have no parents\n");
6497 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6498 actorA.RaiseAbove(actorC);
6499 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6501 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6502 application.SendNotification();
6504 application.ProcessEvent(touchEvent);
6506 tet_printf("Not parented so RaiseAbove should show no effect\n");
6508 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6509 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6510 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6512 ResetTouchCallbacks();
6514 orderChangedSignal = false;
6517 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6519 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6520 actorA.LowerBelow(actorC);
6521 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6523 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6524 application.SendNotification();
6525 application.Render();
6527 application.ProcessEvent(touchEvent);
6529 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6530 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6531 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6532 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6534 ResetTouchCallbacks();
6536 orderChangedSignal = false;
6538 tet_printf("Adding Actor A to stage, will be on top\n");
6541 application.SendNotification();
6542 application.Render();
6544 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6546 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6547 actorB.RaiseAbove(actorC);
6548 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6550 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6551 application.SendNotification();
6553 application.ProcessEvent(touchEvent);
6555 tet_printf("C not parented so RaiseAbove should show no effect\n");
6556 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6557 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6558 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6560 ResetTouchCallbacks();
6562 orderChangedSignal = false;
6564 tet_printf("Lower actor A below Actor C when only A has a parent\n");
6566 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6567 actorA.LowerBelow(actorC);
6568 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6570 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6571 application.SendNotification();
6573 application.ProcessEvent(touchEvent);
6575 tet_printf("C not parented so LowerBelow should show no effect\n");
6576 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6577 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6578 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6580 ResetTouchCallbacks();
6582 orderChangedSignal = false;
6586 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6587 actorA.RaiseAbove(actorC);
6588 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6589 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6591 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6592 application.SendNotification();
6593 application.Render();
6595 application.ProcessEvent(touchEvent);
6597 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6598 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6599 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6600 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6605 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6607 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6609 TestApplication application;
6611 Integration::Scene stage(application.GetScene());
6613 Actor actorA = Actor::New();
6614 Actor actorB = Actor::New();
6615 Actor actorC = Actor::New();
6617 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6618 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6620 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6621 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6623 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6624 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6626 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6627 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6629 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6630 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6632 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6633 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6635 ResetTouchCallbacks();
6637 // Connect ChildOrderChangedSignal
6638 bool orderChangedSignal(false);
6639 Actor orderChangedActor;
6640 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6641 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6643 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6644 // Only top actor will get touched.
6645 actorA.TouchedSignal().Connect(TestTouchCallback);
6646 actorB.TouchedSignal().Connect(TestTouchCallback2);
6647 actorC.TouchedSignal().Connect(TestTouchCallback3);
6649 Dali::Integration::Point point;
6650 point.SetDeviceId(1);
6651 point.SetState(PointState::DOWN);
6652 point.SetScreenPosition(Vector2(10.f, 10.f));
6653 Dali::Integration::TouchEvent touchEvent;
6654 touchEvent.AddPoint(point);
6657 tet_printf("Raise actor B Above Actor C but B not parented\n");
6659 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6661 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6663 application.SendNotification();
6664 application.Render();
6666 application.ProcessEvent(touchEvent);
6668 tet_printf("Not parented so RaiseAbove should show no effect\n");
6670 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6671 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6672 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6674 tet_printf("Raise actor B Above Actor C but B not parented\n");
6675 ResetTouchCallbacks();
6677 orderChangedSignal = false;
6679 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6681 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6683 // Sort actor tree before next touch event
6684 application.SendNotification();
6685 application.Render();
6687 application.ProcessEvent(touchEvent);
6689 tet_printf("Not parented so RaiseAbove should show no effect\n");
6691 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6692 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6693 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6694 ResetTouchCallbacks();
6696 orderChangedSignal = false;
6698 tet_printf("Lower actor C below B but C not parented\n");
6700 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6702 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6704 // Sort actor tree before next touch event
6705 application.SendNotification();
6706 application.Render();
6708 application.ProcessEvent(touchEvent);
6710 tet_printf("Not parented so Lower should show no effect\n");
6712 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6713 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6714 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6715 ResetTouchCallbacks();
6717 orderChangedSignal = false;
6719 tet_printf("Raise actor B to top\n");
6721 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6722 actorB.RaiseToTop();
6723 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6725 // Sort actor tree before next touch event
6726 application.SendNotification();
6727 application.Render();
6729 application.ProcessEvent(touchEvent);
6731 tet_printf("Not parented so RaiseToTop should show no effect\n");
6733 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6734 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6735 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6736 ResetTouchCallbacks();
6738 orderChangedSignal = false;
6740 tet_printf("Add ActorB to stage so only Actor C not parented\n");
6744 tet_printf("Lower actor C to Bottom, B stays at top\n");
6746 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6747 actorC.LowerToBottom();
6748 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6750 application.SendNotification();
6751 application.Render();
6753 application.ProcessEvent(touchEvent);
6755 tet_printf("Not parented so LowerToBottom should show no effect\n");
6757 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6758 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6759 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6760 ResetTouchCallbacks();
6765 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6767 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
6769 TestApplication application;
6771 Integration::Scene stage(application.GetScene());
6773 Actor actorA = Actor::New();
6774 Actor actorB = Actor::New();
6775 Actor actorC = Actor::New();
6777 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6778 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6780 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6781 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6783 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6784 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6786 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6787 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6789 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6790 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6792 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6793 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6799 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6800 // Only top actor will get touched.
6801 actorA.TouchedSignal().Connect(TestTouchCallback);
6802 actorB.TouchedSignal().Connect(TestTouchCallback2);
6803 actorC.TouchedSignal().Connect(TestTouchCallback3);
6805 ResetTouchCallbacks();
6807 // Connect ChildOrderChangedSignal
6808 bool orderChangedSignal(false);
6809 Actor orderChangedActor;
6810 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6811 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6813 application.SendNotification();
6814 application.Render();
6816 Dali::Integration::Point point;
6817 point.SetDeviceId(1);
6818 point.SetState(PointState::DOWN);
6819 point.SetScreenPosition(Vector2(10.f, 10.f));
6820 Dali::Integration::TouchEvent touchEvent;
6821 touchEvent.AddPoint(point);
6823 application.ProcessEvent(touchEvent);
6825 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6826 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6827 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6829 ResetTouchCallbacks();
6831 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6833 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6834 actorA.RaiseAbove(actorA);
6835 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6836 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6838 application.SendNotification();
6839 application.Render();
6841 application.ProcessEvent(touchEvent);
6843 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6845 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6846 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6847 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6849 ResetTouchCallbacks();
6851 orderChangedSignal = false;
6853 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6854 actorA.RaiseAbove(actorC);
6855 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6856 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6858 application.SendNotification();
6859 application.Render();
6861 application.ProcessEvent(touchEvent);
6863 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6864 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6865 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6866 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6871 int UtcDaliActorGetScreenPosition(void)
6873 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6875 TestApplication application;
6877 Integration::Scene stage(application.GetScene());
6879 Actor actorA = Actor::New();
6880 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6882 Vector2 size2(10.0f, 20.0f);
6883 actorA.SetProperty(Actor::Property::SIZE, size2);
6885 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6887 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6891 application.SendNotification();
6892 application.Render();
6894 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6895 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6897 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6898 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6900 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6901 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6903 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6905 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6907 application.SendNotification();
6908 application.Render();
6910 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6911 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6913 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6914 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6916 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6917 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6919 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6921 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6923 application.SendNotification();
6924 application.Render();
6926 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6927 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6929 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6930 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6932 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6933 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6935 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6937 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6939 application.SendNotification();
6940 application.Render();
6942 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6943 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6945 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6946 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6948 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6949 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6951 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6953 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6955 application.SendNotification();
6956 application.Render();
6958 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6959 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6961 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6962 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6964 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6965 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6967 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6969 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6970 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6972 Actor actorB = Actor::New();
6973 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6974 actorB.SetProperty(Actor::Property::SIZE, size2);
6975 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6978 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6980 application.SendNotification();
6981 application.Render();
6983 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6985 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6986 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6991 int UtcDaliActorGetScreenPositionAfterScaling(void)
6993 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6995 TestApplication application;
6997 Integration::Scene stage(application.GetScene());
6999 Actor actorA = Actor::New();
7000 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7002 Vector2 size2(10.0f, 20.0f);
7003 actorA.SetProperty(Actor::Property::SIZE, size2);
7004 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
7005 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7007 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
7011 application.SendNotification();
7012 application.Render();
7014 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7015 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7017 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7018 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7020 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
7021 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
7023 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
7025 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7027 application.SendNotification();
7028 application.Render();
7030 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7031 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7033 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7034 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7036 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
7037 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7042 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
7044 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
7046 TestApplication application;
7048 Integration::Scene stage(application.GetScene());
7050 Actor actorA = Actor::New();
7051 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7052 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7053 Vector2 size2(10.0f, 20.0f);
7054 actorA.SetProperty(Actor::Property::SIZE, size2);
7055 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7057 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7061 application.SendNotification();
7062 application.Render();
7064 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7065 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7067 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7068 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7070 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
7071 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
7073 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
7075 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
7076 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7078 application.SendNotification();
7079 application.Render();
7081 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7082 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7084 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
7085 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7087 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
7088 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
7094 int UtcDaliActorGetScreenPositionWithChildActors(void)
7096 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
7098 TestApplication application;
7100 Integration::Scene stage(application.GetScene());
7102 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7104 Actor actorA = Actor::New();
7105 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7106 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7107 Vector2 size1(10.0f, 20.0f);
7108 actorA.SetProperty(Actor::Property::SIZE, size1);
7109 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7111 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7113 Actor parentActorA = Actor::New();
7114 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7115 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7116 Vector2 size2(30.0f, 60.0f);
7117 parentActorA.SetProperty(Actor::Property::SIZE, size2);
7118 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7120 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7122 stage.Add(parentActorA);
7123 parentActorA.Add(actorA);
7125 application.SendNotification();
7126 application.Render();
7128 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7129 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7131 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7132 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7134 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
7135 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
7137 tet_infoline("Test 2\n");
7139 tet_infoline("change parent anchor point and parent origin then check screen position \n");
7141 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7142 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
7144 application.SendNotification();
7145 application.Render();
7147 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7148 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7150 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
7151 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7153 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
7154 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
7159 int UtcDaliActorGetScreenPositionWithChildActors02(void)
7161 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
7163 TestApplication application;
7165 Integration::Scene stage(application.GetScene());
7167 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7169 Actor actorA = Actor::New();
7170 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7171 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7172 Vector2 size1(10.0f, 20.0f);
7173 actorA.SetProperty(Actor::Property::SIZE, size1);
7174 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7176 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
7178 Actor parentActorA = Actor::New();
7179 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7180 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7181 Vector2 size2(30.0f, 60.0f);
7182 parentActorA.SetProperty(Actor::Property::SIZE, size2);
7183 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7185 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
7187 Actor grandParentActorA = Actor::New();
7188 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
7189 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
7190 Vector2 size3(60.0f, 120.0f);
7191 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
7192 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
7194 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
7196 stage.Add(grandParentActorA);
7197 grandParentActorA.Add(parentActorA);
7199 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
7201 parentActorA.Add(actorA);
7203 application.SendNotification();
7204 application.Render();
7206 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
7207 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7209 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
7210 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
7212 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
7213 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
7218 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
7220 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
7222 TestApplication application;
7224 Integration::Scene stage(application.GetScene());
7226 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7228 Actor actorA = Actor::New();
7229 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7230 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7231 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7232 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
7235 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7237 Actor actorB = Actor::New();
7238 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7239 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7240 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7241 Vector2 actorBSize(30.0f, 60.0f);
7242 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7245 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7247 Actor actorC = Actor::New();
7248 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7249 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7250 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7251 Vector2 actorCSize(60.0f, 120.0f);
7252 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7255 application.SendNotification();
7256 application.Render();
7258 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7260 Vector2 center(stage.GetSize() * 0.5f);
7262 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7263 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7264 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7266 tet_infoline("Add scale to all actors");
7268 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7269 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7270 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7272 application.SendNotification();
7273 application.Render();
7275 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7276 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7277 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7282 int UtcDaliActorGetScreenPositionResizeScene(void)
7284 tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
7286 TestApplication application;
7287 Integration::Scene scene = application.GetScene();
7289 Actor actorA = Actor::New();
7290 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7291 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7292 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7296 application.SendNotification();
7297 application.Render();
7299 Vector2 sceneSize = scene.GetSize();
7300 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7302 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7305 Vector2 newSize(1000.0f, 2000.0f);
7306 DALI_TEST_CHECK(scene.GetSize() != newSize);
7308 scene.SurfaceResized(newSize.width, newSize.height);
7310 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7312 // The screen position should not be updated yet
7313 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7315 application.SendNotification();
7316 application.Render();
7318 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7320 // The screen position should be updated
7321 sceneSize = scene.GetSize();
7322 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7327 int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void)
7329 tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera");
7331 TestApplication application;
7332 Integration::Scene scene = application.GetScene();
7335 Layer layer = scene.GetRootLayer();
7336 layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D);
7338 // Build custom camera with top-view
7339 CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor();
7341 // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ])
7342 Vector3 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7343 Quaternion cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7346 std::ostringstream oss;
7347 oss << cameraPos << "\n";
7348 oss << cameraOrient << "\n";
7349 tet_printf("%s\n", oss.str().c_str());
7352 cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f));
7353 cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient);
7355 // Now, upside : -Z, leftside : -X, foward : +Y
7357 cameraPos = cameraActor.GetProperty<Vector3>(Actor::Property::POSITION);
7358 cameraOrient = cameraActor.GetProperty<Quaternion>(Actor::Property::ORIENTATION);
7360 std::ostringstream oss;
7361 oss << cameraPos << "\n";
7362 oss << cameraOrient << "\n";
7363 tet_printf("%s\n", oss.str().c_str());
7367 Actor actorA = Actor::New();
7368 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7369 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7370 actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7371 actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f));
7373 Actor actorB = Actor::New();
7374 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7375 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7376 actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f));
7377 actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f));
7382 application.SendNotification();
7383 application.Render();
7385 Vector2 sceneSize = scene.GetSize();
7386 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7388 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION);
7390 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7392 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION);
7397 int utcDaliActorPositionUsesAnchorPoint(void)
7399 TestApplication application;
7400 tet_infoline("Check default behaviour\n");
7402 Actor actor = Actor::New();
7403 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7404 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7405 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7406 application.GetScene().Add(actor);
7408 application.SendNotification();
7409 application.Render();
7411 tet_infoline("Check that the world position is in the center\n");
7412 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7414 tet_infoline("Set the position uses anchor point property to false\n");
7415 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7417 application.SendNotification();
7418 application.Render();
7420 tet_infoline("Check that the world position has changed appropriately\n");
7421 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7426 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7428 TestApplication application;
7429 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7431 Actor actor = Actor::New();
7432 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7433 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7434 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7435 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7436 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7437 application.GetScene().Add(actor);
7439 application.SendNotification();
7440 application.Render();
7442 tet_infoline("Check the world position is the same as it would be without a scale\n");
7443 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7445 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7446 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7447 application.SendNotification();
7448 application.Render();
7449 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7451 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7452 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7453 application.SendNotification();
7454 application.Render();
7455 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7460 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7462 TestApplication application;
7463 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7465 Actor actor = Actor::New();
7466 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7467 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7468 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7469 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7470 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7471 application.GetScene().Add(actor);
7473 application.SendNotification();
7474 application.Render();
7476 tet_infoline("Check the world position is the same as it would be without a rotation\n");
7477 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7479 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7480 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7481 application.SendNotification();
7482 application.Render();
7483 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7485 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7486 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7487 application.SendNotification();
7488 application.Render();
7489 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7494 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7496 TestApplication application;
7497 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7499 Actor actor = Actor::New();
7500 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7501 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7502 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7503 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7504 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7505 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7506 application.GetScene().Add(actor);
7508 application.SendNotification();
7509 application.Render();
7511 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7512 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7514 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7515 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7516 application.SendNotification();
7517 application.Render();
7518 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7520 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7521 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7522 application.SendNotification();
7523 application.Render();
7524 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7529 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7531 TestApplication application;
7532 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7534 Actor parent = Actor::New();
7536 application.GetScene().Add(parent);
7537 Vector2 stageSize(application.GetScene().GetSize());
7539 Actor actor = Actor::New();
7540 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7541 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7542 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7543 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7544 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7545 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7548 application.SendNotification();
7549 application.Render();
7551 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7553 tet_infoline("Check the world position is in the right place\n");
7554 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7556 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7557 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7558 application.SendNotification();
7559 application.Render();
7560 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7562 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7563 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7564 application.SendNotification();
7565 application.Render();
7566 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7571 int utcDaliActorVisibilityChangeSignalSelf(void)
7573 TestApplication application;
7574 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7576 Actor actor = Actor::New();
7578 VisibilityChangedFunctorData data;
7579 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7581 actor.SetProperty(Actor::Property::VISIBLE, false);
7583 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7585 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7588 actor.SetProperty(Actor::Property::VISIBLE, false);
7589 data.Check(false /* not called */, TEST_LOCATION);
7591 tet_infoline("Change the visibility using properties, ensure called");
7594 actor.SetProperty(Actor::Property::VISIBLE, true);
7595 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7597 tet_infoline("Set the visibility to current using properties, ensure not called");
7600 actor.SetProperty(Actor::Property::VISIBLE, true);
7601 data.Check(false /* not called */, TEST_LOCATION);
7606 int utcDaliActorVisibilityChangeSignalChildren(void)
7608 TestApplication application;
7609 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7611 Actor parent = Actor::New();
7612 Actor child = Actor::New();
7615 Actor grandChild = Actor::New();
7616 child.Add(grandChild);
7618 VisibilityChangedFunctorData parentData;
7619 VisibilityChangedFunctorData childData;
7620 VisibilityChangedFunctorData grandChildData;
7622 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7623 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7624 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7626 parent.SetProperty(Actor::Property::VISIBLE, false);
7627 parentData.Check(false /* not called */, TEST_LOCATION);
7628 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7629 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7631 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7634 grandChildData.Reset();
7636 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7638 parent.SetProperty(Actor::Property::VISIBLE, true);
7639 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7640 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7641 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7643 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7646 grandChildData.Reset();
7648 parent.SetProperty(Actor::Property::VISIBLE, true);
7649 parentData.Check(false /* not called */, TEST_LOCATION);
7650 childData.Check(false /* not called */, TEST_LOCATION);
7651 grandChildData.Check(false /* not called */, TEST_LOCATION);
7656 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7658 TestApplication application;
7659 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7661 Actor actor = Actor::New();
7662 application.GetScene().Add(actor);
7664 application.SendNotification();
7665 application.Render();
7667 VisibilityChangedFunctorData data;
7668 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7670 Animation animation = Animation::New(1.0f);
7671 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7673 data.Check(false, TEST_LOCATION);
7674 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7675 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7677 tet_infoline("Play the animation and check the property value");
7680 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7681 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7683 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7684 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7686 application.SendNotification();
7687 application.Render(1100); // After the animation
7689 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7694 int utcDaliActorVisibilityChangeSignalByName(void)
7696 TestApplication application;
7697 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7699 Actor actor = Actor::New();
7701 bool signalCalled = false;
7702 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7703 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7704 actor.SetProperty(Actor::Property::VISIBLE, false);
7705 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7707 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7708 signalCalled = false;
7709 actor.SetProperty(Actor::Property::VISIBLE, false);
7710 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7712 tet_infoline("Change the visibility using properties, ensure called");
7713 actor.SetProperty(Actor::Property::VISIBLE, true);
7714 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7716 tet_infoline("Set the visibility to current using properties, ensure not called");
7717 signalCalled = false;
7719 actor.SetProperty(Actor::Property::VISIBLE, true);
7720 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7725 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7727 gLayoutDirectionType = type;
7730 int UtcDaliActorLayoutDirectionProperty(void)
7732 TestApplication application;
7733 tet_infoline("Check layout direction property");
7735 Actor actor0 = Actor::New();
7736 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7737 application.GetScene().Add(actor0);
7739 application.SendNotification();
7740 application.Render();
7742 Actor actor1 = Actor::New();
7743 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7744 Actor actor2 = Actor::New();
7745 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7746 Actor actor3 = Actor::New();
7747 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7748 Actor actor4 = Actor::New();
7749 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7750 Actor actor5 = Actor::New();
7751 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7752 Actor actor6 = Actor::New();
7753 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7754 Actor actor7 = Actor::New();
7755 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7756 Actor actor8 = Actor::New();
7757 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7758 Actor actor9 = Actor::New();
7759 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7762 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7763 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7765 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7766 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7767 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7769 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7770 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7771 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7773 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7775 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7776 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7778 application.GetScene().Add(actor3);
7785 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7786 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7788 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7789 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7790 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7792 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7794 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7795 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7796 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7797 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7798 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7799 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7800 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7802 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7803 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7804 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7806 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7807 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7808 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7809 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7811 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7812 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7813 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7818 struct LayoutDirectionFunctor
7820 LayoutDirectionFunctor(bool& signalCalled)
7821 : mSignalCalled(signalCalled)
7825 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7826 : mSignalCalled(rhs.mSignalCalled)
7832 mSignalCalled = true;
7835 bool& mSignalCalled;
7838 int UtcDaliActorLayoutDirectionSignal(void)
7840 TestApplication application;
7841 tet_infoline("Check changing layout direction property sends a signal");
7843 Actor actor = Actor::New();
7844 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7845 application.GetScene().Add(actor);
7846 bool signalCalled = false;
7847 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7849 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7850 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7852 // Test that writing the same value doesn't send a signal
7853 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7854 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7856 // Test that writing a different value sends the signal
7857 signalCalled = false;
7858 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7859 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7861 signalCalled = false;
7862 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7863 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7868 struct ChildAddedSignalCheck
7870 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7871 : mSignalReceived(signalReceived),
7872 mChildHandle(childHandle)
7876 void operator()(Actor childHandle)
7878 mSignalReceived = true;
7879 mChildHandle = childHandle;
7883 mSignalReceived = true;
7884 mChildHandle = Actor();
7887 bool& mSignalReceived;
7888 Actor& mChildHandle;
7891 int UtcDaliChildAddedSignalP1(void)
7893 TestApplication application;
7894 auto stage = application.GetScene();
7896 bool signalReceived = false;
7899 ChildAddedSignalCheck signal(signalReceived, childActor);
7900 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7901 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7903 auto actorA = Actor::New();
7905 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7906 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7907 signalReceived = false;
7909 auto actorB = Actor::New();
7911 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7912 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7917 int UtcDaliChildAddedSignalP2(void)
7919 TestApplication application;
7920 auto stage = application.GetScene();
7922 bool signalReceived = false;
7925 ChildAddedSignalCheck signal(signalReceived, childActor);
7926 tet_infoline("Connect to childAdded signal by name");
7928 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7929 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7931 auto actorA = Actor::New();
7933 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7935 // Can't test which actor was added; signal signature is void() when connecting via name.
7936 signalReceived = false;
7938 auto actorB = Actor::New();
7940 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7945 int UtcDaliChildAddedSignalN(void)
7947 TestApplication application;
7948 auto stage = application.GetScene();
7950 bool signalReceived = false;
7953 ChildAddedSignalCheck signal(signalReceived, childActor);
7954 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7955 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7957 auto actorA = Actor::New();
7959 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7960 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7961 signalReceived = false;
7963 auto actorB = Actor::New();
7965 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7969 struct ChildRemovedSignalCheck
7971 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7972 : mSignalReceived(signalReceived),
7973 mChildHandle(childHandle)
7977 void operator()(Actor childHandle)
7979 mSignalReceived = true;
7980 mChildHandle = childHandle;
7985 mSignalReceived = true;
7988 bool& mSignalReceived;
7989 Actor& mChildHandle;
7992 int UtcDaliChildRemovedSignalP1(void)
7994 TestApplication application;
7995 auto stage = application.GetScene();
7997 bool signalReceived = false;
8000 ChildRemovedSignalCheck signal(signalReceived, childActor);
8001 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8002 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8004 auto actorA = Actor::New();
8006 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8007 DALI_TEST_CHECK(!childActor);
8009 stage.Remove(actorA);
8010 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
8011 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8013 signalReceived = false;
8014 auto actorB = Actor::New();
8016 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8018 stage.Remove(actorB);
8019 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8020 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
8025 int UtcDaliChildRemovedSignalP2(void)
8027 TestApplication application;
8028 auto stage = application.GetScene();
8030 bool signalReceived = false;
8033 ChildAddedSignalCheck signal(signalReceived, childActor);
8034 tet_infoline("Connect to childRemoved signal by name");
8036 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
8037 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8039 auto actorA = Actor::New();
8041 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8043 stage.Remove(actorA);
8044 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8046 signalReceived = false;
8047 auto actorB = Actor::New();
8049 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8051 stage.Remove(actorB);
8052 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
8057 int UtcDaliChildRemovedSignalN(void)
8059 TestApplication application;
8060 auto stage = application.GetScene();
8062 bool signalReceived = false;
8065 ChildRemovedSignalCheck signal(signalReceived, childActor);
8066 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
8067 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8069 auto actorA = Actor::New();
8072 auto actorB = Actor::New();
8075 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8076 DALI_TEST_CHECK(!childActor);
8078 actorA.Remove(actorB);
8079 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
8083 int UtcDaliChildMovedSignalP(void)
8085 TestApplication application;
8086 auto stage = application.GetScene();
8088 bool addedASignalReceived = false;
8089 bool removedASignalReceived = false;
8090 bool addedBSignalReceived = false;
8091 bool removedBSignalReceived = false;
8094 auto actorA = Actor::New();
8095 auto actorB = Actor::New();
8099 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
8100 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
8101 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
8102 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
8104 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
8105 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
8106 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
8107 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
8109 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8110 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8111 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8112 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8114 // Create a child of A
8116 auto child = Actor::New();
8119 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8120 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8121 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8122 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8123 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
8126 addedASignalReceived = false;
8127 addedBSignalReceived = false;
8128 removedASignalReceived = false;
8129 removedBSignalReceived = false;
8131 actorB.Add(child); // Expect this child to be re-parented
8132 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
8133 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
8134 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
8135 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
8137 // Move child back to A:
8138 addedASignalReceived = false;
8139 addedBSignalReceived = false;
8140 removedASignalReceived = false;
8141 removedBSignalReceived = false;
8143 actorA.Add(child); // Expect this child to be re-parented
8144 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
8145 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
8146 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
8147 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
8152 int UtcDaliActorSwitchParentP(void)
8154 tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
8155 TestApplication application;
8157 Actor parent1 = Actor::New();
8158 Actor child = Actor::New();
8160 application.GetScene().Add(parent1);
8162 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8164 child.OnSceneSignal().Connect(OnSceneCallback);
8165 child.OffSceneSignal().Connect(OffSceneCallback);
8168 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
8169 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8173 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
8175 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8176 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8178 Actor parent2 = Actor::New();
8179 application.GetScene().Add(parent2);
8181 bool addSignalReceived = false;
8182 ChildAddedSignalCheck addedSignal(addSignalReceived, child);
8183 DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
8184 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8186 bool removedSignalReceived = false;
8187 ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
8188 DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
8189 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8191 DevelActor::SwitchParent(child, parent2);
8193 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
8194 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
8196 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
8197 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
8199 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
8200 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
8201 DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
8202 DALI_TEST_CHECK(child.GetParent() == parent2);
8207 int utcDaliActorCulled(void)
8209 TestApplication application;
8210 auto stage = application.GetScene();
8212 tet_infoline("Check that the actor is culled if the actor is out of the screen");
8214 Actor actor = Actor::New();
8215 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
8217 Geometry geometry = CreateQuadGeometry();
8218 Shader shader = CreateShader();
8219 Renderer renderer = Renderer::New(geometry, shader);
8220 actor.AddRenderer(renderer);
8224 application.SendNotification();
8225 application.Render(0);
8227 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
8229 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
8230 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
8232 // Connect NotifySignal
8233 bool propertyNotificationSignal(false);
8234 PropertyNotification source;
8235 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
8236 notification.NotifySignal().Connect(&application, f);
8238 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
8240 application.SendNotification();
8241 application.Render();
8243 application.SendNotification();
8245 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
8247 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
8248 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
8249 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
8254 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
8256 TestApplication application;
8257 auto stage = application.GetScene();
8259 tet_infoline("Ensure we clear the screen when the last actor is removed");
8261 Actor actor = CreateRenderableActor();
8262 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
8265 application.SendNotification();
8266 application.Render();
8268 auto& glAbstraction = application.GetGlAbstraction();
8269 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
8273 application.SendNotification();
8274 application.Render();
8276 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8281 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
8283 TestApplication application;
8284 auto stage = application.GetScene();
8286 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
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();
8298 actor.SetProperty(Actor::Property::VISIBLE, false);
8300 application.SendNotification();
8301 application.Render();
8303 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8308 int utcDaliActorGetSizeAfterAnimation(void)
8310 TestApplication application;
8311 tet_infoline("Check the actor size before / after an animation is finished");
8313 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8315 Actor actor = Actor::New();
8316 actor.SetProperty(Actor::Property::SIZE, actorSize);
8317 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8318 application.GetScene().Add(actor);
8320 // Size should be updated without rendering.
8321 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8322 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8324 application.SendNotification();
8325 application.Render();
8327 // Size and current size should be updated.
8328 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8329 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8330 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8331 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8332 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8334 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8335 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8336 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8337 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8338 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8341 actorSize = Vector3(200.0f, 200.0f, 0.0f);
8342 actor.SetProperty(Actor::Property::SIZE, actorSize);
8344 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8345 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8347 Vector3 targetValue(10.0f, 20.0f, 0.0f);
8349 Animation animation = Animation::New(1.0f);
8350 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8353 // Size should be updated without rendering.
8354 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8355 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8357 application.SendNotification();
8358 application.Render(1100); // After the animation
8360 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8361 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8362 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8363 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8364 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8366 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8367 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8368 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8369 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8370 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8372 targetValue.width = 50.0f;
8375 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8378 application.SendNotification();
8379 application.Render(1100); // After the animation
8381 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8382 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8383 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8384 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8385 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8387 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8388 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8389 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8390 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8391 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8393 targetValue.height = 70.0f;
8396 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8399 application.SendNotification();
8400 application.Render(1100); // After the animation
8402 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8403 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8404 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8405 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8406 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8408 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8409 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8410 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8411 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8412 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8414 Vector3 offset(10.0f, 20.0f, 0.0f);
8417 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8420 application.SendNotification();
8421 application.Render(1100); // After the animation
8423 targetValue += offset;
8425 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8426 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8427 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8428 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8429 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8431 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8432 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8433 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8434 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8435 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8437 offset.width = 20.0f;
8440 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8443 application.SendNotification();
8444 application.Render(1100); // After the animation
8446 targetValue.width += offset.width;
8448 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8449 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8450 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8451 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8452 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8454 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8455 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8456 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8457 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8458 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8460 offset.height = 10.0f;
8463 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8466 application.SendNotification();
8467 application.Render(1100); // After the animation
8469 targetValue.height += offset.height;
8471 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8472 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8473 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8474 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8475 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8477 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8478 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8479 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8480 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8481 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8484 actorSize = Vector3(300.0f, 300.0f, 0.0f);
8486 actor.SetProperty(Actor::Property::SIZE, actorSize);
8488 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8489 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8491 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8492 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8494 application.SendNotification();
8495 application.Render();
8497 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8498 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8500 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8501 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8506 int utcDaliActorRelayoutAndAnimation(void)
8508 TestApplication application;
8509 tet_infoline("Check the actor size when relayoutting and playing animation");
8511 Vector3 parentSize(300.0f, 300.0f, 0.0f);
8512 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8515 Actor parentA = Actor::New();
8516 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8517 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8518 application.GetScene().Add(parentA);
8520 Actor parentB = Actor::New();
8521 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8522 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8523 application.GetScene().Add(parentB);
8525 Actor actor = Actor::New();
8526 actor.SetProperty(Actor::Property::SIZE, actorSize);
8527 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8530 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8531 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8533 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8535 Animation animation = Animation::New(1.0f);
8536 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8539 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8540 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8542 application.SendNotification();
8543 application.Render(1100); // After the animation
8545 // Size and current size should be updated.
8546 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8547 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8549 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8550 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8555 application.SendNotification();
8556 application.Render();
8558 // Size and current size should be same.
8559 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8560 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8562 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8563 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8571 Actor parentA = Actor::New();
8572 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8573 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8574 application.GetScene().Add(parentA);
8576 Actor parentB = Actor::New();
8577 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8578 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8579 application.GetScene().Add(parentB);
8581 Actor actor = Actor::New();
8582 actor.SetProperty(Actor::Property::SIZE, actorSize);
8583 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8586 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8587 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8589 application.SendNotification();
8590 application.Render();
8592 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8593 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8595 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8596 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8598 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8600 // Make an animation
8601 Animation animation = Animation::New(1.0f);
8602 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8605 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8606 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8608 application.SendNotification();
8609 application.Render(1100); // After the animation
8611 // Size and current size should be updated.
8612 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8613 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8615 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8616 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8621 application.SendNotification();
8622 application.Render();
8624 // Size and current size should be same.
8625 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8626 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8628 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8629 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8639 int utcDaliActorPartialUpdate(void)
8641 TestApplication application(
8642 TestApplication::DEFAULT_SURFACE_WIDTH,
8643 TestApplication::DEFAULT_SURFACE_HEIGHT,
8644 TestApplication::DEFAULT_HORIZONTAL_DPI,
8645 TestApplication::DEFAULT_VERTICAL_DPI,
8649 tet_infoline("Check the damaged area");
8651 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8653 std::vector<Rect<int>> damagedRects;
8654 Rect<int> clippingRect;
8655 application.SendNotification();
8656 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8658 // First render pass, nothing to render, adaptor would just do swap buffer.
8659 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8661 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8662 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8664 Actor actor = CreateRenderableActor();
8665 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8666 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8667 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8668 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8669 application.GetScene().Add(actor);
8671 application.SendNotification();
8673 // 1. Actor added, damaged rect is added size of actor
8674 damagedRects.clear();
8675 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8676 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8679 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8680 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8681 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8682 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8683 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8684 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8685 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8688 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8689 application.SendNotification();
8691 damagedRects.clear();
8692 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8693 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8696 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
8697 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8698 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8699 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8700 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8701 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8702 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8704 // 3. Set new position
8705 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8706 application.SendNotification();
8708 damagedRects.clear();
8709 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8710 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8713 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
8714 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8715 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8716 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8717 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8718 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8719 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8721 application.GetScene().Remove(actor);
8722 application.SendNotification();
8724 // Actor removed, last a dirty rect is reported.
8725 damagedRects.clear();
8726 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8727 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8729 clippingRect = damagedRects[0];
8731 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8732 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(32, 736, 48, 48), TEST_LOCATION);
8734 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8735 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8736 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8737 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8738 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8743 int utcDaliActorPartialUpdateSetColor(void)
8745 TestApplication application(
8746 TestApplication::DEFAULT_SURFACE_WIDTH,
8747 TestApplication::DEFAULT_SURFACE_HEIGHT,
8748 TestApplication::DEFAULT_HORIZONTAL_DPI,
8749 TestApplication::DEFAULT_VERTICAL_DPI,
8753 tet_infoline("Check uniform update");
8755 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8757 std::vector<Rect<int>> damagedRects;
8758 Rect<int> clippingRect;
8759 application.SendNotification();
8760 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8762 // First render pass, nothing to render, adaptor would just do swap buffer.
8763 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8765 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8766 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8768 Actor actor = CreateRenderableActor();
8769 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8770 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8771 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8772 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8773 application.GetScene().Add(actor);
8775 application.SendNotification();
8777 // 1. Actor added, damaged rect is added size of actor
8778 damagedRects.clear();
8779 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8780 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8783 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8784 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8785 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8786 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8787 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8788 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8789 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8791 damagedRects.clear();
8792 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8793 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8795 damagedRects.clear();
8796 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8797 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8800 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8801 application.SendNotification();
8803 damagedRects.clear();
8804 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8805 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8808 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8809 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8810 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8811 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8812 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8813 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8814 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8819 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8820 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8821 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8822 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8823 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8824 " uniform mediump mat4 uLightCameraViewMatrix;\n"
8828 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8829 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
8830 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8833 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8834 "uniform lowp vec4 uShadowColor;\n"
8837 " lowp float alpha;\n"
8838 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8839 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8842 int utcDaliActorPartialUpdateSetProperty(void)
8844 TestApplication application(
8845 TestApplication::DEFAULT_SURFACE_WIDTH,
8846 TestApplication::DEFAULT_SURFACE_HEIGHT,
8847 TestApplication::DEFAULT_HORIZONTAL_DPI,
8848 TestApplication::DEFAULT_VERTICAL_DPI,
8852 tet_infoline("Set/Update property with partial update");
8854 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8856 std::vector<Rect<int>> damagedRects;
8857 Rect<int> clippingRect;
8858 application.SendNotification();
8859 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8861 // First render pass, nothing to render, adaptor would just do swap buffer.
8862 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8864 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8865 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8867 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8868 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8869 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8870 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8871 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8872 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8873 application.GetScene().Add(actor);
8875 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8877 damagedRects.clear();
8878 application.SendNotification();
8879 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8880 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8883 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8884 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8885 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8886 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8887 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8888 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8889 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8891 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8892 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8894 damagedRects.clear();
8895 application.SendNotification();
8896 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8897 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8899 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8900 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8901 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8902 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8903 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8904 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8906 // Should be no damage rects, nothing changed
8907 damagedRects.clear();
8908 application.SendNotification();
8909 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8910 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8912 // Should be 1 damage rect due to change in size
8913 damagedRects.clear();
8914 actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8915 application.SendNotification();
8916 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8917 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8919 clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8920 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8921 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8922 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8923 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8924 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8925 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8927 damagedRects.clear();
8928 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8929 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8934 int utcDaliActorPartialUpdateTwoActors(void)
8936 TestApplication application(
8937 TestApplication::DEFAULT_SURFACE_WIDTH,
8938 TestApplication::DEFAULT_SURFACE_HEIGHT,
8939 TestApplication::DEFAULT_HORIZONTAL_DPI,
8940 TestApplication::DEFAULT_VERTICAL_DPI,
8944 tet_infoline("Check the damaged rects with partial update and two actors");
8946 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8948 Actor actor = CreateRenderableActor();
8949 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8950 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8951 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8952 application.GetScene().Add(actor);
8954 Actor actor2 = CreateRenderableActor();
8955 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8956 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8957 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8958 application.GetScene().Add(actor2);
8960 application.SendNotification();
8961 std::vector<Rect<int>> damagedRects;
8962 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8964 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8965 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8966 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8968 // in screen coordinates, adaptor would calculate it using previous frames information
8969 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8970 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8972 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8973 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8974 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8975 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8977 // Change a Renderer of actor1
8978 Geometry geometry = CreateQuadGeometry();
8979 Shader shader = CreateShader();
8980 Renderer newRenderer = Renderer::New(geometry, shader);
8981 Renderer renderer = actor.GetRendererAt(0);
8983 actor.RemoveRenderer(renderer);
8984 actor.AddRenderer(newRenderer);
8986 damagedRects.clear();
8988 application.SendNotification();
8989 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8991 DALI_TEST_CHECK(damagedRects.size() > 0);
8992 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8994 // in screen coordinates, adaptor would calculate it using previous frames information
8995 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8997 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8998 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8999 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9000 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9005 int utcDaliActorPartialUpdateActorsWithSizeHint01(void)
9007 TestApplication application(
9008 TestApplication::DEFAULT_SURFACE_WIDTH,
9009 TestApplication::DEFAULT_SURFACE_HEIGHT,
9010 TestApplication::DEFAULT_HORIZONTAL_DPI,
9011 TestApplication::DEFAULT_VERTICAL_DPI,
9015 tet_infoline("Check the damaged rect with partial update and actor size hint");
9017 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9019 Actor actor = CreateRenderableActor();
9020 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9021 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9022 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9023 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9024 application.GetScene().Add(actor);
9026 application.SendNotification();
9027 std::vector<Rect<int>> damagedRects;
9028 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9030 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9032 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
9033 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9035 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9037 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9038 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9039 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9040 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9045 damagedRects.clear();
9046 application.SendNotification();
9047 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9049 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9050 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9052 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9054 damagedRects.clear();
9055 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9056 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9058 // Ensure the damaged rect is empty
9059 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9061 // Chnage UPDATE_AREA_HINT
9062 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f));
9063 application.GetScene().Add(actor);
9065 application.SendNotification();
9066 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9068 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9070 clippingRect = Rect<int>(64, 704, 48, 48);
9071 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9073 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9075 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9076 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9077 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9078 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9083 damagedRects.clear();
9084 application.SendNotification();
9085 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9087 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9088 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9090 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9092 damagedRects.clear();
9093 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9094 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9096 // Ensure the damaged rect is empty
9097 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9099 // Chnage UPDATE_AREA_HINT
9100 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f));
9101 application.GetScene().Add(actor);
9103 application.SendNotification();
9104 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9106 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9108 clippingRect = Rect<int>(0, 720, 80, 80);
9109 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9111 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9113 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9114 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9115 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9116 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9121 int utcDaliActorPartialUpdateActorsWithSizeHint02(void)
9123 TestApplication application(
9124 TestApplication::DEFAULT_SURFACE_WIDTH,
9125 TestApplication::DEFAULT_SURFACE_HEIGHT,
9126 TestApplication::DEFAULT_HORIZONTAL_DPI,
9127 TestApplication::DEFAULT_VERTICAL_DPI,
9131 tet_infoline("Check the damaged rect with partial update and actor size hint");
9133 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9135 Actor actor = CreateRenderableActor();
9136 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
9137 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
9138 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9139 application.GetScene().Add(actor);
9141 application.SendNotification();
9142 std::vector<Rect<int>> damagedRects;
9143 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9145 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9147 Rect<int> clippingRect = Rect<int>(48, 720, 48, 48);
9148 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9150 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9152 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9153 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9154 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9155 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9157 damagedRects.clear();
9158 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9159 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9161 // Ensure the damaged rect is empty
9162 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9164 // Chnage UPDATE_AREA_HINT
9165 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f));
9167 application.SendNotification();
9168 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9170 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9172 clippingRect = Rect<int>(32, 704, 80, 80);
9173 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9175 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9177 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9178 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9179 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9180 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9182 damagedRects.clear();
9183 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9184 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9186 // Ensure the damaged rect is empty
9187 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9189 // Chnage UPDATE_AREA_HINT
9190 actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f));
9191 application.GetScene().Add(actor);
9193 application.SendNotification();
9194 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
9196 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9198 clippingRect = Rect<int>(32, 688, 96, 96);
9199 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9201 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9203 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9204 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9205 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9206 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9211 int utcDaliActorPartialUpdateAnimation(void)
9213 TestApplication application(
9214 TestApplication::DEFAULT_SURFACE_WIDTH,
9215 TestApplication::DEFAULT_SURFACE_HEIGHT,
9216 TestApplication::DEFAULT_HORIZONTAL_DPI,
9217 TestApplication::DEFAULT_VERTICAL_DPI,
9221 tet_infoline("Check the damaged area with partial update and animation");
9223 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9224 drawTrace.Enable(true);
9227 Actor actor1 = CreateRenderableActor();
9228 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9229 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9230 application.GetScene().Add(actor1);
9232 Actor actor2 = CreateRenderableActor();
9233 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9234 actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9235 application.GetScene().Add(actor2);
9237 std::vector<Rect<int>> damagedRects;
9238 Rect<int> clippingRect;
9239 Rect<int> expectedRect1, expectedRect2;
9241 application.SendNotification();
9242 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9244 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
9247 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
9248 expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
9249 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9250 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
9252 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9253 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9255 // Make an animation
9256 Animation animation = Animation::New(1.0f);
9257 animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
9260 application.SendNotification();
9262 damagedRects.clear();
9263 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9264 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9265 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9268 damagedRects.clear();
9270 // In animation deley time
9271 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9272 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9273 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9276 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9279 damagedRects.clear();
9281 // Also in animation deley time
9282 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9283 application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
9284 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9287 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9289 // Unparent 2 actors and make a new actor
9293 Actor actor3 = CreateRenderableActor();
9294 actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9295 actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9296 application.GetScene().Add(actor3);
9298 application.SendNotification();
9300 // Started animation
9301 damagedRects.clear();
9302 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9303 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
9305 // The first dirty rect is actor3's.
9306 // We don't know the exact dirty rect of actor2
9307 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
9308 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
9310 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9311 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9313 // Finished animation, but the actor was already unparented
9314 damagedRects.clear();
9315 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
9317 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9319 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9320 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9325 int utcDaliActorPartialUpdateChangeVisibility(void)
9327 TestApplication application(
9328 TestApplication::DEFAULT_SURFACE_WIDTH,
9329 TestApplication::DEFAULT_SURFACE_HEIGHT,
9330 TestApplication::DEFAULT_HORIZONTAL_DPI,
9331 TestApplication::DEFAULT_VERTICAL_DPI,
9335 tet_infoline("Check the damaged rect with partial update and visibility change");
9337 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9339 Actor actor = CreateRenderableActor();
9340 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9341 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9342 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9343 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9344 application.GetScene().Add(actor);
9346 application.SendNotification();
9348 std::vector<Rect<int>> damagedRects;
9349 Rect<int> clippingRect;
9351 // 1. Actor added, damaged rect is added size of actor
9352 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9353 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9356 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9357 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9358 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9359 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9360 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9361 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9362 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9364 damagedRects.clear();
9365 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9366 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9368 damagedRects.clear();
9369 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9370 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9372 // Ensure the damaged rect is empty
9373 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9375 // 2. Make the Actor invisible
9376 actor.SetProperty(Actor::Property::VISIBLE, false);
9377 application.SendNotification();
9379 damagedRects.clear();
9380 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9381 DALI_TEST_CHECK(damagedRects.size() > 0);
9382 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9384 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9385 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9386 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9387 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9388 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9390 // 3. Make the Actor visible again
9391 actor.SetProperty(Actor::Property::VISIBLE, true);
9392 application.SendNotification();
9394 damagedRects.clear();
9395 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9396 DALI_TEST_CHECK(damagedRects.size() > 0);
9397 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9399 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9400 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9401 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9402 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9403 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9408 int utcDaliActorPartialUpdateOnOffScene(void)
9410 TestApplication application(
9411 TestApplication::DEFAULT_SURFACE_WIDTH,
9412 TestApplication::DEFAULT_SURFACE_HEIGHT,
9413 TestApplication::DEFAULT_HORIZONTAL_DPI,
9414 TestApplication::DEFAULT_VERTICAL_DPI,
9418 tet_infoline("Check the damaged rect with partial update and on/off scene");
9420 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9422 Actor actor = CreateRenderableActor();
9423 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9424 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
9425 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
9426 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9427 application.GetScene().Add(actor);
9429 application.SendNotification();
9431 std::vector<Rect<int>> damagedRects;
9432 Rect<int> clippingRect;
9434 // 1. Actor added, damaged rect is added size of actor
9435 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9436 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9439 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9440 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9441 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9442 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9443 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9444 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9445 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9447 damagedRects.clear();
9448 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9449 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9451 damagedRects.clear();
9452 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9453 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9455 // Ensure the damaged rect is empty
9456 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9458 // 2. Remove the Actor from the Scene
9460 application.SendNotification();
9462 damagedRects.clear();
9463 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9464 DALI_TEST_CHECK(damagedRects.size() > 0);
9465 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9467 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9468 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9469 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9470 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9471 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9473 // 3. Add the Actor to the Scene again
9474 application.GetScene().Add(actor);
9475 application.SendNotification();
9477 damagedRects.clear();
9478 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9479 DALI_TEST_CHECK(damagedRects.size() > 0);
9480 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9482 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9483 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9484 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9485 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9486 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9491 int utcDaliActorPartialUpdateSkipRendering(void)
9493 TestApplication application(
9494 TestApplication::DEFAULT_SURFACE_WIDTH,
9495 TestApplication::DEFAULT_SURFACE_HEIGHT,
9496 TestApplication::DEFAULT_HORIZONTAL_DPI,
9497 TestApplication::DEFAULT_VERTICAL_DPI,
9501 tet_infoline("Check to skip rendering in case of the empty damaged rect");
9503 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9504 drawTrace.Enable(true);
9507 Actor actor1 = CreateRenderableActor();
9508 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9509 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9510 application.GetScene().Add(actor1);
9512 std::vector<Rect<int>> damagedRects;
9513 Rect<int> clippingRect;
9514 Rect<int> expectedRect1;
9516 application.SendNotification();
9517 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9519 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9522 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
9523 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9525 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9526 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9528 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9530 damagedRects.clear();
9531 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9532 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9533 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9538 application.SendNotification();
9540 damagedRects.clear();
9541 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9543 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9545 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9546 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9548 // Render again without any change
9549 damagedRects.clear();
9551 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9553 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9555 clippingRect = Rect<int>();
9556 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9559 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9561 // Add the actor again
9562 application.GetScene().Add(actor1);
9564 application.SendNotification();
9566 damagedRects.clear();
9568 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9570 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9572 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9573 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9575 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9580 int utcDaliActorPartialUpdate3DNode(void)
9582 TestApplication application(
9583 TestApplication::DEFAULT_SURFACE_WIDTH,
9584 TestApplication::DEFAULT_SURFACE_HEIGHT,
9585 TestApplication::DEFAULT_HORIZONTAL_DPI,
9586 TestApplication::DEFAULT_VERTICAL_DPI,
9590 tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9592 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9593 drawTrace.Enable(true);
9596 Actor actor1 = CreateRenderableActor();
9597 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9598 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9599 application.GetScene().Add(actor1);
9601 std::vector<Rect<int>> damagedRects;
9602 Rect<int> clippingRect;
9604 application.SendNotification();
9605 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9607 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9609 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9610 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9612 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9614 // Change the layer to 3D
9615 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9617 application.SendNotification();
9619 damagedRects.clear();
9620 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9622 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9623 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9625 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9627 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9629 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9631 // Change the layer to 2D
9632 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9634 application.SendNotification();
9636 damagedRects.clear();
9637 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9639 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9641 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9642 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9644 // Make 3D transform
9645 actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9647 application.SendNotification();
9649 damagedRects.clear();
9650 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9652 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9653 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9655 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9657 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9659 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9664 int utcDaliActorPartialUpdateNotRenderableActor(void)
9666 TestApplication application(
9667 TestApplication::DEFAULT_SURFACE_WIDTH,
9668 TestApplication::DEFAULT_SURFACE_HEIGHT,
9669 TestApplication::DEFAULT_HORIZONTAL_DPI,
9670 TestApplication::DEFAULT_VERTICAL_DPI,
9674 tet_infoline("Check the damaged rect with not renderable parent actor");
9676 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9678 Actor parent = Actor::New();
9679 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9680 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9681 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9682 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9683 application.GetScene().Add(parent);
9685 Actor child = CreateRenderableActor();
9686 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9687 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9688 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9691 application.SendNotification();
9693 std::vector<Rect<int>> damagedRects;
9695 // 1. Actor added, damaged rect is added size of actor
9696 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9697 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9700 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9701 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9703 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9704 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9705 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9706 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9707 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9709 damagedRects.clear();
9710 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9711 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9713 damagedRects.clear();
9714 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9715 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9717 // Ensure the damaged rect is empty
9718 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9723 int utcDaliActorPartialUpdateChangeTransparency(void)
9725 TestApplication application(
9726 TestApplication::DEFAULT_SURFACE_WIDTH,
9727 TestApplication::DEFAULT_SURFACE_HEIGHT,
9728 TestApplication::DEFAULT_HORIZONTAL_DPI,
9729 TestApplication::DEFAULT_VERTICAL_DPI,
9733 tet_infoline("Check the damaged rect with changing transparency");
9735 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9737 Actor actor = CreateRenderableActor();
9738 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9739 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9740 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9741 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9742 application.GetScene().Add(actor);
9744 application.SendNotification();
9746 std::vector<Rect<int>> damagedRects;
9748 // Actor added, damaged rect is added size of actor
9749 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9750 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9753 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
9754 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9756 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9757 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9758 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9759 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9760 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9762 damagedRects.clear();
9763 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9764 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9766 // Ensure the damaged rect is empty
9767 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9769 // Make the actor transparent by changing opacity of the Renderer
9770 // It changes a uniform value
9771 Renderer renderer = actor.GetRendererAt(0);
9772 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9774 application.SendNotification();
9776 // The damaged rect should be same
9777 damagedRects.clear();
9778 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9779 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9780 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9781 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9783 damagedRects.clear();
9784 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9785 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9787 // Ensure the damaged rect is empty
9788 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9790 // Make the actor opaque again
9791 renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9793 application.SendNotification();
9795 // The damaged rect should not be empty
9796 damagedRects.clear();
9797 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9798 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9799 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9800 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9802 damagedRects.clear();
9803 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9804 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9806 // Ensure the damaged rect is empty
9807 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9809 // Make the actor translucent
9810 renderer[DevelRenderer::Property::OPACITY] = 0.5f;
9812 application.SendNotification();
9814 // The damaged rect should not be empty
9815 damagedRects.clear();
9816 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9817 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9818 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9819 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9821 damagedRects.clear();
9822 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9823 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9825 // Ensure the damaged rect is empty
9826 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9828 // Change Renderer opacity - also translucent
9829 renderer[DevelRenderer::Property::OPACITY] = 0.2f;
9831 application.SendNotification();
9833 // The damaged rect should not be empty
9834 damagedRects.clear();
9835 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9836 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9837 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9838 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9840 damagedRects.clear();
9841 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9842 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9844 // Ensure the damaged rect is empty
9845 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9847 // Make the actor culled
9848 actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9850 application.SendNotification();
9852 // The damaged rect should be same
9853 damagedRects.clear();
9854 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9855 DALI_TEST_CHECK(damagedRects.size() > 0);
9856 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9857 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9859 damagedRects.clear();
9860 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9861 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9863 // Ensure the damaged rect is empty
9864 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9866 // Make the actor not culled again
9867 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
9869 application.SendNotification();
9871 // The damaged rect should not be empty
9872 damagedRects.clear();
9873 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9874 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9875 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9876 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9881 int utcDaliActorPartialUpdateChangeParentOpacity(void)
9883 TestApplication application(
9884 TestApplication::DEFAULT_SURFACE_WIDTH,
9885 TestApplication::DEFAULT_SURFACE_HEIGHT,
9886 TestApplication::DEFAULT_HORIZONTAL_DPI,
9887 TestApplication::DEFAULT_VERTICAL_DPI,
9891 tet_infoline("Check the damaged rect with changing parent's opacity");
9893 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9895 Actor parent = Actor::New();
9896 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9897 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9898 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9899 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9900 application.GetScene().Add(parent);
9902 Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
9903 Actor child = CreateRenderableActor(texture);
9904 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9905 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9906 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9909 application.SendNotification();
9911 std::vector<Rect<int>> damagedRects;
9913 // Actor added, damaged rect is added size of actor
9914 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9915 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9918 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9919 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9921 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9922 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9923 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9924 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9925 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9927 damagedRects.clear();
9928 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9929 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9931 damagedRects.clear();
9932 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9933 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9935 // Ensure the damaged rect is empty
9936 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9938 // Change the parent's opacity
9939 parent[Actor::Property::OPACITY] = 0.5f;
9941 application.SendNotification();
9943 // The damaged rect should be same
9944 damagedRects.clear();
9945 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9946 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9947 DALI_TEST_CHECK(damagedRects.size() > 0);
9948 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9953 int utcDaliActorPartialUpdateAddRemoveRenderer(void)
9955 TestApplication application(
9956 TestApplication::DEFAULT_SURFACE_WIDTH,
9957 TestApplication::DEFAULT_SURFACE_HEIGHT,
9958 TestApplication::DEFAULT_HORIZONTAL_DPI,
9959 TestApplication::DEFAULT_VERTICAL_DPI,
9963 tet_infoline("Check the damaged rect with adding / removing renderer");
9965 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9967 Actor actor = CreateRenderableActor();
9968 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9969 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9970 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9971 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9972 application.GetScene().Add(actor);
9974 application.SendNotification();
9976 std::vector<Rect<int>> damagedRects;
9978 // Actor added, damaged rect is added size of actor
9979 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9980 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9983 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9984 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9986 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9987 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9988 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9989 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9990 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9992 damagedRects.clear();
9993 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9994 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9996 damagedRects.clear();
9997 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9998 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10000 // Remove the Renderer
10001 Renderer renderer = actor.GetRendererAt(0);
10002 actor.RemoveRenderer(renderer);
10004 application.SendNotification();
10006 // The damaged rect should be the actor area
10007 damagedRects.clear();
10008 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10009 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10010 DALI_TEST_CHECK(damagedRects.size() > 0);
10011 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10013 damagedRects.clear();
10014 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10015 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10017 // Ensure the damaged rect is empty
10018 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10020 // Add the Renderer again
10021 actor.AddRenderer(renderer);
10023 application.SendNotification();
10025 // The damaged rect should be the actor area
10026 damagedRects.clear();
10027 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10028 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10029 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10030 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10035 int utcDaliActorPartialUpdate3DTransform(void)
10037 TestApplication application(
10038 TestApplication::DEFAULT_SURFACE_WIDTH,
10039 TestApplication::DEFAULT_SURFACE_HEIGHT,
10040 TestApplication::DEFAULT_HORIZONTAL_DPI,
10041 TestApplication::DEFAULT_VERTICAL_DPI,
10045 tet_infoline("Check the damaged rect with 3D transformed actors");
10047 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10049 Actor actor1 = CreateRenderableActor();
10050 actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10051 actor1[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10052 actor1[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10053 actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10054 application.GetScene().Add(actor1);
10057 Actor actor2 = CreateRenderableActor();
10058 actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10059 actor2[Actor::Property::POSITION] = Vector3(160.0f, 160.0f, 0.0f);
10060 actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10061 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10062 application.GetScene().Add(actor2);
10064 application.SendNotification();
10066 std::vector<Rect<int>> damagedRects;
10068 // Actor added, damaged rect is added size of actor
10069 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10070 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10073 Rect<int> clippingRect1 = Rect<int>(16, 768, 32, 32); // in screen coordinates
10074 Rect<int> clippingRect2 = Rect<int>(160, 624, 32, 32);
10075 DALI_TEST_EQUALS<Rect<int>>(clippingRect1, damagedRects[0], TEST_LOCATION);
10076 DALI_TEST_EQUALS<Rect<int>>(clippingRect2, damagedRects[1], TEST_LOCATION);
10078 Rect<int> surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10079 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10081 damagedRects.clear();
10082 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10083 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10084 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10086 damagedRects.clear();
10087 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10088 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10089 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10091 // Rotate actor1 on y axis
10092 actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10097 application.SendNotification();
10099 damagedRects.clear();
10100 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10102 // Should update full area
10103 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10104 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10105 DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10106 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10108 // Add actor2 again
10109 application.GetScene().Add(actor2);
10111 application.SendNotification();
10113 damagedRects.clear();
10114 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10116 // Should update full area
10117 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10118 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10119 DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10120 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10122 // Reset the orientation of actor1
10123 actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY;
10125 application.SendNotification();
10127 damagedRects.clear();
10128 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10130 // Should update full area
10131 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10132 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10133 DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10134 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10136 // Make actor2 dirty
10137 actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f);
10139 application.SendNotification();
10141 damagedRects.clear();
10142 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10144 clippingRect2 = Rect<int>(160, 608, 48, 48);
10145 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10146 DALI_TEST_EQUALS<Rect<int>>(clippingRect2, damagedRects[0], TEST_LOCATION);
10148 application.RenderWithPartialUpdate(damagedRects, clippingRect2);
10149 DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION);
10150 DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION);
10151 DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION);
10152 DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION);
10157 application.SendNotification();
10159 damagedRects.clear();
10160 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10161 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10162 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10164 // Rotate actor1 on y axis
10165 actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS);
10167 // Add actor1 again
10168 application.GetScene().Add(actor1);
10170 application.SendNotification();
10172 damagedRects.clear();
10173 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10175 // Should update full area
10176 surfaceRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
10177 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10178 DALI_TEST_EQUALS<Rect<int>>(surfaceRect, damagedRects[0], TEST_LOCATION);
10179 application.RenderWithPartialUpdate(damagedRects, surfaceRect);
10184 int utcDaliActorPartialUpdateOneActorMultipleRenderers(void)
10186 TestApplication application(
10187 TestApplication::DEFAULT_SURFACE_WIDTH,
10188 TestApplication::DEFAULT_SURFACE_HEIGHT,
10189 TestApplication::DEFAULT_HORIZONTAL_DPI,
10190 TestApplication::DEFAULT_VERTICAL_DPI,
10194 tet_infoline("Check the damaged rect with one actor which has multiple renderers");
10196 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10198 Actor actor = CreateRenderableActor();
10200 // Create another renderer
10201 Geometry geometry = CreateQuadGeometry();
10202 Shader shader = CreateShader();
10203 Renderer renderer2 = Renderer::New(geometry, shader);
10204 actor.AddRenderer(renderer2);
10206 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10207 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10208 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10209 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10210 application.GetScene().Add(actor);
10212 application.SendNotification();
10214 DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
10216 std::vector<Rect<int>> damagedRects;
10218 // Actor added, damaged rect is added size of actor
10219 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10220 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10223 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10224 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10225 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[1], TEST_LOCATION);
10227 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10228 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10229 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10230 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10231 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10233 damagedRects.clear();
10234 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10235 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10237 // Ensure the damaged rect is empty
10238 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10240 // Make renderer2 dirty
10241 renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
10243 application.SendNotification();
10245 // The damaged rect should be the actor area
10246 damagedRects.clear();
10247 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10249 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10250 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10251 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10253 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10255 damagedRects.clear();
10256 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10257 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10259 // Ensure the damaged rect is empty
10260 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10262 // Make renderer2 dirty
10263 renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK;
10265 application.SendNotification();
10267 // The damaged rect should be the actor area
10268 damagedRects.clear();
10269 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10271 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10272 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
10273 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10275 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10277 damagedRects.clear();
10278 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10279 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10281 // Ensure the damaged rect is empty
10282 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10287 int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void)
10289 TestApplication application(
10290 TestApplication::DEFAULT_SURFACE_WIDTH,
10291 TestApplication::DEFAULT_SURFACE_HEIGHT,
10292 TestApplication::DEFAULT_HORIZONTAL_DPI,
10293 TestApplication::DEFAULT_VERTICAL_DPI,
10297 tet_infoline("Check the damaged rect with multiple actors which share a same renderer");
10299 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
10301 Actor actor = CreateRenderableActor();
10302 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10303 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10304 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10305 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10306 application.GetScene().Add(actor);
10308 // Create another actor which has the same renderer with actor1
10309 Actor actor2 = Actor::New();
10310 Renderer renderer = actor.GetRendererAt(0);
10311 actor2.AddRenderer(renderer);
10312 actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
10313 actor2[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
10314 actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
10315 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
10316 application.GetScene().Add(actor2);
10318 application.SendNotification();
10320 std::vector<Rect<int>> damagedRects;
10322 // Actor added, damaged rect is added size of actor
10323 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10324 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10327 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10328 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10329 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[1], TEST_LOCATION);
10331 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10332 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
10333 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
10334 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
10335 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
10337 damagedRects.clear();
10338 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10339 application.RenderWithPartialUpdate(damagedRects, clippingRect);
10341 // Ensure the damaged rect is empty
10342 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
10344 // Make renderer dirty
10345 renderer[DevelRenderer::Property::OPACITY] = 0.5f;
10347 application.SendNotification();
10349 // The damaged rect should be the actor area
10350 damagedRects.clear();
10351 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
10353 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
10354 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
10355 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
10356 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[1], TEST_LOCATION);
10358 application.RenderWithPartialUpdate(damagedRects, clippingRect);
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);
10370 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
10372 TestApplication application;
10374 Actor actor = Actor::New();
10375 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
10376 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
10377 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
10378 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
10379 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
10380 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10381 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
10382 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
10386 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
10388 TestApplication application;
10390 Actor actor = Actor::New();
10392 // Make sure setting invalid types does not cause a crash
10395 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
10396 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
10397 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
10398 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
10399 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
10400 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
10401 tet_result(TET_PASS);
10405 tet_result(TET_FAIL);
10410 int UtcDaliActorTouchAreaOffsetPropertyP(void)
10412 TestApplication application;
10414 Actor actor = Actor::New();
10415 Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10416 DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
10417 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
10418 touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
10419 DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
10423 int UtcDaliActorTouchAreaOffsetPropertyN(void)
10425 TestApplication application;
10427 Actor actor = Actor::New();
10429 // Make sure setting invalid types does not cause a crash
10432 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
10433 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
10434 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
10435 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
10436 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
10437 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
10438 tet_result(TET_PASS);
10442 tet_result(TET_FAIL);
10447 int UtcDaliActorLowerBelowNegative(void)
10449 TestApplication application;
10450 Dali::Actor instance;
10454 instance.LowerBelow(arg1);
10455 DALI_TEST_CHECK(false); // Should not get here
10459 DALI_TEST_CHECK(true); // We expect an assert
10464 int UtcDaliActorRaiseAboveNegative(void)
10466 TestApplication application;
10467 Dali::Actor instance;
10471 instance.RaiseAbove(arg1);
10472 DALI_TEST_CHECK(false); // Should not get here
10476 DALI_TEST_CHECK(true); // We expect an assert
10481 int UtcDaliActorRaiseToTopNegative(void)
10483 TestApplication application;
10484 Dali::Actor instance;
10487 instance.RaiseToTop();
10488 DALI_TEST_CHECK(false); // Should not get here
10492 DALI_TEST_CHECK(true); // We expect an assert
10497 int UtcDaliActorAddRendererNegative(void)
10499 TestApplication application;
10500 Dali::Actor instance;
10503 Dali::Renderer arg1;
10504 instance.AddRenderer(arg1);
10505 DALI_TEST_CHECK(false); // Should not get here
10509 DALI_TEST_CHECK(true); // We expect an assert
10514 int UtcDaliActorTouchedSignalNegative(void)
10516 TestApplication application;
10517 Dali::Actor instance;
10520 instance.TouchedSignal();
10521 DALI_TEST_CHECK(false); // Should not get here
10525 DALI_TEST_CHECK(true); // We expect an assert
10530 int UtcDaliActorTranslateByNegative(void)
10532 TestApplication application;
10533 Dali::Actor instance;
10536 Dali::Vector3 arg1;
10537 instance.TranslateBy(arg1);
10538 DALI_TEST_CHECK(false); // Should not get here
10542 DALI_TEST_CHECK(true); // We expect an assert
10547 int UtcDaliActorFindChildByIdNegative(void)
10549 TestApplication application;
10550 Dali::Actor instance;
10553 unsigned int arg1 = 0u;
10554 instance.FindChildById(arg1);
10555 DALI_TEST_CHECK(false); // Should not get here
10559 DALI_TEST_CHECK(true); // We expect an assert
10564 int UtcDaliActorGetRendererAtNegative(void)
10566 TestApplication application;
10567 Dali::Actor instance;
10570 unsigned int arg1 = 0u;
10571 instance.GetRendererAt(arg1);
10572 DALI_TEST_CHECK(false); // Should not get here
10576 DALI_TEST_CHECK(true); // We expect an assert
10581 int UtcDaliActorHoveredSignalNegative(void)
10583 TestApplication application;
10584 Dali::Actor instance;
10587 instance.HoveredSignal();
10588 DALI_TEST_CHECK(false); // Should not get here
10592 DALI_TEST_CHECK(true); // We expect an assert
10597 int UtcDaliActorLowerToBottomNegative(void)
10599 TestApplication application;
10600 Dali::Actor instance;
10603 instance.LowerToBottom();
10604 DALI_TEST_CHECK(false); // Should not get here
10608 DALI_TEST_CHECK(true); // We expect an assert
10613 int UtcDaliActorOnSceneSignalNegative(void)
10615 TestApplication application;
10616 Dali::Actor instance;
10619 instance.OnSceneSignal();
10620 DALI_TEST_CHECK(false); // Should not get here
10624 DALI_TEST_CHECK(true); // We expect an assert
10629 int UtcDaliActorOffSceneSignalNegative(void)
10631 TestApplication application;
10632 Dali::Actor instance;
10635 instance.OffSceneSignal();
10636 DALI_TEST_CHECK(false); // Should not get here
10640 DALI_TEST_CHECK(true); // We expect an assert
10645 int UtcDaliActorRemoveRendererNegative01(void)
10647 TestApplication application;
10648 Dali::Actor instance;
10651 unsigned int arg1 = 0u;
10652 instance.RemoveRenderer(arg1);
10653 DALI_TEST_CHECK(false); // Should not get here
10657 DALI_TEST_CHECK(true); // We expect an assert
10662 int UtcDaliActorRemoveRendererNegative02(void)
10664 TestApplication application;
10665 Dali::Actor instance;
10668 Dali::Renderer arg1;
10669 instance.RemoveRenderer(arg1);
10670 DALI_TEST_CHECK(false); // Should not get here
10674 DALI_TEST_CHECK(true); // We expect an assert
10679 int UtcDaliActorFindChildByNameNegative(void)
10681 TestApplication application;
10682 Dali::Actor instance;
10686 instance.FindChildByName(arg1);
10687 DALI_TEST_CHECK(false); // Should not get here
10691 DALI_TEST_CHECK(true); // We expect an assert
10696 int UtcDaliActorSetResizePolicyNegative(void)
10698 TestApplication application;
10699 Dali::Actor instance;
10702 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
10703 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
10704 instance.SetResizePolicy(arg1, arg2);
10705 DALI_TEST_CHECK(false); // Should not get here
10709 DALI_TEST_CHECK(true); // We expect an assert
10714 int UtcDaliActorOnRelayoutSignalNegative(void)
10716 TestApplication application;
10717 Dali::Actor instance;
10720 instance.OnRelayoutSignal();
10721 DALI_TEST_CHECK(false); // Should not get here
10725 DALI_TEST_CHECK(true); // We expect an assert
10730 int UtcDaliActorWheelEventSignalNegative(void)
10732 TestApplication application;
10733 Dali::Actor instance;
10736 instance.WheelEventSignal();
10737 DALI_TEST_CHECK(false); // Should not get here
10741 DALI_TEST_CHECK(true); // We expect an assert
10746 int UtcDaliActorGetHeightForWidthNegative(void)
10748 TestApplication application;
10749 Dali::Actor instance;
10753 instance.GetHeightForWidth(arg1);
10754 DALI_TEST_CHECK(false); // Should not get here
10758 DALI_TEST_CHECK(true); // We expect an assert
10763 int UtcDaliActorGetWidthForHeightNegative(void)
10765 TestApplication application;
10766 Dali::Actor instance;
10770 instance.GetWidthForHeight(arg1);
10771 DALI_TEST_CHECK(false); // Should not get here
10775 DALI_TEST_CHECK(true); // We expect an assert
10780 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
10782 TestApplication application;
10783 Dali::Actor instance;
10786 instance.LayoutDirectionChangedSignal();
10787 DALI_TEST_CHECK(false); // Should not get here
10791 DALI_TEST_CHECK(true); // We expect an assert
10796 int UtcDaliActorAddNegative(void)
10798 TestApplication application;
10799 Dali::Actor instance;
10803 instance.Add(arg1);
10804 DALI_TEST_CHECK(false); // Should not get here
10808 DALI_TEST_CHECK(true); // We expect an assert
10813 int UtcDaliActorLowerNegative(void)
10815 TestApplication application;
10816 Dali::Actor instance;
10820 DALI_TEST_CHECK(false); // Should not get here
10824 DALI_TEST_CHECK(true); // We expect an assert
10829 int UtcDaliActorRaiseNegative(void)
10831 TestApplication application;
10832 Dali::Actor instance;
10836 DALI_TEST_CHECK(false); // Should not get here
10840 DALI_TEST_CHECK(true); // We expect an assert
10845 int UtcDaliActorRemoveNegative(void)
10847 TestApplication application;
10848 Dali::Actor instance;
10852 instance.Remove(arg1);
10853 DALI_TEST_CHECK(false); // Should not get here
10857 DALI_TEST_CHECK(true); // We expect an assert
10862 int UtcDaliActorScaleByNegative(void)
10864 TestApplication application;
10865 Dali::Actor instance;
10868 Dali::Vector3 arg1;
10869 instance.ScaleBy(arg1);
10870 DALI_TEST_CHECK(false); // Should not get here
10874 DALI_TEST_CHECK(true); // We expect an assert
10879 int UtcDaliActorGetLayerNegative(void)
10881 TestApplication application;
10882 Dali::Actor instance;
10885 instance.GetLayer();
10886 DALI_TEST_CHECK(false); // Should not get here
10890 DALI_TEST_CHECK(true); // We expect an assert
10895 int UtcDaliActorRotateByNegative01(void)
10897 TestApplication application;
10898 Dali::Actor instance;
10901 Dali::Quaternion arg1;
10902 instance.RotateBy(arg1);
10903 DALI_TEST_CHECK(false); // Should not get here
10907 DALI_TEST_CHECK(true); // We expect an assert
10912 int UtcDaliActorRotateByNegative02(void)
10914 TestApplication application;
10915 Dali::Actor instance;
10919 Dali::Vector3 arg2;
10920 instance.RotateBy(arg1, arg2);
10921 DALI_TEST_CHECK(false); // Should not get here
10925 DALI_TEST_CHECK(true); // We expect an assert
10930 int UtcDaliActorUnparentNegative(void)
10932 TestApplication application;
10933 Dali::Actor instance;
10936 instance.Unparent();
10937 DALI_TEST_CHECK(false); // Should not get here
10941 DALI_TEST_CHECK(true); // We expect an assert
10946 int UtcDaliActorGetChildAtNegative(void)
10948 TestApplication application;
10949 Dali::Actor instance;
10952 unsigned int arg1 = 0u;
10953 instance.GetChildAt(arg1);
10954 DALI_TEST_CHECK(false); // Should not get here
10958 DALI_TEST_CHECK(true); // We expect an assert
10963 int UtcDaliActorGetChildCountNegative(void)
10965 TestApplication application;
10966 Dali::Actor instance;
10969 instance.GetChildCount();
10970 DALI_TEST_CHECK(false); // Should not get here
10974 DALI_TEST_CHECK(true); // We expect an assert
10979 int UtcDaliActorGetTargetSizeNegative(void)
10981 TestApplication application;
10982 Dali::Actor instance;
10985 instance.GetTargetSize();
10986 DALI_TEST_CHECK(false); // Should not get here
10990 DALI_TEST_CHECK(true); // We expect an assert
10995 int UtcDaliActorScreenToLocalNegative(void)
10997 TestApplication application;
10998 Dali::Actor instance;
11005 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
11006 DALI_TEST_CHECK(false); // Should not get here
11010 DALI_TEST_CHECK(true); // We expect an assert
11015 int UtcDaliActorGetNaturalSizeNegative(void)
11017 TestApplication application;
11018 Dali::Actor instance;
11021 instance.GetNaturalSize();
11022 DALI_TEST_CHECK(false); // Should not get here
11026 DALI_TEST_CHECK(true); // We expect an assert
11031 int UtcDaliActorGetRelayoutSizeNegative(void)
11033 TestApplication application;
11034 Dali::Actor instance;
11037 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
11038 instance.GetRelayoutSize(arg1);
11039 DALI_TEST_CHECK(false); // Should not get here
11043 DALI_TEST_CHECK(true); // We expect an assert
11048 int UtcDaliActorGetResizePolicyNegative(void)
11050 TestApplication application;
11051 Dali::Actor instance;
11054 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
11055 instance.GetResizePolicy(arg1);
11056 DALI_TEST_CHECK(false); // Should not get here
11060 DALI_TEST_CHECK(true); // We expect an assert
11065 int UtcDaliActorGetRendererCountNegative(void)
11067 TestApplication application;
11068 Dali::Actor instance;
11071 instance.GetRendererCount();
11072 DALI_TEST_CHECK(false); // Should not get here
11076 DALI_TEST_CHECK(true); // We expect an assert
11081 int UtcDaliActorGetParentNegative(void)
11083 TestApplication application;
11084 Dali::Actor instance;
11087 instance.GetParent();
11088 DALI_TEST_CHECK(false); // Should not get here
11092 DALI_TEST_CHECK(true); // We expect an assert
11097 int UtcDaliActorPropertyBlendEquation(void)
11099 TestApplication application;
11101 tet_infoline("Test SetProperty AdvancedBlendEquation");
11103 Geometry geometry = CreateQuadGeometry();
11104 Shader shader = CreateShader();
11105 Renderer renderer1 = Renderer::New(geometry, shader);
11107 Actor actor = Actor::New();
11108 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
11110 actor.AddRenderer(renderer1);
11111 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
11112 application.GetScene().Add(actor);
11114 if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11116 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11117 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11118 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
11121 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
11123 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
11124 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
11125 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
11128 Renderer renderer2 = Renderer::New(geometry, shader);
11129 actor.AddRenderer(renderer2);
11134 int UtcDaliActorRegisterProperty(void)
11136 tet_infoline("Test property registration and uniform map update\n");
11138 TestApplication application;
11140 Geometry geometry = CreateQuadGeometry();
11141 Shader shader = CreateShader();
11142 Renderer renderer1 = Renderer::New(geometry, shader);
11143 Renderer renderer2 = Renderer::New(geometry, shader);
11145 Actor actor1 = Actor::New();
11146 actor1.AddRenderer(renderer1);
11147 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11148 actor1.RegisterProperty("uCustom", 1);
11149 application.GetScene().Add(actor1);
11151 Actor actor2 = Actor::New();
11152 actor2.AddRenderer(renderer2);
11153 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
11154 application.GetScene().Add(actor2);
11156 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
11157 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
11158 glAbstraction.EnableSetUniformCallTrace(true);
11160 application.SendNotification();
11161 application.Render();
11163 std::stringstream out;
11165 std::string params;
11167 // Test uniform value of the custom property
11168 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11169 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11172 actor1[Actor::Property::VISIBLE] = false;
11174 application.SendNotification();
11175 application.Render();
11177 // Make visible again
11178 actor1[Actor::Property::VISIBLE] = true;
11179 actor1["uCustom"] = 2;
11181 glAbstraction.ResetSetUniformCallStack();
11183 application.SendNotification();
11184 application.Render();
11188 // The uniform value should not be changed
11189 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
11190 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
11195 int UtcDaliActorDoesWantedHitTest(void)
11200 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
11202 mTouchPoint(touchPoint),
11208 Vector2 mTouchPoint;
11212 TestApplication application;
11213 tet_infoline(" UtcDaliActorDoesWantedHitTest");
11215 // Fill a vector with different hit tests.
11216 struct HitTestData* hitTestData[] = {
11217 // scale touch point result
11218 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
11219 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
11220 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.
11221 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
11222 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.
11226 // get the root layer
11227 Actor actor = Actor::New();
11228 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11229 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11231 Actor lowerActor = Actor::New();
11232 lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
11233 lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
11235 // actor and lowerActor have no relationship.
11236 application.GetScene().Add(lowerActor);
11237 application.GetScene().Add(actor);
11239 ResetTouchCallbacks();
11240 gHitTestTouchCallBackCalled = false;
11242 unsigned int index = 0;
11243 while(NULL != hitTestData[index])
11245 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11246 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11248 lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
11249 lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
11251 // flush the queue and render once
11252 application.SendNotification();
11253 application.Render();
11255 DALI_TEST_CHECK(!gTouchCallBackCalled);
11256 DALI_TEST_CHECK(!gTouchCallBackCalled2);
11257 DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
11259 // connect to its touch signal
11260 actor.TouchedSignal().Connect(TestTouchCallback);
11261 lowerActor.TouchedSignal().Connect(TestTouchCallback2);
11263 // connect to its hit-test signal
11264 Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
11266 Dali::Integration::Point point;
11267 point.SetState(PointState::DOWN);
11268 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
11269 Dali::Integration::TouchEvent event;
11270 event.AddPoint(point);
11272 // flush the queue and render once
11273 application.SendNotification();
11274 application.Render();
11275 application.ProcessEvent(event);
11277 // check hit-test events
11278 DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
11279 // Passed all hit-tests of actor.
11280 DALI_TEST_CHECK(gTouchCallBackCalled == false);
11281 // The lowerActor was hit-tested.
11282 DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
11284 if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
11285 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
11286 hitTestData[index]->mScale.x,
11287 hitTestData[index]->mScale.y,
11288 hitTestData[index]->mScale.z,
11289 hitTestData[index]->mTouchPoint.x,
11290 hitTestData[index]->mTouchPoint.y,
11291 hitTestData[index]->mResult);
11293 ResetTouchCallbacks();
11294 gHitTestTouchCallBackCalled = false;
11300 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
11302 TestApplication application;
11304 Actor actor = Actor::New();
11305 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
11306 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
11307 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
11308 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
11309 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
11310 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11311 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
11312 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
11316 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
11318 TestApplication application;
11320 Actor actor = Actor::New();
11322 // Make sure setting invalid types does not cause a crash
11325 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
11326 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
11327 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
11328 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
11329 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
11330 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
11331 tet_result(TET_PASS);
11335 tet_result(TET_FAIL);
11340 int UtcDaliActorCalculateWorldTransform01(void)
11342 TestApplication application;
11344 tet_infoline("Test that actor position inheritance produces right transform matrix");
11346 Actor rootActor = Actor::New();
11347 Actor branchActor = Actor::New();
11348 Actor leafActor = Actor::New();
11350 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11351 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11352 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11354 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11355 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11356 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11358 // Set anchor point to the same value as parent origin
11359 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11360 branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11361 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
11363 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11364 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11365 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11367 application.GetScene().Add(rootActor);
11368 rootActor.Add(branchActor);
11369 branchActor.Add(leafActor);
11371 application.SendNotification();
11372 application.Render(0);
11373 application.SendNotification();
11374 application.Render(0);
11376 Matrix m = DevelActor::GetWorldTransform(leafActor);
11378 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11379 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11382 Vector3 worldScale;
11383 Quaternion worldRotation;
11384 m.GetTransformComponents(worldPos, worldRotation, worldScale);
11385 DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION);
11390 int UtcDaliActorCalculateWorldTransform02(void)
11392 TestApplication application;
11394 tet_infoline("Test that actor position produces right transform matrix");
11396 Actor rootActor = Actor::New();
11397 Actor branchActor = Actor::New();
11398 Actor leafActor = Actor::New();
11400 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11401 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11402 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11404 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11405 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11406 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11408 // Set anchor point to the same value as parent origin
11409 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11410 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11411 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11413 application.GetScene().Add(rootActor);
11414 rootActor.Add(branchActor);
11415 branchActor.Add(leafActor);
11417 leafActor[Actor::Property::INHERIT_POSITION] = false;
11418 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11419 leafActor[Actor::Property::INHERIT_SCALE] = false;
11421 application.SendNotification();
11422 application.Render(0);
11423 application.SendNotification();
11424 application.Render(0);
11426 Matrix m = DevelActor::GetWorldTransform(leafActor);
11428 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11429 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11434 int UtcDaliActorCalculateWorldTransform03(void)
11436 TestApplication application;
11438 tet_infoline("Test that actor position produces right transform matrix");
11440 Actor rootActor = Actor::New();
11441 Actor branchActor = Actor::New();
11442 Actor leafActor = Actor::New();
11444 rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f);
11445 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11446 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11448 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11449 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11450 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11452 // Set anchor point to the same value as parent origin
11453 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11454 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11455 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11457 application.GetScene().Add(rootActor);
11458 rootActor.Add(branchActor);
11459 branchActor.Add(leafActor);
11461 leafActor[Actor::Property::INHERIT_POSITION] = true;
11462 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11463 leafActor[Actor::Property::INHERIT_SCALE] = false;
11465 application.SendNotification();
11466 application.Render(0);
11467 application.SendNotification();
11468 application.Render(0);
11470 Matrix m = DevelActor::GetWorldTransform(leafActor);
11472 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11473 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11478 int UtcDaliActorCalculateWorldTransform04(void)
11480 TestApplication application;
11482 tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix");
11484 Actor rootActor = Actor::New();
11485 Actor branchActor = Actor::New();
11486 Actor leafActor = Actor::New();
11488 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11489 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11490 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11492 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11493 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11494 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11496 // Set anchor point to the same value as parent origin
11497 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11498 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11499 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11500 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11502 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11503 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11505 application.GetScene().Add(rootActor);
11506 rootActor.Add(branchActor);
11507 branchActor.Add(leafActor);
11509 application.SendNotification();
11510 application.Render(0);
11511 application.SendNotification();
11512 application.Render(0);
11514 Matrix m = DevelActor::GetWorldTransform(leafActor);
11516 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11517 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11522 int UtcDaliActorCalculateWorldTransform05(void)
11524 TestApplication application;
11526 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11528 Actor rootActor = Actor::New();
11529 Actor branchActor = Actor::New();
11530 Actor leafActor = Actor::New();
11532 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11533 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11534 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11536 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11537 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11538 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11540 // Set anchor point to the same value as parent origin
11541 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11542 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11543 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11544 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11546 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f);
11547 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11549 leafActor[Actor::Property::INHERIT_POSITION] = false;
11550 leafActor[Actor::Property::INHERIT_ORIENTATION] = false;
11552 application.GetScene().Add(rootActor);
11553 rootActor.Add(branchActor);
11554 branchActor.Add(leafActor);
11556 application.SendNotification();
11557 application.Render(0);
11558 application.SendNotification();
11559 application.Render(0);
11561 Matrix m = DevelActor::GetWorldTransform(leafActor);
11563 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11564 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11569 int UtcDaliActorCalculateWorldTransform06(void)
11571 TestApplication application;
11573 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11575 Actor rootActor = Actor::New();
11576 Actor branchActor = Actor::New();
11577 Actor leafActor = Actor::New();
11579 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11580 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11581 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11583 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11584 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11585 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11587 // Set anchor point to the same value as parent origin
11588 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11589 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11590 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11591 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11593 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
11594 branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11595 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11597 leafActor[Actor::Property::INHERIT_POSITION] = false;
11598 leafActor[Actor::Property::INHERIT_SCALE] = false;
11600 application.GetScene().Add(rootActor);
11601 rootActor.Add(branchActor);
11602 branchActor.Add(leafActor);
11604 application.SendNotification();
11605 application.Render(0);
11606 application.SendNotification();
11607 application.Render(0);
11609 Matrix m = DevelActor::GetWorldTransform(leafActor);
11611 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11612 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11617 int UtcDaliActorCalculateWorldTransform07(void)
11619 TestApplication application;
11621 tet_infoline("Test that actor inheritance of scale produces right transform matrix");
11623 Actor rootActor = Actor::New();
11624 Actor branchActor = Actor::New();
11625 Actor leafActor = Actor::New();
11627 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11628 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11629 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11631 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11632 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11633 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11635 // Set anchor point to the same value as parent origin
11636 rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11637 rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11638 branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
11640 // This should be ignored.
11641 leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
11642 leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
11644 branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f);
11645 branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS);
11646 leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f);
11648 leafActor[Actor::Property::INHERIT_POSITION] = false;
11649 leafActor[Actor::Property::INHERIT_SCALE] = false;
11650 leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false;
11652 application.GetScene().Add(rootActor);
11653 rootActor.Add(branchActor);
11654 branchActor.Add(leafActor);
11656 application.SendNotification();
11657 application.Render(0);
11658 application.SendNotification();
11659 application.Render(0);
11661 Matrix m = DevelActor::GetWorldTransform(leafActor);
11663 Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
11664 DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION);
11669 int UtcDaliActorCalculateWorldColor01(void)
11671 TestApplication application;
11673 tet_infoline("Test that actor inheritance of color produces right final color");
11675 Actor rootActor = Actor::New();
11676 Actor branchActor = Actor::New();
11677 Actor leafActor = Actor::New();
11679 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11680 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11681 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11683 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11684 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11685 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11687 rootActor[Actor::Property::COLOR] = Color::WHITE;
11688 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11689 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11691 // Default is to inherit:
11692 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
11694 application.GetScene().Add(rootActor);
11695 rootActor.Add(branchActor);
11696 branchActor.Add(leafActor);
11698 application.SendNotification();
11699 application.Render(0);
11701 Vector4 color = DevelActor::GetWorldColor(leafActor);
11703 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11704 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11709 int UtcDaliActorCalculateWorldColor02(void)
11711 TestApplication application;
11713 tet_infoline("Test that actor uses own color");
11715 Actor rootActor = Actor::New();
11716 Actor branchActor = Actor::New();
11717 Actor leafActor = Actor::New();
11719 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11720 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11721 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11723 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11724 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11725 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11727 rootActor[Actor::Property::COLOR] = Color::WHITE;
11728 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11729 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11731 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR;
11733 application.GetScene().Add(rootActor);
11734 rootActor.Add(branchActor);
11735 branchActor.Add(leafActor);
11737 application.SendNotification();
11738 application.Render(0);
11740 Vector4 color = DevelActor::GetWorldColor(leafActor);
11742 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11743 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11744 DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION);
11748 int UtcDaliActorCalculateWorldColor03(void)
11750 TestApplication application;
11752 tet_infoline("Test that actor uses parent color");
11754 Actor rootActor = Actor::New();
11755 Actor branchActor = Actor::New();
11756 Actor leafActor = Actor::New();
11758 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11759 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11760 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11762 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11763 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11764 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11766 rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
11767 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11768 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11770 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR;
11772 application.GetScene().Add(rootActor);
11773 rootActor.Add(branchActor);
11774 branchActor.Add(leafActor);
11776 application.SendNotification();
11777 application.Render(0);
11779 Vector4 color = DevelActor::GetWorldColor(leafActor);
11781 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11782 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);
11783 DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION);
11787 int UtcDaliActorCalculateWorldColor04(void)
11789 TestApplication application;
11791 tet_infoline("Test that actor blends with parent color");
11793 Actor rootActor = Actor::New();
11794 Actor branchActor = Actor::New();
11795 Actor leafActor = Actor::New();
11797 rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f);
11798 rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f);
11799 rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS);
11801 rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11802 branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11803 leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
11805 rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f;
11806 branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f);
11807 leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f);
11809 leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR;
11811 application.GetScene().Add(rootActor);
11812 rootActor.Add(branchActor);
11813 branchActor.Add(leafActor);
11815 application.SendNotification();
11816 application.Render(0);
11818 Vector4 color = DevelActor::GetWorldColor(leafActor);
11820 Vector4 actualColor = leafActor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR);
11821 DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION);