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.SendNotification();
1358 application.Render();
1360 auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f};
1361 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1362 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1363 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1364 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1365 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1367 application.GetScene().Remove(actor);
1371 // SetPosition(float x, float y)
1372 int UtcDaliActorSetPosition01(void)
1374 TestApplication application;
1376 Actor actor = Actor::New();
1378 // Set to random to start off with
1379 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1381 Vector3 vector(100.0f, 100.0f, 0.0f);
1383 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1385 actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1386 // flush the queue and render once
1387 application.SendNotification();
1388 application.Render();
1389 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1391 application.GetScene().Add(actor);
1392 actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1393 // flush the queue and render once
1394 application.SendNotification();
1395 application.Render();
1396 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1398 actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1399 actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1400 actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1401 // flush the queue and render once
1402 application.SendNotification();
1403 application.Render();
1404 DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1406 actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1407 // flush the queue and render once
1408 application.SendNotification();
1409 application.Render();
1410 DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1412 application.GetScene().Remove(actor);
1416 // SetPosition(float x, float y, float z)
1417 int UtcDaliActorSetPosition02(void)
1419 TestApplication application;
1421 Actor actor = Actor::New();
1423 // Set to random to start off with
1424 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1426 Vector3 vector(100.0f, 100.0f, 100.0f);
1428 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1430 actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1432 // flush the queue and render once
1433 application.SendNotification();
1434 application.Render();
1436 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1440 // SetPosition(Vector3 position)
1441 int UtcDaliActorSetPosition03(void)
1443 TestApplication application;
1445 Actor actor = Actor::New();
1447 // Set to random to start off with
1448 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1450 Vector3 vector(100.0f, 100.0f, 100.0f);
1452 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1454 actor.SetProperty(Actor::Property::POSITION, vector);
1456 // flush the queue and render once
1457 application.SendNotification();
1458 application.Render();
1460 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1464 int UtcDaliActorSetX(void)
1466 TestApplication application;
1468 Actor actor = Actor::New();
1470 Vector3 vector(100.0f, 0.0f, 0.0f);
1472 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1474 actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1476 // flush the queue and render once
1477 application.SendNotification();
1478 application.Render();
1480 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1484 int UtcDaliActorSetY(void)
1486 TestApplication application;
1488 Actor actor = Actor::New();
1490 Vector3 vector(0.0f, 100.0f, 0.0f);
1492 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1494 actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1496 // flush the queue and render once
1497 application.SendNotification();
1498 application.Render();
1500 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1504 int UtcDaliActorSetZ(void)
1506 TestApplication application;
1508 Actor actor = Actor::New();
1510 Vector3 vector(0.0f, 0.0f, 100.0f);
1512 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1514 actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1516 // flush the queue and render once
1517 application.SendNotification();
1518 application.Render();
1520 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1524 int UtcDaliActorSetPositionProperties(void)
1526 TestApplication application;
1528 Actor actor = Actor::New();
1530 Vector3 vector(0.7f, 0.8f, 0.9f);
1531 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1533 actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1534 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1535 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1537 // flush the queue and render once
1538 application.SendNotification();
1539 application.Render();
1541 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1542 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1543 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1544 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1545 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1547 actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1548 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1549 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1551 // flush the queue and render once
1552 application.SendNotification();
1553 application.Render();
1555 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1556 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1557 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1558 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1559 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1561 actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1562 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1563 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1565 // flush the queue and render once
1566 application.SendNotification();
1567 application.Render();
1569 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1570 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1571 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1572 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1573 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1578 int UtcDaliActorTranslateBy(void)
1580 TestApplication application;
1582 Actor actor = Actor::New();
1583 Vector3 vector(100.0f, 100.0f, 100.0f);
1585 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1587 actor.SetProperty(Actor::Property::POSITION, vector);
1589 // flush the queue and render once
1590 application.SendNotification();
1591 application.Render();
1593 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1595 actor.TranslateBy(vector);
1597 // flush the queue and render once
1598 application.SendNotification();
1599 application.Render();
1601 DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1605 int UtcDaliActorGetCurrentPosition(void)
1607 TestApplication application;
1609 Actor actor = Actor::New();
1610 Vector3 setVector(100.0f, 100.0f, 0.0f);
1611 actor.SetProperty(Actor::Property::POSITION, setVector);
1613 // flush the queue and render once
1614 application.SendNotification();
1615 application.Render();
1617 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1621 int UtcDaliActorGetCurrentWorldPosition(void)
1623 TestApplication application;
1625 Actor parent = Actor::New();
1626 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1627 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1628 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1629 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1630 application.GetScene().Add(parent);
1632 Actor child = Actor::New();
1633 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1634 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1635 Vector3 childPosition(6.0f, 6.0f, 6.0f);
1636 child.SetProperty(Actor::Property::POSITION, childPosition);
1639 // The actors should not have a world position yet
1640 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1641 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1643 application.SendNotification();
1644 application.Render(0);
1646 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1647 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1649 // The actors should have a world position now
1650 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1651 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1655 int UtcDaliActorSetInheritPosition(void)
1657 tet_infoline("Testing Actor::SetInheritPosition");
1658 TestApplication application;
1660 Actor parent = Actor::New();
1661 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1662 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1663 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1664 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1665 application.GetScene().Add(parent);
1667 Actor child = Actor::New();
1668 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1669 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1670 Vector3 childPosition(10.0f, 11.0f, 12.0f);
1671 child.SetProperty(Actor::Property::POSITION, childPosition);
1674 // The actors should not have a world position yet
1675 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1676 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1678 // first test default, which is to inherit position
1679 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1680 application.SendNotification();
1681 application.Render(0); // should only really call Update as Render is not required to update scene
1682 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1683 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1684 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1685 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1687 //Change child position
1688 Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1689 child.SetProperty(Actor::Property::POSITION, childOffset);
1691 // Use local position as world postion
1692 child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1693 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1694 application.SendNotification();
1695 application.Render(0); // should only really call Update as Render is not required to update scene
1696 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1697 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1698 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1699 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1701 //Change back to inherit position from parent
1702 child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1703 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1704 application.SendNotification();
1705 application.Render(0); // should only really call Update as Render is not required to update scene
1706 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1707 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1708 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1709 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1713 int UtcDaliActorInheritOpacity(void)
1715 tet_infoline("Testing Actor::Inherit Opacity");
1716 TestApplication application;
1718 Actor parent = Actor::New();
1719 Actor child = Actor::New();
1721 application.GetScene().Add(parent);
1723 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1724 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1726 // flush the queue and render once
1727 application.SendNotification();
1728 application.Render();
1730 parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1732 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1733 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1735 application.SendNotification();
1736 application.Render();
1738 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1739 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1740 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1741 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1742 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1743 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1748 // SetOrientation(float angleRadians, Vector3 axis)
1749 int UtcDaliActorSetOrientation01(void)
1751 TestApplication application;
1753 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1754 Actor actor = Actor::New();
1756 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1758 // flush the queue and render once
1759 application.SendNotification();
1760 application.Render();
1762 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1766 int UtcDaliActorSetOrientation02(void)
1768 TestApplication application;
1770 Actor actor = Actor::New();
1772 Radian angle(0.785f);
1773 Vector3 axis(1.0f, 1.0f, 0.0f);
1775 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1776 Quaternion rotation(angle, axis);
1777 // flush the queue and render once
1778 application.SendNotification();
1779 application.Render();
1780 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1782 application.GetScene().Add(actor);
1783 actor.RotateBy(Degree(360), axis);
1784 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1786 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
1787 Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
1788 // flush the queue and render once
1789 application.SendNotification();
1790 application.Render();
1791 DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1793 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1794 // flush the queue and render once
1795 application.SendNotification();
1796 application.Render();
1797 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1799 application.GetScene().Remove(actor);
1803 // SetOrientation(float angleRadians, Vector3 axis)
1804 int UtcDaliActorSetOrientationProperty(void)
1806 TestApplication application;
1808 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1809 Actor actor = Actor::New();
1811 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1812 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1814 // flush the queue and render once
1815 application.SendNotification();
1816 application.Render();
1818 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1819 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1820 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1824 // RotateBy(float angleRadians, Vector3 axis)
1825 int UtcDaliActorRotateBy01(void)
1827 TestApplication application;
1829 Actor actor = Actor::New();
1831 Radian angle(M_PI * 0.25f);
1832 actor.RotateBy((angle), Vector3::ZAXIS);
1833 // flush the queue and render once
1834 application.SendNotification();
1835 application.Render();
1836 DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1838 application.GetScene().Add(actor);
1840 actor.RotateBy(angle, Vector3::ZAXIS);
1841 // flush the queue and render once
1842 application.SendNotification();
1843 application.Render();
1844 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1846 application.GetScene().Remove(actor);
1850 // RotateBy(Quaternion relativeRotation)
1851 int UtcDaliActorRotateBy02(void)
1853 TestApplication application;
1855 Actor actor = Actor::New();
1857 Radian angle(M_PI * 0.25f);
1858 Quaternion rotation(angle, Vector3::ZAXIS);
1859 actor.RotateBy(rotation);
1860 // flush the queue and render once
1861 application.SendNotification();
1862 application.Render();
1863 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1865 actor.RotateBy(rotation);
1866 // flush the queue and render once
1867 application.SendNotification();
1868 application.Render();
1869 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1873 int UtcDaliActorGetCurrentOrientation(void)
1875 TestApplication application;
1876 Actor actor = Actor::New();
1878 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1879 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1880 // flush the queue and render once
1881 application.SendNotification();
1882 application.Render();
1883 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1887 int UtcDaliActorGetCurrentWorldOrientation(void)
1889 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1890 TestApplication application;
1892 Actor parent = Actor::New();
1893 Radian rotationAngle(Degree(90.0f));
1894 Quaternion rotation(rotationAngle, Vector3::YAXIS);
1895 parent.SetProperty(Actor::Property::ORIENTATION, rotation);
1896 application.GetScene().Add(parent);
1898 Actor child = Actor::New();
1899 child.SetProperty(Actor::Property::ORIENTATION, rotation);
1902 // The actors should not have a world rotation yet
1903 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1904 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1906 application.SendNotification();
1907 application.Render(0);
1909 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1910 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1912 // The actors should have a world rotation now
1913 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1914 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
1916 // turn off child rotation inheritance
1917 child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
1918 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
1919 application.SendNotification();
1920 application.Render(0);
1922 // The actors should have a world rotation now
1923 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1924 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
1928 // SetScale(float scale)
1929 int UtcDaliActorSetScale01(void)
1931 TestApplication application;
1933 Actor actor = Actor::New();
1935 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1936 actor.SetProperty(Actor::Property::SCALE, 0.25f);
1938 Vector3 scale(10.0f, 10.0f, 10.0f);
1939 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1941 actor.SetProperty(Actor::Property::SCALE, scale.x);
1943 // flush the queue and render once
1944 application.SendNotification();
1945 application.Render();
1947 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1951 // SetScale(float scaleX, float scaleY, float scaleZ)
1952 int UtcDaliActorSetScale02(void)
1954 TestApplication application;
1955 Vector3 scale(10.0f, 10.0f, 10.0f);
1957 Actor actor = Actor::New();
1959 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1960 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1962 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1964 actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
1965 // flush the queue and render once
1966 application.SendNotification();
1967 application.Render();
1968 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1970 // add to stage and test
1971 application.GetScene().Add(actor);
1972 actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
1973 // flush the queue and render once
1974 application.SendNotification();
1975 application.Render();
1976 DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
1978 application.GetScene().Remove(actor);
1983 // SetScale(Vector3 scale)
1984 int UtcDaliActorSetScale03(void)
1986 TestApplication application;
1987 Vector3 scale(10.0f, 10.0f, 10.0f);
1989 Actor actor = Actor::New();
1991 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1992 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1994 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1996 actor.SetProperty(Actor::Property::SCALE, scale);
1998 // flush the queue and render once
1999 application.SendNotification();
2000 application.Render();
2002 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2006 int UtcDaliActorSetScaleIndividual(void)
2008 TestApplication application;
2010 Actor actor = Actor::New();
2012 Vector3 vector(0.7f, 0.8f, 0.9f);
2013 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2015 actor.SetProperty(Actor::Property::SCALE_X, vector.x);
2016 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2018 // flush the queue and render once
2019 application.SendNotification();
2020 application.Render();
2022 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
2023 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2024 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2026 actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2027 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2029 // flush the queue and render once
2030 application.SendNotification();
2031 application.Render();
2033 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2034 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2035 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2037 actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2038 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2040 // flush the queue and render once
2041 application.SendNotification();
2042 application.Render();
2044 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2045 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2046 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2048 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2049 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2054 int UtcDaliActorScaleBy(void)
2056 TestApplication application;
2057 Actor actor = Actor::New();
2058 Vector3 vector(100.0f, 100.0f, 100.0f);
2060 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2062 actor.SetProperty(Actor::Property::SCALE, vector);
2064 // flush the queue and render once
2065 application.SendNotification();
2066 application.Render();
2068 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2070 actor.ScaleBy(vector);
2072 // flush the queue and render once
2073 application.SendNotification();
2074 application.Render();
2076 DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2080 int UtcDaliActorGetCurrentScale(void)
2082 TestApplication application;
2083 Vector3 scale(12.0f, 1.0f, 2.0f);
2085 Actor actor = Actor::New();
2087 actor.SetProperty(Actor::Property::SCALE, scale);
2089 // flush the queue and render once
2090 application.SendNotification();
2091 application.Render();
2093 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2097 int UtcDaliActorGetCurrentWorldScale(void)
2099 TestApplication application;
2101 Actor parent = Actor::New();
2102 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2103 parent.SetProperty(Actor::Property::SCALE, parentScale);
2104 application.GetScene().Add(parent);
2106 Actor child = Actor::New();
2107 Vector3 childScale(2.0f, 2.0f, 2.0f);
2108 child.SetProperty(Actor::Property::SCALE, childScale);
2111 // The actors should not have a scale yet
2112 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2113 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2115 // The actors should not have a world scale yet
2116 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2117 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2119 application.SendNotification();
2120 application.Render(0);
2122 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2123 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2125 // The actors should have a world scale now
2126 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2127 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2131 int UtcDaliActorInheritScale(void)
2133 tet_infoline("Testing Actor::SetInheritScale");
2134 TestApplication application;
2136 Actor parent = Actor::New();
2137 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2138 parent.SetProperty(Actor::Property::SCALE, parentScale);
2139 application.GetScene().Add(parent);
2141 Actor child = Actor::New();
2142 Vector3 childScale(2.0f, 2.0f, 2.0f);
2143 child.SetProperty(Actor::Property::SCALE, childScale);
2146 application.SendNotification();
2147 application.Render(0);
2149 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2150 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2152 child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2153 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2155 application.SendNotification();
2156 application.Render(0);
2158 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2162 int UtcDaliActorSetVisible(void)
2164 TestApplication application;
2166 Actor actor = Actor::New();
2167 actor.SetProperty(Actor::Property::VISIBLE, false);
2168 // flush the queue and render once
2169 application.SendNotification();
2170 application.Render();
2171 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2173 actor.SetProperty(Actor::Property::VISIBLE, true);
2174 // flush the queue and render once
2175 application.SendNotification();
2176 application.Render();
2177 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2179 // put actor on stage
2180 application.GetScene().Add(actor);
2181 actor.SetProperty(Actor::Property::VISIBLE, false);
2182 // flush the queue and render once
2183 application.SendNotification();
2184 application.Render();
2185 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2189 int UtcDaliActorIsVisible(void)
2191 TestApplication application;
2193 Actor actor = Actor::New();
2195 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2199 int UtcDaliActorSetOpacity(void)
2201 TestApplication application;
2203 Actor actor = Actor::New();
2204 // initial opacity is 1
2205 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2207 actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2208 // flush the queue and render once
2209 application.SendNotification();
2210 application.Render();
2211 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2213 // change opacity, actor is on stage to change is not immediate
2214 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2215 // flush the queue and render once
2216 application.SendNotification();
2217 application.Render();
2218 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2220 // put actor on stage
2221 application.GetScene().Add(actor);
2223 // change opacity, actor is on stage to change is not immediate
2224 actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2225 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2226 // flush the queue and render once
2227 application.SendNotification();
2228 application.Render();
2229 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2231 // change opacity, actor is on stage to change is not immediate
2232 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2233 // flush the queue and render once
2234 application.SendNotification();
2235 application.Render();
2236 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2240 int UtcDaliActorGetCurrentOpacity(void)
2242 TestApplication application;
2244 Actor actor = Actor::New();
2245 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2247 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2248 // flush the queue and render once
2249 application.SendNotification();
2250 application.Render();
2251 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2255 int UtcDaliActorSetSensitive(void)
2257 TestApplication application;
2258 Actor actor = Actor::New();
2260 bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2262 actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2264 DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2268 int UtcDaliActorIsSensitive(void)
2270 TestApplication application;
2271 Actor actor = Actor::New();
2272 actor.SetProperty(Actor::Property::SENSITIVE, false);
2274 DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2278 int UtcDaliActorSetColor(void)
2280 TestApplication application;
2281 Actor actor = Actor::New();
2282 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2284 DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2286 actor.SetProperty(Actor::Property::COLOR, color);
2287 // flush the queue and render once
2288 application.SendNotification();
2289 application.Render();
2290 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2292 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2293 // flush the queue and render once
2294 application.SendNotification();
2295 application.Render();
2296 DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2298 application.GetScene().Add(actor);
2299 actor.SetProperty(Actor::Property::COLOR, color);
2300 // flush the queue and render once
2301 application.SendNotification();
2302 application.Render();
2303 DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2305 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2306 // flush the queue and render once
2307 application.SendNotification();
2308 application.Render();
2309 // Actor color is not clamped
2310 DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2311 // world color is clamped
2312 DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2314 actor.SetProperty(Actor::Property::COLOR, color);
2315 DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2317 Vector3 newColor(1.0f, 0.0f, 0.0f);
2318 actor.SetProperty(Actor::Property::COLOR, newColor);
2319 DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2321 application.GetScene().Remove(actor);
2325 int UtcDaliActorSetColorIndividual(void)
2327 TestApplication application;
2329 Actor actor = Actor::New();
2331 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2332 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2334 actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2335 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2337 // flush the queue and render once
2338 application.SendNotification();
2339 application.Render();
2341 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2342 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2343 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2345 actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2346 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2348 // flush the queue and render once
2349 application.SendNotification();
2350 application.Render();
2352 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2353 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2354 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2356 actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2357 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2359 // flush the queue and render once
2360 application.SendNotification();
2361 application.Render();
2363 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2364 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2365 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2367 actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2368 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2370 // flush the queue and render once
2371 application.SendNotification();
2372 application.Render();
2374 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2375 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2376 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2378 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2379 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2381 actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2383 // flush the queue and render once
2384 application.SendNotification();
2385 application.Render();
2387 DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2392 int UtcDaliActorGetCurrentColor(void)
2394 TestApplication application;
2395 Actor actor = Actor::New();
2396 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2398 actor.SetProperty(Actor::Property::COLOR, color);
2399 // flush the queue and render once
2400 application.SendNotification();
2401 application.Render();
2402 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2406 int UtcDaliActorGetCurrentWorldColor(void)
2408 tet_infoline("Actor::GetCurrentWorldColor");
2409 TestApplication application;
2411 Actor parent = Actor::New();
2412 Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2413 parent.SetProperty(Actor::Property::COLOR, parentColor);
2414 application.GetScene().Add(parent);
2416 Actor child = Actor::New();
2417 Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2418 child.SetProperty(Actor::Property::COLOR, childColor);
2421 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2422 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2424 // verify the default color mode
2425 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2427 // The actors should not have a world color yet
2428 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2429 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2431 application.SendNotification();
2432 application.Render(0);
2434 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2435 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2437 // The actors should have a world color now
2438 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2439 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2442 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2443 application.SendNotification();
2444 application.Render(0);
2445 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2448 child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2449 application.SendNotification();
2450 application.Render(0);
2451 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2452 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2455 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2456 application.SendNotification();
2457 application.Render(0);
2458 Vector4 expectedColor(childColor);
2459 expectedColor.a *= parentColor.a;
2460 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2461 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2465 int UtcDaliActorSetColorMode(void)
2467 tet_infoline("Actor::SetColorMode");
2468 TestApplication application;
2469 Actor actor = Actor::New();
2470 Actor child = Actor::New();
2473 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2474 DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2476 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2477 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2479 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2480 DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2482 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2483 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2487 int UtcDaliActorScreenToLocal(void)
2489 TestApplication application;
2490 Actor actor = Actor::New();
2491 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2492 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2493 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2494 application.GetScene().Add(actor);
2496 // flush the queue and render once
2497 application.SendNotification();
2498 application.Render();
2503 application.SendNotification();
2504 application.Render();
2506 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2508 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2509 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2513 int UtcDaliActorSetLeaveRequired(void)
2515 TestApplication application;
2517 Actor actor = Actor::New();
2519 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2520 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2522 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2523 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2527 int UtcDaliActorGetLeaveRequired(void)
2529 TestApplication application;
2531 Actor actor = Actor::New();
2533 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2537 int UtcDaliActorSetKeyboardFocusable(void)
2539 TestApplication application;
2541 Actor actor = Actor::New();
2543 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2544 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2546 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2547 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2551 int UtcDaliActorIsKeyboardFocusable(void)
2553 TestApplication application;
2555 Actor actor = Actor::New();
2557 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2561 int UtcDaliActorSetKeyboardFocusableChildren(void)
2563 TestApplication application;
2565 Actor actor = Actor::New();
2567 actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2568 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2570 actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2571 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false);
2575 int UtcDaliActorAreChildrenKeyBoardFocusable(void)
2577 TestApplication application;
2579 Actor actor = Actor::New();
2581 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true);
2585 int UtcDaliActorSetTouchFocusable(void)
2587 TestApplication application;
2589 Actor actor = Actor::New();
2591 actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
2592 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == true);
2594 actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false);
2595 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2599 int UtcDaliActorIsTouchFocusable(void)
2601 TestApplication application;
2603 Actor actor = Actor::New();
2605 DALI_TEST_CHECK(actor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE) == false);
2609 int UtcDaliActorSetUserInteractionEnabled(void)
2611 TestApplication application;
2612 Actor actor = Actor::New();
2614 bool enabled = !actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED);
2616 actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled);
2618 DALI_TEST_CHECK(enabled == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2622 int UtcDaliActorIsUserInteractionEnabled(void)
2624 TestApplication application;
2625 Actor actor = Actor::New();
2626 actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true);
2628 DALI_TEST_CHECK(true == actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED));
2632 int UtcDaliActorRemoveConstraints(void)
2634 tet_infoline(" UtcDaliActorRemoveConstraints");
2635 TestApplication application;
2637 gTestConstraintCalled = false;
2639 Actor actor = Actor::New();
2641 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2643 actor.RemoveConstraints();
2645 DALI_TEST_CHECK(gTestConstraintCalled == false);
2647 application.GetScene().Add(actor);
2650 // flush the queue and render once
2651 application.SendNotification();
2652 application.Render();
2654 actor.RemoveConstraints();
2656 DALI_TEST_CHECK(gTestConstraintCalled == true);
2660 int UtcDaliActorRemoveConstraintTag(void)
2662 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2663 TestApplication application;
2665 Actor actor = Actor::New();
2667 // 1. Apply Constraint1 and Constraint2, and test...
2668 unsigned int result1 = 0u;
2669 unsigned int result2 = 0u;
2671 unsigned constraint1Tag = 1u;
2672 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2673 constraint1.SetTag(constraint1Tag);
2674 constraint1.Apply();
2676 unsigned constraint2Tag = 2u;
2677 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2678 constraint2.SetTag(constraint2Tag);
2679 constraint2.Apply();
2681 application.GetScene().Add(actor);
2682 // flush the queue and render once
2683 application.SendNotification();
2684 application.Render();
2686 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2687 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2689 // 2. Remove Constraint1 and test...
2692 actor.RemoveConstraints(constraint1Tag);
2693 // make color property dirty, which will trigger constraints to be reapplied.
2694 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2695 // flush the queue and render once
2696 application.SendNotification();
2697 application.Render();
2699 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2700 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2702 // 3. Re-Apply Constraint1 and test...
2705 constraint1.Apply();
2706 // make color property dirty, which will trigger constraints to be reapplied.
2707 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2708 // flush the queue and render once
2709 application.SendNotification();
2710 application.Render();
2712 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2713 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2715 // 2. Remove Constraint2 and test...
2718 actor.RemoveConstraints(constraint2Tag);
2719 // make color property dirty, which will trigger constraints to be reapplied.
2720 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2721 // flush the queue and render once
2722 application.SendNotification();
2723 application.Render();
2725 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2726 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2728 // 2. Remove Constraint1 as well and test...
2731 actor.RemoveConstraints(constraint1Tag);
2732 // make color property dirty, which will trigger constraints to be reapplied.
2733 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2734 // flush the queue and render once
2735 application.SendNotification();
2736 application.Render();
2738 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2739 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2743 int UtcDaliActorTouchedSignal(void)
2745 TestApplication application;
2747 ResetTouchCallbacks();
2749 // get the root layer
2750 Actor actor = application.GetScene().GetRootLayer();
2751 DALI_TEST_CHECK(gTouchCallBackCalled == false);
2753 application.SendNotification();
2754 application.Render();
2756 // connect to its touch signal
2757 actor.TouchedSignal().Connect(TestTouchCallback);
2759 // simulate a touch event in the middle of the screen
2760 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2761 Dali::Integration::Point point;
2762 point.SetDeviceId(1);
2763 point.SetState(PointState::DOWN);
2764 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2765 Dali::Integration::TouchEvent touchEvent;
2766 touchEvent.AddPoint(point);
2767 application.ProcessEvent(touchEvent);
2769 DALI_TEST_CHECK(gTouchCallBackCalled == true);
2773 int UtcDaliActorHoveredSignal(void)
2775 TestApplication application;
2777 gHoverCallBackCalled = false;
2779 // get the root layer
2780 Actor actor = application.GetScene().GetRootLayer();
2781 DALI_TEST_CHECK(gHoverCallBackCalled == false);
2783 application.SendNotification();
2784 application.Render();
2786 // connect to its hover signal
2787 actor.HoveredSignal().Connect(TestCallback3);
2789 // simulate a hover event in the middle of the screen
2790 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2791 Dali::Integration::Point point;
2792 point.SetDeviceId(1);
2793 point.SetState(PointState::MOTION);
2794 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2795 Dali::Integration::HoverEvent hoverEvent;
2796 hoverEvent.AddPoint(point);
2797 application.ProcessEvent(hoverEvent);
2799 DALI_TEST_CHECK(gHoverCallBackCalled == true);
2803 int UtcDaliActorOnOffSceneSignal(void)
2805 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2807 TestApplication application;
2810 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2811 gActorNamesOnOffScene.clear();
2813 Actor parent = Actor::New();
2814 parent.SetProperty(Actor::Property::NAME, "parent");
2815 parent.OnSceneSignal().Connect(OnSceneCallback);
2816 parent.OffSceneSignal().Connect(OffSceneCallback);
2818 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2819 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2821 // add parent to the scene
2822 application.GetScene().Add(parent);
2823 // onstage emitted, offstage not
2824 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2825 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2826 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2828 // test adding a child, should get onstage emitted
2830 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2831 gActorNamesOnOffScene.clear();
2833 Actor child = Actor::New();
2834 child.SetProperty(Actor::Property::NAME, "child");
2835 child.OnSceneSignal().Connect(OnSceneCallback);
2836 child.OffSceneSignal().Connect(OffSceneCallback);
2837 parent.Add(child); // add child
2838 // onscene emitted, offscene not
2839 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2840 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2841 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2843 // test removing parent from the scene
2845 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2846 gActorNamesOnOffScene.clear();
2848 application.GetScene().Remove(parent);
2849 // onscene not emitted, offscene is
2850 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2851 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2852 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2853 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2855 // test adding parent back to the scene
2857 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2858 gActorNamesOnOffScene.clear();
2860 application.GetScene().Add(parent);
2861 // onscene emitted, offscene not
2862 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2863 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2864 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2865 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2867 // test removing child
2869 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2870 gActorNamesOnOffScene.clear();
2872 parent.Remove(child);
2873 // onscene not emitted, offscene is
2874 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2875 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2876 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2878 // test removing parent
2880 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2881 gActorNamesOnOffScene.clear();
2883 application.GetScene().Remove(parent);
2884 // onscene not emitted, offscene is
2885 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2886 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2887 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2891 int UtcDaliActorFindChildByName(void)
2893 tet_infoline("Testing Dali::Actor::FindChildByName()");
2894 TestApplication application;
2896 Actor parent = Actor::New();
2897 parent.SetProperty(Actor::Property::NAME, "parent");
2898 Actor first = Actor::New();
2899 first.SetProperty(Actor::Property::NAME, "first");
2900 Actor second = Actor::New();
2901 second.SetProperty(Actor::Property::NAME, "second");
2906 Actor found = parent.FindChildByName("foo");
2907 DALI_TEST_CHECK(!found);
2909 found = parent.FindChildByName("parent");
2910 DALI_TEST_CHECK(found == parent);
2912 found = parent.FindChildByName("first");
2913 DALI_TEST_CHECK(found == first);
2915 found = parent.FindChildByName("second");
2916 DALI_TEST_CHECK(found == second);
2920 int UtcDaliActorFindChildById(void)
2922 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2923 TestApplication application;
2925 Actor parent = Actor::New();
2926 Actor first = Actor::New();
2927 Actor second = Actor::New();
2932 Actor found = parent.FindChildById(100000);
2933 DALI_TEST_CHECK(!found);
2935 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2936 DALI_TEST_CHECK(found == parent);
2938 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2939 DALI_TEST_CHECK(found == first);
2941 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2942 DALI_TEST_CHECK(found == second);
2946 int UtcDaliActorHitTest(void)
2951 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2953 mTouchPoint(touchPoint),
2959 Vector2 mTouchPoint;
2963 TestApplication application;
2964 tet_infoline(" UtcDaliActorHitTest");
2966 // Fill a vector with different hit tests.
2967 struct HitTestData* hitTestData[] = {
2968 // scale touch point result
2969 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
2970 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2971 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.
2972 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2973 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.
2977 // get the root layer
2978 Actor actor = Actor::New();
2979 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2980 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2982 application.GetScene().Add(actor);
2984 ResetTouchCallbacks();
2986 unsigned int index = 0;
2987 while(NULL != hitTestData[index])
2989 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2990 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2992 // flush the queue and render once
2993 application.SendNotification();
2994 application.Render();
2996 DALI_TEST_CHECK(!gTouchCallBackCalled);
2998 // connect to its touch signal
2999 actor.TouchedSignal().Connect(TestTouchCallback);
3001 Dali::Integration::Point point;
3002 point.SetState(PointState::DOWN);
3003 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
3004 Dali::Integration::TouchEvent event;
3005 event.AddPoint(point);
3007 // flush the queue and render once
3008 application.SendNotification();
3009 application.Render();
3010 application.ProcessEvent(event);
3012 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
3014 if(gTouchCallBackCalled != hitTestData[index]->mResult)
3015 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
3016 hitTestData[index]->mScale.x,
3017 hitTestData[index]->mScale.y,
3018 hitTestData[index]->mScale.z,
3019 hitTestData[index]->mTouchPoint.x,
3020 hitTestData[index]->mTouchPoint.y,
3021 hitTestData[index]->mResult);
3023 ResetTouchCallbacks();
3029 int UtcDaliActorSetDrawMode(void)
3031 TestApplication application;
3032 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3034 Actor a = Actor::New();
3036 application.GetScene().Add(a);
3037 application.SendNotification();
3038 application.Render(0);
3039 application.SendNotification();
3040 application.Render(1);
3042 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3044 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3045 application.SendNotification();
3046 application.Render(1);
3048 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3050 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3051 application.SendNotification();
3052 application.Render(1);
3054 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3058 int UtcDaliActorSetDrawModeOverlayRender(void)
3060 TestApplication application;
3061 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3063 application.SendNotification();
3064 application.Render(1);
3066 std::vector<GLuint> ids;
3067 ids.push_back(8); // first rendered actor
3068 ids.push_back(9); // second rendered actor
3069 ids.push_back(10); // third rendered actor
3070 application.GetGlAbstraction().SetNextTextureIds(ids);
3072 Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3073 Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3074 Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3075 Actor a = CreateRenderableActor(imageA);
3076 Actor b = CreateRenderableActor(imageB);
3077 Actor c = CreateRenderableActor(imageC);
3079 application.SendNotification();
3080 application.Render(1);
3082 //Textures are bound when first created. Clear bound textures vector
3083 application.GetGlAbstraction().ClearBoundTextures();
3085 // Render a,b,c as regular non-overlays. so order will be:
3089 application.GetScene().Add(a);
3090 application.GetScene().Add(b);
3091 application.GetScene().Add(c);
3093 application.SendNotification();
3094 application.Render(1);
3096 // Should be 3 textures changes.
3097 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3098 typedef std::vector<GLuint>::size_type TextureSize;
3099 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3100 if(boundTextures.size() == 3)
3102 DALI_TEST_CHECK(boundTextures[0] == 8u);
3103 DALI_TEST_CHECK(boundTextures[1] == 9u);
3104 DALI_TEST_CHECK(boundTextures[2] == 10u);
3107 // Now texture ids have been set, we can monitor their render order.
3108 // render a as an overlay (last), so order will be:
3112 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3113 application.GetGlAbstraction().ClearBoundTextures();
3115 application.SendNotification();
3116 application.Render(1);
3118 // Should be 3 texture changes.
3119 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3120 if(boundTextures.size() == 3)
3122 DALI_TEST_CHECK(boundTextures[0] == 9u);
3123 DALI_TEST_CHECK(boundTextures[1] == 10u);
3124 DALI_TEST_CHECK(boundTextures[2] == 8u);
3129 int UtcDaliActorGetCurrentWorldMatrix(void)
3131 TestApplication application;
3132 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3134 Actor parent = Actor::New();
3135 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3136 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3137 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3138 Radian rotationAngle(Degree(85.0f));
3139 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3140 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3141 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3142 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3143 parent.SetProperty(Actor::Property::SCALE, parentScale);
3144 application.GetScene().Add(parent);
3146 Actor child = Actor::New();
3147 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3148 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3149 Radian childRotationAngle(Degree(23.0f));
3150 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3151 Vector3 childScale(2.0f, 2.0f, 2.0f);
3152 child.SetProperty(Actor::Property::POSITION, childPosition);
3153 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3154 child.SetProperty(Actor::Property::SCALE, childScale);
3157 application.SendNotification();
3158 application.Render(0);
3159 application.Render();
3160 application.SendNotification();
3162 Matrix parentMatrix(false);
3163 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3165 Matrix childMatrix(false);
3166 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3168 //Child matrix should be the composition of child and parent
3169 Matrix childWorldMatrix(false);
3170 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3172 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3173 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3177 int UtcDaliActorConstrainedToWorldMatrix(void)
3179 TestApplication application;
3180 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3182 Actor parent = Actor::New();
3183 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3184 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3185 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3186 Radian rotationAngle(Degree(85.0f));
3187 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3188 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3189 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3190 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3191 parent.SetProperty(Actor::Property::SCALE, parentScale);
3192 application.GetScene().Add(parent);
3194 Actor child = Actor::New();
3195 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3196 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3197 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3198 posConstraint.Apply();
3200 application.GetScene().Add(child);
3202 application.SendNotification();
3203 application.Render(0);
3204 application.Render();
3205 application.SendNotification();
3207 Matrix parentMatrix(false);
3208 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3210 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3211 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3215 int UtcDaliActorConstrainedToOrientation(void)
3217 TestApplication application;
3218 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3220 Actor parent = Actor::New();
3221 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3222 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3223 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3224 Radian rotationAngle(Degree(85.0f));
3225 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3226 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3227 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3228 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3229 parent.SetProperty(Actor::Property::SCALE, parentScale);
3230 application.GetScene().Add(parent);
3232 Actor child = Actor::New();
3233 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3234 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3235 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3236 posConstraint.Apply();
3238 application.GetScene().Add(child);
3240 application.SendNotification();
3241 application.Render(0);
3242 application.Render();
3243 application.SendNotification();
3245 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3249 int UtcDaliActorConstrainedToOpacity(void)
3251 TestApplication application;
3252 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3254 Actor parent = Actor::New();
3255 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3256 application.GetScene().Add(parent);
3258 Actor child = Actor::New();
3259 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3260 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3261 opacityConstraint.Apply();
3263 application.GetScene().Add(child);
3265 application.SendNotification();
3266 application.Render(0);
3267 application.Render();
3268 application.SendNotification();
3270 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3272 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3274 application.SendNotification();
3275 application.Render(0);
3276 application.Render();
3277 application.SendNotification();
3279 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3284 int UtcDaliActorUnparent(void)
3286 TestApplication application;
3287 tet_infoline(" UtcDaliActorUnparent");
3289 Actor parent = Actor::New();
3290 application.GetScene().Add(parent);
3292 Actor child = Actor::New();
3294 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3295 DALI_TEST_CHECK(!child.GetParent());
3297 // Test that calling Unparent with no parent is a NOOP
3300 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3301 DALI_TEST_CHECK(!child.GetParent());
3303 // Test that Unparent works
3306 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3307 DALI_TEST_CHECK(parent == child.GetParent());
3311 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3312 DALI_TEST_CHECK(!child.GetParent());
3314 // Test that UnparentAndReset works
3317 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3318 DALI_TEST_CHECK(parent == child.GetParent());
3320 UnparentAndReset(child);
3322 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3323 DALI_TEST_CHECK(!child);
3325 // Test that UnparentAndReset is a NOOP with empty handle
3326 UnparentAndReset(child);
3328 DALI_TEST_CHECK(!child);
3332 int UtcDaliActorGetChildAt(void)
3334 TestApplication application;
3335 tet_infoline(" UtcDaliActorGetChildAt");
3337 Actor parent = Actor::New();
3338 application.GetScene().Add(parent);
3340 Actor child0 = Actor::New();
3343 Actor child1 = Actor::New();
3346 Actor child2 = Actor::New();
3349 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3350 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3351 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3355 int UtcDaliActorSetGetOverlay(void)
3357 TestApplication application;
3358 tet_infoline(" UtcDaliActorSetGetOverlay");
3360 Actor parent = Actor::New();
3361 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3362 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3366 int UtcDaliActorCreateDestroy(void)
3368 Actor* actor = new Actor;
3369 DALI_TEST_CHECK(actor);
3376 struct PropertyStringIndex
3378 const char* const name;
3379 const Property::Index index;
3380 const Property::Type type;
3383 const PropertyStringIndex PROPERTY_TABLE[] =
3385 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3386 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3387 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3388 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3389 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3390 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3391 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3392 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3393 {"size", Actor::Property::SIZE, Property::VECTOR3},
3394 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3395 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3396 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3397 {"position", Actor::Property::POSITION, Property::VECTOR3},
3398 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3399 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3400 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3401 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3402 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3403 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3404 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3405 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3406 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3407 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3408 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3409 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3410 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3411 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3412 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3413 {"color", Actor::Property::COLOR, Property::VECTOR4},
3414 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3415 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3416 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3417 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3418 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3419 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3420 {"name", Actor::Property::NAME, Property::STRING},
3421 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3422 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3423 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3424 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3425 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3426 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3427 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3428 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3429 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3430 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3431 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3432 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3433 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3434 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3435 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3436 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3437 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3438 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3440 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3441 } // unnamed namespace
3443 int UtcDaliActorProperties(void)
3445 TestApplication application;
3447 Actor actor = Actor::New();
3449 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3451 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3452 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3453 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3454 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3459 int UtcDaliRelayoutProperties_ResizePolicies(void)
3461 TestApplication application;
3463 Actor actor = Actor::New();
3466 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3467 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3469 // Set resize policy for all dimensions
3470 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3471 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3473 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3476 // Set individual dimensions
3477 const char* const widthPolicy = "FILL_TO_PARENT";
3478 const char* const heightPolicy = "FIXED";
3480 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3481 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3483 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3484 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3486 // Set individual dimensions using enums
3487 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3488 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3490 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3491 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3493 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3494 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3499 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3501 TestApplication application;
3503 Actor actor = Actor::New();
3506 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3508 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3509 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3510 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3513 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3514 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3516 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3517 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3519 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3520 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3525 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3527 TestApplication application;
3529 Actor actor = Actor::New();
3532 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3533 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3535 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3536 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3537 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3540 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3542 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3543 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3548 int UtcDaliRelayoutProperties_DimensionDependency(void)
3550 TestApplication application;
3552 Actor actor = Actor::New();
3555 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3556 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3559 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3560 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3562 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3563 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3565 // Test setting another resize policy
3566 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3567 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3572 int UtcDaliRelayoutProperties_Padding(void)
3574 TestApplication application;
3576 Actor actor = Actor::New();
3579 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3582 actor.SetProperty(Actor::Property::PADDING, padding);
3583 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3585 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3590 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3592 TestApplication application;
3594 Actor actor = Actor::New();
3597 Vector2 minSize(1.0f, 2.0f);
3599 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3600 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3602 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3604 Vector2 maxSize(3.0f, 4.0f);
3606 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3607 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3609 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3614 int UtcDaliActorGetHeightForWidth(void)
3616 TestApplication application;
3618 Actor actor = Actor::New();
3620 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3625 int UtcDaliActorGetWidthForHeight(void)
3627 TestApplication application;
3629 Actor actor = Actor::New();
3631 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3636 int UtcDaliActorGetRelayoutSize(void)
3638 TestApplication application;
3640 Actor actor = Actor::New();
3642 // Add actor to stage
3643 application.GetScene().Add(actor);
3645 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3647 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3648 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3650 // Flush the queue and render once
3651 application.SendNotification();
3652 application.Render();
3654 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3659 int UtcDaliActorSetPadding(void)
3661 TestApplication application;
3663 Actor actor = Actor::New();
3666 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3668 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3669 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3670 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3671 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3673 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3674 actor.SetProperty(Actor::Property::PADDING, padding2);
3676 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3678 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3679 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3680 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3681 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3686 int UtcDaliActorSetMinimumSize(void)
3688 TestApplication application;
3690 Actor actor = Actor::New();
3692 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3694 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3695 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3697 Vector2 size2(1.0f, 2.0f);
3698 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3700 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3702 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3703 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3708 int UtcDaliActorSetMaximumSize(void)
3710 TestApplication application;
3712 Actor actor = Actor::New();
3714 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3716 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3717 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3719 Vector2 size2(1.0f, 2.0f);
3720 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3722 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3724 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3725 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3730 int UtcDaliActorOnRelayoutSignal(void)
3732 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3734 TestApplication application;
3737 gOnRelayoutCallBackCalled = false;
3738 gActorNamesRelayout.clear();
3740 Actor actor = Actor::New();
3741 actor.SetProperty(Actor::Property::NAME, "actor");
3742 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3745 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3747 // Add actor to stage
3748 application.GetScene().Add(actor);
3750 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3751 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3753 // Flush the queue and render once
3754 application.SendNotification();
3755 application.Render();
3757 // OnRelayout emitted
3758 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3759 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3764 int UtcDaliActorGetHierachyDepth(void)
3766 TestApplication application;
3767 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3769 /* Build tree of actors:
3779 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3781 Integration::Scene stage(application.GetScene());
3783 Actor actorA = Actor::New();
3784 Actor actorB = Actor::New();
3785 Actor actorC = Actor::New();
3786 Actor actorD = Actor::New();
3787 Actor actorE = Actor::New();
3788 Actor actorF = Actor::New();
3790 //Test that root actor has depth equal 0
3791 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3793 //Test actors return depth -1 when not connected to the tree
3794 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3795 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3796 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3797 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3798 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3799 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3801 //Create the hierarchy
3809 //Test actors return correct depth
3810 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3811 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3812 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3813 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3814 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3815 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3817 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3818 actorA.Remove(actorB);
3820 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3821 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3822 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3824 //Removing actorA from the stage. All actors should have depth equal -1
3825 stage.Remove(actorA);
3827 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3828 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3829 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3830 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3831 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3832 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3837 int UtcDaliActorAnchorPointPropertyAsString(void)
3839 TestApplication application;
3841 Actor actor = Actor::New();
3843 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3844 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3846 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3847 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3849 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3850 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3852 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3853 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3855 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3856 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3858 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3859 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3861 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3862 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3864 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3865 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3867 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3868 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3870 // Invalid should not change anything
3871 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3872 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3877 int UtcDaliActorParentOriginPropertyAsString(void)
3879 TestApplication application;
3881 Actor actor = Actor::New();
3883 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3884 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3886 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3887 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3889 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3890 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3892 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3893 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3895 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3896 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3898 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3899 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3901 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3902 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3904 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3905 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3907 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3908 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3910 // Invalid should not change anything
3911 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3912 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3917 int UtcDaliActorColorModePropertyAsString(void)
3919 TestApplication application;
3921 Actor actor = Actor::New();
3923 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3924 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3926 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3927 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3929 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3930 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3932 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3933 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3935 // Invalid should not change anything
3936 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3937 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3942 int UtcDaliActorDrawModePropertyAsString(void)
3944 TestApplication application;
3946 Actor actor = Actor::New();
3948 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3949 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3951 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3952 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3954 // Invalid should not change anything
3955 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3956 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3961 int UtcDaliActorColorModePropertyAsEnum(void)
3963 TestApplication application;
3965 Actor actor = Actor::New();
3967 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3968 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3970 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3971 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3973 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3974 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3976 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3977 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3982 int UtcDaliActorDrawModePropertyAsEnum(void)
3984 TestApplication application;
3986 Actor actor = Actor::New();
3988 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3989 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3991 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3992 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3997 int UtcDaliActorAddRendererP(void)
3999 tet_infoline("Testing Actor::AddRenderer");
4000 TestApplication application;
4002 Actor actor = Actor::New();
4004 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4006 Geometry geometry = CreateQuadGeometry();
4007 Shader shader = CreateShader();
4008 Renderer renderer = Renderer::New(geometry, shader);
4010 actor.AddRenderer(renderer);
4011 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4012 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4017 int UtcDaliActorAddRendererN01(void)
4019 tet_infoline("Testing Actor::AddRenderer");
4020 TestApplication application;
4022 Actor actor = Actor::New();
4028 actor.AddRenderer(renderer);
4029 tet_printf("Assertion test failed - no Exception\n");
4030 tet_result(TET_FAIL);
4032 catch(Dali::DaliException& e)
4034 DALI_TEST_PRINT_ASSERT(e);
4035 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4036 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4040 tet_printf("Assertion test failed - wrong Exception\n");
4041 tet_result(TET_FAIL);
4047 int UtcDaliActorAddRendererN02(void)
4049 tet_infoline("UtcDaliActorAddRendererN02");
4055 TestApplication application;
4057 Geometry geometry = CreateQuadGeometry();
4058 Shader shader = CreateShader();
4059 renderer = Renderer::New(geometry, shader);
4061 actor = Actor::New();
4064 // try illegal AddRenderer
4067 actor.AddRenderer(renderer);
4068 tet_printf("Assertion test failed - no Exception\n");
4069 tet_result(TET_FAIL);
4071 catch(Dali::DaliException& e)
4073 DALI_TEST_PRINT_ASSERT(e);
4074 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4078 tet_printf("Assertion test failed - wrong Exception\n");
4079 tet_result(TET_FAIL);
4085 int UtcDaliActorAddRendererOnScene(void)
4087 tet_infoline("Testing Actor::AddRenderer");
4088 TestApplication application;
4090 Actor actor = Actor::New();
4091 application.GetScene().Add(actor);
4093 application.SendNotification();
4094 application.Render(0);
4096 Geometry geometry = CreateQuadGeometry();
4097 Shader shader = CreateShader();
4098 Renderer renderer = Renderer::New(geometry, shader);
4100 application.SendNotification();
4101 application.Render(0);
4105 actor.AddRenderer(renderer);
4106 tet_result(TET_PASS);
4110 tet_result(TET_FAIL);
4116 int UtcDaliActorRemoveRendererP1(void)
4118 tet_infoline("Testing Actor::RemoveRenderer");
4119 TestApplication application;
4121 Actor actor = Actor::New();
4123 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4126 Geometry geometry = CreateQuadGeometry();
4127 Shader shader = CreateShader();
4128 Renderer renderer = Renderer::New(geometry, shader);
4130 actor.AddRenderer(renderer);
4131 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4132 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4134 application.SendNotification();
4135 application.Render();
4139 Renderer renderer = actor.GetRendererAt(0);
4140 actor.RemoveRenderer(renderer);
4141 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4143 application.SendNotification();
4144 application.Render();
4147 // Call one final time to ensure that the renderer is actually removed after
4148 // the handle goes out of scope, and excercises the deletion code path in
4149 // scene graph and render.
4150 application.SendNotification();
4151 application.Render();
4156 int UtcDaliActorRemoveRendererP2(void)
4158 tet_infoline("Testing Actor::RemoveRenderer");
4159 TestApplication application;
4161 Actor actor = Actor::New();
4163 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4165 Geometry geometry = CreateQuadGeometry();
4166 Shader shader = CreateShader();
4167 Renderer renderer = Renderer::New(geometry, shader);
4169 actor.AddRenderer(renderer);
4170 application.SendNotification();
4171 application.Render();
4173 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4174 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4176 actor.RemoveRenderer(0);
4177 application.SendNotification();
4178 application.Render();
4180 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4182 // Shut down whilst holding onto the renderer handle.
4186 int UtcDaliActorRemoveRendererN(void)
4188 tet_infoline("Testing Actor::RemoveRenderer");
4189 TestApplication application;
4191 Actor actor = Actor::New();
4193 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4195 Geometry geometry = CreateQuadGeometry();
4196 Shader shader = CreateShader();
4197 Renderer renderer = Renderer::New(geometry, shader);
4199 actor.AddRenderer(renderer);
4200 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4201 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4203 actor.RemoveRenderer(10);
4204 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4205 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4210 // Clipping test helper functions:
4211 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4213 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4214 Actor actor = CreateRenderableActor(image);
4216 // Setup dimensions and position so actor is not skipped by culling.
4217 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4218 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4219 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4220 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4225 Actor CreateActorWithContent16x16()
4227 return CreateActorWithContent(16, 16);
4230 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4232 enabledDisableTrace.Reset();
4233 stencilTrace.Reset();
4234 enabledDisableTrace.Enable(true);
4235 stencilTrace.Enable(true);
4237 application.SendNotification();
4238 application.Render();
4240 enabledDisableTrace.Enable(false);
4241 stencilTrace.Enable(false);
4244 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4246 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4248 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4249 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4250 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4252 // @todo only test alpha if the framebuffer has an alpha channel
4253 //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4256 int UtcDaliActorPropertyClippingP(void)
4258 // This test checks the clippingMode property.
4259 tet_infoline("Testing Actor::Property::ClippingMode: P");
4260 TestApplication application;
4262 Actor actor = Actor::New();
4264 // Check default clippingEnabled value.
4265 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4268 bool getValueResult = getValue.Get(value);
4269 DALI_TEST_CHECK(getValueResult);
4273 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4276 // Check setting the property to the stencil mode.
4277 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4279 // Check the new value was set.
4280 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4281 getValueResult = getValue.Get(value);
4282 DALI_TEST_CHECK(getValueResult);
4286 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4289 // Check setting the property to the scissor mode.
4290 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4292 // Check the new value was set.
4293 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4294 getValueResult = getValue.Get(value);
4295 DALI_TEST_CHECK(getValueResult);
4299 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4304 int UtcDaliActorPropertyClippingN(void)
4306 // Negative test case for Clipping.
4307 tet_infoline("Testing Actor::Property::ClippingMode: N");
4308 TestApplication application;
4310 Actor actor = Actor::New();
4312 // Check default clippingEnabled value.
4313 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4316 bool getValueResult = getValue.Get(value);
4317 DALI_TEST_CHECK(getValueResult);
4321 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4324 // Check setting an invalid property value won't change the current property value.
4325 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4327 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4328 getValueResult = getValue.Get(value);
4329 DALI_TEST_CHECK(getValueResult);
4333 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4339 int UtcDaliActorPropertyClippingActor(void)
4341 // This test checks that an actor is correctly setup for clipping.
4342 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4343 TestApplication application;
4345 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4346 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4347 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4348 size_t startIndex = 0u;
4350 // Create a clipping actor.
4351 Actor actorDepth1Clip = CreateActorWithContent16x16();
4352 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4353 application.GetScene().Add(actorDepth1Clip);
4355 // Gather the call trace.
4356 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4358 // Check we are writing to the color buffer.
4359 CheckColorMask(glAbstraction, true);
4361 // Check the stencil buffer was enabled.
4362 std::ostringstream oss;
4363 oss << std::hex << GL_STENCIL_TEST;
4364 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4366 // Check the stencil buffer was cleared.
4367 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4369 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4370 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4371 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4372 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4377 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4379 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4380 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4381 TestApplication application;
4383 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4384 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4385 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4386 size_t startIndex = 0u;
4388 // Create a clipping actor.
4389 Actor actorDepth1Clip = CreateActorWithContent16x16();
4390 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4391 application.GetScene().Add(actorDepth1Clip);
4393 // Gather the call trace.
4394 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4396 // Check we are writing to the color buffer.
4397 CheckColorMask(glAbstraction, true);
4399 // Check the stencil buffer was enabled.
4400 std::ostringstream oss;
4401 oss << std::hex << GL_STENCIL_TEST;
4402 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4404 // Check the stencil buffer was cleared.
4405 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4407 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4408 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4409 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4410 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4412 // Now disable the clipping
4413 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4415 // Gather the call trace.
4416 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4418 // Check the stencil buffer was disabled.
4419 std::ostringstream stencil;
4420 stencil << std::hex << GL_STENCIL_TEST;
4421 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4423 // Ensure all values in stencil-mask are set to 1.
4425 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4430 int UtcDaliActorPropertyClippingNestedChildren(void)
4432 // This test checks that a hierarchy of actors are clipped correctly by
4433 // writing to and reading from the correct bit-planes of the stencil buffer.
4434 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4435 TestApplication application;
4436 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4437 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4438 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4440 // Create a clipping actor.
4441 Actor actorDepth1Clip = CreateActorWithContent16x16();
4442 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4443 application.GetScene().Add(actorDepth1Clip);
4445 // Create a child actor.
4446 Actor childDepth2 = CreateActorWithContent16x16();
4447 actorDepth1Clip.Add(childDepth2);
4449 // Create another clipping actor.
4450 Actor childDepth2Clip = CreateActorWithContent16x16();
4451 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4452 childDepth2.Add(childDepth2Clip);
4454 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4455 // This tests the sort algorithm.
4456 Actor childDepth3 = CreateActorWithContent16x16();
4457 childDepth2Clip.Add(childDepth3);
4458 Actor childDepth4 = CreateActorWithContent16x16();
4459 childDepth3.Add(childDepth4);
4461 // Gather the call trace.
4462 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4464 // Check we are writing to the color buffer.
4465 CheckColorMask(glAbstraction, true);
4467 // Check the stencil buffer was enabled.
4468 std::ostringstream oss;
4469 oss << std::hex << GL_STENCIL_TEST;
4470 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4472 // Perform the test twice, once for 2D layer, and once for 3D.
4473 for(unsigned int i = 0u; i < 2u; ++i)
4475 size_t startIndex = 0u;
4477 // Check the stencil buffer was cleared.
4478 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4480 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4481 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4482 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4483 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4485 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4486 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
4487 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4489 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4490 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4491 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4492 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4494 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4495 // (Both must be set to pass the check).
4496 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4497 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4499 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4502 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4503 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4510 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4512 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4513 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4514 TestApplication application;
4515 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4516 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4518 /* We create a small tree of actors as follows:
4522 Clipping enabled -> B D
4526 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4529 for(int i = 0; i < 5; ++i)
4531 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4532 Actor actor = CreateRenderableActor(image);
4534 // Setup dimensions and position so actor is not skipped by culling.
4535 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4536 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4540 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4544 float b = i > 2 ? 1.0f : -1.0f;
4545 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4551 // Enable clipping on the actor at the top of the left branch.
4552 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4554 // Build the scene graph.
4555 application.GetScene().Add(actors[0]);
4558 actors[0].Add(actors[1]);
4559 actors[1].Add(actors[2]);
4562 actors[0].Add(actors[3]);
4563 actors[3].Add(actors[4]);
4565 // Gather the call trace.
4566 enabledDisableTrace.Reset();
4567 enabledDisableTrace.Enable(true);
4568 application.SendNotification();
4569 application.Render();
4570 enabledDisableTrace.Enable(false);
4572 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4574 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
4575 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4577 size_t startIndex = 0u;
4578 std::ostringstream blend;
4579 blend << std::hex << GL_BLEND;
4580 std::ostringstream stencil;
4581 stencil << std::hex << GL_STENCIL_TEST;
4583 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4584 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4585 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4587 // Swap the clipping actor from top of left branch to top of right branch.
4588 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4589 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4591 // Gather the call trace.
4592 enabledDisableTrace.Reset();
4593 enabledDisableTrace.Enable(true);
4594 application.SendNotification();
4595 application.Render();
4596 enabledDisableTrace.Enable(false);
4598 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4599 // This proves the draw order has remained the same.
4601 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4602 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4607 int UtcDaliActorPropertyScissorClippingActor01(void)
4609 // This test checks that an actor is correctly setup for clipping.
4610 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4611 TestApplication application;
4613 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4614 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4615 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4617 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4618 const Vector2 imageSize(16.0f, 16.0f);
4620 // Create a clipping actor.
4621 Actor clippingActorA = CreateActorWithContent16x16();
4622 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4623 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4624 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4625 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4626 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4627 application.GetScene().Add(clippingActorA);
4629 // Gather the call trace.
4630 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4632 // Check we are writing to the color buffer.
4633 CheckColorMask(glAbstraction, true);
4635 // Check scissor test was enabled.
4637 std::ostringstream scissor;
4638 scissor << std::hex << GL_SCISSOR_TEST;
4639 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4641 // Check the scissor was set, and the coordinates are correct.
4642 std::stringstream compareParametersString;
4643 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4644 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4646 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4647 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4649 // Gather the call trace.
4650 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4652 // Check the scissor was set, and the coordinates are correct.
4653 compareParametersString.str(std::string());
4654 compareParametersString.clear();
4655 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4656 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4661 int UtcDaliActorPropertyScissorClippingActor02(void)
4663 // This test checks that an actor is correctly setup for clipping.
4664 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4665 TestApplication application;
4667 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4668 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4669 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4671 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4672 const Vector2 actorSize(16.0f, 16.0f);
4674 // Create a clipping actor.
4675 Actor clippingActorA = CreateRenderableActor();
4676 clippingActorA[Actor::Property::SIZE] = actorSize;
4678 Renderer renderer = clippingActorA.GetRendererAt(0);
4679 DALI_TEST_CHECK(renderer);
4681 // Make Renderer opacity 0.
4682 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4684 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4685 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4686 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4687 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4688 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4689 application.GetScene().Add(clippingActorA);
4691 // Gather the call trace.
4692 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4694 // Check we are writing to the color buffer.
4695 CheckColorMask(glAbstraction, true);
4697 // Check scissor test was enabled.
4699 std::ostringstream scissor;
4700 scissor << std::hex << GL_SCISSOR_TEST;
4701 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4703 // Check the scissor was set, and the coordinates are correct.
4704 std::stringstream compareParametersString;
4705 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
4706 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4708 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4709 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4711 // Gather the call trace.
4712 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4714 // Check the scissor was set, and the coordinates are correct.
4715 compareParametersString.str(std::string());
4716 compareParametersString.clear();
4717 compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
4718 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4723 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4725 // This test checks that an actor is correctly setup for clipping.
4726 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4727 TestApplication application;
4729 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4730 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4731 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4733 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4734 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4735 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4737 // Create a clipping actors.
4738 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4739 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4741 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4742 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4743 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4745 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4746 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4747 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4749 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4750 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4752 application.GetScene().Add(clippingActorA);
4753 application.GetScene().Add(clippingActorB);
4755 // Gather the call trace.
4756 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4758 // Check we are writing to the color buffer.
4759 CheckColorMask(glAbstraction, true);
4761 // Check scissor test was enabled.
4762 std::ostringstream scissor;
4763 scissor << std::hex << GL_SCISSOR_TEST;
4764 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4766 // Check the scissor was set, and the coordinates are correct.
4767 std::stringstream compareParametersString;
4769 std::string clipA("0, 500, 480, 200");
4770 std::string clipB("0, 380, 480, 40");
4772 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4773 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4778 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4780 // This test checks that an actor is correctly setup for clipping.
4781 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4782 TestApplication application;
4784 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4785 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4786 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4788 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4789 const Vector2 imageSize(16.0f, 16.0f);
4791 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4793 A is drawn first - with scissor clipping on
4794 B is drawn second - also with scissor clipping on
4795 C is the generated clipping region, the intersection ( A ∩ B )
4799 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4800 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4801 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4805 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4808 // Create a clipping actor.
4809 Actor clippingActorA = CreateActorWithContent16x16();
4810 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4811 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4812 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4813 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4814 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4815 application.GetScene().Add(clippingActorA);
4817 // Create a child clipping actor.
4818 Actor clippingActorB = CreateActorWithContent16x16();
4819 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4820 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4821 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4822 clippingActorA.Add(clippingActorB);
4824 // positionModifiers is an array of positions to position B around.
4825 // expect is an array of expected scissor clip coordinate results.
4826 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4827 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4829 // Loop through each overlap combination.
4830 for(unsigned int test = 0u; test < 4u; ++test)
4832 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4833 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4834 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4836 // Gather the call trace.
4837 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4839 // Check we are writing to the color buffer.
4840 CheckColorMask(glAbstraction, true);
4842 // Check scissor test was enabled.
4843 std::ostringstream scissor;
4844 scissor << std::hex << GL_SCISSOR_TEST;
4845 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4847 // Check the scissor was set, and the coordinates are correct.
4848 const Vector4& expectResults(expect[test]);
4849 std::stringstream compareParametersString;
4850 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4851 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4857 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4859 // This test checks that an actor is correctly setup for clipping.
4860 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4861 TestApplication application;
4863 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4864 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4865 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4867 /* Create a nest of 2 scissors and siblings of the parent.
4877 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4878 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4879 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4880 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4881 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4882 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4884 // Create a clipping actors.
4885 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4886 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4887 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4888 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4889 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4891 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4892 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4893 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4895 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4896 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4897 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4899 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4900 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4901 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4903 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4904 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4905 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4907 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4908 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4910 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4911 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4912 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4913 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4914 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4916 application.GetScene().Add(clippingActorA);
4917 clippingActorA.Add(clippingActorB);
4918 application.GetScene().Add(clippingActorC);
4919 application.GetScene().Add(clippingActorD);
4920 clippingActorD.Add(clippingActorE);
4922 // Gather the call trace.
4923 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4925 // Check we are writing to the color buffer.
4926 CheckColorMask(glAbstraction, true);
4928 // Check scissor test was enabled.
4929 std::ostringstream scissor;
4930 scissor << std::hex << GL_SCISSOR_TEST;
4931 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4933 // Check the scissor was set, and the coordinates are correct.
4934 std::string clipA("0, 500, 480, 200");
4935 std::string clipB("0, 580, 480, 40");
4936 std::string clipC("0, 200, 480, 200");
4937 std::string clipD("0, 300, 480, 200");
4939 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4940 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4941 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4942 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4943 DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4948 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4950 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4951 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4952 TestApplication application;
4954 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4955 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4956 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4958 // Create a clipping actor.
4959 Actor actorDepth1Clip = CreateActorWithContent16x16();
4960 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4961 application.GetScene().Add(actorDepth1Clip);
4963 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4964 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4966 // Gather the call trace.
4967 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4969 // Check we are writing to the color buffer.
4970 CheckColorMask(glAbstraction, true);
4972 // Check the stencil buffer was not enabled.
4973 std::ostringstream stencil;
4974 stencil << std::hex << GL_STENCIL_TEST;
4975 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
4977 // Check stencil functions are not called.
4978 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4979 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4981 // Check that scissor clipping is overriden by the renderer properties.
4982 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4984 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4986 // Gather the call trace.
4987 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4989 // Check the stencil buffer was not enabled.
4990 std::ostringstream scissor;
4991 scissor << std::hex << GL_SCISSOR_TEST;
4992 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4994 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4999 int UtcDaliActorPropertyClippingActorCulled(void)
5001 // This test checks that child actors are clipped by an culled parent actor.
5002 tet_infoline("Testing child actors are clipped by an culled parent actor");
5003 TestApplication application;
5005 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5006 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
5007 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
5009 const Vector2 actorSize(160.0f, 160.0f);
5011 // Create a clipping actor.
5012 Actor clippingActorA = CreateRenderableActor();
5013 clippingActorA[Actor::Property::SIZE] = actorSize;
5015 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
5016 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
5017 clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5018 clippingActorA[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5019 clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
5020 application.GetScene().Add(clippingActorA);
5022 // Create a child actor
5023 Actor childActor = CreateRenderableActor();
5024 childActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5025 childActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5026 childActor[Actor::Property::SIZE] = Vector2(50.0f, 50.0f);
5027 childActor[Actor::Property::INHERIT_POSITION] = false;
5029 // Gather the call trace.
5030 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5032 // Check scissor test was enabled.
5033 std::ostringstream scissor;
5034 scissor << std::hex << GL_SCISSOR_TEST;
5035 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5037 // Check the scissor was set, and the coordinates are correct.
5038 std::stringstream compareParametersString;
5039 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5040 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5042 // Move the clipping actor out of screen
5043 clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5045 // Gather the call trace.
5046 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5048 // Check the scissor was set, and the coordinates are correct.
5049 compareParametersString.str(std::string());
5050 compareParametersString.clear();
5051 compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5052 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5057 int UtcDaliGetPropertyN(void)
5059 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5060 TestApplication application;
5062 Actor actor = Actor::New();
5064 unsigned int propertyCount = actor.GetPropertyCount();
5065 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5069 int UtcDaliActorRaiseLower(void)
5071 tet_infoline("UtcDaliActor Raise and Lower test\n");
5073 TestApplication application;
5075 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5077 Integration::Scene stage(application.GetScene());
5079 Actor actorA = Actor::New();
5080 Actor actorB = Actor::New();
5081 Actor actorC = Actor::New();
5083 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5084 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5086 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5087 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5089 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5090 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5092 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5093 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5095 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5096 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5098 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5099 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5105 ResetTouchCallbacks();
5107 application.SendNotification();
5108 application.Render();
5110 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5111 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5112 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5114 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5115 // Only top actor will get touched.
5116 actorA.TouchedSignal().Connect(TestTouchCallback);
5117 actorB.TouchedSignal().Connect(TestTouchCallback2);
5118 actorC.TouchedSignal().Connect(TestTouchCallback3);
5120 // Connect ChildOrderChangedSignal
5121 bool orderChangedSignal(false);
5122 Actor orderChangedActor;
5123 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5124 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5126 Dali::Integration::Point point;
5127 point.SetDeviceId(1);
5128 point.SetState(PointState::DOWN);
5129 point.SetScreenPosition(Vector2(10.f, 10.f));
5130 Dali::Integration::TouchEvent touchEvent;
5131 touchEvent.AddPoint(point);
5133 application.ProcessEvent(touchEvent);
5135 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5136 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5137 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5139 ResetTouchCallbacks();
5141 tet_printf("Testing Raising of Actor\n");
5143 int preActorOrder(0);
5144 int postActorOrder(0);
5146 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5147 value.Get(preActorOrder);
5149 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5151 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5152 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5154 // Ensure sort order is calculated before next touch event
5155 application.SendNotification();
5157 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5158 value.Get(postActorOrder);
5160 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5162 application.ProcessEvent(touchEvent);
5164 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5165 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5166 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5168 ResetTouchCallbacks();
5170 tet_printf("Testing Lowering of Actor\n");
5172 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5173 value.Get(preActorOrder);
5175 orderChangedSignal = false;
5177 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5179 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5180 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5182 application.SendNotification(); // ensure sort order calculated before next touch event
5184 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5185 value.Get(postActorOrder);
5187 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5189 application.ProcessEvent(touchEvent);
5191 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5192 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5193 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5195 ResetTouchCallbacks();
5197 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5202 int UtcDaliActorRaiseToTopLowerToBottom(void)
5204 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5206 TestApplication application;
5208 Integration::Scene stage(application.GetScene());
5210 Actor actorA = Actor::New();
5211 Actor actorB = Actor::New();
5212 Actor actorC = Actor::New();
5214 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5215 // enables checking of which actor the uniform is assigned too
5216 Shader shaderA = CreateShader();
5217 shaderA.RegisterProperty("uRendererColor", 1.f);
5219 Shader shaderB = CreateShader();
5220 shaderB.RegisterProperty("uRendererColor", 2.f);
5222 Shader shaderC = CreateShader();
5223 shaderC.RegisterProperty("uRendererColor", 3.f);
5225 Geometry geometry = CreateQuadGeometry();
5227 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5228 Renderer rendererA = Renderer::New(geometry, shaderA);
5229 actorA.AddRenderer(rendererA);
5231 Renderer rendererB = Renderer::New(geometry, shaderB);
5232 actorB.AddRenderer(rendererB);
5234 Renderer rendererC = Renderer::New(geometry, shaderC);
5235 actorC.AddRenderer(rendererC);
5237 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5238 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5240 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5241 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5243 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5244 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5246 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5247 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5249 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5250 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5252 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5253 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5259 ResetTouchCallbacks();
5261 // Connect ChildOrderChangedSignal
5262 bool orderChangedSignal(false);
5263 Actor orderChangedActor;
5264 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5265 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5267 // Set up gl abstraction trace so can query the set uniform order
5268 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5269 glAbstraction.EnableSetUniformCallTrace(true);
5270 glAbstraction.ResetSetUniformCallStack();
5272 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5274 application.SendNotification();
5275 application.Render();
5277 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5279 // Test order of uniforms in stack
5280 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5281 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5282 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5284 bool CBA = (indexC > indexB) && (indexB > indexA);
5286 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5288 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5289 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5290 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5292 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5293 // Only top actor will get touched.
5294 actorA.TouchedSignal().Connect(TestTouchCallback);
5295 actorB.TouchedSignal().Connect(TestTouchCallback2);
5296 actorC.TouchedSignal().Connect(TestTouchCallback3);
5298 Dali::Integration::Point point;
5299 point.SetDeviceId(1);
5300 point.SetState(PointState::DOWN);
5301 point.SetScreenPosition(Vector2(10.f, 10.f));
5302 Dali::Integration::TouchEvent touchEvent;
5303 touchEvent.AddPoint(point);
5305 application.ProcessEvent(touchEvent);
5307 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5308 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5309 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5311 ResetTouchCallbacks();
5313 tet_printf("RaiseToTop ActorA\n");
5315 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5316 actorA.RaiseToTop();
5317 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5318 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5320 application.SendNotification(); // ensure sorting order is calculated before next touch event
5322 application.ProcessEvent(touchEvent);
5324 glSetUniformStack.Reset();
5326 application.SendNotification();
5327 application.Render();
5329 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5331 // Test order of uniforms in stack
5332 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5333 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5334 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5336 tet_infoline("Testing A above C and B at bottom\n");
5337 bool ACB = (indexA > indexC) && (indexC > indexB);
5339 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5341 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5342 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5343 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5345 ResetTouchCallbacks();
5347 tet_printf("RaiseToTop ActorB\n");
5349 orderChangedSignal = false;
5351 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5352 actorB.RaiseToTop();
5353 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5354 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5356 application.SendNotification(); // Ensure sort order is calculated before next touch event
5358 application.ProcessEvent(touchEvent);
5360 glSetUniformStack.Reset();
5362 application.SendNotification();
5363 application.Render();
5365 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5367 // Test order of uniforms in stack
5368 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5369 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5370 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5372 tet_infoline("Testing B above A and C at bottom\n");
5373 bool BAC = (indexB > indexA) && (indexA > indexC);
5375 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5377 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5378 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5379 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5381 ResetTouchCallbacks();
5383 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5385 orderChangedSignal = false;
5387 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5388 actorA.LowerToBottom();
5389 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5390 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5392 application.SendNotification();
5393 application.Render();
5395 orderChangedSignal = false;
5397 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5398 actorB.LowerToBottom();
5399 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5400 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5402 application.SendNotification();
5403 application.Render();
5405 application.ProcessEvent(touchEvent);
5407 glSetUniformStack.Reset();
5409 application.SendNotification();
5410 application.Render();
5412 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5414 // Test order of uniforms in stack
5415 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5416 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5417 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5419 tet_infoline("Testing C above A and B at bottom\n");
5420 bool CAB = (indexC > indexA) && (indexA > indexB);
5422 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5424 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5425 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5426 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5428 ResetTouchCallbacks();
5433 int UtcDaliActorRaiseAbove(void)
5435 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5437 TestApplication application;
5439 Integration::Scene stage(application.GetScene());
5441 Actor actorA = Actor::New();
5442 Actor actorB = Actor::New();
5443 Actor actorC = Actor::New();
5445 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5446 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5448 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5449 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5451 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5452 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5454 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5455 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5457 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5458 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5460 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5461 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5467 ResetTouchCallbacks();
5469 application.SendNotification();
5470 application.Render();
5472 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5473 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5474 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5476 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5477 // Only top actor will get touched.
5478 actorA.TouchedSignal().Connect(TestTouchCallback);
5479 actorB.TouchedSignal().Connect(TestTouchCallback2);
5480 actorC.TouchedSignal().Connect(TestTouchCallback3);
5482 bool orderChangedSignal(false);
5483 Actor orderChangedActor;
5484 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5485 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5487 Dali::Integration::Point point;
5488 point.SetDeviceId(1);
5489 point.SetState(PointState::DOWN);
5490 point.SetScreenPosition(Vector2(10.f, 10.f));
5491 Dali::Integration::TouchEvent touchEvent;
5492 touchEvent.AddPoint(point);
5494 application.ProcessEvent(touchEvent);
5496 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5497 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5498 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5500 ResetTouchCallbacks();
5502 tet_printf("Raise actor B Above Actor C\n");
5504 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5505 actorB.RaiseAbove(actorC);
5506 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5507 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5509 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5510 application.SendNotification();
5511 application.ProcessEvent(touchEvent);
5513 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5514 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5515 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5517 ResetTouchCallbacks();
5519 tet_printf("Raise actor A Above Actor B\n");
5521 orderChangedSignal = false;
5523 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5524 actorA.RaiseAbove(actorB);
5525 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5526 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5528 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5529 application.SendNotification();
5531 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5533 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5534 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5535 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5537 ResetTouchCallbacks();
5542 int UtcDaliActorRaiseAbove2(void)
5544 tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5546 TestApplication application;
5548 Integration::Scene stage(application.GetScene());
5550 Actor actorA = Actor::New();
5551 Actor actorB = Actor::New();
5552 Actor actorC = Actor::New();
5554 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5555 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5557 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5558 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5560 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5561 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5563 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5564 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5566 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5567 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5569 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5570 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5576 ResetTouchCallbacks();
5578 application.SendNotification();
5579 application.Render();
5581 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5582 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5583 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5585 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5586 // Only top actor will get touched.
5587 actorA.TouchedSignal().Connect(TestTouchCallback);
5588 actorB.TouchedSignal().Connect(TestTouchCallback2);
5589 actorC.TouchedSignal().Connect(TestTouchCallback3);
5591 bool orderChangedSignal(false);
5592 Actor orderChangedActor;
5593 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5594 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5596 Dali::Integration::Point point;
5597 point.SetDeviceId(1);
5598 point.SetState(PointState::DOWN);
5599 point.SetScreenPosition(Vector2(10.f, 10.f));
5600 Dali::Integration::TouchEvent touchEvent;
5601 touchEvent.AddPoint(point);
5603 application.ProcessEvent(touchEvent);
5605 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5606 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5607 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5609 ResetTouchCallbacks();
5611 tet_printf("Raise actor B Above Actor C\n");
5613 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5614 int newOrder = actorC[DevelActor::Property::SIBLING_ORDER];
5615 actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5616 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5617 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5619 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5620 application.SendNotification();
5621 application.ProcessEvent(touchEvent);
5623 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5624 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5625 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5627 ResetTouchCallbacks();
5629 tet_printf("Raise actor A Above Actor B\n");
5631 orderChangedSignal = false;
5633 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5634 newOrder = actorB[DevelActor::Property::SIBLING_ORDER];
5635 actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5636 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5637 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5639 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5640 application.SendNotification();
5642 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5644 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5645 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5646 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5648 ResetTouchCallbacks();
5653 int UtcDaliActorLowerBelow(void)
5655 tet_infoline("UtcDaliActor LowerBelow test \n");
5657 TestApplication application;
5659 Integration::Scene stage(application.GetScene());
5661 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5662 // enables checking of which actor the uniform is assigned too
5663 Shader shaderA = CreateShader();
5664 shaderA.RegisterProperty("uRendererColor", 1.f);
5666 Shader shaderB = CreateShader();
5667 shaderB.RegisterProperty("uRendererColor", 2.f);
5669 Shader shaderC = CreateShader();
5670 shaderC.RegisterProperty("uRendererColor", 3.f);
5672 Actor actorA = Actor::New();
5673 Actor actorB = Actor::New();
5674 Actor actorC = Actor::New();
5676 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5677 Geometry geometry = CreateQuadGeometry();
5679 Renderer rendererA = Renderer::New(geometry, shaderA);
5680 actorA.AddRenderer(rendererA);
5682 Renderer rendererB = Renderer::New(geometry, shaderB);
5683 actorB.AddRenderer(rendererB);
5685 Renderer rendererC = Renderer::New(geometry, shaderC);
5686 actorC.AddRenderer(rendererC);
5688 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5689 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5691 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5692 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5694 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5695 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5697 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5698 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5700 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5701 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5703 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5704 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5706 Actor container = Actor::New();
5707 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5708 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5709 stage.Add(container);
5711 container.Add(actorA);
5712 container.Add(actorB);
5713 container.Add(actorC);
5715 ResetTouchCallbacks();
5717 // Connect ChildOrderChangedSignal
5718 bool orderChangedSignal(false);
5719 Actor orderChangedActor;
5720 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5721 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5723 // Set up gl abstraction trace so can query the set uniform order
5724 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5725 glAbstraction.EnableSetUniformCallTrace(true);
5726 glAbstraction.ResetSetUniformCallStack();
5727 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5729 glAbstraction.ResetSetUniformCallStack();
5731 application.SendNotification();
5732 application.Render();
5734 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5736 // Test order of uniforms in stack
5737 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5738 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5739 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5741 tet_infoline("Testing C above B and A at bottom\n");
5742 bool CBA = (indexC > indexB) && (indexB > indexA);
5744 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5746 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5747 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5748 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5750 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5751 // Only top actor will get touched.
5752 actorA.TouchedSignal().Connect(TestTouchCallback);
5753 actorB.TouchedSignal().Connect(TestTouchCallback2);
5754 actorC.TouchedSignal().Connect(TestTouchCallback3);
5756 Dali::Integration::Point point;
5757 point.SetDeviceId(1);
5758 point.SetState(PointState::DOWN);
5759 point.SetScreenPosition(Vector2(10.f, 10.f));
5760 Dali::Integration::TouchEvent touchEvent;
5761 touchEvent.AddPoint(point);
5763 tet_infoline("UtcDaliActor Test Set up completed \n");
5765 application.ProcessEvent(touchEvent);
5767 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5768 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5769 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5771 ResetTouchCallbacks();
5773 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");
5775 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5776 actorC.LowerBelow(actorB);
5777 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5778 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5780 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5781 application.SendNotification();
5782 application.Render();
5784 application.ProcessEvent(touchEvent); // touch event
5786 glSetUniformStack.Reset();
5788 application.SendNotification();
5789 application.Render();
5791 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5793 // Test order of uniforms in stack
5794 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5795 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5796 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5798 tet_infoline("Testing render order is A, C, B");
5799 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5800 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5802 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5803 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5804 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5806 ResetTouchCallbacks();
5808 tet_printf("Lower actor C below Actor A leaving B on top\n");
5810 orderChangedSignal = false;
5812 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5813 actorC.LowerBelow(actorA);
5814 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5815 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5817 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5818 application.SendNotification();
5819 application.Render();
5821 application.ProcessEvent(touchEvent);
5823 glSetUniformStack.Reset();
5825 application.Render();
5826 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5828 // Test order of uniforms in stack
5829 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5830 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5831 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5833 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5834 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5836 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5837 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5838 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5840 ResetTouchCallbacks();
5842 tet_printf("Lower actor B below Actor C leaving A on top\n");
5844 orderChangedSignal = false;
5846 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5847 actorB.LowerBelow(actorC);
5848 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5849 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5851 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5852 application.SendNotification();
5853 application.Render();
5855 application.ProcessEvent(touchEvent);
5857 glSetUniformStack.Reset();
5859 application.Render();
5860 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5862 // Test order of uniforms in stack
5863 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5864 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5865 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5867 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5868 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5873 int UtcDaliActorLowerBelow2(void)
5875 tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
5877 TestApplication application;
5879 Integration::Scene stage(application.GetScene());
5881 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5882 // enables checking of which actor the uniform is assigned too
5883 Shader shaderA = CreateShader();
5884 shaderA.RegisterProperty("uRendererColor", 1.f);
5886 Shader shaderB = CreateShader();
5887 shaderB.RegisterProperty("uRendererColor", 2.f);
5889 Shader shaderC = CreateShader();
5890 shaderC.RegisterProperty("uRendererColor", 3.f);
5892 Actor actorA = Actor::New();
5893 Actor actorB = Actor::New();
5894 Actor actorC = Actor::New();
5896 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5897 Geometry geometry = CreateQuadGeometry();
5899 Renderer rendererA = Renderer::New(geometry, shaderA);
5900 actorA.AddRenderer(rendererA);
5902 Renderer rendererB = Renderer::New(geometry, shaderB);
5903 actorB.AddRenderer(rendererB);
5905 Renderer rendererC = Renderer::New(geometry, shaderC);
5906 actorC.AddRenderer(rendererC);
5908 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5909 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5911 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5912 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5914 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5915 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5917 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5918 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5920 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5921 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5923 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5924 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5926 Actor container = Actor::New();
5927 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5928 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5929 stage.Add(container);
5931 container.Add(actorA);
5932 container.Add(actorB);
5933 container.Add(actorC);
5935 ResetTouchCallbacks();
5937 // Connect ChildOrderChangedSignal
5938 bool orderChangedSignal(false);
5939 Actor orderChangedActor;
5940 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5941 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5943 // Set up gl abstraction trace so can query the set uniform order
5944 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5945 glAbstraction.EnableSetUniformCallTrace(true);
5946 glAbstraction.ResetSetUniformCallStack();
5947 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5949 glAbstraction.ResetSetUniformCallStack();
5951 application.SendNotification();
5952 application.Render();
5954 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5956 // Test order of uniforms in stack
5957 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5958 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5959 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5961 tet_infoline("Testing C above B and A at bottom\n");
5962 bool CBA = (indexC > indexB) && (indexB > indexA);
5964 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5966 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5967 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5968 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5970 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5971 // Only top actor will get touched.
5972 actorA.TouchedSignal().Connect(TestTouchCallback);
5973 actorB.TouchedSignal().Connect(TestTouchCallback2);
5974 actorC.TouchedSignal().Connect(TestTouchCallback3);
5976 Dali::Integration::Point point;
5977 point.SetDeviceId(1);
5978 point.SetState(PointState::DOWN);
5979 point.SetScreenPosition(Vector2(10.f, 10.f));
5980 Dali::Integration::TouchEvent touchEvent;
5981 touchEvent.AddPoint(point);
5983 tet_infoline("UtcDaliActor Test Set up completed \n");
5985 application.ProcessEvent(touchEvent);
5987 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5988 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5989 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5991 ResetTouchCallbacks();
5993 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");
5995 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5996 actorC[DevelActor::Property::SIBLING_ORDER] = 1;
5997 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5998 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6000 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6001 application.SendNotification();
6002 application.Render();
6004 application.ProcessEvent(touchEvent); // touch event
6006 glSetUniformStack.Reset();
6008 application.SendNotification();
6009 application.Render();
6011 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6013 // Test order of uniforms in stack
6014 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6015 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6016 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6018 tet_infoline("Testing render order is A, C, B");
6019 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
6020 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
6022 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6023 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6024 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6026 ResetTouchCallbacks();
6028 tet_printf("Lower actor C below Actor A leaving B on top\n");
6030 orderChangedSignal = false;
6032 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6033 actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6034 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6035 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6037 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6038 application.SendNotification();
6039 application.Render();
6041 application.ProcessEvent(touchEvent);
6043 glSetUniformStack.Reset();
6045 application.Render();
6046 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6048 // Test order of uniforms in stack
6049 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6050 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6051 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6053 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6054 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6056 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6057 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6058 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6060 ResetTouchCallbacks();
6062 tet_printf("Lower actor B below Actor C leaving A on top\n");
6064 orderChangedSignal = false;
6066 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6067 actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6068 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6069 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6071 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6072 application.SendNotification();
6073 application.Render();
6075 application.ProcessEvent(touchEvent);
6077 glSetUniformStack.Reset();
6079 application.Render();
6080 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6082 // Test order of uniforms in stack
6083 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6084 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6085 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6087 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6088 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6093 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6095 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6097 TestApplication application;
6099 Integration::Scene stage(application.GetScene());
6101 Actor parentA = Actor::New();
6102 Actor parentB = Actor::New();
6103 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6104 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6105 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6106 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6108 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6109 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6111 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6112 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6117 Actor actorA = Actor::New();
6118 Actor actorB = Actor::New();
6119 Actor actorC = Actor::New();
6121 parentA.Add(actorA);
6122 parentA.Add(actorB);
6124 tet_printf("Actor C added to different parent from A and B \n");
6125 parentB.Add(actorC);
6127 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6128 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6130 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6131 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6133 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6134 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6136 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6137 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6139 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6140 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6142 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6143 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6145 ResetTouchCallbacks();
6147 // Connect ChildOrderChangedSignal
6148 bool orderChangedSignal(false);
6149 Actor orderChangedActor;
6150 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6151 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6153 application.SendNotification();
6154 application.Render();
6156 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6157 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6158 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6160 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6161 // Only top actor will get touched.
6162 actorA.TouchedSignal().Connect(TestTouchCallback);
6163 actorB.TouchedSignal().Connect(TestTouchCallback2);
6164 actorC.TouchedSignal().Connect(TestTouchCallback3);
6166 Dali::Integration::Point point;
6167 point.SetDeviceId(1);
6168 point.SetState(PointState::DOWN);
6169 point.SetScreenPosition(Vector2(10.f, 10.f));
6170 Dali::Integration::TouchEvent touchEvent;
6171 touchEvent.AddPoint(point);
6173 application.ProcessEvent(touchEvent);
6175 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6176 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6177 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6179 ResetTouchCallbacks();
6181 tet_printf("Raise actor A Above Actor C which have different parents\n");
6183 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6184 actorA.RaiseAbove(actorC);
6185 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6187 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6188 application.SendNotification();
6190 application.ProcessEvent(touchEvent); // touch event
6192 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6193 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6194 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6196 ResetTouchCallbacks();
6201 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6203 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
6205 TestApplication application;
6207 Integration::Scene stage(application.GetScene());
6209 Actor actorA = Actor::New();
6210 Actor actorB = Actor::New();
6211 Actor actorC = Actor::New();
6213 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6214 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6216 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6217 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6219 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6220 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6222 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6223 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6225 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6226 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6228 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6229 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6231 ResetTouchCallbacks();
6233 // Connect ChildOrderChangedSignal
6234 bool orderChangedSignal(false);
6235 Actor orderChangedActor;
6236 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6237 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6239 application.SendNotification();
6240 application.Render();
6242 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6243 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6244 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6246 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6247 // Only top actor will get touched.
6248 actorA.TouchedSignal().Connect(TestTouchCallback);
6249 actorB.TouchedSignal().Connect(TestTouchCallback2);
6250 actorC.TouchedSignal().Connect(TestTouchCallback3);
6252 Dali::Integration::Point point;
6253 point.SetDeviceId(1);
6254 point.SetState(PointState::DOWN);
6255 point.SetScreenPosition(Vector2(10.f, 10.f));
6256 Dali::Integration::TouchEvent touchEvent;
6257 touchEvent.AddPoint(point);
6259 tet_printf("Raise actor A Above Actor C which have no parents\n");
6261 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6262 actorA.RaiseAbove(actorC);
6263 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6265 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6266 application.SendNotification();
6268 application.ProcessEvent(touchEvent);
6270 tet_printf("Not parented so RaiseAbove should show no effect\n");
6272 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6273 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6274 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6276 ResetTouchCallbacks();
6278 orderChangedSignal = false;
6281 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6283 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6284 actorA.LowerBelow(actorC);
6285 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6287 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6288 application.SendNotification();
6289 application.Render();
6291 application.ProcessEvent(touchEvent);
6293 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6294 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6295 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6296 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6298 ResetTouchCallbacks();
6300 orderChangedSignal = false;
6302 tet_printf("Adding Actor A to stage, will be on top\n");
6305 application.SendNotification();
6306 application.Render();
6308 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6310 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6311 actorB.RaiseAbove(actorC);
6312 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6314 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6315 application.SendNotification();
6317 application.ProcessEvent(touchEvent);
6319 tet_printf("C not parented so RaiseAbove should show no effect\n");
6320 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6321 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6322 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6324 ResetTouchCallbacks();
6326 orderChangedSignal = false;
6328 tet_printf("Lower actor A below Actor C when only A has a parent\n");
6330 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6331 actorA.LowerBelow(actorC);
6332 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6334 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6335 application.SendNotification();
6337 application.ProcessEvent(touchEvent);
6339 tet_printf("C not parented so LowerBelow should show no effect\n");
6340 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6341 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6342 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6344 ResetTouchCallbacks();
6346 orderChangedSignal = false;
6350 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6351 actorA.RaiseAbove(actorC);
6352 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6353 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6355 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6356 application.SendNotification();
6357 application.Render();
6359 application.ProcessEvent(touchEvent);
6361 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6362 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6363 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6364 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6369 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6371 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6373 TestApplication application;
6375 Integration::Scene stage(application.GetScene());
6377 Actor actorA = Actor::New();
6378 Actor actorB = Actor::New();
6379 Actor actorC = Actor::New();
6381 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6382 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6384 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6385 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6387 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6388 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6390 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6391 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6393 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6394 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6396 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6397 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6399 ResetTouchCallbacks();
6401 // Connect ChildOrderChangedSignal
6402 bool orderChangedSignal(false);
6403 Actor orderChangedActor;
6404 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6405 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6407 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6408 // Only top actor will get touched.
6409 actorA.TouchedSignal().Connect(TestTouchCallback);
6410 actorB.TouchedSignal().Connect(TestTouchCallback2);
6411 actorC.TouchedSignal().Connect(TestTouchCallback3);
6413 Dali::Integration::Point point;
6414 point.SetDeviceId(1);
6415 point.SetState(PointState::DOWN);
6416 point.SetScreenPosition(Vector2(10.f, 10.f));
6417 Dali::Integration::TouchEvent touchEvent;
6418 touchEvent.AddPoint(point);
6421 tet_printf("Raise actor B Above Actor C but B not parented\n");
6423 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6425 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6427 application.SendNotification();
6428 application.Render();
6430 application.ProcessEvent(touchEvent);
6432 tet_printf("Not parented so RaiseAbove should show no effect\n");
6434 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6435 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6436 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6438 tet_printf("Raise actor B Above Actor C but B not parented\n");
6439 ResetTouchCallbacks();
6441 orderChangedSignal = false;
6443 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6445 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6447 // Sort actor tree before next touch event
6448 application.SendNotification();
6449 application.Render();
6451 application.ProcessEvent(touchEvent);
6453 tet_printf("Not parented so RaiseAbove should show no effect\n");
6455 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6456 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6457 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6458 ResetTouchCallbacks();
6460 orderChangedSignal = false;
6462 tet_printf("Lower actor C below B but C not parented\n");
6464 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6466 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6468 // Sort actor tree before next touch event
6469 application.SendNotification();
6470 application.Render();
6472 application.ProcessEvent(touchEvent);
6474 tet_printf("Not parented so Lower should show no effect\n");
6476 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6477 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6478 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6479 ResetTouchCallbacks();
6481 orderChangedSignal = false;
6483 tet_printf("Raise actor B to top\n");
6485 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6486 actorB.RaiseToTop();
6487 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6489 // Sort actor tree before next touch event
6490 application.SendNotification();
6491 application.Render();
6493 application.ProcessEvent(touchEvent);
6495 tet_printf("Not parented so RaiseToTop should show no effect\n");
6497 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6498 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6499 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6500 ResetTouchCallbacks();
6502 orderChangedSignal = false;
6504 tet_printf("Add ActorB to stage so only Actor C not parented\n");
6508 tet_printf("Lower actor C to Bottom, B stays at top\n");
6510 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6511 actorC.LowerToBottom();
6512 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6514 application.SendNotification();
6515 application.Render();
6517 application.ProcessEvent(touchEvent);
6519 tet_printf("Not parented so LowerToBottom should show no effect\n");
6521 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6522 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6523 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6524 ResetTouchCallbacks();
6529 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6531 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
6533 TestApplication application;
6535 Integration::Scene stage(application.GetScene());
6537 Actor actorA = Actor::New();
6538 Actor actorB = Actor::New();
6539 Actor actorC = Actor::New();
6541 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6542 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6544 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6545 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6547 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6548 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6550 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6551 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6553 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6554 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6556 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6557 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6563 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6564 // Only top actor will get touched.
6565 actorA.TouchedSignal().Connect(TestTouchCallback);
6566 actorB.TouchedSignal().Connect(TestTouchCallback2);
6567 actorC.TouchedSignal().Connect(TestTouchCallback3);
6569 ResetTouchCallbacks();
6571 // Connect ChildOrderChangedSignal
6572 bool orderChangedSignal(false);
6573 Actor orderChangedActor;
6574 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6575 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6577 application.SendNotification();
6578 application.Render();
6580 Dali::Integration::Point point;
6581 point.SetDeviceId(1);
6582 point.SetState(PointState::DOWN);
6583 point.SetScreenPosition(Vector2(10.f, 10.f));
6584 Dali::Integration::TouchEvent touchEvent;
6585 touchEvent.AddPoint(point);
6587 application.ProcessEvent(touchEvent);
6589 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6590 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6591 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6593 ResetTouchCallbacks();
6595 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6597 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6598 actorA.RaiseAbove(actorA);
6599 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6600 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6602 application.SendNotification();
6603 application.Render();
6605 application.ProcessEvent(touchEvent);
6607 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6609 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6610 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6611 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6613 ResetTouchCallbacks();
6615 orderChangedSignal = false;
6617 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6618 actorA.RaiseAbove(actorC);
6619 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6620 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6622 application.SendNotification();
6623 application.Render();
6625 application.ProcessEvent(touchEvent);
6627 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6628 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6629 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6630 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6635 int UtcDaliActorGetScreenPosition(void)
6637 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6639 TestApplication application;
6641 Integration::Scene stage(application.GetScene());
6643 Actor actorA = Actor::New();
6644 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6646 Vector2 size2(10.0f, 20.0f);
6647 actorA.SetProperty(Actor::Property::SIZE, size2);
6649 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6651 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6655 application.SendNotification();
6656 application.Render();
6658 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6659 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6661 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6662 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6664 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6665 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6667 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6669 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6671 application.SendNotification();
6672 application.Render();
6674 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6675 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6677 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6678 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6680 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6681 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6683 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6685 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6687 application.SendNotification();
6688 application.Render();
6690 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6691 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6693 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6694 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6696 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6697 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6699 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6701 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6703 application.SendNotification();
6704 application.Render();
6706 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6707 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6709 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6710 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6712 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6713 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6715 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6717 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6719 application.SendNotification();
6720 application.Render();
6722 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6723 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6725 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6726 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6728 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6729 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6731 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6733 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6734 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6736 Actor actorB = Actor::New();
6737 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6738 actorB.SetProperty(Actor::Property::SIZE, size2);
6739 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6742 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6744 application.SendNotification();
6745 application.Render();
6747 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6749 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6750 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6755 int UtcDaliActorGetScreenPositionAfterScaling(void)
6757 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6759 TestApplication application;
6761 Integration::Scene stage(application.GetScene());
6763 Actor actorA = Actor::New();
6764 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6766 Vector2 size2(10.0f, 20.0f);
6767 actorA.SetProperty(Actor::Property::SIZE, size2);
6768 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6769 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6771 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6775 application.SendNotification();
6776 application.Render();
6778 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6779 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6781 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6782 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6784 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6785 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6787 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6789 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6791 application.SendNotification();
6792 application.Render();
6794 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6795 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6797 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6798 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6800 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6801 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6806 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6808 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6810 TestApplication application;
6812 Integration::Scene stage(application.GetScene());
6814 Actor actorA = Actor::New();
6815 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6816 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6817 Vector2 size2(10.0f, 20.0f);
6818 actorA.SetProperty(Actor::Property::SIZE, size2);
6819 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6821 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6825 application.SendNotification();
6826 application.Render();
6828 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6829 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6831 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6832 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6834 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6835 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6837 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6839 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6840 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6842 application.SendNotification();
6843 application.Render();
6845 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6846 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6848 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6849 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6851 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6852 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6858 int UtcDaliActorGetScreenPositionWithChildActors(void)
6860 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6862 TestApplication application;
6864 Integration::Scene stage(application.GetScene());
6866 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6868 Actor actorA = Actor::New();
6869 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6870 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6871 Vector2 size1(10.0f, 20.0f);
6872 actorA.SetProperty(Actor::Property::SIZE, size1);
6873 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6875 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6877 Actor parentActorA = Actor::New();
6878 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6879 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6880 Vector2 size2(30.0f, 60.0f);
6881 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6882 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6884 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6886 stage.Add(parentActorA);
6887 parentActorA.Add(actorA);
6889 application.SendNotification();
6890 application.Render();
6892 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6893 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6895 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6896 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6898 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6899 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6901 tet_infoline("Test 2\n");
6903 tet_infoline("change parent anchor point and parent origin then check screen position \n");
6905 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6906 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6908 application.SendNotification();
6909 application.Render();
6911 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6912 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6914 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6915 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6917 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6918 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6923 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6925 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6927 TestApplication application;
6929 Integration::Scene stage(application.GetScene());
6931 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6933 Actor actorA = Actor::New();
6934 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6935 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6936 Vector2 size1(10.0f, 20.0f);
6937 actorA.SetProperty(Actor::Property::SIZE, size1);
6938 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6940 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6942 Actor parentActorA = Actor::New();
6943 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6944 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6945 Vector2 size2(30.0f, 60.0f);
6946 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6947 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6949 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6951 Actor grandParentActorA = Actor::New();
6952 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6953 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6954 Vector2 size3(60.0f, 120.0f);
6955 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6956 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6958 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6960 stage.Add(grandParentActorA);
6961 grandParentActorA.Add(parentActorA);
6963 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6965 parentActorA.Add(actorA);
6967 application.SendNotification();
6968 application.Render();
6970 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6971 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6973 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6974 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6976 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6977 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6982 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6984 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6986 TestApplication application;
6988 Integration::Scene stage(application.GetScene());
6990 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6992 Actor actorA = Actor::New();
6993 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6994 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6995 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6996 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6999 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7001 Actor actorB = Actor::New();
7002 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7003 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7004 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7005 Vector2 actorBSize(30.0f, 60.0f);
7006 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
7009 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
7011 Actor actorC = Actor::New();
7012 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7013 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7014 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7015 Vector2 actorCSize(60.0f, 120.0f);
7016 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
7019 application.SendNotification();
7020 application.Render();
7022 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7024 Vector2 center(stage.GetSize() * 0.5f);
7026 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7027 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7028 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7030 tet_infoline("Add scale to all actors");
7032 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7033 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7034 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7036 application.SendNotification();
7037 application.Render();
7039 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7040 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7041 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7046 int UtcDaliActorGetScreenPositionResizeScene(void)
7048 tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size");
7050 TestApplication application;
7051 Integration::Scene scene = application.GetScene();
7053 Actor actorA = Actor::New();
7054 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7055 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7056 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7060 application.SendNotification();
7061 application.Render();
7063 Vector2 sceneSize = scene.GetSize();
7064 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7066 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7069 Vector2 newSize(1000.0f, 2000.0f);
7070 DALI_TEST_CHECK(scene.GetSize() != newSize);
7072 scene.SurfaceResized(newSize.width, newSize.height);
7074 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7076 // The screen position should not be updated yet
7077 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7079 application.SendNotification();
7080 application.Render();
7082 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
7084 // The screen position should be updated
7085 sceneSize = scene.GetSize();
7086 DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION);
7091 int utcDaliActorPositionUsesAnchorPoint(void)
7093 TestApplication application;
7094 tet_infoline("Check default behaviour\n");
7096 Actor actor = Actor::New();
7097 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7098 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7099 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7100 application.GetScene().Add(actor);
7102 application.SendNotification();
7103 application.Render();
7105 tet_infoline("Check that the world position is in the center\n");
7106 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7108 tet_infoline("Set the position uses anchor point property to false\n");
7109 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7111 application.SendNotification();
7112 application.Render();
7114 tet_infoline("Check that the world position has changed appropriately\n");
7115 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7120 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7122 TestApplication application;
7123 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7125 Actor actor = Actor::New();
7126 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7127 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7128 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7129 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7130 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7131 application.GetScene().Add(actor);
7133 application.SendNotification();
7134 application.Render();
7136 tet_infoline("Check the world position is the same as it would be without a scale\n");
7137 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7139 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7140 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7141 application.SendNotification();
7142 application.Render();
7143 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7145 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7146 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7147 application.SendNotification();
7148 application.Render();
7149 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7154 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7156 TestApplication application;
7157 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7159 Actor actor = Actor::New();
7160 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7161 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7162 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7163 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7164 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7165 application.GetScene().Add(actor);
7167 application.SendNotification();
7168 application.Render();
7170 tet_infoline("Check the world position is the same as it would be without a rotation\n");
7171 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7173 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7174 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7175 application.SendNotification();
7176 application.Render();
7177 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7179 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7180 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7181 application.SendNotification();
7182 application.Render();
7183 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7188 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7190 TestApplication application;
7191 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7193 Actor actor = Actor::New();
7194 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7195 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7196 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7197 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7198 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7199 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7200 application.GetScene().Add(actor);
7202 application.SendNotification();
7203 application.Render();
7205 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7206 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7208 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7209 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7210 application.SendNotification();
7211 application.Render();
7212 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7214 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7215 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7216 application.SendNotification();
7217 application.Render();
7218 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7223 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7225 TestApplication application;
7226 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7228 Actor parent = Actor::New();
7230 application.GetScene().Add(parent);
7231 Vector2 stageSize(application.GetScene().GetSize());
7233 Actor actor = Actor::New();
7234 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7235 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7236 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7237 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7238 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7239 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7242 application.SendNotification();
7243 application.Render();
7245 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7247 tet_infoline("Check the world position is in the right place\n");
7248 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7250 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7251 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7252 application.SendNotification();
7253 application.Render();
7254 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7256 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7257 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7258 application.SendNotification();
7259 application.Render();
7260 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7265 int utcDaliActorVisibilityChangeSignalSelf(void)
7267 TestApplication application;
7268 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7270 Actor actor = Actor::New();
7272 VisibilityChangedFunctorData data;
7273 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7275 actor.SetProperty(Actor::Property::VISIBLE, false);
7277 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7279 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7282 actor.SetProperty(Actor::Property::VISIBLE, false);
7283 data.Check(false /* not called */, TEST_LOCATION);
7285 tet_infoline("Change the visibility using properties, ensure called");
7288 actor.SetProperty(Actor::Property::VISIBLE, true);
7289 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7291 tet_infoline("Set the visibility to current using properties, ensure not called");
7294 actor.SetProperty(Actor::Property::VISIBLE, true);
7295 data.Check(false /* not called */, TEST_LOCATION);
7300 int utcDaliActorVisibilityChangeSignalChildren(void)
7302 TestApplication application;
7303 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7305 Actor parent = Actor::New();
7306 Actor child = Actor::New();
7309 Actor grandChild = Actor::New();
7310 child.Add(grandChild);
7312 VisibilityChangedFunctorData parentData;
7313 VisibilityChangedFunctorData childData;
7314 VisibilityChangedFunctorData grandChildData;
7316 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7317 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7318 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7320 parent.SetProperty(Actor::Property::VISIBLE, false);
7321 parentData.Check(false /* not called */, TEST_LOCATION);
7322 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7323 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7325 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7328 grandChildData.Reset();
7330 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7332 parent.SetProperty(Actor::Property::VISIBLE, true);
7333 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7334 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7335 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7337 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7340 grandChildData.Reset();
7342 parent.SetProperty(Actor::Property::VISIBLE, true);
7343 parentData.Check(false /* not called */, TEST_LOCATION);
7344 childData.Check(false /* not called */, TEST_LOCATION);
7345 grandChildData.Check(false /* not called */, TEST_LOCATION);
7350 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7352 TestApplication application;
7353 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7355 Actor actor = Actor::New();
7356 application.GetScene().Add(actor);
7358 application.SendNotification();
7359 application.Render();
7361 VisibilityChangedFunctorData data;
7362 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7364 Animation animation = Animation::New(1.0f);
7365 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7367 data.Check(false, TEST_LOCATION);
7368 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7369 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7371 tet_infoline("Play the animation and check the property value");
7374 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7375 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7377 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7378 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7380 application.SendNotification();
7381 application.Render(1100); // After the animation
7383 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7388 int utcDaliActorVisibilityChangeSignalByName(void)
7390 TestApplication application;
7391 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7393 Actor actor = Actor::New();
7395 bool signalCalled = false;
7396 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7397 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7398 actor.SetProperty(Actor::Property::VISIBLE, false);
7399 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7401 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7402 signalCalled = false;
7403 actor.SetProperty(Actor::Property::VISIBLE, false);
7404 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7406 tet_infoline("Change the visibility using properties, ensure called");
7407 actor.SetProperty(Actor::Property::VISIBLE, true);
7408 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7410 tet_infoline("Set the visibility to current using properties, ensure not called");
7411 signalCalled = false;
7413 actor.SetProperty(Actor::Property::VISIBLE, true);
7414 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7419 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7421 gLayoutDirectionType = type;
7424 int UtcDaliActorLayoutDirectionProperty(void)
7426 TestApplication application;
7427 tet_infoline("Check layout direction property");
7429 Actor actor0 = Actor::New();
7430 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7431 application.GetScene().Add(actor0);
7433 application.SendNotification();
7434 application.Render();
7436 Actor actor1 = Actor::New();
7437 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7438 Actor actor2 = Actor::New();
7439 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7440 Actor actor3 = Actor::New();
7441 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7442 Actor actor4 = Actor::New();
7443 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7444 Actor actor5 = Actor::New();
7445 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7446 Actor actor6 = Actor::New();
7447 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7448 Actor actor7 = Actor::New();
7449 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7450 Actor actor8 = Actor::New();
7451 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7452 Actor actor9 = Actor::New();
7453 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7456 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7457 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7459 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7460 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7461 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7463 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7464 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7465 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7467 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7469 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7470 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7472 application.GetScene().Add(actor3);
7479 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7480 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7482 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7483 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7484 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7486 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7488 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7489 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7490 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7491 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7492 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7493 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7494 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7496 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7497 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7498 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7500 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7501 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7502 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7503 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7505 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7506 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7507 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7512 struct LayoutDirectionFunctor
7514 LayoutDirectionFunctor(bool& signalCalled)
7515 : mSignalCalled(signalCalled)
7519 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7520 : mSignalCalled(rhs.mSignalCalled)
7526 mSignalCalled = true;
7529 bool& mSignalCalled;
7532 int UtcDaliActorLayoutDirectionSignal(void)
7534 TestApplication application;
7535 tet_infoline("Check changing layout direction property sends a signal");
7537 Actor actor = Actor::New();
7538 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7539 application.GetScene().Add(actor);
7540 bool signalCalled = false;
7541 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7543 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7544 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7546 // Test that writing the same value doesn't send a signal
7547 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7548 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7550 // Test that writing a different value sends the signal
7551 signalCalled = false;
7552 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7553 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7555 signalCalled = false;
7556 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7557 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7562 struct ChildAddedSignalCheck
7564 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7565 : mSignalReceived(signalReceived),
7566 mChildHandle(childHandle)
7570 void operator()(Actor childHandle)
7572 mSignalReceived = true;
7573 mChildHandle = childHandle;
7577 mSignalReceived = true;
7578 mChildHandle = Actor();
7581 bool& mSignalReceived;
7582 Actor& mChildHandle;
7585 int UtcDaliChildAddedSignalP1(void)
7587 TestApplication application;
7588 auto stage = application.GetScene();
7590 bool signalReceived = false;
7593 ChildAddedSignalCheck signal(signalReceived, childActor);
7594 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7595 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7597 auto actorA = Actor::New();
7599 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7600 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7601 signalReceived = false;
7603 auto actorB = Actor::New();
7605 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7606 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7611 int UtcDaliChildAddedSignalP2(void)
7613 TestApplication application;
7614 auto stage = application.GetScene();
7616 bool signalReceived = false;
7619 ChildAddedSignalCheck signal(signalReceived, childActor);
7620 tet_infoline("Connect to childAdded signal by name");
7622 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7623 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7625 auto actorA = Actor::New();
7627 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7629 // Can't test which actor was added; signal signature is void() when connecting via name.
7630 signalReceived = false;
7632 auto actorB = Actor::New();
7634 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7639 int UtcDaliChildAddedSignalN(void)
7641 TestApplication application;
7642 auto stage = application.GetScene();
7644 bool signalReceived = false;
7647 ChildAddedSignalCheck signal(signalReceived, childActor);
7648 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7649 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7651 auto actorA = Actor::New();
7653 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7654 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7655 signalReceived = false;
7657 auto actorB = Actor::New();
7659 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7663 struct ChildRemovedSignalCheck
7665 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7666 : mSignalReceived(signalReceived),
7667 mChildHandle(childHandle)
7671 void operator()(Actor childHandle)
7673 mSignalReceived = true;
7674 mChildHandle = childHandle;
7679 mSignalReceived = true;
7682 bool& mSignalReceived;
7683 Actor& mChildHandle;
7686 int UtcDaliChildRemovedSignalP1(void)
7688 TestApplication application;
7689 auto stage = application.GetScene();
7691 bool signalReceived = false;
7694 ChildRemovedSignalCheck signal(signalReceived, childActor);
7695 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7696 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7698 auto actorA = Actor::New();
7700 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7701 DALI_TEST_CHECK(!childActor);
7703 stage.Remove(actorA);
7704 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7705 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7707 signalReceived = false;
7708 auto actorB = Actor::New();
7710 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7712 stage.Remove(actorB);
7713 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7714 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7719 int UtcDaliChildRemovedSignalP2(void)
7721 TestApplication application;
7722 auto stage = application.GetScene();
7724 bool signalReceived = false;
7727 ChildAddedSignalCheck signal(signalReceived, childActor);
7728 tet_infoline("Connect to childRemoved signal by name");
7730 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7731 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7733 auto actorA = Actor::New();
7735 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7737 stage.Remove(actorA);
7738 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7740 signalReceived = false;
7741 auto actorB = Actor::New();
7743 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7745 stage.Remove(actorB);
7746 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7751 int UtcDaliChildRemovedSignalN(void)
7753 TestApplication application;
7754 auto stage = application.GetScene();
7756 bool signalReceived = false;
7759 ChildRemovedSignalCheck signal(signalReceived, childActor);
7760 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7761 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7763 auto actorA = Actor::New();
7766 auto actorB = Actor::New();
7769 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7770 DALI_TEST_CHECK(!childActor);
7772 actorA.Remove(actorB);
7773 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7777 int UtcDaliChildMovedSignalP(void)
7779 TestApplication application;
7780 auto stage = application.GetScene();
7782 bool addedASignalReceived = false;
7783 bool removedASignalReceived = false;
7784 bool addedBSignalReceived = false;
7785 bool removedBSignalReceived = false;
7788 auto actorA = Actor::New();
7789 auto actorB = Actor::New();
7793 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
7794 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7795 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
7796 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7798 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7799 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7800 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7801 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7803 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7804 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7805 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7806 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7808 // Create a child of A
7810 auto child = Actor::New();
7813 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7814 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7815 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7816 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7817 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7820 addedASignalReceived = false;
7821 addedBSignalReceived = false;
7822 removedASignalReceived = false;
7823 removedBSignalReceived = false;
7825 actorB.Add(child); // Expect this child to be re-parented
7826 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7827 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7828 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7829 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7831 // Move child back to A:
7832 addedASignalReceived = false;
7833 addedBSignalReceived = false;
7834 removedASignalReceived = false;
7835 removedBSignalReceived = false;
7837 actorA.Add(child); // Expect this child to be re-parented
7838 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7839 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7840 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7841 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7846 int UtcDaliActorSwitchParentP(void)
7848 tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
7849 TestApplication application;
7851 Actor parent1 = Actor::New();
7852 Actor child = Actor::New();
7854 application.GetScene().Add(parent1);
7856 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7858 child.OnSceneSignal().Connect(OnSceneCallback);
7859 child.OffSceneSignal().Connect(OffSceneCallback);
7862 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
7863 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7867 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
7869 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7870 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7872 Actor parent2 = Actor::New();
7873 application.GetScene().Add(parent2);
7875 bool addSignalReceived = false;
7876 ChildAddedSignalCheck addedSignal(addSignalReceived, child);
7877 DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
7878 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7880 bool removedSignalReceived = false;
7881 ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
7882 DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
7883 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7885 DevelActor::SwitchParent(child, parent2);
7887 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7888 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7890 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7891 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
7893 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7894 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7895 DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
7896 DALI_TEST_CHECK(child.GetParent() == parent2);
7901 int utcDaliActorCulled(void)
7903 TestApplication application;
7904 auto stage = application.GetScene();
7906 tet_infoline("Check that the actor is culled if the actor is out of the screen");
7908 Actor actor = Actor::New();
7909 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7911 Geometry geometry = CreateQuadGeometry();
7912 Shader shader = CreateShader();
7913 Renderer renderer = Renderer::New(geometry, shader);
7914 actor.AddRenderer(renderer);
7918 application.SendNotification();
7919 application.Render(0);
7921 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7923 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7924 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7926 // Connect NotifySignal
7927 bool propertyNotificationSignal(false);
7928 PropertyNotification source;
7929 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7930 notification.NotifySignal().Connect(&application, f);
7932 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7934 application.SendNotification();
7935 application.Render();
7937 application.SendNotification();
7939 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7941 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7942 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7943 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7948 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7950 TestApplication application;
7951 auto stage = application.GetScene();
7953 tet_infoline("Ensure we clear the screen when the last actor is removed");
7955 Actor actor = CreateRenderableActor();
7956 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7959 application.SendNotification();
7960 application.Render();
7962 auto& glAbstraction = application.GetGlAbstraction();
7963 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7967 application.SendNotification();
7968 application.Render();
7970 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7975 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7977 TestApplication application;
7978 auto stage = application.GetScene();
7980 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7982 Actor actor = CreateRenderableActor();
7983 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7986 application.SendNotification();
7987 application.Render();
7989 auto& glAbstraction = application.GetGlAbstraction();
7990 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7992 actor.SetProperty(Actor::Property::VISIBLE, false);
7994 application.SendNotification();
7995 application.Render();
7997 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
8002 int utcDaliActorGetSizeAfterAnimation(void)
8004 TestApplication application;
8005 tet_infoline("Check the actor size before / after an animation is finished");
8007 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8009 Actor actor = Actor::New();
8010 actor.SetProperty(Actor::Property::SIZE, actorSize);
8011 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8012 application.GetScene().Add(actor);
8014 // Size should be updated without rendering.
8015 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8016 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8018 application.SendNotification();
8019 application.Render();
8021 // Size and current size should be updated.
8022 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8023 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8024 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8025 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8026 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8028 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8029 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8030 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8031 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8032 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8035 actorSize = Vector3(200.0f, 200.0f, 0.0f);
8036 actor.SetProperty(Actor::Property::SIZE, actorSize);
8038 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8039 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8041 Vector3 targetValue(10.0f, 20.0f, 0.0f);
8043 Animation animation = Animation::New(1.0f);
8044 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8047 // Size should be updated without rendering.
8048 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8049 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8051 application.SendNotification();
8052 application.Render(1100); // After the animation
8054 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8055 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8056 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8057 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8058 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8060 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8061 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8062 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8063 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8064 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8066 targetValue.width = 50.0f;
8069 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8072 application.SendNotification();
8073 application.Render(1100); // After the animation
8075 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8076 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8077 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8078 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8079 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8081 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8082 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8083 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8084 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8085 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8087 targetValue.height = 70.0f;
8090 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8093 application.SendNotification();
8094 application.Render(1100); // After the animation
8096 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8097 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8098 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8099 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8100 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8102 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8103 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8104 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8105 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8106 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8108 Vector3 offset(10.0f, 20.0f, 0.0f);
8111 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8114 application.SendNotification();
8115 application.Render(1100); // After the animation
8117 targetValue += offset;
8119 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8120 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8121 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8122 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8123 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8125 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8126 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8127 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8128 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8129 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8131 offset.width = 20.0f;
8134 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8137 application.SendNotification();
8138 application.Render(1100); // After the animation
8140 targetValue.width += offset.width;
8142 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8143 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8144 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8145 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8146 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8148 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8149 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8150 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8151 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8152 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8154 offset.height = 10.0f;
8157 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8160 application.SendNotification();
8161 application.Render(1100); // After the animation
8163 targetValue.height += offset.height;
8165 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8166 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8167 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8168 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8169 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8171 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8172 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8173 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8174 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8175 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8178 actorSize = Vector3(300.0f, 300.0f, 0.0f);
8180 actor.SetProperty(Actor::Property::SIZE, actorSize);
8182 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8183 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8185 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8186 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8188 application.SendNotification();
8189 application.Render();
8191 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8192 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8194 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8195 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8200 int utcDaliActorRelayoutAndAnimation(void)
8202 TestApplication application;
8203 tet_infoline("Check the actor size when relayoutting and playing animation");
8205 Vector3 parentSize(300.0f, 300.0f, 0.0f);
8206 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8209 Actor parentA = Actor::New();
8210 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8211 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8212 application.GetScene().Add(parentA);
8214 Actor parentB = Actor::New();
8215 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8216 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8217 application.GetScene().Add(parentB);
8219 Actor actor = Actor::New();
8220 actor.SetProperty(Actor::Property::SIZE, actorSize);
8221 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8224 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8225 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8227 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8229 Animation animation = Animation::New(1.0f);
8230 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8233 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8234 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8236 application.SendNotification();
8237 application.Render(1100); // After the animation
8239 // Size and current size should be updated.
8240 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8241 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8243 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8244 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8249 application.SendNotification();
8250 application.Render();
8252 // Size and current size should be same.
8253 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8254 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8256 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8257 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8265 Actor parentA = Actor::New();
8266 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8267 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8268 application.GetScene().Add(parentA);
8270 Actor parentB = Actor::New();
8271 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8272 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8273 application.GetScene().Add(parentB);
8275 Actor actor = Actor::New();
8276 actor.SetProperty(Actor::Property::SIZE, actorSize);
8277 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8280 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8281 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8283 application.SendNotification();
8284 application.Render();
8286 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8287 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8289 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8290 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8292 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8294 // Make an animation
8295 Animation animation = Animation::New(1.0f);
8296 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8299 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8300 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8302 application.SendNotification();
8303 application.Render(1100); // After the animation
8305 // Size and current size should be updated.
8306 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8307 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8309 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8310 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8315 application.SendNotification();
8316 application.Render();
8318 // Size and current size should be same.
8319 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8320 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8322 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8323 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8333 int utcDaliActorPartialUpdate(void)
8335 TestApplication application(
8336 TestApplication::DEFAULT_SURFACE_WIDTH,
8337 TestApplication::DEFAULT_SURFACE_HEIGHT,
8338 TestApplication::DEFAULT_HORIZONTAL_DPI,
8339 TestApplication::DEFAULT_VERTICAL_DPI,
8343 tet_infoline("Check the damaged area");
8345 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8347 std::vector<Rect<int>> damagedRects;
8348 Rect<int> clippingRect;
8349 application.SendNotification();
8350 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8352 // First render pass, nothing to render, adaptor would just do swap buffer.
8353 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8355 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8356 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8358 Actor actor = CreateRenderableActor();
8359 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8360 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8361 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8362 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8363 application.GetScene().Add(actor);
8365 application.SendNotification();
8367 // 1. Actor added, damaged rect is added size of actor
8368 damagedRects.clear();
8369 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8370 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8373 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8374 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8375 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8376 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8377 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8378 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8379 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8382 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8383 application.SendNotification();
8385 damagedRects.clear();
8386 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8387 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8390 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
8391 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8392 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8393 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8394 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8395 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8396 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8398 // 3. Set new position
8399 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8400 application.SendNotification();
8402 damagedRects.clear();
8403 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8404 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8407 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
8408 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8409 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8410 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8411 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8412 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8413 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8415 application.GetScene().Remove(actor);
8416 application.SendNotification();
8418 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
8419 damagedRects.clear();
8420 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8421 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
8423 clippingRect = damagedRects[0];
8424 clippingRect.Merge(damagedRects[1]);
8425 clippingRect.Merge(damagedRects[2]);
8427 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
8428 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8429 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
8431 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8432 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8433 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8434 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8435 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8440 int utcDaliActorPartialUpdateSetColor(void)
8442 TestApplication application(
8443 TestApplication::DEFAULT_SURFACE_WIDTH,
8444 TestApplication::DEFAULT_SURFACE_HEIGHT,
8445 TestApplication::DEFAULT_HORIZONTAL_DPI,
8446 TestApplication::DEFAULT_VERTICAL_DPI,
8450 tet_infoline("Check uniform update");
8452 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8454 std::vector<Rect<int>> damagedRects;
8455 Rect<int> clippingRect;
8456 application.SendNotification();
8457 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8459 // First render pass, nothing to render, adaptor would just do swap buffer.
8460 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8462 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8463 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8465 Actor actor = CreateRenderableActor();
8466 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8467 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8468 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8469 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8470 application.GetScene().Add(actor);
8472 application.SendNotification();
8474 // 1. Actor added, damaged rect is added size of actor
8475 damagedRects.clear();
8476 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8477 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8480 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8481 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8482 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8483 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8484 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8485 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8486 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8488 damagedRects.clear();
8489 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8491 damagedRects.clear();
8492 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8495 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8496 application.SendNotification();
8498 damagedRects.clear();
8499 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8500 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8503 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8504 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8505 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8506 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8507 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8508 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8509 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8514 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8515 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8516 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8517 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8518 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8519 " uniform mediump mat4 uLightCameraViewMatrix;\n"
8523 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8524 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
8525 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8528 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8529 "uniform lowp vec4 uShadowColor;\n"
8532 " lowp float alpha;\n"
8533 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8534 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8537 int utcDaliActorPartialUpdateSetProperty(void)
8539 TestApplication application(
8540 TestApplication::DEFAULT_SURFACE_WIDTH,
8541 TestApplication::DEFAULT_SURFACE_HEIGHT,
8542 TestApplication::DEFAULT_HORIZONTAL_DPI,
8543 TestApplication::DEFAULT_VERTICAL_DPI,
8547 tet_infoline("Set/Update property with partial update");
8549 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8551 std::vector<Rect<int>> damagedRects;
8552 Rect<int> clippingRect;
8553 application.SendNotification();
8554 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8556 // First render pass, nothing to render, adaptor would just do swap buffer.
8557 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8559 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8560 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8562 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8563 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8564 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8565 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8566 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8567 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8568 application.GetScene().Add(actor);
8570 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8572 damagedRects.clear();
8573 application.SendNotification();
8574 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8575 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8578 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8579 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8580 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8581 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8582 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8583 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8584 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8586 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8587 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8589 damagedRects.clear();
8590 application.SendNotification();
8591 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8592 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8594 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8595 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8596 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8597 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8598 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8599 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8601 // Should be no damage rects, nothing changed
8602 damagedRects.clear();
8603 application.SendNotification();
8604 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8605 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8607 // Should be 1 damage rect due to change in size
8608 damagedRects.clear();
8609 actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8610 application.SendNotification();
8611 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8612 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8614 clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8615 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8616 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8617 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8618 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8619 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8620 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8622 damagedRects.clear();
8623 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8624 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8629 int utcDaliActorPartialUpdateTwoActors(void)
8631 TestApplication application(
8632 TestApplication::DEFAULT_SURFACE_WIDTH,
8633 TestApplication::DEFAULT_SURFACE_HEIGHT,
8634 TestApplication::DEFAULT_HORIZONTAL_DPI,
8635 TestApplication::DEFAULT_VERTICAL_DPI,
8639 tet_infoline("Check the damaged rects with partial update and two actors");
8641 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8643 Actor actor = CreateRenderableActor();
8644 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8645 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8646 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8647 application.GetScene().Add(actor);
8649 Actor actor2 = CreateRenderableActor();
8650 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8651 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8652 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8653 application.GetScene().Add(actor2);
8655 application.SendNotification();
8656 std::vector<Rect<int>> damagedRects;
8657 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8659 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8660 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8661 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8663 // in screen coordinates, adaptor would calculate it using previous frames information
8664 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8665 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8667 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8668 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8669 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8670 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8672 // Change a Renderer of actor1
8673 Geometry geometry = CreateQuadGeometry();
8674 Shader shader = CreateShader();
8675 Renderer newRenderer = Renderer::New(geometry, shader);
8676 Renderer renderer = actor.GetRendererAt(0);
8678 actor.RemoveRenderer(renderer);
8679 actor.AddRenderer(newRenderer);
8681 damagedRects.clear();
8683 application.SendNotification();
8684 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8686 DALI_TEST_CHECK(damagedRects.size() > 0);
8687 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8689 // in screen coordinates, adaptor would calculate it using previous frames information
8690 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8692 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8693 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8694 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8695 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8700 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8702 TestApplication application(
8703 TestApplication::DEFAULT_SURFACE_WIDTH,
8704 TestApplication::DEFAULT_SURFACE_HEIGHT,
8705 TestApplication::DEFAULT_HORIZONTAL_DPI,
8706 TestApplication::DEFAULT_VERTICAL_DPI,
8710 tet_infoline("Check the damaged rect with partial update and actor size hint");
8712 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8714 Actor actor = CreateRenderableActor();
8715 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
8716 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
8717 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f));
8718 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8719 application.GetScene().Add(actor);
8721 application.SendNotification();
8722 std::vector<Rect<int>> damagedRects;
8723 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8725 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8727 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
8728 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8730 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8732 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8733 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8734 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8735 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8740 int utcDaliActorPartialUpdateAnimation(void)
8742 TestApplication application(
8743 TestApplication::DEFAULT_SURFACE_WIDTH,
8744 TestApplication::DEFAULT_SURFACE_HEIGHT,
8745 TestApplication::DEFAULT_HORIZONTAL_DPI,
8746 TestApplication::DEFAULT_VERTICAL_DPI,
8750 tet_infoline("Check the damaged area with partial update and animation");
8752 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8753 drawTrace.Enable(true);
8756 Actor actor1 = CreateRenderableActor();
8757 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8758 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8759 application.GetScene().Add(actor1);
8761 Actor actor2 = CreateRenderableActor();
8762 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8763 actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8764 application.GetScene().Add(actor2);
8766 std::vector<Rect<int>> damagedRects;
8767 Rect<int> clippingRect;
8768 Rect<int> expectedRect1, expectedRect2;
8770 application.SendNotification();
8771 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8773 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8776 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8777 expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
8778 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8779 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
8781 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8782 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8784 damagedRects.clear();
8785 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8786 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8787 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8789 // Make an animation
8790 Animation animation = Animation::New(1.0f);
8791 animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
8794 application.SendNotification();
8796 damagedRects.clear();
8797 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8798 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8799 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8802 damagedRects.clear();
8804 // In animation deley time
8805 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8806 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8807 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8810 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8813 damagedRects.clear();
8815 // Also in animation deley time
8816 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8817 application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
8818 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8821 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8823 // Unparent 2 actors and make a new actor
8827 Actor actor3 = CreateRenderableActor();
8828 actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8829 actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8830 application.GetScene().Add(actor3);
8832 application.SendNotification();
8834 // Started animation
8835 damagedRects.clear();
8836 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8837 DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION);
8839 // The first dirty rect is actor3's.
8840 // We don't know the exact dirty rect of actor2
8841 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8842 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
8844 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8845 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8847 // Finished animation, but the actor was already unparented
8848 damagedRects.clear();
8849 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8851 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8852 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8854 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8855 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8860 int utcDaliActorPartialUpdateChangeVisibility(void)
8862 TestApplication application(
8863 TestApplication::DEFAULT_SURFACE_WIDTH,
8864 TestApplication::DEFAULT_SURFACE_HEIGHT,
8865 TestApplication::DEFAULT_HORIZONTAL_DPI,
8866 TestApplication::DEFAULT_VERTICAL_DPI,
8870 tet_infoline("Check the damaged rect with partial update and visibility change");
8872 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8874 Actor actor = CreateRenderableActor();
8875 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8876 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8877 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8878 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8879 application.GetScene().Add(actor);
8881 application.SendNotification();
8883 std::vector<Rect<int>> damagedRects;
8884 Rect<int> clippingRect;
8886 // 1. Actor added, damaged rect is added size of actor
8887 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8888 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8891 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8892 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8893 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8894 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8895 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8896 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8897 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8899 damagedRects.clear();
8900 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8901 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8903 damagedRects.clear();
8904 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8905 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8907 // Ensure the damaged rect is empty
8908 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8910 // 2. Make the Actor invisible
8911 actor.SetProperty(Actor::Property::VISIBLE, false);
8912 application.SendNotification();
8914 damagedRects.clear();
8915 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8916 DALI_TEST_CHECK(damagedRects.size() > 0);
8917 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8919 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8920 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8921 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8922 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8923 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8925 // 3. Make the Actor visible again
8926 actor.SetProperty(Actor::Property::VISIBLE, true);
8927 application.SendNotification();
8929 damagedRects.clear();
8930 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8931 DALI_TEST_CHECK(damagedRects.size() > 0);
8932 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8934 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8935 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8936 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8937 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8938 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8943 int utcDaliActorPartialUpdateOnOffScene(void)
8945 TestApplication application(
8946 TestApplication::DEFAULT_SURFACE_WIDTH,
8947 TestApplication::DEFAULT_SURFACE_HEIGHT,
8948 TestApplication::DEFAULT_HORIZONTAL_DPI,
8949 TestApplication::DEFAULT_VERTICAL_DPI,
8953 tet_infoline("Check the damaged rect with partial update and on/off scene");
8955 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8957 Actor actor = CreateRenderableActor();
8958 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8959 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8960 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8961 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8962 application.GetScene().Add(actor);
8964 application.SendNotification();
8966 std::vector<Rect<int>> damagedRects;
8967 Rect<int> clippingRect;
8969 // 1. Actor added, damaged rect is added size of actor
8970 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8971 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8974 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8975 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8976 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8977 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8978 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8979 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8980 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8982 damagedRects.clear();
8983 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8984 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8986 damagedRects.clear();
8987 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8988 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8990 // Ensure the damaged rect is empty
8991 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8993 // 2. Remove the Actor from the Scene
8995 application.SendNotification();
8997 damagedRects.clear();
8998 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8999 DALI_TEST_CHECK(damagedRects.size() > 0);
9000 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9002 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9003 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9004 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9005 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9006 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9008 // 3. Add the Actor to the Scene again
9009 application.GetScene().Add(actor);
9010 application.SendNotification();
9012 damagedRects.clear();
9013 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9014 DALI_TEST_CHECK(damagedRects.size() > 0);
9015 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9017 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9018 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9019 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9020 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9021 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9026 int utcDaliActorPartialUpdateSkipRendering(void)
9028 TestApplication application(
9029 TestApplication::DEFAULT_SURFACE_WIDTH,
9030 TestApplication::DEFAULT_SURFACE_HEIGHT,
9031 TestApplication::DEFAULT_HORIZONTAL_DPI,
9032 TestApplication::DEFAULT_VERTICAL_DPI,
9036 tet_infoline("Check to skip rendering in case of the empty damaged rect");
9038 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9039 drawTrace.Enable(true);
9042 Actor actor1 = CreateRenderableActor();
9043 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9044 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9045 application.GetScene().Add(actor1);
9047 std::vector<Rect<int>> damagedRects;
9048 Rect<int> clippingRect;
9049 Rect<int> expectedRect1;
9051 application.SendNotification();
9052 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9054 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9057 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
9058 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9060 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9061 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9063 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9065 damagedRects.clear();
9066 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9067 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9068 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9073 application.SendNotification();
9075 damagedRects.clear();
9076 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9078 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9080 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9081 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9083 // Render again without any change
9084 damagedRects.clear();
9086 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9088 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9090 clippingRect = Rect<int>();
9091 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9094 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9096 // Add the actor again
9097 application.GetScene().Add(actor1);
9099 application.SendNotification();
9101 damagedRects.clear();
9103 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9105 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9107 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9108 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9110 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9115 int utcDaliActorPartialUpdate3DNode(void)
9117 TestApplication application(
9118 TestApplication::DEFAULT_SURFACE_WIDTH,
9119 TestApplication::DEFAULT_SURFACE_HEIGHT,
9120 TestApplication::DEFAULT_HORIZONTAL_DPI,
9121 TestApplication::DEFAULT_VERTICAL_DPI,
9125 tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9127 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9128 drawTrace.Enable(true);
9131 Actor actor1 = CreateRenderableActor();
9132 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9133 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9134 application.GetScene().Add(actor1);
9136 std::vector<Rect<int>> damagedRects;
9137 Rect<int> clippingRect;
9139 application.SendNotification();
9140 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9142 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9144 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9145 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9147 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9149 // Change the layer to 3D
9150 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9152 application.SendNotification();
9154 damagedRects.clear();
9155 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9157 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9158 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9160 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9162 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9164 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9166 // Change the layer to 2D
9167 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9169 application.SendNotification();
9171 damagedRects.clear();
9172 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9174 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9176 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9177 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9179 // Make 3D transform
9180 actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9182 application.SendNotification();
9184 damagedRects.clear();
9185 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9187 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9188 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9190 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9192 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9194 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9199 int utcDaliActorPartialUpdateNotRenderableActor(void)
9201 TestApplication application(
9202 TestApplication::DEFAULT_SURFACE_WIDTH,
9203 TestApplication::DEFAULT_SURFACE_HEIGHT,
9204 TestApplication::DEFAULT_HORIZONTAL_DPI,
9205 TestApplication::DEFAULT_VERTICAL_DPI,
9209 tet_infoline("Check the damaged rect with not renderable parent actor");
9211 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9213 Actor parent = Actor::New();
9214 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9215 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9216 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9217 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9218 application.GetScene().Add(parent);
9220 Actor child = CreateRenderableActor();
9221 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9222 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9223 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9226 application.SendNotification();
9228 std::vector<Rect<int>> damagedRects;
9230 // 1. Actor added, damaged rect is added size of actor
9231 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9232 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9235 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9236 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9238 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9239 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9240 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9241 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9242 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9244 damagedRects.clear();
9245 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9246 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9248 damagedRects.clear();
9249 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9250 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9252 // Ensure the damaged rect is empty
9253 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9258 int utcDaliActorPartialUpdateChangeTransparency(void)
9260 TestApplication application(
9261 TestApplication::DEFAULT_SURFACE_WIDTH,
9262 TestApplication::DEFAULT_SURFACE_HEIGHT,
9263 TestApplication::DEFAULT_HORIZONTAL_DPI,
9264 TestApplication::DEFAULT_VERTICAL_DPI,
9268 tet_infoline("Check the damaged rect with changing transparency");
9270 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9272 Actor actor = CreateRenderableActor();
9273 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9274 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9275 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9276 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9277 application.GetScene().Add(actor);
9279 application.SendNotification();
9281 std::vector<Rect<int>> damagedRects;
9283 // Actor added, damaged rect is added size of actor
9284 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9285 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9288 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9289 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9291 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9292 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9293 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9294 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9295 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9297 damagedRects.clear();
9298 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9299 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9301 damagedRects.clear();
9302 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9303 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9305 // Make the actor transparent by changing opacity of the Renderer
9306 // It changes a uniform value
9307 Renderer renderer = actor.GetRendererAt(0);
9308 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9310 application.SendNotification();
9312 // The damaged rect should be same
9313 damagedRects.clear();
9314 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9315 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9316 DALI_TEST_CHECK(damagedRects.size() > 0);
9317 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9319 damagedRects.clear();
9320 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9321 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9323 // Ensure the damaged rect is empty
9324 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9326 // Make the actor opaque again
9327 renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9329 application.SendNotification();
9331 // The damaged rect should not be empty
9332 damagedRects.clear();
9333 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9334 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9335 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9336 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9338 damagedRects.clear();
9339 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9340 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9342 damagedRects.clear();
9343 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9344 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9346 // Ensure the damaged rect is empty
9347 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9349 // Make the actor translucent
9350 renderer[DevelRenderer::Property::OPACITY] = 0.5f;
9352 application.SendNotification();
9354 // The damaged rect should not be empty
9355 damagedRects.clear();
9356 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9357 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9358 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9359 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9361 damagedRects.clear();
9362 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9363 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9365 damagedRects.clear();
9366 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9367 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9369 // Ensure the damaged rect is empty
9370 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9372 // Change Renderer opacity - also translucent
9373 renderer[DevelRenderer::Property::OPACITY] = 0.2f;
9375 application.SendNotification();
9377 // The damaged rect should not be empty
9378 damagedRects.clear();
9379 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9380 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9381 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9382 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9384 damagedRects.clear();
9385 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9386 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9388 damagedRects.clear();
9389 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9390 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9392 // Ensure the damaged rect is empty
9393 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9395 // Make the actor culled
9396 actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9398 application.SendNotification();
9400 // The damaged rect should be same
9401 damagedRects.clear();
9402 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9403 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9404 DALI_TEST_CHECK(damagedRects.size() > 0);
9405 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9407 damagedRects.clear();
9408 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9409 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9411 // Ensure the damaged rect is empty
9412 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9414 // Make the actor not culled again
9415 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
9417 application.SendNotification();
9419 // The damaged rect should not be empty
9420 damagedRects.clear();
9421 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9422 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9423 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9424 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9429 int utcDaliActorPartialUpdateChangeParentOpacity(void)
9431 TestApplication application(
9432 TestApplication::DEFAULT_SURFACE_WIDTH,
9433 TestApplication::DEFAULT_SURFACE_HEIGHT,
9434 TestApplication::DEFAULT_HORIZONTAL_DPI,
9435 TestApplication::DEFAULT_VERTICAL_DPI,
9439 tet_infoline("Check the damaged rect with changing parent's opacity");
9441 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9443 Actor parent = Actor::New();
9444 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9445 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9446 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9447 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9448 application.GetScene().Add(parent);
9450 Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
9451 Actor child = CreateRenderableActor(texture);
9452 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9453 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9454 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9457 application.SendNotification();
9459 std::vector<Rect<int>> damagedRects;
9461 // Actor added, damaged rect is added size of actor
9462 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9463 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9466 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9467 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9469 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9470 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9471 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9472 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9473 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9475 damagedRects.clear();
9476 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9477 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9479 damagedRects.clear();
9480 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9481 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9483 // Ensure the damaged rect is empty
9484 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9486 // Change the parent's opacity
9487 parent[Actor::Property::OPACITY] = 0.5f;
9489 application.SendNotification();
9491 // The damaged rect should be same
9492 damagedRects.clear();
9493 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9494 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9495 DALI_TEST_CHECK(damagedRects.size() > 0);
9496 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9501 int utcDaliActorPartialAddRemoveRenderer(void)
9503 TestApplication application(
9504 TestApplication::DEFAULT_SURFACE_WIDTH,
9505 TestApplication::DEFAULT_SURFACE_HEIGHT,
9506 TestApplication::DEFAULT_HORIZONTAL_DPI,
9507 TestApplication::DEFAULT_VERTICAL_DPI,
9511 tet_infoline("Check the damaged rect with adding / removing renderer");
9513 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9515 Actor actor = CreateRenderableActor();
9516 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9517 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9518 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9519 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9520 application.GetScene().Add(actor);
9522 application.SendNotification();
9524 std::vector<Rect<int>> damagedRects;
9526 // Actor added, damaged rect is added size of actor
9527 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9528 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9531 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9532 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9534 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9535 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9536 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9537 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9538 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9540 damagedRects.clear();
9541 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9542 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9544 damagedRects.clear();
9545 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9546 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9548 // Remove the Renderer
9549 Renderer renderer = actor.GetRendererAt(0);
9550 actor.RemoveRenderer(renderer);
9552 application.SendNotification();
9554 // The damaged rect should be the actor area
9555 damagedRects.clear();
9556 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9557 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9558 DALI_TEST_CHECK(damagedRects.size() > 0);
9559 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9561 damagedRects.clear();
9562 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9563 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9565 // Ensure the damaged rect is empty
9566 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9568 // Add the Renderer again
9569 actor.AddRenderer(renderer);
9571 application.SendNotification();
9573 // The damaged rect should be the actor area
9574 damagedRects.clear();
9575 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9576 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9577 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9578 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9583 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
9585 TestApplication application;
9587 Actor actor = Actor::New();
9588 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
9589 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
9590 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
9591 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
9592 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
9593 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9594 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9595 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
9599 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
9601 TestApplication application;
9603 Actor actor = Actor::New();
9605 // Make sure setting invalid types does not cause a crash
9608 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
9609 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
9610 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
9611 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
9612 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
9613 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
9614 tet_result(TET_PASS);
9618 tet_result(TET_FAIL);
9623 int UtcDaliActorTouchAreaOffsetPropertyP(void)
9625 TestApplication application;
9627 Actor actor = Actor::New();
9628 Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9629 DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
9630 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
9631 touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9632 DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
9636 int UtcDaliActorTouchAreaOffsetPropertyN(void)
9638 TestApplication application;
9640 Actor actor = Actor::New();
9642 // Make sure setting invalid types does not cause a crash
9645 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
9646 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
9647 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
9648 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
9649 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
9650 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
9651 tet_result(TET_PASS);
9655 tet_result(TET_FAIL);
9660 int UtcDaliActorLowerBelowNegative(void)
9662 TestApplication application;
9663 Dali::Actor instance;
9667 instance.LowerBelow(arg1);
9668 DALI_TEST_CHECK(false); // Should not get here
9672 DALI_TEST_CHECK(true); // We expect an assert
9677 int UtcDaliActorRaiseAboveNegative(void)
9679 TestApplication application;
9680 Dali::Actor instance;
9684 instance.RaiseAbove(arg1);
9685 DALI_TEST_CHECK(false); // Should not get here
9689 DALI_TEST_CHECK(true); // We expect an assert
9694 int UtcDaliActorRaiseToTopNegative(void)
9696 TestApplication application;
9697 Dali::Actor instance;
9700 instance.RaiseToTop();
9701 DALI_TEST_CHECK(false); // Should not get here
9705 DALI_TEST_CHECK(true); // We expect an assert
9710 int UtcDaliActorAddRendererNegative(void)
9712 TestApplication application;
9713 Dali::Actor instance;
9716 Dali::Renderer arg1;
9717 instance.AddRenderer(arg1);
9718 DALI_TEST_CHECK(false); // Should not get here
9722 DALI_TEST_CHECK(true); // We expect an assert
9727 int UtcDaliActorTouchedSignalNegative(void)
9729 TestApplication application;
9730 Dali::Actor instance;
9733 instance.TouchedSignal();
9734 DALI_TEST_CHECK(false); // Should not get here
9738 DALI_TEST_CHECK(true); // We expect an assert
9743 int UtcDaliActorTranslateByNegative(void)
9745 TestApplication application;
9746 Dali::Actor instance;
9750 instance.TranslateBy(arg1);
9751 DALI_TEST_CHECK(false); // Should not get here
9755 DALI_TEST_CHECK(true); // We expect an assert
9760 int UtcDaliActorFindChildByIdNegative(void)
9762 TestApplication application;
9763 Dali::Actor instance;
9766 unsigned int arg1 = 0u;
9767 instance.FindChildById(arg1);
9768 DALI_TEST_CHECK(false); // Should not get here
9772 DALI_TEST_CHECK(true); // We expect an assert
9777 int UtcDaliActorGetRendererAtNegative(void)
9779 TestApplication application;
9780 Dali::Actor instance;
9783 unsigned int arg1 = 0u;
9784 instance.GetRendererAt(arg1);
9785 DALI_TEST_CHECK(false); // Should not get here
9789 DALI_TEST_CHECK(true); // We expect an assert
9794 int UtcDaliActorHoveredSignalNegative(void)
9796 TestApplication application;
9797 Dali::Actor instance;
9800 instance.HoveredSignal();
9801 DALI_TEST_CHECK(false); // Should not get here
9805 DALI_TEST_CHECK(true); // We expect an assert
9810 int UtcDaliActorLowerToBottomNegative(void)
9812 TestApplication application;
9813 Dali::Actor instance;
9816 instance.LowerToBottom();
9817 DALI_TEST_CHECK(false); // Should not get here
9821 DALI_TEST_CHECK(true); // We expect an assert
9826 int UtcDaliActorOnSceneSignalNegative(void)
9828 TestApplication application;
9829 Dali::Actor instance;
9832 instance.OnSceneSignal();
9833 DALI_TEST_CHECK(false); // Should not get here
9837 DALI_TEST_CHECK(true); // We expect an assert
9842 int UtcDaliActorOffSceneSignalNegative(void)
9844 TestApplication application;
9845 Dali::Actor instance;
9848 instance.OffSceneSignal();
9849 DALI_TEST_CHECK(false); // Should not get here
9853 DALI_TEST_CHECK(true); // We expect an assert
9858 int UtcDaliActorRemoveRendererNegative01(void)
9860 TestApplication application;
9861 Dali::Actor instance;
9864 unsigned int arg1 = 0u;
9865 instance.RemoveRenderer(arg1);
9866 DALI_TEST_CHECK(false); // Should not get here
9870 DALI_TEST_CHECK(true); // We expect an assert
9875 int UtcDaliActorRemoveRendererNegative02(void)
9877 TestApplication application;
9878 Dali::Actor instance;
9881 Dali::Renderer arg1;
9882 instance.RemoveRenderer(arg1);
9883 DALI_TEST_CHECK(false); // Should not get here
9887 DALI_TEST_CHECK(true); // We expect an assert
9892 int UtcDaliActorFindChildByNameNegative(void)
9894 TestApplication application;
9895 Dali::Actor instance;
9899 instance.FindChildByName(arg1);
9900 DALI_TEST_CHECK(false); // Should not get here
9904 DALI_TEST_CHECK(true); // We expect an assert
9909 int UtcDaliActorSetResizePolicyNegative(void)
9911 TestApplication application;
9912 Dali::Actor instance;
9915 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
9916 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
9917 instance.SetResizePolicy(arg1, arg2);
9918 DALI_TEST_CHECK(false); // Should not get here
9922 DALI_TEST_CHECK(true); // We expect an assert
9927 int UtcDaliActorOnRelayoutSignalNegative(void)
9929 TestApplication application;
9930 Dali::Actor instance;
9933 instance.OnRelayoutSignal();
9934 DALI_TEST_CHECK(false); // Should not get here
9938 DALI_TEST_CHECK(true); // We expect an assert
9943 int UtcDaliActorWheelEventSignalNegative(void)
9945 TestApplication application;
9946 Dali::Actor instance;
9949 instance.WheelEventSignal();
9950 DALI_TEST_CHECK(false); // Should not get here
9954 DALI_TEST_CHECK(true); // We expect an assert
9959 int UtcDaliActorGetHeightForWidthNegative(void)
9961 TestApplication application;
9962 Dali::Actor instance;
9966 instance.GetHeightForWidth(arg1);
9967 DALI_TEST_CHECK(false); // Should not get here
9971 DALI_TEST_CHECK(true); // We expect an assert
9976 int UtcDaliActorGetWidthForHeightNegative(void)
9978 TestApplication application;
9979 Dali::Actor instance;
9983 instance.GetWidthForHeight(arg1);
9984 DALI_TEST_CHECK(false); // Should not get here
9988 DALI_TEST_CHECK(true); // We expect an assert
9993 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
9995 TestApplication application;
9996 Dali::Actor instance;
9999 instance.LayoutDirectionChangedSignal();
10000 DALI_TEST_CHECK(false); // Should not get here
10004 DALI_TEST_CHECK(true); // We expect an assert
10009 int UtcDaliActorAddNegative(void)
10011 TestApplication application;
10012 Dali::Actor instance;
10016 instance.Add(arg1);
10017 DALI_TEST_CHECK(false); // Should not get here
10021 DALI_TEST_CHECK(true); // We expect an assert
10026 int UtcDaliActorLowerNegative(void)
10028 TestApplication application;
10029 Dali::Actor instance;
10033 DALI_TEST_CHECK(false); // Should not get here
10037 DALI_TEST_CHECK(true); // We expect an assert
10042 int UtcDaliActorRaiseNegative(void)
10044 TestApplication application;
10045 Dali::Actor instance;
10049 DALI_TEST_CHECK(false); // Should not get here
10053 DALI_TEST_CHECK(true); // We expect an assert
10058 int UtcDaliActorRemoveNegative(void)
10060 TestApplication application;
10061 Dali::Actor instance;
10065 instance.Remove(arg1);
10066 DALI_TEST_CHECK(false); // Should not get here
10070 DALI_TEST_CHECK(true); // We expect an assert
10075 int UtcDaliActorScaleByNegative(void)
10077 TestApplication application;
10078 Dali::Actor instance;
10081 Dali::Vector3 arg1;
10082 instance.ScaleBy(arg1);
10083 DALI_TEST_CHECK(false); // Should not get here
10087 DALI_TEST_CHECK(true); // We expect an assert
10092 int UtcDaliActorGetLayerNegative(void)
10094 TestApplication application;
10095 Dali::Actor instance;
10098 instance.GetLayer();
10099 DALI_TEST_CHECK(false); // Should not get here
10103 DALI_TEST_CHECK(true); // We expect an assert
10108 int UtcDaliActorRotateByNegative01(void)
10110 TestApplication application;
10111 Dali::Actor instance;
10114 Dali::Quaternion arg1;
10115 instance.RotateBy(arg1);
10116 DALI_TEST_CHECK(false); // Should not get here
10120 DALI_TEST_CHECK(true); // We expect an assert
10125 int UtcDaliActorRotateByNegative02(void)
10127 TestApplication application;
10128 Dali::Actor instance;
10132 Dali::Vector3 arg2;
10133 instance.RotateBy(arg1, arg2);
10134 DALI_TEST_CHECK(false); // Should not get here
10138 DALI_TEST_CHECK(true); // We expect an assert
10143 int UtcDaliActorUnparentNegative(void)
10145 TestApplication application;
10146 Dali::Actor instance;
10149 instance.Unparent();
10150 DALI_TEST_CHECK(false); // Should not get here
10154 DALI_TEST_CHECK(true); // We expect an assert
10159 int UtcDaliActorGetChildAtNegative(void)
10161 TestApplication application;
10162 Dali::Actor instance;
10165 unsigned int arg1 = 0u;
10166 instance.GetChildAt(arg1);
10167 DALI_TEST_CHECK(false); // Should not get here
10171 DALI_TEST_CHECK(true); // We expect an assert
10176 int UtcDaliActorGetChildCountNegative(void)
10178 TestApplication application;
10179 Dali::Actor instance;
10182 instance.GetChildCount();
10183 DALI_TEST_CHECK(false); // Should not get here
10187 DALI_TEST_CHECK(true); // We expect an assert
10192 int UtcDaliActorGetTargetSizeNegative(void)
10194 TestApplication application;
10195 Dali::Actor instance;
10198 instance.GetTargetSize();
10199 DALI_TEST_CHECK(false); // Should not get here
10203 DALI_TEST_CHECK(true); // We expect an assert
10208 int UtcDaliActorScreenToLocalNegative(void)
10210 TestApplication application;
10211 Dali::Actor instance;
10218 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
10219 DALI_TEST_CHECK(false); // Should not get here
10223 DALI_TEST_CHECK(true); // We expect an assert
10228 int UtcDaliActorGetNaturalSizeNegative(void)
10230 TestApplication application;
10231 Dali::Actor instance;
10234 instance.GetNaturalSize();
10235 DALI_TEST_CHECK(false); // Should not get here
10239 DALI_TEST_CHECK(true); // We expect an assert
10244 int UtcDaliActorGetRelayoutSizeNegative(void)
10246 TestApplication application;
10247 Dali::Actor instance;
10250 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
10251 instance.GetRelayoutSize(arg1);
10252 DALI_TEST_CHECK(false); // Should not get here
10256 DALI_TEST_CHECK(true); // We expect an assert
10261 int UtcDaliActorGetResizePolicyNegative(void)
10263 TestApplication application;
10264 Dali::Actor instance;
10267 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
10268 instance.GetResizePolicy(arg1);
10269 DALI_TEST_CHECK(false); // Should not get here
10273 DALI_TEST_CHECK(true); // We expect an assert
10278 int UtcDaliActorGetRendererCountNegative(void)
10280 TestApplication application;
10281 Dali::Actor instance;
10284 instance.GetRendererCount();
10285 DALI_TEST_CHECK(false); // Should not get here
10289 DALI_TEST_CHECK(true); // We expect an assert
10294 int UtcDaliActorGetParentNegative(void)
10296 TestApplication application;
10297 Dali::Actor instance;
10300 instance.GetParent();
10301 DALI_TEST_CHECK(false); // Should not get here
10305 DALI_TEST_CHECK(true); // We expect an assert
10310 int UtcDaliActorPropertyBlendEquation(void)
10312 TestApplication application;
10314 tet_infoline("Test SetProperty AdvancedBlendEquation");
10316 Geometry geometry = CreateQuadGeometry();
10317 Shader shader = CreateShader();
10318 Renderer renderer1 = Renderer::New(geometry, shader);
10320 Actor actor = Actor::New();
10321 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
10323 actor.AddRenderer(renderer1);
10324 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
10325 application.GetScene().Add(actor);
10327 if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10329 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10330 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10331 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
10334 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10336 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10337 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10338 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
10341 Renderer renderer2 = Renderer::New(geometry, shader);
10342 actor.AddRenderer(renderer2);
10347 int UtcDaliActorRegisterProperty(void)
10349 tet_infoline("Test property registration and uniform map update\n");
10351 TestApplication application;
10353 Geometry geometry = CreateQuadGeometry();
10354 Shader shader = CreateShader();
10355 Renderer renderer1 = Renderer::New(geometry, shader);
10356 Renderer renderer2 = Renderer::New(geometry, shader);
10358 Actor actor1 = Actor::New();
10359 actor1.AddRenderer(renderer1);
10360 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10361 actor1.RegisterProperty("uCustom", 1);
10362 application.GetScene().Add(actor1);
10364 Actor actor2 = Actor::New();
10365 actor2.AddRenderer(renderer2);
10366 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10367 application.GetScene().Add(actor2);
10369 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
10370 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
10371 glAbstraction.EnableSetUniformCallTrace(true);
10373 application.SendNotification();
10374 application.Render();
10376 std::stringstream out;
10378 std::string params;
10380 // Test uniform value of the custom property
10381 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10382 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10385 actor1[Actor::Property::VISIBLE] = false;
10387 application.SendNotification();
10388 application.Render();
10390 // Make visible again
10391 actor1[Actor::Property::VISIBLE] = true;
10392 actor1["uCustom"] = 2;
10394 glAbstraction.ResetSetUniformCallStack();
10396 application.SendNotification();
10397 application.Render();
10401 // The uniform value should not be changed
10402 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10403 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10408 int UtcDaliActorDoesWantedHitTest(void)
10413 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
10415 mTouchPoint(touchPoint),
10421 Vector2 mTouchPoint;
10425 TestApplication application;
10426 tet_infoline(" UtcDaliActorDoesWantedHitTest");
10428 // Fill a vector with different hit tests.
10429 struct HitTestData* hitTestData[] = {
10430 // scale touch point result
10431 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
10432 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
10433 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.
10434 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
10435 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.
10439 // get the root layer
10440 Actor actor = Actor::New();
10441 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
10442 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
10444 Actor lowerActor = Actor::New();
10445 lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
10446 lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
10448 // actor and lowerActor have no relationship.
10449 application.GetScene().Add(lowerActor);
10450 application.GetScene().Add(actor);
10452 ResetTouchCallbacks();
10453 gHitTestTouchCallBackCalled = false;
10455 unsigned int index = 0;
10456 while(NULL != hitTestData[index])
10458 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
10459 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
10461 lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
10462 lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
10464 // flush the queue and render once
10465 application.SendNotification();
10466 application.Render();
10468 DALI_TEST_CHECK(!gTouchCallBackCalled);
10469 DALI_TEST_CHECK(!gTouchCallBackCalled2);
10470 DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
10472 // connect to its touch signal
10473 actor.TouchedSignal().Connect(TestTouchCallback);
10474 lowerActor.TouchedSignal().Connect(TestTouchCallback2);
10476 // connect to its hit-test signal
10477 Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
10479 Dali::Integration::Point point;
10480 point.SetState(PointState::DOWN);
10481 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
10482 Dali::Integration::TouchEvent event;
10483 event.AddPoint(point);
10485 // flush the queue and render once
10486 application.SendNotification();
10487 application.Render();
10488 application.ProcessEvent(event);
10490 // check hit-test events
10491 DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
10492 // Passed all hit-tests of actor.
10493 DALI_TEST_CHECK(gTouchCallBackCalled == false);
10494 // The lowerActor was hit-tested.
10495 DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
10497 if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
10498 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
10499 hitTestData[index]->mScale.x,
10500 hitTestData[index]->mScale.y,
10501 hitTestData[index]->mScale.z,
10502 hitTestData[index]->mTouchPoint.x,
10503 hitTestData[index]->mTouchPoint.y,
10504 hitTestData[index]->mResult);
10506 ResetTouchCallbacks();
10507 gHitTestTouchCallBackCalled = false;
10513 int UtcDaliActorAllowOnlyOwnTouchPropertyP(void)
10515 TestApplication application;
10517 Actor actor = Actor::New();
10518 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), false, TEST_LOCATION);
10519 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true);
10520 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get<bool>(), true, TEST_LOCATION);
10521 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION);
10522 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION);
10523 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
10524 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION);
10525 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION);
10529 int UtcDaliActorAllowOnlyOwnTouchPropertyN(void)
10531 TestApplication application;
10533 Actor actor = Actor::New();
10535 // Make sure setting invalid types does not cause a crash
10538 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f);
10539 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE);
10540 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE);
10541 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE);
10542 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map());
10543 actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array());
10544 tet_result(TET_PASS);
10548 tet_result(TET_FAIL);