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 utcDaliActorPositionUsesAnchorPoint(void)
7048 TestApplication application;
7049 tet_infoline("Check default behaviour\n");
7051 Actor actor = Actor::New();
7052 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7053 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7054 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7055 application.GetScene().Add(actor);
7057 application.SendNotification();
7058 application.Render();
7060 tet_infoline("Check that the world position is in the center\n");
7061 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7063 tet_infoline("Set the position uses anchor point property to false\n");
7064 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7066 application.SendNotification();
7067 application.Render();
7069 tet_infoline("Check that the world position has changed appropriately\n");
7070 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7075 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7077 TestApplication application;
7078 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7080 Actor actor = Actor::New();
7081 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7082 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7083 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7084 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7085 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7086 application.GetScene().Add(actor);
7088 application.SendNotification();
7089 application.Render();
7091 tet_infoline("Check the world position is the same as it would be without a scale\n");
7092 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7094 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7095 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7096 application.SendNotification();
7097 application.Render();
7098 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7100 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7101 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7102 application.SendNotification();
7103 application.Render();
7104 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7109 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7111 TestApplication application;
7112 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7114 Actor actor = Actor::New();
7115 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7116 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7117 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7118 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7119 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7120 application.GetScene().Add(actor);
7122 application.SendNotification();
7123 application.Render();
7125 tet_infoline("Check the world position is the same as it would be without a rotation\n");
7126 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7128 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7129 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7130 application.SendNotification();
7131 application.Render();
7132 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7134 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7135 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7136 application.SendNotification();
7137 application.Render();
7138 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7143 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7145 TestApplication application;
7146 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7148 Actor actor = Actor::New();
7149 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7150 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7151 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7152 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7153 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7154 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7155 application.GetScene().Add(actor);
7157 application.SendNotification();
7158 application.Render();
7160 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7161 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7163 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7164 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7165 application.SendNotification();
7166 application.Render();
7167 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7169 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7170 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7171 application.SendNotification();
7172 application.Render();
7173 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7178 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7180 TestApplication application;
7181 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7183 Actor parent = Actor::New();
7185 application.GetScene().Add(parent);
7186 Vector2 stageSize(application.GetScene().GetSize());
7188 Actor actor = Actor::New();
7189 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7190 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7191 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7192 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7193 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7194 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7197 application.SendNotification();
7198 application.Render();
7200 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7202 tet_infoline("Check the world position is in the right place\n");
7203 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7205 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7206 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7207 application.SendNotification();
7208 application.Render();
7209 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7211 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7212 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7213 application.SendNotification();
7214 application.Render();
7215 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7220 int utcDaliActorVisibilityChangeSignalSelf(void)
7222 TestApplication application;
7223 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7225 Actor actor = Actor::New();
7227 VisibilityChangedFunctorData data;
7228 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7230 actor.SetProperty(Actor::Property::VISIBLE, false);
7232 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7234 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7237 actor.SetProperty(Actor::Property::VISIBLE, false);
7238 data.Check(false /* not called */, TEST_LOCATION);
7240 tet_infoline("Change the visibility using properties, ensure called");
7243 actor.SetProperty(Actor::Property::VISIBLE, true);
7244 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7246 tet_infoline("Set the visibility to current using properties, ensure not called");
7249 actor.SetProperty(Actor::Property::VISIBLE, true);
7250 data.Check(false /* not called */, TEST_LOCATION);
7255 int utcDaliActorVisibilityChangeSignalChildren(void)
7257 TestApplication application;
7258 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7260 Actor parent = Actor::New();
7261 Actor child = Actor::New();
7264 Actor grandChild = Actor::New();
7265 child.Add(grandChild);
7267 VisibilityChangedFunctorData parentData;
7268 VisibilityChangedFunctorData childData;
7269 VisibilityChangedFunctorData grandChildData;
7271 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7272 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7273 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7275 parent.SetProperty(Actor::Property::VISIBLE, false);
7276 parentData.Check(false /* not called */, TEST_LOCATION);
7277 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7278 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7280 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7283 grandChildData.Reset();
7285 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7287 parent.SetProperty(Actor::Property::VISIBLE, true);
7288 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7289 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7290 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7292 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7295 grandChildData.Reset();
7297 parent.SetProperty(Actor::Property::VISIBLE, true);
7298 parentData.Check(false /* not called */, TEST_LOCATION);
7299 childData.Check(false /* not called */, TEST_LOCATION);
7300 grandChildData.Check(false /* not called */, TEST_LOCATION);
7305 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7307 TestApplication application;
7308 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7310 Actor actor = Actor::New();
7311 application.GetScene().Add(actor);
7313 application.SendNotification();
7314 application.Render();
7316 VisibilityChangedFunctorData data;
7317 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7319 Animation animation = Animation::New(1.0f);
7320 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7322 data.Check(false, TEST_LOCATION);
7323 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7324 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7326 tet_infoline("Play the animation and check the property value");
7329 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7330 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7332 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7333 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7335 application.SendNotification();
7336 application.Render(1100); // After the animation
7338 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7343 int utcDaliActorVisibilityChangeSignalByName(void)
7345 TestApplication application;
7346 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7348 Actor actor = Actor::New();
7350 bool signalCalled = false;
7351 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7352 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7353 actor.SetProperty(Actor::Property::VISIBLE, false);
7354 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7356 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7357 signalCalled = false;
7358 actor.SetProperty(Actor::Property::VISIBLE, false);
7359 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7361 tet_infoline("Change the visibility using properties, ensure called");
7362 actor.SetProperty(Actor::Property::VISIBLE, true);
7363 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7365 tet_infoline("Set the visibility to current using properties, ensure not called");
7366 signalCalled = false;
7368 actor.SetProperty(Actor::Property::VISIBLE, true);
7369 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7374 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7376 gLayoutDirectionType = type;
7379 int UtcDaliActorLayoutDirectionProperty(void)
7381 TestApplication application;
7382 tet_infoline("Check layout direction property");
7384 Actor actor0 = Actor::New();
7385 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7386 application.GetScene().Add(actor0);
7388 application.SendNotification();
7389 application.Render();
7391 Actor actor1 = Actor::New();
7392 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7393 Actor actor2 = Actor::New();
7394 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7395 Actor actor3 = Actor::New();
7396 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7397 Actor actor4 = Actor::New();
7398 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7399 Actor actor5 = Actor::New();
7400 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7401 Actor actor6 = Actor::New();
7402 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7403 Actor actor7 = Actor::New();
7404 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7405 Actor actor8 = Actor::New();
7406 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7407 Actor actor9 = Actor::New();
7408 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7411 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7412 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7414 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7415 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7416 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7418 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7419 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7420 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7422 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7424 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7425 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7427 application.GetScene().Add(actor3);
7434 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7435 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7437 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7438 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7439 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7441 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7443 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7444 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7445 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7446 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7447 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7448 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7449 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7451 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7452 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7453 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7455 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7456 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7457 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7458 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7460 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7461 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7462 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7467 struct LayoutDirectionFunctor
7469 LayoutDirectionFunctor(bool& signalCalled)
7470 : mSignalCalled(signalCalled)
7474 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7475 : mSignalCalled(rhs.mSignalCalled)
7481 mSignalCalled = true;
7484 bool& mSignalCalled;
7487 int UtcDaliActorLayoutDirectionSignal(void)
7489 TestApplication application;
7490 tet_infoline("Check changing layout direction property sends a signal");
7492 Actor actor = Actor::New();
7493 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7494 application.GetScene().Add(actor);
7495 bool signalCalled = false;
7496 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7498 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7499 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7501 // Test that writing the same value doesn't send a signal
7502 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7503 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7505 // Test that writing a different value sends the signal
7506 signalCalled = false;
7507 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7508 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7510 signalCalled = false;
7511 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7512 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7517 struct ChildAddedSignalCheck
7519 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7520 : mSignalReceived(signalReceived),
7521 mChildHandle(childHandle)
7525 void operator()(Actor childHandle)
7527 mSignalReceived = true;
7528 mChildHandle = childHandle;
7532 mSignalReceived = true;
7533 mChildHandle = Actor();
7536 bool& mSignalReceived;
7537 Actor& mChildHandle;
7540 int UtcDaliChildAddedSignalP1(void)
7542 TestApplication application;
7543 auto stage = application.GetScene();
7545 bool signalReceived = false;
7548 ChildAddedSignalCheck signal(signalReceived, childActor);
7549 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7550 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7552 auto actorA = Actor::New();
7554 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7555 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7556 signalReceived = false;
7558 auto actorB = Actor::New();
7560 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7561 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7566 int UtcDaliChildAddedSignalP2(void)
7568 TestApplication application;
7569 auto stage = application.GetScene();
7571 bool signalReceived = false;
7574 ChildAddedSignalCheck signal(signalReceived, childActor);
7575 tet_infoline("Connect to childAdded signal by name");
7577 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7578 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7580 auto actorA = Actor::New();
7582 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7584 // Can't test which actor was added; signal signature is void() when connecting via name.
7585 signalReceived = false;
7587 auto actorB = Actor::New();
7589 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7594 int UtcDaliChildAddedSignalN(void)
7596 TestApplication application;
7597 auto stage = application.GetScene();
7599 bool signalReceived = false;
7602 ChildAddedSignalCheck signal(signalReceived, childActor);
7603 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7604 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7606 auto actorA = Actor::New();
7608 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7609 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7610 signalReceived = false;
7612 auto actorB = Actor::New();
7614 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7618 struct ChildRemovedSignalCheck
7620 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7621 : mSignalReceived(signalReceived),
7622 mChildHandle(childHandle)
7626 void operator()(Actor childHandle)
7628 mSignalReceived = true;
7629 mChildHandle = childHandle;
7634 mSignalReceived = true;
7637 bool& mSignalReceived;
7638 Actor& mChildHandle;
7641 int UtcDaliChildRemovedSignalP1(void)
7643 TestApplication application;
7644 auto stage = application.GetScene();
7646 bool signalReceived = false;
7649 ChildRemovedSignalCheck signal(signalReceived, childActor);
7650 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7651 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7653 auto actorA = Actor::New();
7655 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7656 DALI_TEST_CHECK(!childActor);
7658 stage.Remove(actorA);
7659 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7660 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7662 signalReceived = false;
7663 auto actorB = Actor::New();
7665 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7667 stage.Remove(actorB);
7668 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7669 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7674 int UtcDaliChildRemovedSignalP2(void)
7676 TestApplication application;
7677 auto stage = application.GetScene();
7679 bool signalReceived = false;
7682 ChildAddedSignalCheck signal(signalReceived, childActor);
7683 tet_infoline("Connect to childRemoved signal by name");
7685 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7686 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7688 auto actorA = Actor::New();
7690 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7692 stage.Remove(actorA);
7693 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7695 signalReceived = false;
7696 auto actorB = Actor::New();
7698 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7700 stage.Remove(actorB);
7701 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7706 int UtcDaliChildRemovedSignalN(void)
7708 TestApplication application;
7709 auto stage = application.GetScene();
7711 bool signalReceived = false;
7714 ChildRemovedSignalCheck signal(signalReceived, childActor);
7715 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7716 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7718 auto actorA = Actor::New();
7721 auto actorB = Actor::New();
7724 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7725 DALI_TEST_CHECK(!childActor);
7727 actorA.Remove(actorB);
7728 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7732 int UtcDaliChildMovedSignalP(void)
7734 TestApplication application;
7735 auto stage = application.GetScene();
7737 bool addedASignalReceived = false;
7738 bool removedASignalReceived = false;
7739 bool addedBSignalReceived = false;
7740 bool removedBSignalReceived = false;
7743 auto actorA = Actor::New();
7744 auto actorB = Actor::New();
7748 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
7749 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7750 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
7751 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7753 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7754 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7755 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7756 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7758 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7759 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7760 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7761 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7763 // Create a child of A
7765 auto child = Actor::New();
7768 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7769 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7770 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7771 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7772 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7775 addedASignalReceived = false;
7776 addedBSignalReceived = false;
7777 removedASignalReceived = false;
7778 removedBSignalReceived = false;
7780 actorB.Add(child); // Expect this child to be re-parented
7781 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7782 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7783 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7784 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7786 // Move child back to A:
7787 addedASignalReceived = false;
7788 addedBSignalReceived = false;
7789 removedASignalReceived = false;
7790 removedBSignalReceived = false;
7792 actorA.Add(child); // Expect this child to be re-parented
7793 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7794 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7795 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7796 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7801 int UtcDaliActorSwitchParentP(void)
7803 tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
7804 TestApplication application;
7806 Actor parent1 = Actor::New();
7807 Actor child = Actor::New();
7809 application.GetScene().Add(parent1);
7811 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7813 child.OnSceneSignal().Connect(OnSceneCallback);
7814 child.OffSceneSignal().Connect(OffSceneCallback);
7817 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
7818 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7822 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
7824 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7825 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7827 Actor parent2 = Actor::New();
7828 application.GetScene().Add(parent2);
7830 bool addSignalReceived = false;
7831 ChildAddedSignalCheck addedSignal(addSignalReceived, child);
7832 DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
7833 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7835 bool removedSignalReceived = false;
7836 ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
7837 DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
7838 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7840 DevelActor::SwitchParent(child, parent2);
7842 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7843 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7845 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7846 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
7848 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7849 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7850 DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
7851 DALI_TEST_CHECK(child.GetParent() == parent2);
7856 int utcDaliActorCulled(void)
7858 TestApplication application;
7859 auto stage = application.GetScene();
7861 tet_infoline("Check that the actor is culled if the actor is out of the screen");
7863 Actor actor = Actor::New();
7864 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7866 Geometry geometry = CreateQuadGeometry();
7867 Shader shader = CreateShader();
7868 Renderer renderer = Renderer::New(geometry, shader);
7869 actor.AddRenderer(renderer);
7873 application.SendNotification();
7874 application.Render(0);
7876 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7878 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7879 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7881 // Connect NotifySignal
7882 bool propertyNotificationSignal(false);
7883 PropertyNotification source;
7884 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7885 notification.NotifySignal().Connect(&application, f);
7887 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7889 application.SendNotification();
7890 application.Render();
7892 application.SendNotification();
7894 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7896 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7897 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7898 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7903 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7905 TestApplication application;
7906 auto stage = application.GetScene();
7908 tet_infoline("Ensure we clear the screen when the last actor is removed");
7910 Actor actor = CreateRenderableActor();
7911 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7914 application.SendNotification();
7915 application.Render();
7917 auto& glAbstraction = application.GetGlAbstraction();
7918 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7922 application.SendNotification();
7923 application.Render();
7925 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7930 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7932 TestApplication application;
7933 auto stage = application.GetScene();
7935 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7937 Actor actor = CreateRenderableActor();
7938 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7941 application.SendNotification();
7942 application.Render();
7944 auto& glAbstraction = application.GetGlAbstraction();
7945 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7947 actor.SetProperty(Actor::Property::VISIBLE, false);
7949 application.SendNotification();
7950 application.Render();
7952 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7957 int utcDaliActorGetSizeAfterAnimation(void)
7959 TestApplication application;
7960 tet_infoline("Check the actor size before / after an animation is finished");
7962 Vector3 actorSize(100.0f, 100.0f, 0.0f);
7964 Actor actor = Actor::New();
7965 actor.SetProperty(Actor::Property::SIZE, actorSize);
7966 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7967 application.GetScene().Add(actor);
7969 // Size should be updated without rendering.
7970 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7971 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7973 application.SendNotification();
7974 application.Render();
7976 // Size and current size should be updated.
7977 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7978 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7979 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7980 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7981 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7983 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7984 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7985 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7986 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7987 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7990 actorSize = Vector3(200.0f, 200.0f, 0.0f);
7991 actor.SetProperty(Actor::Property::SIZE, actorSize);
7993 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7994 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7996 Vector3 targetValue(10.0f, 20.0f, 0.0f);
7998 Animation animation = Animation::New(1.0f);
7999 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8002 // Size should be updated without rendering.
8003 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8004 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8006 application.SendNotification();
8007 application.Render(1100); // After the animation
8009 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8010 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8011 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8012 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8013 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8015 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8016 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8017 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8018 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8019 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8021 targetValue.width = 50.0f;
8024 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8027 application.SendNotification();
8028 application.Render(1100); // After the animation
8030 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8031 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8032 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8033 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8034 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8036 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8037 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8038 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8039 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8040 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8042 targetValue.height = 70.0f;
8045 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8048 application.SendNotification();
8049 application.Render(1100); // After the animation
8051 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8052 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8053 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8054 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8055 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8057 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8058 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8059 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8060 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8061 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8063 Vector3 offset(10.0f, 20.0f, 0.0f);
8066 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8069 application.SendNotification();
8070 application.Render(1100); // After the animation
8072 targetValue += offset;
8074 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8075 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8076 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8077 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8078 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8080 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8081 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8082 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8083 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8084 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8086 offset.width = 20.0f;
8089 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8092 application.SendNotification();
8093 application.Render(1100); // After the animation
8095 targetValue.width += offset.width;
8097 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8098 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8099 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8100 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8101 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8103 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8104 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8105 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8106 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8107 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8109 offset.height = 10.0f;
8112 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8115 application.SendNotification();
8116 application.Render(1100); // After the animation
8118 targetValue.height += offset.height;
8120 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8121 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8122 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8123 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8124 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8126 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8127 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8128 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8129 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8130 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8133 actorSize = Vector3(300.0f, 300.0f, 0.0f);
8135 actor.SetProperty(Actor::Property::SIZE, actorSize);
8137 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8138 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8140 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8141 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8143 application.SendNotification();
8144 application.Render();
8146 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8147 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8149 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8150 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8155 int utcDaliActorRelayoutAndAnimation(void)
8157 TestApplication application;
8158 tet_infoline("Check the actor size when relayoutting and playing animation");
8160 Vector3 parentSize(300.0f, 300.0f, 0.0f);
8161 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8164 Actor parentA = Actor::New();
8165 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8166 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8167 application.GetScene().Add(parentA);
8169 Actor parentB = Actor::New();
8170 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8171 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8172 application.GetScene().Add(parentB);
8174 Actor actor = Actor::New();
8175 actor.SetProperty(Actor::Property::SIZE, actorSize);
8176 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8179 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8180 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8182 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8184 Animation animation = Animation::New(1.0f);
8185 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8188 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8189 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8191 application.SendNotification();
8192 application.Render(1100); // After the animation
8194 // Size and current size should be updated.
8195 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8196 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8198 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8199 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8204 application.SendNotification();
8205 application.Render();
8207 // Size and current size should be same.
8208 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8209 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8211 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8212 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8220 Actor parentA = Actor::New();
8221 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8222 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8223 application.GetScene().Add(parentA);
8225 Actor parentB = Actor::New();
8226 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8227 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8228 application.GetScene().Add(parentB);
8230 Actor actor = Actor::New();
8231 actor.SetProperty(Actor::Property::SIZE, actorSize);
8232 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8235 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8236 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8238 application.SendNotification();
8239 application.Render();
8241 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8242 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8244 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8245 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8247 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8249 // Make an animation
8250 Animation animation = Animation::New(1.0f);
8251 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8254 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8255 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8257 application.SendNotification();
8258 application.Render(1100); // After the animation
8260 // Size and current size should be updated.
8261 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8262 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8264 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8265 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8270 application.SendNotification();
8271 application.Render();
8273 // Size and current size should be same.
8274 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8275 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8277 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8278 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8288 int utcDaliActorPartialUpdate(void)
8290 TestApplication application(
8291 TestApplication::DEFAULT_SURFACE_WIDTH,
8292 TestApplication::DEFAULT_SURFACE_HEIGHT,
8293 TestApplication::DEFAULT_HORIZONTAL_DPI,
8294 TestApplication::DEFAULT_VERTICAL_DPI,
8298 tet_infoline("Check the damaged area");
8300 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8302 std::vector<Rect<int>> damagedRects;
8303 Rect<int> clippingRect;
8304 application.SendNotification();
8305 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8307 // First render pass, nothing to render, adaptor would just do swap buffer.
8308 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8310 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8311 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8313 Actor actor = CreateRenderableActor();
8314 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8315 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8316 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8317 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8318 application.GetScene().Add(actor);
8320 application.SendNotification();
8322 // 1. Actor added, damaged rect is added size of actor
8323 damagedRects.clear();
8324 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8325 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8328 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8329 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8330 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8331 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8332 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8333 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8334 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8337 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8338 application.SendNotification();
8340 damagedRects.clear();
8341 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8342 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8345 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
8346 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8347 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8348 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8349 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8350 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8351 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8353 // 3. Set new position
8354 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8355 application.SendNotification();
8357 damagedRects.clear();
8358 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8359 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8362 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
8363 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8364 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8365 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8366 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8367 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8368 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8370 application.GetScene().Remove(actor);
8371 application.SendNotification();
8373 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
8374 damagedRects.clear();
8375 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8376 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
8378 clippingRect = damagedRects[0];
8379 clippingRect.Merge(damagedRects[1]);
8380 clippingRect.Merge(damagedRects[2]);
8382 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
8383 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8384 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
8386 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8387 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8388 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8389 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8390 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8395 int utcDaliActorPartialUpdateSetColor(void)
8397 TestApplication application(
8398 TestApplication::DEFAULT_SURFACE_WIDTH,
8399 TestApplication::DEFAULT_SURFACE_HEIGHT,
8400 TestApplication::DEFAULT_HORIZONTAL_DPI,
8401 TestApplication::DEFAULT_VERTICAL_DPI,
8405 tet_infoline("Check uniform update");
8407 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8409 std::vector<Rect<int>> damagedRects;
8410 Rect<int> clippingRect;
8411 application.SendNotification();
8412 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8414 // First render pass, nothing to render, adaptor would just do swap buffer.
8415 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8417 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8418 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8420 Actor actor = CreateRenderableActor();
8421 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8422 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8423 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8424 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8425 application.GetScene().Add(actor);
8427 application.SendNotification();
8429 // 1. Actor added, damaged rect is added size of actor
8430 damagedRects.clear();
8431 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8432 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8435 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8436 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8437 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8438 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8439 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8440 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8441 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8443 damagedRects.clear();
8444 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8446 damagedRects.clear();
8447 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8450 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8451 application.SendNotification();
8453 damagedRects.clear();
8454 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8455 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8458 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8459 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8460 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8461 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8462 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8463 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8464 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8469 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8470 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8471 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8472 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8473 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8474 " uniform mediump mat4 uLightCameraViewMatrix;\n"
8478 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8479 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
8480 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8483 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8484 "uniform lowp vec4 uShadowColor;\n"
8487 " lowp float alpha;\n"
8488 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8489 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8492 int utcDaliActorPartialUpdateSetProperty(void)
8494 TestApplication application(
8495 TestApplication::DEFAULT_SURFACE_WIDTH,
8496 TestApplication::DEFAULT_SURFACE_HEIGHT,
8497 TestApplication::DEFAULT_HORIZONTAL_DPI,
8498 TestApplication::DEFAULT_VERTICAL_DPI,
8502 tet_infoline("Set/Update property with partial update");
8504 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8506 std::vector<Rect<int>> damagedRects;
8507 Rect<int> clippingRect;
8508 application.SendNotification();
8509 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8511 // First render pass, nothing to render, adaptor would just do swap buffer.
8512 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8514 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8515 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8517 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8518 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8519 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8520 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8521 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8522 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8523 application.GetScene().Add(actor);
8525 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8527 damagedRects.clear();
8528 application.SendNotification();
8529 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8530 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8533 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8534 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8535 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8536 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8537 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8538 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8539 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8541 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8542 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8544 damagedRects.clear();
8545 application.SendNotification();
8546 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8547 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8549 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8550 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8551 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8552 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8553 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8554 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8556 // Should be no damage rects, nothing changed
8557 damagedRects.clear();
8558 application.SendNotification();
8559 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8560 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8562 // Should be 1 damage rect due to change in size
8563 damagedRects.clear();
8564 actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8565 application.SendNotification();
8566 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8567 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8569 clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8570 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8571 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8572 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8573 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8574 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8575 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8577 damagedRects.clear();
8578 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8579 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8584 int utcDaliActorPartialUpdateTwoActors(void)
8586 TestApplication application(
8587 TestApplication::DEFAULT_SURFACE_WIDTH,
8588 TestApplication::DEFAULT_SURFACE_HEIGHT,
8589 TestApplication::DEFAULT_HORIZONTAL_DPI,
8590 TestApplication::DEFAULT_VERTICAL_DPI,
8594 tet_infoline("Check the damaged rects with partial update and two actors");
8596 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8598 Actor actor = CreateRenderableActor();
8599 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8600 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8601 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8602 application.GetScene().Add(actor);
8604 Actor actor2 = CreateRenderableActor();
8605 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8606 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8607 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8608 application.GetScene().Add(actor2);
8610 application.SendNotification();
8611 std::vector<Rect<int>> damagedRects;
8612 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8614 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8615 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8616 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8618 // in screen coordinates, adaptor would calculate it using previous frames information
8619 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8620 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8622 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8623 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8624 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8625 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8627 // Change a Renderer of actor1
8628 Geometry geometry = CreateQuadGeometry();
8629 Shader shader = CreateShader();
8630 Renderer newRenderer = Renderer::New(geometry, shader);
8631 Renderer renderer = actor.GetRendererAt(0);
8633 actor.RemoveRenderer(renderer);
8634 actor.AddRenderer(newRenderer);
8636 damagedRects.clear();
8638 application.SendNotification();
8639 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8641 DALI_TEST_CHECK(damagedRects.size() > 0);
8642 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8644 // in screen coordinates, adaptor would calculate it using previous frames information
8645 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8647 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8648 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8649 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8650 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8655 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8657 TestApplication application(
8658 TestApplication::DEFAULT_SURFACE_WIDTH,
8659 TestApplication::DEFAULT_SURFACE_HEIGHT,
8660 TestApplication::DEFAULT_HORIZONTAL_DPI,
8661 TestApplication::DEFAULT_VERTICAL_DPI,
8665 tet_infoline("Check the damaged rect with partial update and actor size hint");
8667 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8669 Actor actor = CreateRenderableActor();
8670 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
8671 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
8672 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f));
8673 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8674 application.GetScene().Add(actor);
8676 application.SendNotification();
8677 std::vector<Rect<int>> damagedRects;
8678 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8680 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8682 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
8683 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8685 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8687 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8688 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8689 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8690 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8695 int utcDaliActorPartialUpdateAnimation(void)
8697 TestApplication application(
8698 TestApplication::DEFAULT_SURFACE_WIDTH,
8699 TestApplication::DEFAULT_SURFACE_HEIGHT,
8700 TestApplication::DEFAULT_HORIZONTAL_DPI,
8701 TestApplication::DEFAULT_VERTICAL_DPI,
8705 tet_infoline("Check the damaged area with partial update and animation");
8707 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8708 drawTrace.Enable(true);
8711 Actor actor1 = CreateRenderableActor();
8712 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8713 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8714 application.GetScene().Add(actor1);
8716 Actor actor2 = CreateRenderableActor();
8717 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8718 actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8719 application.GetScene().Add(actor2);
8721 std::vector<Rect<int>> damagedRects;
8722 Rect<int> clippingRect;
8723 Rect<int> expectedRect1, expectedRect2;
8725 application.SendNotification();
8726 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8728 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8731 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8732 expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
8733 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8734 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
8736 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8737 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8739 damagedRects.clear();
8740 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8741 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8742 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8744 // Make an animation
8745 Animation animation = Animation::New(1.0f);
8746 animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
8749 application.SendNotification();
8751 damagedRects.clear();
8752 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8753 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8754 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8757 damagedRects.clear();
8759 // In animation deley time
8760 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8761 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8762 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8765 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8768 damagedRects.clear();
8770 // Also in animation deley time
8771 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8772 application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
8773 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8776 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8778 // Unparent 2 actors and make a new actor
8782 Actor actor3 = CreateRenderableActor();
8783 actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8784 actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8785 application.GetScene().Add(actor3);
8787 application.SendNotification();
8789 // Started animation
8790 damagedRects.clear();
8791 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8792 DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION);
8794 // The first dirty rect is actor3's.
8795 // We don't know the exact dirty rect of actor2
8796 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8797 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
8799 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8800 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8802 // Finished animation, but the actor was already unparented
8803 damagedRects.clear();
8804 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8806 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8807 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8809 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8810 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8815 int utcDaliActorPartialUpdateChangeVisibility(void)
8817 TestApplication application(
8818 TestApplication::DEFAULT_SURFACE_WIDTH,
8819 TestApplication::DEFAULT_SURFACE_HEIGHT,
8820 TestApplication::DEFAULT_HORIZONTAL_DPI,
8821 TestApplication::DEFAULT_VERTICAL_DPI,
8825 tet_infoline("Check the damaged rect with partial update and visibility change");
8827 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8829 Actor actor = CreateRenderableActor();
8830 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8831 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8832 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8833 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8834 application.GetScene().Add(actor);
8836 application.SendNotification();
8838 std::vector<Rect<int>> damagedRects;
8839 Rect<int> clippingRect;
8841 // 1. Actor added, damaged rect is added size of actor
8842 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8843 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8846 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8847 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8848 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8849 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8850 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8851 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8852 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8854 damagedRects.clear();
8855 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8856 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8858 damagedRects.clear();
8859 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8860 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8862 // Ensure the damaged rect is empty
8863 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8865 // 2. Make the Actor invisible
8866 actor.SetProperty(Actor::Property::VISIBLE, false);
8867 application.SendNotification();
8869 damagedRects.clear();
8870 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8871 DALI_TEST_CHECK(damagedRects.size() > 0);
8872 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8874 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8875 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8876 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8877 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8878 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8880 // 3. Make the Actor visible again
8881 actor.SetProperty(Actor::Property::VISIBLE, true);
8882 application.SendNotification();
8884 damagedRects.clear();
8885 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8886 DALI_TEST_CHECK(damagedRects.size() > 0);
8887 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8889 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8890 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8891 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8892 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8893 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8898 int utcDaliActorPartialUpdateOnOffScene(void)
8900 TestApplication application(
8901 TestApplication::DEFAULT_SURFACE_WIDTH,
8902 TestApplication::DEFAULT_SURFACE_HEIGHT,
8903 TestApplication::DEFAULT_HORIZONTAL_DPI,
8904 TestApplication::DEFAULT_VERTICAL_DPI,
8908 tet_infoline("Check the damaged rect with partial update and on/off scene");
8910 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8912 Actor actor = CreateRenderableActor();
8913 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8914 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8915 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8916 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8917 application.GetScene().Add(actor);
8919 application.SendNotification();
8921 std::vector<Rect<int>> damagedRects;
8922 Rect<int> clippingRect;
8924 // 1. Actor added, damaged rect is added size of actor
8925 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8926 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8929 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8930 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8931 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8932 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8933 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8934 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8935 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8937 damagedRects.clear();
8938 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8939 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8941 damagedRects.clear();
8942 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8943 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8945 // Ensure the damaged rect is empty
8946 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8948 // 2. Remove the Actor from the Scene
8950 application.SendNotification();
8952 damagedRects.clear();
8953 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8954 DALI_TEST_CHECK(damagedRects.size() > 0);
8955 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8957 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8958 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8959 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8960 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8961 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8963 // 3. Add the Actor to the Scene again
8964 application.GetScene().Add(actor);
8965 application.SendNotification();
8967 damagedRects.clear();
8968 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8969 DALI_TEST_CHECK(damagedRects.size() > 0);
8970 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8972 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8973 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8974 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8975 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8976 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8981 int utcDaliActorPartialUpdateSkipRendering(void)
8983 TestApplication application(
8984 TestApplication::DEFAULT_SURFACE_WIDTH,
8985 TestApplication::DEFAULT_SURFACE_HEIGHT,
8986 TestApplication::DEFAULT_HORIZONTAL_DPI,
8987 TestApplication::DEFAULT_VERTICAL_DPI,
8991 tet_infoline("Check to skip rendering in case of the empty damaged rect");
8993 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8994 drawTrace.Enable(true);
8997 Actor actor1 = CreateRenderableActor();
8998 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8999 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9000 application.GetScene().Add(actor1);
9002 std::vector<Rect<int>> damagedRects;
9003 Rect<int> clippingRect;
9004 Rect<int> expectedRect1;
9006 application.SendNotification();
9007 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9009 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9012 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
9013 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9015 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9016 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9018 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9020 damagedRects.clear();
9021 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9022 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9023 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9028 application.SendNotification();
9030 damagedRects.clear();
9031 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9033 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9035 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9036 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9038 // Render again without any change
9039 damagedRects.clear();
9041 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9043 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9045 clippingRect = Rect<int>();
9046 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9049 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9051 // Add the actor again
9052 application.GetScene().Add(actor1);
9054 application.SendNotification();
9056 damagedRects.clear();
9058 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9060 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9062 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9063 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9065 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9070 int utcDaliActorPartialUpdate3DNode(void)
9072 TestApplication application(
9073 TestApplication::DEFAULT_SURFACE_WIDTH,
9074 TestApplication::DEFAULT_SURFACE_HEIGHT,
9075 TestApplication::DEFAULT_HORIZONTAL_DPI,
9076 TestApplication::DEFAULT_VERTICAL_DPI,
9080 tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9082 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9083 drawTrace.Enable(true);
9086 Actor actor1 = CreateRenderableActor();
9087 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9088 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9089 application.GetScene().Add(actor1);
9091 std::vector<Rect<int>> damagedRects;
9092 Rect<int> clippingRect;
9094 application.SendNotification();
9095 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9097 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9099 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9100 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9102 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9104 // Change the layer to 3D
9105 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9107 application.SendNotification();
9109 damagedRects.clear();
9110 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9112 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9113 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9115 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9117 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9119 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9121 // Change the layer to 2D
9122 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9124 application.SendNotification();
9126 damagedRects.clear();
9127 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9129 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9131 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9132 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9134 // Make 3D transform
9135 actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9137 application.SendNotification();
9139 damagedRects.clear();
9140 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9142 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9143 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9145 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9147 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9149 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9154 int utcDaliActorPartialUpdateNotRenderableActor(void)
9156 TestApplication application(
9157 TestApplication::DEFAULT_SURFACE_WIDTH,
9158 TestApplication::DEFAULT_SURFACE_HEIGHT,
9159 TestApplication::DEFAULT_HORIZONTAL_DPI,
9160 TestApplication::DEFAULT_VERTICAL_DPI,
9164 tet_infoline("Check the damaged rect with not renderable parent actor");
9166 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9168 Actor parent = Actor::New();
9169 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9170 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9171 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9172 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9173 application.GetScene().Add(parent);
9175 Actor child = CreateRenderableActor();
9176 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9177 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9178 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9181 application.SendNotification();
9183 std::vector<Rect<int>> damagedRects;
9185 // 1. Actor added, damaged rect is added size of actor
9186 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9187 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9190 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9191 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9193 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9194 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9195 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9196 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9197 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9199 damagedRects.clear();
9200 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9201 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9203 damagedRects.clear();
9204 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9205 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9207 // Ensure the damaged rect is empty
9208 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9213 int utcDaliActorPartialUpdateChangeTransparency(void)
9215 TestApplication application(
9216 TestApplication::DEFAULT_SURFACE_WIDTH,
9217 TestApplication::DEFAULT_SURFACE_HEIGHT,
9218 TestApplication::DEFAULT_HORIZONTAL_DPI,
9219 TestApplication::DEFAULT_VERTICAL_DPI,
9223 tet_infoline("Check the damaged rect with changing transparency");
9225 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9227 Actor actor = CreateRenderableActor();
9228 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9229 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9230 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9231 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9232 application.GetScene().Add(actor);
9234 application.SendNotification();
9236 std::vector<Rect<int>> damagedRects;
9238 // Actor added, damaged rect is added size of actor
9239 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9240 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9243 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9244 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9246 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9247 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9248 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9249 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9250 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9252 damagedRects.clear();
9253 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9254 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9256 damagedRects.clear();
9257 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9258 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9260 // Make the actor transparent by changing opacity of the Renderer
9261 // It changes a uniform value
9262 Renderer renderer = actor.GetRendererAt(0);
9263 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9265 application.SendNotification();
9267 // The damaged rect should be same
9268 damagedRects.clear();
9269 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9270 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9271 DALI_TEST_CHECK(damagedRects.size() > 0);
9272 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9274 damagedRects.clear();
9275 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9276 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9278 // Ensure the damaged rect is empty
9279 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9281 // Make the actor opaque again
9282 renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9284 application.SendNotification();
9286 // The damaged rect should not be empty
9287 damagedRects.clear();
9288 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9289 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9290 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9291 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9293 damagedRects.clear();
9294 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9295 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9297 damagedRects.clear();
9298 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9299 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9301 // Make the actor culled
9302 actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9304 application.SendNotification();
9306 // The damaged rect should be same
9307 damagedRects.clear();
9308 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9309 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9310 DALI_TEST_CHECK(damagedRects.size() > 0);
9311 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9313 damagedRects.clear();
9314 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9315 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9317 // Ensure the damaged rect is empty
9318 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9320 // Make the actor not culled again
9321 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
9323 application.SendNotification();
9325 // The damaged rect should not be empty
9326 damagedRects.clear();
9327 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9328 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9329 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9330 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9335 int utcDaliActorPartialUpdateChangeParentOpacity(void)
9337 TestApplication application(
9338 TestApplication::DEFAULT_SURFACE_WIDTH,
9339 TestApplication::DEFAULT_SURFACE_HEIGHT,
9340 TestApplication::DEFAULT_HORIZONTAL_DPI,
9341 TestApplication::DEFAULT_VERTICAL_DPI,
9345 tet_infoline("Check the damaged rect with changing parent's opacity");
9347 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9349 Actor parent = Actor::New();
9350 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9351 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9352 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9353 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9354 application.GetScene().Add(parent);
9356 Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
9357 Actor child = CreateRenderableActor(texture);
9358 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9359 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9360 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9363 application.SendNotification();
9365 std::vector<Rect<int>> damagedRects;
9367 // Actor added, damaged rect is added size of actor
9368 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9369 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9372 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9373 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9375 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9376 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9377 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9378 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9379 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9381 damagedRects.clear();
9382 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9383 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9385 damagedRects.clear();
9386 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9387 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9389 // Ensure the damaged rect is empty
9390 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9392 // Change the parent's opacity
9393 parent[Actor::Property::OPACITY] = 0.5f;
9395 application.SendNotification();
9397 // The damaged rect should be same
9398 damagedRects.clear();
9399 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9400 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9401 DALI_TEST_CHECK(damagedRects.size() > 0);
9402 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9407 int utcDaliActorPartialAddRemoveRenderer(void)
9409 TestApplication application(
9410 TestApplication::DEFAULT_SURFACE_WIDTH,
9411 TestApplication::DEFAULT_SURFACE_HEIGHT,
9412 TestApplication::DEFAULT_HORIZONTAL_DPI,
9413 TestApplication::DEFAULT_VERTICAL_DPI,
9417 tet_infoline("Check the damaged rect with adding / removing renderer");
9419 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9421 Actor actor = CreateRenderableActor();
9422 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9423 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9424 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9425 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9426 application.GetScene().Add(actor);
9428 application.SendNotification();
9430 std::vector<Rect<int>> damagedRects;
9432 // Actor added, damaged rect is added size of actor
9433 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9434 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9437 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9438 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9440 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9441 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9442 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9443 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9444 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9446 damagedRects.clear();
9447 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9448 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9450 damagedRects.clear();
9451 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9452 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9454 // Remove the Renderer
9455 Renderer renderer = actor.GetRendererAt(0);
9456 actor.RemoveRenderer(renderer);
9458 application.SendNotification();
9460 // The damaged rect should be the actor area
9461 damagedRects.clear();
9462 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9463 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9464 DALI_TEST_CHECK(damagedRects.size() > 0);
9465 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9467 damagedRects.clear();
9468 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9469 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9471 // Ensure the damaged rect is empty
9472 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9474 // Add the Renderer again
9475 actor.AddRenderer(renderer);
9477 application.SendNotification();
9479 // The damaged rect should be the actor area
9480 damagedRects.clear();
9481 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9482 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9483 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9484 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9489 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
9491 TestApplication application;
9493 Actor actor = Actor::New();
9494 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
9495 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
9496 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
9497 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
9498 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
9499 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9500 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9501 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
9505 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
9507 TestApplication application;
9509 Actor actor = Actor::New();
9511 // Make sure setting invalid types does not cause a crash
9514 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
9515 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
9516 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
9517 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
9518 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
9519 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
9520 tet_result(TET_PASS);
9524 tet_result(TET_FAIL);
9529 int UtcDaliActorTouchAreaOffsetPropertyP(void)
9531 TestApplication application;
9533 Actor actor = Actor::New();
9534 Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9535 DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
9536 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
9537 touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9538 DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
9542 int UtcDaliActorTouchAreaOffsetPropertyN(void)
9544 TestApplication application;
9546 Actor actor = Actor::New();
9548 // Make sure setting invalid types does not cause a crash
9551 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
9552 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
9553 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
9554 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
9555 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
9556 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
9557 tet_result(TET_PASS);
9561 tet_result(TET_FAIL);
9566 int UtcDaliActorLowerBelowNegative(void)
9568 TestApplication application;
9569 Dali::Actor instance;
9573 instance.LowerBelow(arg1);
9574 DALI_TEST_CHECK(false); // Should not get here
9578 DALI_TEST_CHECK(true); // We expect an assert
9583 int UtcDaliActorRaiseAboveNegative(void)
9585 TestApplication application;
9586 Dali::Actor instance;
9590 instance.RaiseAbove(arg1);
9591 DALI_TEST_CHECK(false); // Should not get here
9595 DALI_TEST_CHECK(true); // We expect an assert
9600 int UtcDaliActorRaiseToTopNegative(void)
9602 TestApplication application;
9603 Dali::Actor instance;
9606 instance.RaiseToTop();
9607 DALI_TEST_CHECK(false); // Should not get here
9611 DALI_TEST_CHECK(true); // We expect an assert
9616 int UtcDaliActorAddRendererNegative(void)
9618 TestApplication application;
9619 Dali::Actor instance;
9622 Dali::Renderer arg1;
9623 instance.AddRenderer(arg1);
9624 DALI_TEST_CHECK(false); // Should not get here
9628 DALI_TEST_CHECK(true); // We expect an assert
9633 int UtcDaliActorTouchedSignalNegative(void)
9635 TestApplication application;
9636 Dali::Actor instance;
9639 instance.TouchedSignal();
9640 DALI_TEST_CHECK(false); // Should not get here
9644 DALI_TEST_CHECK(true); // We expect an assert
9649 int UtcDaliActorTranslateByNegative(void)
9651 TestApplication application;
9652 Dali::Actor instance;
9656 instance.TranslateBy(arg1);
9657 DALI_TEST_CHECK(false); // Should not get here
9661 DALI_TEST_CHECK(true); // We expect an assert
9666 int UtcDaliActorFindChildByIdNegative(void)
9668 TestApplication application;
9669 Dali::Actor instance;
9672 unsigned int arg1 = 0u;
9673 instance.FindChildById(arg1);
9674 DALI_TEST_CHECK(false); // Should not get here
9678 DALI_TEST_CHECK(true); // We expect an assert
9683 int UtcDaliActorGetRendererAtNegative(void)
9685 TestApplication application;
9686 Dali::Actor instance;
9689 unsigned int arg1 = 0u;
9690 instance.GetRendererAt(arg1);
9691 DALI_TEST_CHECK(false); // Should not get here
9695 DALI_TEST_CHECK(true); // We expect an assert
9700 int UtcDaliActorHoveredSignalNegative(void)
9702 TestApplication application;
9703 Dali::Actor instance;
9706 instance.HoveredSignal();
9707 DALI_TEST_CHECK(false); // Should not get here
9711 DALI_TEST_CHECK(true); // We expect an assert
9716 int UtcDaliActorLowerToBottomNegative(void)
9718 TestApplication application;
9719 Dali::Actor instance;
9722 instance.LowerToBottom();
9723 DALI_TEST_CHECK(false); // Should not get here
9727 DALI_TEST_CHECK(true); // We expect an assert
9732 int UtcDaliActorOnSceneSignalNegative(void)
9734 TestApplication application;
9735 Dali::Actor instance;
9738 instance.OnSceneSignal();
9739 DALI_TEST_CHECK(false); // Should not get here
9743 DALI_TEST_CHECK(true); // We expect an assert
9748 int UtcDaliActorOffSceneSignalNegative(void)
9750 TestApplication application;
9751 Dali::Actor instance;
9754 instance.OffSceneSignal();
9755 DALI_TEST_CHECK(false); // Should not get here
9759 DALI_TEST_CHECK(true); // We expect an assert
9764 int UtcDaliActorRemoveRendererNegative01(void)
9766 TestApplication application;
9767 Dali::Actor instance;
9770 unsigned int arg1 = 0u;
9771 instance.RemoveRenderer(arg1);
9772 DALI_TEST_CHECK(false); // Should not get here
9776 DALI_TEST_CHECK(true); // We expect an assert
9781 int UtcDaliActorRemoveRendererNegative02(void)
9783 TestApplication application;
9784 Dali::Actor instance;
9787 Dali::Renderer arg1;
9788 instance.RemoveRenderer(arg1);
9789 DALI_TEST_CHECK(false); // Should not get here
9793 DALI_TEST_CHECK(true); // We expect an assert
9798 int UtcDaliActorFindChildByNameNegative(void)
9800 TestApplication application;
9801 Dali::Actor instance;
9805 instance.FindChildByName(arg1);
9806 DALI_TEST_CHECK(false); // Should not get here
9810 DALI_TEST_CHECK(true); // We expect an assert
9815 int UtcDaliActorSetResizePolicyNegative(void)
9817 TestApplication application;
9818 Dali::Actor instance;
9821 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
9822 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
9823 instance.SetResizePolicy(arg1, arg2);
9824 DALI_TEST_CHECK(false); // Should not get here
9828 DALI_TEST_CHECK(true); // We expect an assert
9833 int UtcDaliActorOnRelayoutSignalNegative(void)
9835 TestApplication application;
9836 Dali::Actor instance;
9839 instance.OnRelayoutSignal();
9840 DALI_TEST_CHECK(false); // Should not get here
9844 DALI_TEST_CHECK(true); // We expect an assert
9849 int UtcDaliActorWheelEventSignalNegative(void)
9851 TestApplication application;
9852 Dali::Actor instance;
9855 instance.WheelEventSignal();
9856 DALI_TEST_CHECK(false); // Should not get here
9860 DALI_TEST_CHECK(true); // We expect an assert
9865 int UtcDaliActorGetHeightForWidthNegative(void)
9867 TestApplication application;
9868 Dali::Actor instance;
9872 instance.GetHeightForWidth(arg1);
9873 DALI_TEST_CHECK(false); // Should not get here
9877 DALI_TEST_CHECK(true); // We expect an assert
9882 int UtcDaliActorGetWidthForHeightNegative(void)
9884 TestApplication application;
9885 Dali::Actor instance;
9889 instance.GetWidthForHeight(arg1);
9890 DALI_TEST_CHECK(false); // Should not get here
9894 DALI_TEST_CHECK(true); // We expect an assert
9899 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
9901 TestApplication application;
9902 Dali::Actor instance;
9905 instance.LayoutDirectionChangedSignal();
9906 DALI_TEST_CHECK(false); // Should not get here
9910 DALI_TEST_CHECK(true); // We expect an assert
9915 int UtcDaliActorAddNegative(void)
9917 TestApplication application;
9918 Dali::Actor instance;
9923 DALI_TEST_CHECK(false); // Should not get here
9927 DALI_TEST_CHECK(true); // We expect an assert
9932 int UtcDaliActorLowerNegative(void)
9934 TestApplication application;
9935 Dali::Actor instance;
9939 DALI_TEST_CHECK(false); // Should not get here
9943 DALI_TEST_CHECK(true); // We expect an assert
9948 int UtcDaliActorRaiseNegative(void)
9950 TestApplication application;
9951 Dali::Actor instance;
9955 DALI_TEST_CHECK(false); // Should not get here
9959 DALI_TEST_CHECK(true); // We expect an assert
9964 int UtcDaliActorRemoveNegative(void)
9966 TestApplication application;
9967 Dali::Actor instance;
9971 instance.Remove(arg1);
9972 DALI_TEST_CHECK(false); // Should not get here
9976 DALI_TEST_CHECK(true); // We expect an assert
9981 int UtcDaliActorScaleByNegative(void)
9983 TestApplication application;
9984 Dali::Actor instance;
9988 instance.ScaleBy(arg1);
9989 DALI_TEST_CHECK(false); // Should not get here
9993 DALI_TEST_CHECK(true); // We expect an assert
9998 int UtcDaliActorGetLayerNegative(void)
10000 TestApplication application;
10001 Dali::Actor instance;
10004 instance.GetLayer();
10005 DALI_TEST_CHECK(false); // Should not get here
10009 DALI_TEST_CHECK(true); // We expect an assert
10014 int UtcDaliActorRotateByNegative01(void)
10016 TestApplication application;
10017 Dali::Actor instance;
10020 Dali::Quaternion arg1;
10021 instance.RotateBy(arg1);
10022 DALI_TEST_CHECK(false); // Should not get here
10026 DALI_TEST_CHECK(true); // We expect an assert
10031 int UtcDaliActorRotateByNegative02(void)
10033 TestApplication application;
10034 Dali::Actor instance;
10038 Dali::Vector3 arg2;
10039 instance.RotateBy(arg1, arg2);
10040 DALI_TEST_CHECK(false); // Should not get here
10044 DALI_TEST_CHECK(true); // We expect an assert
10049 int UtcDaliActorUnparentNegative(void)
10051 TestApplication application;
10052 Dali::Actor instance;
10055 instance.Unparent();
10056 DALI_TEST_CHECK(false); // Should not get here
10060 DALI_TEST_CHECK(true); // We expect an assert
10065 int UtcDaliActorGetChildAtNegative(void)
10067 TestApplication application;
10068 Dali::Actor instance;
10071 unsigned int arg1 = 0u;
10072 instance.GetChildAt(arg1);
10073 DALI_TEST_CHECK(false); // Should not get here
10077 DALI_TEST_CHECK(true); // We expect an assert
10082 int UtcDaliActorGetChildCountNegative(void)
10084 TestApplication application;
10085 Dali::Actor instance;
10088 instance.GetChildCount();
10089 DALI_TEST_CHECK(false); // Should not get here
10093 DALI_TEST_CHECK(true); // We expect an assert
10098 int UtcDaliActorGetTargetSizeNegative(void)
10100 TestApplication application;
10101 Dali::Actor instance;
10104 instance.GetTargetSize();
10105 DALI_TEST_CHECK(false); // Should not get here
10109 DALI_TEST_CHECK(true); // We expect an assert
10114 int UtcDaliActorScreenToLocalNegative(void)
10116 TestApplication application;
10117 Dali::Actor instance;
10124 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
10125 DALI_TEST_CHECK(false); // Should not get here
10129 DALI_TEST_CHECK(true); // We expect an assert
10134 int UtcDaliActorGetNaturalSizeNegative(void)
10136 TestApplication application;
10137 Dali::Actor instance;
10140 instance.GetNaturalSize();
10141 DALI_TEST_CHECK(false); // Should not get here
10145 DALI_TEST_CHECK(true); // We expect an assert
10150 int UtcDaliActorGetRelayoutSizeNegative(void)
10152 TestApplication application;
10153 Dali::Actor instance;
10156 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
10157 instance.GetRelayoutSize(arg1);
10158 DALI_TEST_CHECK(false); // Should not get here
10162 DALI_TEST_CHECK(true); // We expect an assert
10167 int UtcDaliActorGetResizePolicyNegative(void)
10169 TestApplication application;
10170 Dali::Actor instance;
10173 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
10174 instance.GetResizePolicy(arg1);
10175 DALI_TEST_CHECK(false); // Should not get here
10179 DALI_TEST_CHECK(true); // We expect an assert
10184 int UtcDaliActorGetRendererCountNegative(void)
10186 TestApplication application;
10187 Dali::Actor instance;
10190 instance.GetRendererCount();
10191 DALI_TEST_CHECK(false); // Should not get here
10195 DALI_TEST_CHECK(true); // We expect an assert
10200 int UtcDaliActorGetParentNegative(void)
10202 TestApplication application;
10203 Dali::Actor instance;
10206 instance.GetParent();
10207 DALI_TEST_CHECK(false); // Should not get here
10211 DALI_TEST_CHECK(true); // We expect an assert
10216 int UtcDaliActorPropertyBlendEquation(void)
10218 TestApplication application;
10220 tet_infoline("Test SetProperty AdvancedBlendEquation");
10222 Geometry geometry = CreateQuadGeometry();
10223 Shader shader = CreateShader();
10224 Renderer renderer1 = Renderer::New(geometry, shader);
10226 Actor actor = Actor::New();
10227 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
10229 actor.AddRenderer(renderer1);
10230 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
10231 application.GetScene().Add(actor);
10233 if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10235 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10236 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10237 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
10240 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10242 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10243 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10244 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
10247 Renderer renderer2 = Renderer::New(geometry, shader);
10248 actor.AddRenderer(renderer2);
10253 int UtcDaliActorRegisterProperty(void)
10255 tet_infoline("Test property registration and uniform map update\n");
10257 TestApplication application;
10259 Geometry geometry = CreateQuadGeometry();
10260 Shader shader = CreateShader();
10261 Renderer renderer1 = Renderer::New(geometry, shader);
10262 Renderer renderer2 = Renderer::New(geometry, shader);
10264 Actor actor1 = Actor::New();
10265 actor1.AddRenderer(renderer1);
10266 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10267 actor1.RegisterProperty("uCustom", 1);
10268 application.GetScene().Add(actor1);
10270 Actor actor2 = Actor::New();
10271 actor2.AddRenderer(renderer2);
10272 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10273 application.GetScene().Add(actor2);
10275 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
10276 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
10277 glAbstraction.EnableSetUniformCallTrace(true);
10279 application.SendNotification();
10280 application.Render();
10282 std::stringstream out;
10284 std::string params;
10286 // Test uniform value of the custom property
10287 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10288 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10291 actor1[Actor::Property::VISIBLE] = false;
10293 application.SendNotification();
10294 application.Render();
10296 // Make visible again
10297 actor1[Actor::Property::VISIBLE] = true;
10298 actor1["uCustom"] = 2;
10300 glAbstraction.ResetSetUniformCallStack();
10302 application.SendNotification();
10303 application.Render();
10307 // The uniform value should not be changed
10308 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10309 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10314 int UtcDaliActorDoesWantedHitTest(void)
10319 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
10321 mTouchPoint(touchPoint),
10327 Vector2 mTouchPoint;
10331 TestApplication application;
10332 tet_infoline(" UtcDaliActorDoesWantedHitTest");
10334 // Fill a vector with different hit tests.
10335 struct HitTestData* hitTestData[] = {
10336 // scale touch point result
10337 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
10338 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
10339 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.
10340 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
10341 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.
10345 // get the root layer
10346 Actor actor = Actor::New();
10347 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
10348 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
10350 Actor lowerActor = Actor::New();
10351 lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
10352 lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
10354 // actor and lowerActor have no relationship.
10355 application.GetScene().Add(lowerActor);
10356 application.GetScene().Add(actor);
10358 ResetTouchCallbacks();
10359 gHitTestTouchCallBackCalled = false;
10361 unsigned int index = 0;
10362 while(NULL != hitTestData[index])
10364 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
10365 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
10367 lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
10368 lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
10370 // flush the queue and render once
10371 application.SendNotification();
10372 application.Render();
10374 DALI_TEST_CHECK(!gTouchCallBackCalled);
10375 DALI_TEST_CHECK(!gTouchCallBackCalled2);
10376 DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
10378 // connect to its touch signal
10379 actor.TouchedSignal().Connect(TestTouchCallback);
10380 lowerActor.TouchedSignal().Connect(TestTouchCallback2);
10382 // connect to its hit-test signal
10383 Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
10385 Dali::Integration::Point point;
10386 point.SetState(PointState::DOWN);
10387 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
10388 Dali::Integration::TouchEvent event;
10389 event.AddPoint(point);
10391 // flush the queue and render once
10392 application.SendNotification();
10393 application.Render();
10394 application.ProcessEvent(event);
10396 // check hit-test events
10397 DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
10398 // Passed all hit-tests of actor.
10399 DALI_TEST_CHECK(gTouchCallBackCalled == false);
10400 // The lowerActor was hit-tested.
10401 DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
10403 if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
10404 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
10405 hitTestData[index]->mScale.x,
10406 hitTestData[index]->mScale.y,
10407 hitTestData[index]->mScale.z,
10408 hitTestData[index]->mTouchPoint.x,
10409 hitTestData[index]->mTouchPoint.y,
10410 hitTestData[index]->mResult);
10412 ResetTouchCallbacks();
10413 gHitTestTouchCallBackCalled = false;