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 UtcDaliActorRemoveConstraints(void)
2611 tet_infoline(" UtcDaliActorRemoveConstraints");
2612 TestApplication application;
2614 gTestConstraintCalled = false;
2616 Actor actor = Actor::New();
2618 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2620 actor.RemoveConstraints();
2622 DALI_TEST_CHECK(gTestConstraintCalled == false);
2624 application.GetScene().Add(actor);
2627 // flush the queue and render once
2628 application.SendNotification();
2629 application.Render();
2631 actor.RemoveConstraints();
2633 DALI_TEST_CHECK(gTestConstraintCalled == true);
2637 int UtcDaliActorRemoveConstraintTag(void)
2639 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2640 TestApplication application;
2642 Actor actor = Actor::New();
2644 // 1. Apply Constraint1 and Constraint2, and test...
2645 unsigned int result1 = 0u;
2646 unsigned int result2 = 0u;
2648 unsigned constraint1Tag = 1u;
2649 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2650 constraint1.SetTag(constraint1Tag);
2651 constraint1.Apply();
2653 unsigned constraint2Tag = 2u;
2654 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2655 constraint2.SetTag(constraint2Tag);
2656 constraint2.Apply();
2658 application.GetScene().Add(actor);
2659 // flush the queue and render once
2660 application.SendNotification();
2661 application.Render();
2663 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2664 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2666 // 2. Remove Constraint1 and test...
2669 actor.RemoveConstraints(constraint1Tag);
2670 // make color property dirty, which will trigger constraints to be reapplied.
2671 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2672 // flush the queue and render once
2673 application.SendNotification();
2674 application.Render();
2676 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2677 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2679 // 3. Re-Apply Constraint1 and test...
2682 constraint1.Apply();
2683 // make color property dirty, which will trigger constraints to be reapplied.
2684 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2685 // flush the queue and render once
2686 application.SendNotification();
2687 application.Render();
2689 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2690 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2692 // 2. Remove Constraint2 and test...
2695 actor.RemoveConstraints(constraint2Tag);
2696 // make color property dirty, which will trigger constraints to be reapplied.
2697 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2698 // flush the queue and render once
2699 application.SendNotification();
2700 application.Render();
2702 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2703 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2705 // 2. Remove Constraint1 as well and test...
2708 actor.RemoveConstraints(constraint1Tag);
2709 // make color property dirty, which will trigger constraints to be reapplied.
2710 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2711 // flush the queue and render once
2712 application.SendNotification();
2713 application.Render();
2715 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2716 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2720 int UtcDaliActorTouchedSignal(void)
2722 TestApplication application;
2724 ResetTouchCallbacks();
2726 // get the root layer
2727 Actor actor = application.GetScene().GetRootLayer();
2728 DALI_TEST_CHECK(gTouchCallBackCalled == false);
2730 application.SendNotification();
2731 application.Render();
2733 // connect to its touch signal
2734 actor.TouchedSignal().Connect(TestTouchCallback);
2736 // simulate a touch event in the middle of the screen
2737 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2738 Dali::Integration::Point point;
2739 point.SetDeviceId(1);
2740 point.SetState(PointState::DOWN);
2741 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2742 Dali::Integration::TouchEvent touchEvent;
2743 touchEvent.AddPoint(point);
2744 application.ProcessEvent(touchEvent);
2746 DALI_TEST_CHECK(gTouchCallBackCalled == true);
2750 int UtcDaliActorHoveredSignal(void)
2752 TestApplication application;
2754 gHoverCallBackCalled = false;
2756 // get the root layer
2757 Actor actor = application.GetScene().GetRootLayer();
2758 DALI_TEST_CHECK(gHoverCallBackCalled == false);
2760 application.SendNotification();
2761 application.Render();
2763 // connect to its hover signal
2764 actor.HoveredSignal().Connect(TestCallback3);
2766 // simulate a hover event in the middle of the screen
2767 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2768 Dali::Integration::Point point;
2769 point.SetDeviceId(1);
2770 point.SetState(PointState::MOTION);
2771 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2772 Dali::Integration::HoverEvent hoverEvent;
2773 hoverEvent.AddPoint(point);
2774 application.ProcessEvent(hoverEvent);
2776 DALI_TEST_CHECK(gHoverCallBackCalled == true);
2780 int UtcDaliActorOnOffSceneSignal(void)
2782 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2784 TestApplication application;
2787 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2788 gActorNamesOnOffScene.clear();
2790 Actor parent = Actor::New();
2791 parent.SetProperty(Actor::Property::NAME, "parent");
2792 parent.OnSceneSignal().Connect(OnSceneCallback);
2793 parent.OffSceneSignal().Connect(OffSceneCallback);
2795 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2796 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2798 // add parent to the scene
2799 application.GetScene().Add(parent);
2800 // onstage emitted, offstage not
2801 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2802 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2803 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2805 // test adding a child, should get onstage emitted
2807 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2808 gActorNamesOnOffScene.clear();
2810 Actor child = Actor::New();
2811 child.SetProperty(Actor::Property::NAME, "child");
2812 child.OnSceneSignal().Connect(OnSceneCallback);
2813 child.OffSceneSignal().Connect(OffSceneCallback);
2814 parent.Add(child); // add child
2815 // onscene emitted, offscene not
2816 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2817 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2818 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2820 // test removing parent from the scene
2822 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2823 gActorNamesOnOffScene.clear();
2825 application.GetScene().Remove(parent);
2826 // onscene not emitted, offscene is
2827 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2828 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2829 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2830 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2832 // test adding parent back to the scene
2834 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2835 gActorNamesOnOffScene.clear();
2837 application.GetScene().Add(parent);
2838 // onscene emitted, offscene not
2839 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2840 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2841 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2842 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2844 // test removing child
2846 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2847 gActorNamesOnOffScene.clear();
2849 parent.Remove(child);
2850 // onscene not emitted, offscene is
2851 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2852 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2853 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2855 // test removing parent
2857 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2858 gActorNamesOnOffScene.clear();
2860 application.GetScene().Remove(parent);
2861 // onscene not emitted, offscene is
2862 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2863 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2864 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2868 int UtcDaliActorFindChildByName(void)
2870 tet_infoline("Testing Dali::Actor::FindChildByName()");
2871 TestApplication application;
2873 Actor parent = Actor::New();
2874 parent.SetProperty(Actor::Property::NAME, "parent");
2875 Actor first = Actor::New();
2876 first.SetProperty(Actor::Property::NAME, "first");
2877 Actor second = Actor::New();
2878 second.SetProperty(Actor::Property::NAME, "second");
2883 Actor found = parent.FindChildByName("foo");
2884 DALI_TEST_CHECK(!found);
2886 found = parent.FindChildByName("parent");
2887 DALI_TEST_CHECK(found == parent);
2889 found = parent.FindChildByName("first");
2890 DALI_TEST_CHECK(found == first);
2892 found = parent.FindChildByName("second");
2893 DALI_TEST_CHECK(found == second);
2897 int UtcDaliActorFindChildById(void)
2899 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2900 TestApplication application;
2902 Actor parent = Actor::New();
2903 Actor first = Actor::New();
2904 Actor second = Actor::New();
2909 Actor found = parent.FindChildById(100000);
2910 DALI_TEST_CHECK(!found);
2912 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2913 DALI_TEST_CHECK(found == parent);
2915 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2916 DALI_TEST_CHECK(found == first);
2918 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2919 DALI_TEST_CHECK(found == second);
2923 int UtcDaliActorHitTest(void)
2928 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2930 mTouchPoint(touchPoint),
2936 Vector2 mTouchPoint;
2940 TestApplication application;
2941 tet_infoline(" UtcDaliActorHitTest");
2943 // Fill a vector with different hit tests.
2944 struct HitTestData* hitTestData[] = {
2945 // scale touch point result
2946 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
2947 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2948 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.
2949 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2950 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.
2954 // get the root layer
2955 Actor actor = Actor::New();
2956 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2957 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2959 application.GetScene().Add(actor);
2961 ResetTouchCallbacks();
2963 unsigned int index = 0;
2964 while(NULL != hitTestData[index])
2966 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2967 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2969 // flush the queue and render once
2970 application.SendNotification();
2971 application.Render();
2973 DALI_TEST_CHECK(!gTouchCallBackCalled);
2975 // connect to its touch signal
2976 actor.TouchedSignal().Connect(TestTouchCallback);
2978 Dali::Integration::Point point;
2979 point.SetState(PointState::DOWN);
2980 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2981 Dali::Integration::TouchEvent event;
2982 event.AddPoint(point);
2984 // flush the queue and render once
2985 application.SendNotification();
2986 application.Render();
2987 application.ProcessEvent(event);
2989 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
2991 if(gTouchCallBackCalled != hitTestData[index]->mResult)
2992 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2993 hitTestData[index]->mScale.x,
2994 hitTestData[index]->mScale.y,
2995 hitTestData[index]->mScale.z,
2996 hitTestData[index]->mTouchPoint.x,
2997 hitTestData[index]->mTouchPoint.y,
2998 hitTestData[index]->mResult);
3000 ResetTouchCallbacks();
3006 int UtcDaliActorSetDrawMode(void)
3008 TestApplication application;
3009 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
3011 Actor a = Actor::New();
3013 application.GetScene().Add(a);
3014 application.SendNotification();
3015 application.Render(0);
3016 application.SendNotification();
3017 application.Render(1);
3019 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
3021 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3022 application.SendNotification();
3023 application.Render(1);
3025 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
3027 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3028 application.SendNotification();
3029 application.Render(1);
3031 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
3035 int UtcDaliActorSetDrawModeOverlayRender(void)
3037 TestApplication application;
3038 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
3040 application.SendNotification();
3041 application.Render(1);
3043 std::vector<GLuint> ids;
3044 ids.push_back(8); // first rendered actor
3045 ids.push_back(9); // second rendered actor
3046 ids.push_back(10); // third rendered actor
3047 application.GetGlAbstraction().SetNextTextureIds(ids);
3049 Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3050 Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3051 Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
3052 Actor a = CreateRenderableActor(imageA);
3053 Actor b = CreateRenderableActor(imageB);
3054 Actor c = CreateRenderableActor(imageC);
3056 application.SendNotification();
3057 application.Render(1);
3059 //Textures are bound when first created. Clear bound textures vector
3060 application.GetGlAbstraction().ClearBoundTextures();
3062 // Render a,b,c as regular non-overlays. so order will be:
3066 application.GetScene().Add(a);
3067 application.GetScene().Add(b);
3068 application.GetScene().Add(c);
3070 application.SendNotification();
3071 application.Render(1);
3073 // Should be 3 textures changes.
3074 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3075 typedef std::vector<GLuint>::size_type TextureSize;
3076 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3077 if(boundTextures.size() == 3)
3079 DALI_TEST_CHECK(boundTextures[0] == 8u);
3080 DALI_TEST_CHECK(boundTextures[1] == 9u);
3081 DALI_TEST_CHECK(boundTextures[2] == 10u);
3084 // Now texture ids have been set, we can monitor their render order.
3085 // render a as an overlay (last), so order will be:
3089 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3090 application.GetGlAbstraction().ClearBoundTextures();
3092 application.SendNotification();
3093 application.Render(1);
3095 // Should be 3 texture changes.
3096 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3097 if(boundTextures.size() == 3)
3099 DALI_TEST_CHECK(boundTextures[0] == 9u);
3100 DALI_TEST_CHECK(boundTextures[1] == 10u);
3101 DALI_TEST_CHECK(boundTextures[2] == 8u);
3106 int UtcDaliActorGetCurrentWorldMatrix(void)
3108 TestApplication application;
3109 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3111 Actor parent = Actor::New();
3112 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3113 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3114 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3115 Radian rotationAngle(Degree(85.0f));
3116 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3117 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3118 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3119 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3120 parent.SetProperty(Actor::Property::SCALE, parentScale);
3121 application.GetScene().Add(parent);
3123 Actor child = Actor::New();
3124 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3125 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3126 Radian childRotationAngle(Degree(23.0f));
3127 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3128 Vector3 childScale(2.0f, 2.0f, 2.0f);
3129 child.SetProperty(Actor::Property::POSITION, childPosition);
3130 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3131 child.SetProperty(Actor::Property::SCALE, childScale);
3134 application.SendNotification();
3135 application.Render(0);
3136 application.Render();
3137 application.SendNotification();
3139 Matrix parentMatrix(false);
3140 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3142 Matrix childMatrix(false);
3143 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3145 //Child matrix should be the composition of child and parent
3146 Matrix childWorldMatrix(false);
3147 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3149 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3150 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3154 int UtcDaliActorConstrainedToWorldMatrix(void)
3156 TestApplication application;
3157 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3159 Actor parent = Actor::New();
3160 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3161 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3162 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3163 Radian rotationAngle(Degree(85.0f));
3164 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3165 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3166 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3167 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3168 parent.SetProperty(Actor::Property::SCALE, parentScale);
3169 application.GetScene().Add(parent);
3171 Actor child = Actor::New();
3172 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3173 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3174 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3175 posConstraint.Apply();
3177 application.GetScene().Add(child);
3179 application.SendNotification();
3180 application.Render(0);
3181 application.Render();
3182 application.SendNotification();
3184 Matrix parentMatrix(false);
3185 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3187 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3188 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3192 int UtcDaliActorConstrainedToOrientation(void)
3194 TestApplication application;
3195 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3197 Actor parent = Actor::New();
3198 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3199 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3200 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3201 Radian rotationAngle(Degree(85.0f));
3202 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3203 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3204 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3205 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3206 parent.SetProperty(Actor::Property::SCALE, parentScale);
3207 application.GetScene().Add(parent);
3209 Actor child = Actor::New();
3210 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3211 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3212 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3213 posConstraint.Apply();
3215 application.GetScene().Add(child);
3217 application.SendNotification();
3218 application.Render(0);
3219 application.Render();
3220 application.SendNotification();
3222 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3226 int UtcDaliActorConstrainedToOpacity(void)
3228 TestApplication application;
3229 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3231 Actor parent = Actor::New();
3232 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3233 application.GetScene().Add(parent);
3235 Actor child = Actor::New();
3236 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3237 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3238 opacityConstraint.Apply();
3240 application.GetScene().Add(child);
3242 application.SendNotification();
3243 application.Render(0);
3244 application.Render();
3245 application.SendNotification();
3247 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3249 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3251 application.SendNotification();
3252 application.Render(0);
3253 application.Render();
3254 application.SendNotification();
3256 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3261 int UtcDaliActorUnparent(void)
3263 TestApplication application;
3264 tet_infoline(" UtcDaliActorUnparent");
3266 Actor parent = Actor::New();
3267 application.GetScene().Add(parent);
3269 Actor child = Actor::New();
3271 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3272 DALI_TEST_CHECK(!child.GetParent());
3274 // Test that calling Unparent with no parent is a NOOP
3277 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3278 DALI_TEST_CHECK(!child.GetParent());
3280 // Test that Unparent works
3283 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3284 DALI_TEST_CHECK(parent == child.GetParent());
3288 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3289 DALI_TEST_CHECK(!child.GetParent());
3291 // Test that UnparentAndReset works
3294 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3295 DALI_TEST_CHECK(parent == child.GetParent());
3297 UnparentAndReset(child);
3299 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3300 DALI_TEST_CHECK(!child);
3302 // Test that UnparentAndReset is a NOOP with empty handle
3303 UnparentAndReset(child);
3305 DALI_TEST_CHECK(!child);
3309 int UtcDaliActorGetChildAt(void)
3311 TestApplication application;
3312 tet_infoline(" UtcDaliActorGetChildAt");
3314 Actor parent = Actor::New();
3315 application.GetScene().Add(parent);
3317 Actor child0 = Actor::New();
3320 Actor child1 = Actor::New();
3323 Actor child2 = Actor::New();
3326 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3327 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3328 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3332 int UtcDaliActorSetGetOverlay(void)
3334 TestApplication application;
3335 tet_infoline(" UtcDaliActorSetGetOverlay");
3337 Actor parent = Actor::New();
3338 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3339 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3343 int UtcDaliActorCreateDestroy(void)
3345 Actor* actor = new Actor;
3346 DALI_TEST_CHECK(actor);
3353 struct PropertyStringIndex
3355 const char* const name;
3356 const Property::Index index;
3357 const Property::Type type;
3360 const PropertyStringIndex PROPERTY_TABLE[] =
3362 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3363 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3364 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3365 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3366 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3367 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3368 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3369 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3370 {"size", Actor::Property::SIZE, Property::VECTOR3},
3371 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3372 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3373 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3374 {"position", Actor::Property::POSITION, Property::VECTOR3},
3375 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3376 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3377 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3378 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3379 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3380 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3381 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3382 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3383 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3384 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3385 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3386 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3387 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3388 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3389 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3390 {"color", Actor::Property::COLOR, Property::VECTOR4},
3391 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3392 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3393 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3394 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3395 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3396 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3397 {"name", Actor::Property::NAME, Property::STRING},
3398 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3399 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3400 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3401 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3402 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3403 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3404 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3405 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3406 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3407 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3408 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3409 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3410 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3411 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3412 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3413 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3414 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3415 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3417 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3418 } // unnamed namespace
3420 int UtcDaliActorProperties(void)
3422 TestApplication application;
3424 Actor actor = Actor::New();
3426 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3428 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3429 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3430 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3431 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3436 int UtcDaliRelayoutProperties_ResizePolicies(void)
3438 TestApplication application;
3440 Actor actor = Actor::New();
3443 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3444 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3446 // Set resize policy for all dimensions
3447 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3448 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3450 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3453 // Set individual dimensions
3454 const char* const widthPolicy = "FILL_TO_PARENT";
3455 const char* const heightPolicy = "FIXED";
3457 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3458 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3460 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3461 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3463 // Set individual dimensions using enums
3464 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3465 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3467 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3468 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3470 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3471 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3476 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3478 TestApplication application;
3480 Actor actor = Actor::New();
3483 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3485 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3486 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3487 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3490 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3491 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3493 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3494 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3496 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3497 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3502 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3504 TestApplication application;
3506 Actor actor = Actor::New();
3509 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3510 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3512 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3513 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3514 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3517 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3519 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3520 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3525 int UtcDaliRelayoutProperties_DimensionDependency(void)
3527 TestApplication application;
3529 Actor actor = Actor::New();
3532 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3533 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3536 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3537 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3539 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3540 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3542 // Test setting another resize policy
3543 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3544 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3549 int UtcDaliRelayoutProperties_Padding(void)
3551 TestApplication application;
3553 Actor actor = Actor::New();
3556 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3559 actor.SetProperty(Actor::Property::PADDING, padding);
3560 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3562 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3567 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3569 TestApplication application;
3571 Actor actor = Actor::New();
3574 Vector2 minSize(1.0f, 2.0f);
3576 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3577 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3579 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3581 Vector2 maxSize(3.0f, 4.0f);
3583 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3584 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3586 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3591 int UtcDaliActorGetHeightForWidth(void)
3593 TestApplication application;
3595 Actor actor = Actor::New();
3597 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3602 int UtcDaliActorGetWidthForHeight(void)
3604 TestApplication application;
3606 Actor actor = Actor::New();
3608 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3613 int UtcDaliActorGetRelayoutSize(void)
3615 TestApplication application;
3617 Actor actor = Actor::New();
3619 // Add actor to stage
3620 application.GetScene().Add(actor);
3622 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3624 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3625 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3627 // Flush the queue and render once
3628 application.SendNotification();
3629 application.Render();
3631 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3636 int UtcDaliActorSetPadding(void)
3638 TestApplication application;
3640 Actor actor = Actor::New();
3643 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3645 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3646 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3647 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3648 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3650 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3651 actor.SetProperty(Actor::Property::PADDING, padding2);
3653 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3655 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3656 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3657 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3658 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3663 int UtcDaliActorSetMinimumSize(void)
3665 TestApplication application;
3667 Actor actor = Actor::New();
3669 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3671 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3672 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3674 Vector2 size2(1.0f, 2.0f);
3675 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3677 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3679 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3680 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3685 int UtcDaliActorSetMaximumSize(void)
3687 TestApplication application;
3689 Actor actor = Actor::New();
3691 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3693 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3694 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3696 Vector2 size2(1.0f, 2.0f);
3697 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3699 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3701 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3702 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3707 int UtcDaliActorOnRelayoutSignal(void)
3709 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3711 TestApplication application;
3714 gOnRelayoutCallBackCalled = false;
3715 gActorNamesRelayout.clear();
3717 Actor actor = Actor::New();
3718 actor.SetProperty(Actor::Property::NAME, "actor");
3719 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3722 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3724 // Add actor to stage
3725 application.GetScene().Add(actor);
3727 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3728 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3730 // Flush the queue and render once
3731 application.SendNotification();
3732 application.Render();
3734 // OnRelayout emitted
3735 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3736 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3741 int UtcDaliActorGetHierachyDepth(void)
3743 TestApplication application;
3744 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3746 /* Build tree of actors:
3756 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3758 Integration::Scene stage(application.GetScene());
3760 Actor actorA = Actor::New();
3761 Actor actorB = Actor::New();
3762 Actor actorC = Actor::New();
3763 Actor actorD = Actor::New();
3764 Actor actorE = Actor::New();
3765 Actor actorF = Actor::New();
3767 //Test that root actor has depth equal 0
3768 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3770 //Test actors return depth -1 when not connected to the tree
3771 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3772 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3773 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3774 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3775 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3776 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3778 //Create the hierarchy
3786 //Test actors return correct depth
3787 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3788 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3789 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3790 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3791 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3792 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3794 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3795 actorA.Remove(actorB);
3797 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3798 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3799 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3801 //Removing actorA from the stage. All actors should have depth equal -1
3802 stage.Remove(actorA);
3804 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3805 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3806 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3807 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3808 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3809 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3814 int UtcDaliActorAnchorPointPropertyAsString(void)
3816 TestApplication application;
3818 Actor actor = Actor::New();
3820 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3821 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3823 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3824 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3826 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3827 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3829 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3830 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3832 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3833 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3835 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3836 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3838 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3839 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3841 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3842 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3844 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3845 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3847 // Invalid should not change anything
3848 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3849 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3854 int UtcDaliActorParentOriginPropertyAsString(void)
3856 TestApplication application;
3858 Actor actor = Actor::New();
3860 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3861 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3863 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3864 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3866 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3867 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3869 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3870 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3872 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3873 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3875 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3876 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3878 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3879 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3881 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3882 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3884 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3885 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3887 // Invalid should not change anything
3888 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3889 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3894 int UtcDaliActorColorModePropertyAsString(void)
3896 TestApplication application;
3898 Actor actor = Actor::New();
3900 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3901 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3903 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3904 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3906 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3907 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3909 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3910 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3912 // Invalid should not change anything
3913 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3914 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3919 int UtcDaliActorDrawModePropertyAsString(void)
3921 TestApplication application;
3923 Actor actor = Actor::New();
3925 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3926 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3928 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3929 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3931 // Invalid should not change anything
3932 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3933 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3938 int UtcDaliActorColorModePropertyAsEnum(void)
3940 TestApplication application;
3942 Actor actor = Actor::New();
3944 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3945 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3947 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3948 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3950 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3951 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3953 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3954 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3959 int UtcDaliActorDrawModePropertyAsEnum(void)
3961 TestApplication application;
3963 Actor actor = Actor::New();
3965 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3966 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3968 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3969 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3974 int UtcDaliActorAddRendererP(void)
3976 tet_infoline("Testing Actor::AddRenderer");
3977 TestApplication application;
3979 Actor actor = Actor::New();
3981 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3983 Geometry geometry = CreateQuadGeometry();
3984 Shader shader = CreateShader();
3985 Renderer renderer = Renderer::New(geometry, shader);
3987 actor.AddRenderer(renderer);
3988 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3989 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
3994 int UtcDaliActorAddRendererN01(void)
3996 tet_infoline("Testing Actor::AddRenderer");
3997 TestApplication application;
3999 Actor actor = Actor::New();
4005 actor.AddRenderer(renderer);
4006 tet_printf("Assertion test failed - no Exception\n");
4007 tet_result(TET_FAIL);
4009 catch(Dali::DaliException& e)
4011 DALI_TEST_PRINT_ASSERT(e);
4012 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
4013 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4017 tet_printf("Assertion test failed - wrong Exception\n");
4018 tet_result(TET_FAIL);
4024 int UtcDaliActorAddRendererN02(void)
4026 tet_infoline("UtcDaliActorAddRendererN02");
4032 TestApplication application;
4034 Geometry geometry = CreateQuadGeometry();
4035 Shader shader = CreateShader();
4036 renderer = Renderer::New(geometry, shader);
4038 actor = Actor::New();
4041 // try illegal AddRenderer
4044 actor.AddRenderer(renderer);
4045 tet_printf("Assertion test failed - no Exception\n");
4046 tet_result(TET_FAIL);
4048 catch(Dali::DaliException& e)
4050 DALI_TEST_PRINT_ASSERT(e);
4051 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
4055 tet_printf("Assertion test failed - wrong Exception\n");
4056 tet_result(TET_FAIL);
4062 int UtcDaliActorAddRendererOnScene(void)
4064 tet_infoline("Testing Actor::AddRenderer");
4065 TestApplication application;
4067 Actor actor = Actor::New();
4068 application.GetScene().Add(actor);
4070 application.SendNotification();
4071 application.Render(0);
4073 Geometry geometry = CreateQuadGeometry();
4074 Shader shader = CreateShader();
4075 Renderer renderer = Renderer::New(geometry, shader);
4077 application.SendNotification();
4078 application.Render(0);
4082 actor.AddRenderer(renderer);
4083 tet_result(TET_PASS);
4087 tet_result(TET_FAIL);
4093 int UtcDaliActorRemoveRendererP1(void)
4095 tet_infoline("Testing Actor::RemoveRenderer");
4096 TestApplication application;
4098 Actor actor = Actor::New();
4100 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4103 Geometry geometry = CreateQuadGeometry();
4104 Shader shader = CreateShader();
4105 Renderer renderer = Renderer::New(geometry, shader);
4107 actor.AddRenderer(renderer);
4108 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4109 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4111 application.SendNotification();
4112 application.Render();
4116 Renderer renderer = actor.GetRendererAt(0);
4117 actor.RemoveRenderer(renderer);
4118 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4120 application.SendNotification();
4121 application.Render();
4124 // Call one final time to ensure that the renderer is actually removed after
4125 // the handle goes out of scope, and excercises the deletion code path in
4126 // scene graph and render.
4127 application.SendNotification();
4128 application.Render();
4133 int UtcDaliActorRemoveRendererP2(void)
4135 tet_infoline("Testing Actor::RemoveRenderer");
4136 TestApplication application;
4138 Actor actor = Actor::New();
4140 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4142 Geometry geometry = CreateQuadGeometry();
4143 Shader shader = CreateShader();
4144 Renderer renderer = Renderer::New(geometry, shader);
4146 actor.AddRenderer(renderer);
4147 application.SendNotification();
4148 application.Render();
4150 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4151 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4153 actor.RemoveRenderer(0);
4154 application.SendNotification();
4155 application.Render();
4157 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4159 // Shut down whilst holding onto the renderer handle.
4163 int UtcDaliActorRemoveRendererN(void)
4165 tet_infoline("Testing Actor::RemoveRenderer");
4166 TestApplication application;
4168 Actor actor = Actor::New();
4170 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4172 Geometry geometry = CreateQuadGeometry();
4173 Shader shader = CreateShader();
4174 Renderer renderer = Renderer::New(geometry, shader);
4176 actor.AddRenderer(renderer);
4177 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4178 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4180 actor.RemoveRenderer(10);
4181 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4182 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4187 // Clipping test helper functions:
4188 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4190 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4191 Actor actor = CreateRenderableActor(image);
4193 // Setup dimensions and position so actor is not skipped by culling.
4194 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4195 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4196 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4197 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4202 Actor CreateActorWithContent16x16()
4204 return CreateActorWithContent(16, 16);
4207 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4209 enabledDisableTrace.Reset();
4210 stencilTrace.Reset();
4211 enabledDisableTrace.Enable(true);
4212 stencilTrace.Enable(true);
4214 application.SendNotification();
4215 application.Render();
4217 enabledDisableTrace.Enable(false);
4218 stencilTrace.Enable(false);
4221 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4223 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4225 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4226 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4227 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4229 // @todo only test alpha if the framebuffer has an alpha channel
4230 //DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4233 int UtcDaliActorPropertyClippingP(void)
4235 // This test checks the clippingMode property.
4236 tet_infoline("Testing Actor::Property::ClippingMode: P");
4237 TestApplication application;
4239 Actor actor = Actor::New();
4241 // Check default clippingEnabled value.
4242 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4245 bool getValueResult = getValue.Get(value);
4246 DALI_TEST_CHECK(getValueResult);
4250 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4253 // Check setting the property to the stencil mode.
4254 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4256 // Check the new value was set.
4257 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4258 getValueResult = getValue.Get(value);
4259 DALI_TEST_CHECK(getValueResult);
4263 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4266 // Check setting the property to the scissor mode.
4267 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4269 // Check the new value was set.
4270 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4271 getValueResult = getValue.Get(value);
4272 DALI_TEST_CHECK(getValueResult);
4276 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4281 int UtcDaliActorPropertyClippingN(void)
4283 // Negative test case for Clipping.
4284 tet_infoline("Testing Actor::Property::ClippingMode: N");
4285 TestApplication application;
4287 Actor actor = Actor::New();
4289 // Check default clippingEnabled value.
4290 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4293 bool getValueResult = getValue.Get(value);
4294 DALI_TEST_CHECK(getValueResult);
4298 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4301 // Check setting an invalid property value won't change the current property value.
4302 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4304 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4305 getValueResult = getValue.Get(value);
4306 DALI_TEST_CHECK(getValueResult);
4310 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4316 int UtcDaliActorPropertyClippingActor(void)
4318 // This test checks that an actor is correctly setup for clipping.
4319 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4320 TestApplication application;
4322 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4323 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4324 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4325 size_t startIndex = 0u;
4327 // Create a clipping actor.
4328 Actor actorDepth1Clip = CreateActorWithContent16x16();
4329 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4330 application.GetScene().Add(actorDepth1Clip);
4332 // Gather the call trace.
4333 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4335 // Check we are writing to the color buffer.
4336 CheckColorMask(glAbstraction, true);
4338 // Check the stencil buffer was enabled.
4339 std::ostringstream oss;
4340 oss << std::hex << GL_STENCIL_TEST;
4341 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4343 // Check the stencil buffer was cleared.
4344 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4346 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4347 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4348 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4349 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4354 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4356 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4357 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4358 TestApplication application;
4360 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4361 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4362 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4363 size_t startIndex = 0u;
4365 // Create a clipping actor.
4366 Actor actorDepth1Clip = CreateActorWithContent16x16();
4367 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4368 application.GetScene().Add(actorDepth1Clip);
4370 // Gather the call trace.
4371 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4373 // Check we are writing to the color buffer.
4374 CheckColorMask(glAbstraction, true);
4376 // Check the stencil buffer was enabled.
4377 std::ostringstream oss;
4378 oss << std::hex << GL_STENCIL_TEST;
4379 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4381 // Check the stencil buffer was cleared.
4382 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4384 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4385 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4386 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4387 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4389 // Now disable the clipping
4390 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4392 // Gather the call trace.
4393 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4395 // Check the stencil buffer was disabled.
4396 std::ostringstream stencil;
4397 stencil << std::hex << GL_STENCIL_TEST;
4398 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4400 // Ensure all values in stencil-mask are set to 1.
4402 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4407 int UtcDaliActorPropertyClippingNestedChildren(void)
4409 // This test checks that a hierarchy of actors are clipped correctly by
4410 // writing to and reading from the correct bit-planes of the stencil buffer.
4411 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4412 TestApplication application;
4413 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4414 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4415 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4417 // Create a clipping actor.
4418 Actor actorDepth1Clip = CreateActorWithContent16x16();
4419 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4420 application.GetScene().Add(actorDepth1Clip);
4422 // Create a child actor.
4423 Actor childDepth2 = CreateActorWithContent16x16();
4424 actorDepth1Clip.Add(childDepth2);
4426 // Create another clipping actor.
4427 Actor childDepth2Clip = CreateActorWithContent16x16();
4428 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4429 childDepth2.Add(childDepth2Clip);
4431 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4432 // This tests the sort algorithm.
4433 Actor childDepth3 = CreateActorWithContent16x16();
4434 childDepth2Clip.Add(childDepth3);
4435 Actor childDepth4 = CreateActorWithContent16x16();
4436 childDepth3.Add(childDepth4);
4438 // Gather the call trace.
4439 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4441 // Check we are writing to the color buffer.
4442 CheckColorMask(glAbstraction, true);
4444 // Check the stencil buffer was enabled.
4445 std::ostringstream oss;
4446 oss << std::hex << GL_STENCIL_TEST;
4447 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4449 // Perform the test twice, once for 2D layer, and once for 3D.
4450 for(unsigned int i = 0u; i < 2u; ++i)
4452 size_t startIndex = 0u;
4454 // Check the stencil buffer was cleared.
4455 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4457 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4458 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4459 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4460 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4462 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4463 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
4464 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4466 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4467 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4468 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4469 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4471 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4472 // (Both must be set to pass the check).
4473 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4474 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4476 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4479 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4480 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4487 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4489 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4490 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4491 TestApplication application;
4492 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4493 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4495 /* We create a small tree of actors as follows:
4499 Clipping enabled -> B D
4503 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4506 for(int i = 0; i < 5; ++i)
4508 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4509 Actor actor = CreateRenderableActor(image);
4511 // Setup dimensions and position so actor is not skipped by culling.
4512 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4513 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4517 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4521 float b = i > 2 ? 1.0f : -1.0f;
4522 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4528 // Enable clipping on the actor at the top of the left branch.
4529 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4531 // Build the scene graph.
4532 application.GetScene().Add(actors[0]);
4535 actors[0].Add(actors[1]);
4536 actors[1].Add(actors[2]);
4539 actors[0].Add(actors[3]);
4540 actors[3].Add(actors[4]);
4542 // Gather the call trace.
4543 enabledDisableTrace.Reset();
4544 enabledDisableTrace.Enable(true);
4545 application.SendNotification();
4546 application.Render();
4547 enabledDisableTrace.Enable(false);
4549 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4551 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
4552 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4554 size_t startIndex = 0u;
4555 std::ostringstream blend;
4556 blend << std::hex << GL_BLEND;
4557 std::ostringstream stencil;
4558 stencil << std::hex << GL_STENCIL_TEST;
4560 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4561 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4562 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4564 // Swap the clipping actor from top of left branch to top of right branch.
4565 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4566 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4568 // Gather the call trace.
4569 enabledDisableTrace.Reset();
4570 enabledDisableTrace.Enable(true);
4571 application.SendNotification();
4572 application.Render();
4573 enabledDisableTrace.Enable(false);
4575 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4576 // This proves the draw order has remained the same.
4578 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4579 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4584 int UtcDaliActorPropertyScissorClippingActor01(void)
4586 // This test checks that an actor is correctly setup for clipping.
4587 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4588 TestApplication application;
4590 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4591 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4592 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4594 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4595 const Vector2 imageSize(16.0f, 16.0f);
4597 // Create a clipping actor.
4598 Actor clippingActorA = CreateActorWithContent16x16();
4599 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4600 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4601 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4602 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4603 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4604 application.GetScene().Add(clippingActorA);
4606 // Gather the call trace.
4607 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4609 // Check we are writing to the color buffer.
4610 CheckColorMask(glAbstraction, true);
4612 // Check scissor test was enabled.
4614 std::ostringstream scissor;
4615 scissor << std::hex << GL_SCISSOR_TEST;
4616 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4618 // Check the scissor was set, and the coordinates are correct.
4619 std::stringstream compareParametersString;
4620 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4621 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4623 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4624 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4626 // Gather the call trace.
4627 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4629 // Check the scissor was set, and the coordinates are correct.
4630 compareParametersString.str(std::string());
4631 compareParametersString.clear();
4632 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4633 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4638 int UtcDaliActorPropertyScissorClippingActor02(void)
4640 // This test checks that an actor is correctly setup for clipping.
4641 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer");
4642 TestApplication application;
4644 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4645 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4646 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4648 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4649 const Vector2 actorSize(16.0f, 16.0f);
4651 // Create a clipping actor.
4652 Actor clippingActorA = CreateRenderableActor();
4653 clippingActorA[Actor::Property::SIZE] = actorSize;
4655 Renderer renderer = clippingActorA.GetRendererAt(0);
4656 DALI_TEST_CHECK(renderer);
4658 // Make Renderer opacity 0.
4659 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
4661 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4662 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4663 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4664 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4665 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4666 application.GetScene().Add(clippingActorA);
4668 // Gather the call trace.
4669 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4671 // Check we are writing to the color buffer.
4672 CheckColorMask(glAbstraction, true);
4674 // Check scissor test was enabled.
4676 std::ostringstream scissor;
4677 scissor << std::hex << GL_SCISSOR_TEST;
4678 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4680 // Check the scissor was set, and the coordinates are correct.
4681 std::stringstream compareParametersString;
4682 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
4683 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4685 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4686 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4688 // Gather the call trace.
4689 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4691 // Check the scissor was set, and the coordinates are correct.
4692 compareParametersString.str(std::string());
4693 compareParametersString.clear();
4694 compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y;
4695 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4700 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4702 // This test checks that an actor is correctly setup for clipping.
4703 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4704 TestApplication application;
4706 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4707 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4708 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4710 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4711 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4712 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4714 // Create a clipping actors.
4715 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4716 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4718 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4719 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4720 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4722 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4723 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4724 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4726 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4727 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4729 application.GetScene().Add(clippingActorA);
4730 application.GetScene().Add(clippingActorB);
4732 // Gather the call trace.
4733 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4735 // Check we are writing to the color buffer.
4736 CheckColorMask(glAbstraction, true);
4738 // Check scissor test was enabled.
4739 std::ostringstream scissor;
4740 scissor << std::hex << GL_SCISSOR_TEST;
4741 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4743 // Check the scissor was set, and the coordinates are correct.
4744 std::stringstream compareParametersString;
4746 std::string clipA("0, 500, 480, 200");
4747 std::string clipB("0, 380, 480, 40");
4749 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4750 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4755 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4757 // This test checks that an actor is correctly setup for clipping.
4758 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4759 TestApplication application;
4761 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4762 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4763 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4765 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4766 const Vector2 imageSize(16.0f, 16.0f);
4768 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4770 A is drawn first - with scissor clipping on
4771 B is drawn second - also with scissor clipping on
4772 C is the generated clipping region, the intersection ( A ∩ B )
4776 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4777 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4778 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4782 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4785 // Create a clipping actor.
4786 Actor clippingActorA = CreateActorWithContent16x16();
4787 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4788 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4789 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4790 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4791 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4792 application.GetScene().Add(clippingActorA);
4794 // Create a child clipping actor.
4795 Actor clippingActorB = CreateActorWithContent16x16();
4796 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4797 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4798 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4799 clippingActorA.Add(clippingActorB);
4801 // positionModifiers is an array of positions to position B around.
4802 // expect is an array of expected scissor clip coordinate results.
4803 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4804 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4806 // Loop through each overlap combination.
4807 for(unsigned int test = 0u; test < 4u; ++test)
4809 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4810 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4811 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4813 // Gather the call trace.
4814 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4816 // Check we are writing to the color buffer.
4817 CheckColorMask(glAbstraction, true);
4819 // Check scissor test was enabled.
4820 std::ostringstream scissor;
4821 scissor << std::hex << GL_SCISSOR_TEST;
4822 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4824 // Check the scissor was set, and the coordinates are correct.
4825 const Vector4& expectResults(expect[test]);
4826 std::stringstream compareParametersString;
4827 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4828 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4834 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4836 // This test checks that an actor is correctly setup for clipping.
4837 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4838 TestApplication application;
4840 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4841 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4842 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4844 /* Create a nest of 2 scissors and siblings of the parent.
4854 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4855 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4856 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4857 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4858 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4859 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4861 // Create a clipping actors.
4862 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4863 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4864 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4865 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4866 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4868 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4869 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4870 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4872 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4873 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4874 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4876 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4877 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4878 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4880 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4881 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4882 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4884 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4885 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4887 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4888 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4889 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4890 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4891 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4893 application.GetScene().Add(clippingActorA);
4894 clippingActorA.Add(clippingActorB);
4895 application.GetScene().Add(clippingActorC);
4896 application.GetScene().Add(clippingActorD);
4897 clippingActorD.Add(clippingActorE);
4899 // Gather the call trace.
4900 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4902 // Check we are writing to the color buffer.
4903 CheckColorMask(glAbstraction, true);
4905 // Check scissor test was enabled.
4906 std::ostringstream scissor;
4907 scissor << std::hex << GL_SCISSOR_TEST;
4908 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4910 // Check the scissor was set, and the coordinates are correct.
4911 std::string clipA("0, 500, 480, 200");
4912 std::string clipB("0, 580, 480, 40");
4913 std::string clipC("0, 200, 480, 200");
4914 std::string clipD("0, 300, 480, 200");
4916 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4917 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4918 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4919 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4920 DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4925 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4927 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4928 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4929 TestApplication application;
4931 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4932 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4933 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4935 // Create a clipping actor.
4936 Actor actorDepth1Clip = CreateActorWithContent16x16();
4937 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4938 application.GetScene().Add(actorDepth1Clip);
4940 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4941 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4943 // Gather the call trace.
4944 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4946 // Check we are writing to the color buffer.
4947 CheckColorMask(glAbstraction, true);
4949 // Check the stencil buffer was not enabled.
4950 std::ostringstream stencil;
4951 stencil << std::hex << GL_STENCIL_TEST;
4952 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
4954 // Check stencil functions are not called.
4955 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4956 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4958 // Check that scissor clipping is overriden by the renderer properties.
4959 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4961 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4963 // Gather the call trace.
4964 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4966 // Check the stencil buffer was not enabled.
4967 std::ostringstream scissor;
4968 scissor << std::hex << GL_SCISSOR_TEST;
4969 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4971 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4976 int UtcDaliActorPropertyClippingActorCulled(void)
4978 // This test checks that child actors are clipped by an culled parent actor.
4979 tet_infoline("Testing child actors are clipped by an culled parent actor");
4980 TestApplication application;
4982 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4983 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4984 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4986 const Vector2 actorSize(160.0f, 160.0f);
4988 // Create a clipping actor.
4989 Actor clippingActorA = CreateRenderableActor();
4990 clippingActorA[Actor::Property::SIZE] = actorSize;
4992 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4993 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4994 clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
4995 clippingActorA[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
4996 clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX;
4997 application.GetScene().Add(clippingActorA);
4999 // Create a child actor
5000 Actor childActor = CreateRenderableActor();
5001 childActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT;
5002 childActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT;
5003 childActor[Actor::Property::SIZE] = Vector2(50.0f, 50.0f);
5004 childActor[Actor::Property::INHERIT_POSITION] = false;
5006 // Gather the call trace.
5007 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5009 // Check scissor test was enabled.
5010 std::ostringstream scissor;
5011 scissor << std::hex << GL_SCISSOR_TEST;
5012 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
5014 // Check the scissor was set, and the coordinates are correct.
5015 std::stringstream compareParametersString;
5016 compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y;
5017 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
5019 // Move the clipping actor out of screen
5020 clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f);
5022 // Gather the call trace.
5023 GenerateTrace(application, enabledDisableTrace, scissorTrace);
5025 // Check the scissor was set, and the coordinates are correct.
5026 compareParametersString.str(std::string());
5027 compareParametersString.clear();
5028 compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0;
5029 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty.
5034 int UtcDaliGetPropertyN(void)
5036 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
5037 TestApplication application;
5039 Actor actor = Actor::New();
5041 unsigned int propertyCount = actor.GetPropertyCount();
5042 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
5046 int UtcDaliActorRaiseLower(void)
5048 tet_infoline("UtcDaliActor Raise and Lower test\n");
5050 TestApplication application;
5052 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
5054 Integration::Scene stage(application.GetScene());
5056 Actor actorA = Actor::New();
5057 Actor actorB = Actor::New();
5058 Actor actorC = Actor::New();
5060 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5061 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5063 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5064 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5066 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5067 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5069 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5070 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5072 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5073 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5075 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5076 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5082 ResetTouchCallbacks();
5084 application.SendNotification();
5085 application.Render();
5087 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5088 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5089 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5091 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5092 // Only top actor will get touched.
5093 actorA.TouchedSignal().Connect(TestTouchCallback);
5094 actorB.TouchedSignal().Connect(TestTouchCallback2);
5095 actorC.TouchedSignal().Connect(TestTouchCallback3);
5097 // Connect ChildOrderChangedSignal
5098 bool orderChangedSignal(false);
5099 Actor orderChangedActor;
5100 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5101 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5103 Dali::Integration::Point point;
5104 point.SetDeviceId(1);
5105 point.SetState(PointState::DOWN);
5106 point.SetScreenPosition(Vector2(10.f, 10.f));
5107 Dali::Integration::TouchEvent touchEvent;
5108 touchEvent.AddPoint(point);
5110 application.ProcessEvent(touchEvent);
5112 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5113 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5114 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5116 ResetTouchCallbacks();
5118 tet_printf("Testing Raising of Actor\n");
5120 int preActorOrder(0);
5121 int postActorOrder(0);
5123 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5124 value.Get(preActorOrder);
5126 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5128 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5129 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5131 // Ensure sort order is calculated before next touch event
5132 application.SendNotification();
5134 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5135 value.Get(postActorOrder);
5137 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5139 application.ProcessEvent(touchEvent);
5141 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5142 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5143 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5145 ResetTouchCallbacks();
5147 tet_printf("Testing Lowering of Actor\n");
5149 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5150 value.Get(preActorOrder);
5152 orderChangedSignal = false;
5154 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5156 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5157 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5159 application.SendNotification(); // ensure sort order calculated before next touch event
5161 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
5162 value.Get(postActorOrder);
5164 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
5166 application.ProcessEvent(touchEvent);
5168 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5169 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5170 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5172 ResetTouchCallbacks();
5174 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
5179 int UtcDaliActorRaiseToTopLowerToBottom(void)
5181 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
5183 TestApplication application;
5185 Integration::Scene stage(application.GetScene());
5187 Actor actorA = Actor::New();
5188 Actor actorB = Actor::New();
5189 Actor actorC = Actor::New();
5191 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5192 // enables checking of which actor the uniform is assigned too
5193 Shader shaderA = CreateShader();
5194 shaderA.RegisterProperty("uRendererColor", 1.f);
5196 Shader shaderB = CreateShader();
5197 shaderB.RegisterProperty("uRendererColor", 2.f);
5199 Shader shaderC = CreateShader();
5200 shaderC.RegisterProperty("uRendererColor", 3.f);
5202 Geometry geometry = CreateQuadGeometry();
5204 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5205 Renderer rendererA = Renderer::New(geometry, shaderA);
5206 actorA.AddRenderer(rendererA);
5208 Renderer rendererB = Renderer::New(geometry, shaderB);
5209 actorB.AddRenderer(rendererB);
5211 Renderer rendererC = Renderer::New(geometry, shaderC);
5212 actorC.AddRenderer(rendererC);
5214 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5215 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5217 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5218 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5220 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5221 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5223 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5224 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5226 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5227 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5229 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5230 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5236 ResetTouchCallbacks();
5238 // Connect ChildOrderChangedSignal
5239 bool orderChangedSignal(false);
5240 Actor orderChangedActor;
5241 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5242 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5244 // Set up gl abstraction trace so can query the set uniform order
5245 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5246 glAbstraction.EnableSetUniformCallTrace(true);
5247 glAbstraction.ResetSetUniformCallStack();
5249 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5251 application.SendNotification();
5252 application.Render();
5254 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5256 // Test order of uniforms in stack
5257 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5258 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5259 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5261 bool CBA = (indexC > indexB) && (indexB > indexA);
5263 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5265 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5266 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5267 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5269 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5270 // Only top actor will get touched.
5271 actorA.TouchedSignal().Connect(TestTouchCallback);
5272 actorB.TouchedSignal().Connect(TestTouchCallback2);
5273 actorC.TouchedSignal().Connect(TestTouchCallback3);
5275 Dali::Integration::Point point;
5276 point.SetDeviceId(1);
5277 point.SetState(PointState::DOWN);
5278 point.SetScreenPosition(Vector2(10.f, 10.f));
5279 Dali::Integration::TouchEvent touchEvent;
5280 touchEvent.AddPoint(point);
5282 application.ProcessEvent(touchEvent);
5284 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5285 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5286 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5288 ResetTouchCallbacks();
5290 tet_printf("RaiseToTop ActorA\n");
5292 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5293 actorA.RaiseToTop();
5294 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5295 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5297 application.SendNotification(); // ensure sorting order is calculated before next touch event
5299 application.ProcessEvent(touchEvent);
5301 glSetUniformStack.Reset();
5303 application.SendNotification();
5304 application.Render();
5306 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5308 // Test order of uniforms in stack
5309 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5310 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5311 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5313 tet_infoline("Testing A above C and B at bottom\n");
5314 bool ACB = (indexA > indexC) && (indexC > indexB);
5316 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5318 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5319 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5320 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5322 ResetTouchCallbacks();
5324 tet_printf("RaiseToTop ActorB\n");
5326 orderChangedSignal = false;
5328 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5329 actorB.RaiseToTop();
5330 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5331 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5333 application.SendNotification(); // Ensure sort order is calculated before next touch event
5335 application.ProcessEvent(touchEvent);
5337 glSetUniformStack.Reset();
5339 application.SendNotification();
5340 application.Render();
5342 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5344 // Test order of uniforms in stack
5345 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5346 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5347 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5349 tet_infoline("Testing B above A and C at bottom\n");
5350 bool BAC = (indexB > indexA) && (indexA > indexC);
5352 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5354 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5355 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5356 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5358 ResetTouchCallbacks();
5360 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5362 orderChangedSignal = false;
5364 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5365 actorA.LowerToBottom();
5366 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5367 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5369 application.SendNotification();
5370 application.Render();
5372 orderChangedSignal = false;
5374 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5375 actorB.LowerToBottom();
5376 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5377 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5379 application.SendNotification();
5380 application.Render();
5382 application.ProcessEvent(touchEvent);
5384 glSetUniformStack.Reset();
5386 application.SendNotification();
5387 application.Render();
5389 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5391 // Test order of uniforms in stack
5392 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5393 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5394 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5396 tet_infoline("Testing C above A and B at bottom\n");
5397 bool CAB = (indexC > indexA) && (indexA > indexB);
5399 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5401 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5402 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5403 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5405 ResetTouchCallbacks();
5410 int UtcDaliActorRaiseAbove(void)
5412 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5414 TestApplication application;
5416 Integration::Scene stage(application.GetScene());
5418 Actor actorA = Actor::New();
5419 Actor actorB = Actor::New();
5420 Actor actorC = Actor::New();
5422 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5423 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5425 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5426 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5428 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5429 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5431 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5432 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5434 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5435 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5437 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5438 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5444 ResetTouchCallbacks();
5446 application.SendNotification();
5447 application.Render();
5449 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5450 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5451 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5453 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5454 // Only top actor will get touched.
5455 actorA.TouchedSignal().Connect(TestTouchCallback);
5456 actorB.TouchedSignal().Connect(TestTouchCallback2);
5457 actorC.TouchedSignal().Connect(TestTouchCallback3);
5459 bool orderChangedSignal(false);
5460 Actor orderChangedActor;
5461 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5462 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5464 Dali::Integration::Point point;
5465 point.SetDeviceId(1);
5466 point.SetState(PointState::DOWN);
5467 point.SetScreenPosition(Vector2(10.f, 10.f));
5468 Dali::Integration::TouchEvent touchEvent;
5469 touchEvent.AddPoint(point);
5471 application.ProcessEvent(touchEvent);
5473 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5474 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5475 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5477 ResetTouchCallbacks();
5479 tet_printf("Raise actor B Above Actor C\n");
5481 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5482 actorB.RaiseAbove(actorC);
5483 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5484 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5486 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5487 application.SendNotification();
5488 application.ProcessEvent(touchEvent);
5490 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5491 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5492 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5494 ResetTouchCallbacks();
5496 tet_printf("Raise actor A Above Actor B\n");
5498 orderChangedSignal = false;
5500 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5501 actorA.RaiseAbove(actorB);
5502 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5503 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5505 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5506 application.SendNotification();
5508 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5510 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5511 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5512 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5514 ResetTouchCallbacks();
5519 int UtcDaliActorRaiseAbove2(void)
5521 tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5523 TestApplication application;
5525 Integration::Scene stage(application.GetScene());
5527 Actor actorA = Actor::New();
5528 Actor actorB = Actor::New();
5529 Actor actorC = Actor::New();
5531 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5532 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5534 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5535 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5537 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5538 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5540 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5541 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5543 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5544 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5546 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5547 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5553 ResetTouchCallbacks();
5555 application.SendNotification();
5556 application.Render();
5558 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5559 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5560 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5562 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5563 // Only top actor will get touched.
5564 actorA.TouchedSignal().Connect(TestTouchCallback);
5565 actorB.TouchedSignal().Connect(TestTouchCallback2);
5566 actorC.TouchedSignal().Connect(TestTouchCallback3);
5568 bool orderChangedSignal(false);
5569 Actor orderChangedActor;
5570 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5571 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5573 Dali::Integration::Point point;
5574 point.SetDeviceId(1);
5575 point.SetState(PointState::DOWN);
5576 point.SetScreenPosition(Vector2(10.f, 10.f));
5577 Dali::Integration::TouchEvent touchEvent;
5578 touchEvent.AddPoint(point);
5580 application.ProcessEvent(touchEvent);
5582 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5583 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5584 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5586 ResetTouchCallbacks();
5588 tet_printf("Raise actor B Above Actor C\n");
5590 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5591 int newOrder = actorC[DevelActor::Property::SIBLING_ORDER];
5592 actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5593 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5594 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5596 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5597 application.SendNotification();
5598 application.ProcessEvent(touchEvent);
5600 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5601 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5602 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5604 ResetTouchCallbacks();
5606 tet_printf("Raise actor A Above Actor B\n");
5608 orderChangedSignal = false;
5610 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5611 newOrder = actorB[DevelActor::Property::SIBLING_ORDER];
5612 actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5613 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5614 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5616 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5617 application.SendNotification();
5619 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5621 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5622 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5623 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5625 ResetTouchCallbacks();
5630 int UtcDaliActorLowerBelow(void)
5632 tet_infoline("UtcDaliActor LowerBelow test \n");
5634 TestApplication application;
5636 Integration::Scene stage(application.GetScene());
5638 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5639 // enables checking of which actor the uniform is assigned too
5640 Shader shaderA = CreateShader();
5641 shaderA.RegisterProperty("uRendererColor", 1.f);
5643 Shader shaderB = CreateShader();
5644 shaderB.RegisterProperty("uRendererColor", 2.f);
5646 Shader shaderC = CreateShader();
5647 shaderC.RegisterProperty("uRendererColor", 3.f);
5649 Actor actorA = Actor::New();
5650 Actor actorB = Actor::New();
5651 Actor actorC = Actor::New();
5653 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5654 Geometry geometry = CreateQuadGeometry();
5656 Renderer rendererA = Renderer::New(geometry, shaderA);
5657 actorA.AddRenderer(rendererA);
5659 Renderer rendererB = Renderer::New(geometry, shaderB);
5660 actorB.AddRenderer(rendererB);
5662 Renderer rendererC = Renderer::New(geometry, shaderC);
5663 actorC.AddRenderer(rendererC);
5665 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5666 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5668 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5669 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5671 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5672 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5674 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5675 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5677 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5678 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5680 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5681 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5683 Actor container = Actor::New();
5684 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5685 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5686 stage.Add(container);
5688 container.Add(actorA);
5689 container.Add(actorB);
5690 container.Add(actorC);
5692 ResetTouchCallbacks();
5694 // Connect ChildOrderChangedSignal
5695 bool orderChangedSignal(false);
5696 Actor orderChangedActor;
5697 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5698 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5700 // Set up gl abstraction trace so can query the set uniform order
5701 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5702 glAbstraction.EnableSetUniformCallTrace(true);
5703 glAbstraction.ResetSetUniformCallStack();
5704 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5706 glAbstraction.ResetSetUniformCallStack();
5708 application.SendNotification();
5709 application.Render();
5711 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5713 // Test order of uniforms in stack
5714 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5715 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5716 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5718 tet_infoline("Testing C above B and A at bottom\n");
5719 bool CBA = (indexC > indexB) && (indexB > indexA);
5721 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5723 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5724 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5725 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5727 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5728 // Only top actor will get touched.
5729 actorA.TouchedSignal().Connect(TestTouchCallback);
5730 actorB.TouchedSignal().Connect(TestTouchCallback2);
5731 actorC.TouchedSignal().Connect(TestTouchCallback3);
5733 Dali::Integration::Point point;
5734 point.SetDeviceId(1);
5735 point.SetState(PointState::DOWN);
5736 point.SetScreenPosition(Vector2(10.f, 10.f));
5737 Dali::Integration::TouchEvent touchEvent;
5738 touchEvent.AddPoint(point);
5740 tet_infoline("UtcDaliActor Test Set up completed \n");
5742 application.ProcessEvent(touchEvent);
5744 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5745 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5746 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5748 ResetTouchCallbacks();
5750 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");
5752 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5753 actorC.LowerBelow(actorB);
5754 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5755 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5757 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5758 application.SendNotification();
5759 application.Render();
5761 application.ProcessEvent(touchEvent); // touch event
5763 glSetUniformStack.Reset();
5765 application.SendNotification();
5766 application.Render();
5768 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5770 // Test order of uniforms in stack
5771 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5772 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5773 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5775 tet_infoline("Testing render order is A, C, B");
5776 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5777 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5779 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5780 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5781 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5783 ResetTouchCallbacks();
5785 tet_printf("Lower actor C below Actor A leaving B on top\n");
5787 orderChangedSignal = false;
5789 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5790 actorC.LowerBelow(actorA);
5791 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5792 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5794 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5795 application.SendNotification();
5796 application.Render();
5798 application.ProcessEvent(touchEvent);
5800 glSetUniformStack.Reset();
5802 application.Render();
5803 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5805 // Test order of uniforms in stack
5806 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5807 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5808 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5810 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5811 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5813 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5814 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5815 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5817 ResetTouchCallbacks();
5819 tet_printf("Lower actor B below Actor C leaving A on top\n");
5821 orderChangedSignal = false;
5823 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5824 actorB.LowerBelow(actorC);
5825 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5826 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5828 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5829 application.SendNotification();
5830 application.Render();
5832 application.ProcessEvent(touchEvent);
5834 glSetUniformStack.Reset();
5836 application.Render();
5837 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5839 // Test order of uniforms in stack
5840 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5841 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5842 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5844 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5845 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5850 int UtcDaliActorLowerBelow2(void)
5852 tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
5854 TestApplication application;
5856 Integration::Scene stage(application.GetScene());
5858 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5859 // enables checking of which actor the uniform is assigned too
5860 Shader shaderA = CreateShader();
5861 shaderA.RegisterProperty("uRendererColor", 1.f);
5863 Shader shaderB = CreateShader();
5864 shaderB.RegisterProperty("uRendererColor", 2.f);
5866 Shader shaderC = CreateShader();
5867 shaderC.RegisterProperty("uRendererColor", 3.f);
5869 Actor actorA = Actor::New();
5870 Actor actorB = Actor::New();
5871 Actor actorC = Actor::New();
5873 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5874 Geometry geometry = CreateQuadGeometry();
5876 Renderer rendererA = Renderer::New(geometry, shaderA);
5877 actorA.AddRenderer(rendererA);
5879 Renderer rendererB = Renderer::New(geometry, shaderB);
5880 actorB.AddRenderer(rendererB);
5882 Renderer rendererC = Renderer::New(geometry, shaderC);
5883 actorC.AddRenderer(rendererC);
5885 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5886 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5888 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5889 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5891 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5892 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5894 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5895 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5897 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5898 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5900 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5901 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5903 Actor container = Actor::New();
5904 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5905 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5906 stage.Add(container);
5908 container.Add(actorA);
5909 container.Add(actorB);
5910 container.Add(actorC);
5912 ResetTouchCallbacks();
5914 // Connect ChildOrderChangedSignal
5915 bool orderChangedSignal(false);
5916 Actor orderChangedActor;
5917 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5918 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5920 // Set up gl abstraction trace so can query the set uniform order
5921 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5922 glAbstraction.EnableSetUniformCallTrace(true);
5923 glAbstraction.ResetSetUniformCallStack();
5924 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5926 glAbstraction.ResetSetUniformCallStack();
5928 application.SendNotification();
5929 application.Render();
5931 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5933 // Test order of uniforms in stack
5934 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5935 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5936 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5938 tet_infoline("Testing C above B and A at bottom\n");
5939 bool CBA = (indexC > indexB) && (indexB > indexA);
5941 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5943 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5944 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5945 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5947 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5948 // Only top actor will get touched.
5949 actorA.TouchedSignal().Connect(TestTouchCallback);
5950 actorB.TouchedSignal().Connect(TestTouchCallback2);
5951 actorC.TouchedSignal().Connect(TestTouchCallback3);
5953 Dali::Integration::Point point;
5954 point.SetDeviceId(1);
5955 point.SetState(PointState::DOWN);
5956 point.SetScreenPosition(Vector2(10.f, 10.f));
5957 Dali::Integration::TouchEvent touchEvent;
5958 touchEvent.AddPoint(point);
5960 tet_infoline("UtcDaliActor Test Set up completed \n");
5962 application.ProcessEvent(touchEvent);
5964 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5965 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5966 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5968 ResetTouchCallbacks();
5970 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");
5972 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5973 actorC[DevelActor::Property::SIBLING_ORDER] = 1;
5974 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5975 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5977 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5978 application.SendNotification();
5979 application.Render();
5981 application.ProcessEvent(touchEvent); // touch event
5983 glSetUniformStack.Reset();
5985 application.SendNotification();
5986 application.Render();
5988 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5990 // Test order of uniforms in stack
5991 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5992 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5993 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5995 tet_infoline("Testing render order is A, C, B");
5996 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5997 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5999 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6000 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6001 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6003 ResetTouchCallbacks();
6005 tet_printf("Lower actor C below Actor A leaving B on top\n");
6007 orderChangedSignal = false;
6009 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6010 actorC[DevelActor::Property::SIBLING_ORDER] = 0;
6011 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6012 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
6014 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6015 application.SendNotification();
6016 application.Render();
6018 application.ProcessEvent(touchEvent);
6020 glSetUniformStack.Reset();
6022 application.Render();
6023 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6025 // Test order of uniforms in stack
6026 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6027 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6028 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6030 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6031 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
6033 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6034 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6035 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6037 ResetTouchCallbacks();
6039 tet_printf("Lower actor B below Actor C leaving A on top\n");
6041 orderChangedSignal = false;
6043 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6044 actorB[DevelActor::Property::SIBLING_ORDER] = 0;
6045 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6046 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
6048 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6049 application.SendNotification();
6050 application.Render();
6052 application.ProcessEvent(touchEvent);
6054 glSetUniformStack.Reset();
6056 application.Render();
6057 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
6059 // Test order of uniforms in stack
6060 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
6061 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
6062 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
6064 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
6065 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
6070 int UtcDaliActorRaiseAboveDifferentParentsN(void)
6072 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
6074 TestApplication application;
6076 Integration::Scene stage(application.GetScene());
6078 Actor parentA = Actor::New();
6079 Actor parentB = Actor::New();
6080 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6081 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6082 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6083 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6085 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6086 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6088 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6089 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6094 Actor actorA = Actor::New();
6095 Actor actorB = Actor::New();
6096 Actor actorC = Actor::New();
6098 parentA.Add(actorA);
6099 parentA.Add(actorB);
6101 tet_printf("Actor C added to different parent from A and B \n");
6102 parentB.Add(actorC);
6104 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6105 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6107 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6108 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6110 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6111 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6113 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6114 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6116 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6117 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6119 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6120 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6122 ResetTouchCallbacks();
6124 // Connect ChildOrderChangedSignal
6125 bool orderChangedSignal(false);
6126 Actor orderChangedActor;
6127 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6128 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6130 application.SendNotification();
6131 application.Render();
6133 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6134 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6135 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6137 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6138 // Only top actor will get touched.
6139 actorA.TouchedSignal().Connect(TestTouchCallback);
6140 actorB.TouchedSignal().Connect(TestTouchCallback2);
6141 actorC.TouchedSignal().Connect(TestTouchCallback3);
6143 Dali::Integration::Point point;
6144 point.SetDeviceId(1);
6145 point.SetState(PointState::DOWN);
6146 point.SetScreenPosition(Vector2(10.f, 10.f));
6147 Dali::Integration::TouchEvent touchEvent;
6148 touchEvent.AddPoint(point);
6150 application.ProcessEvent(touchEvent);
6152 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6153 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6154 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6156 ResetTouchCallbacks();
6158 tet_printf("Raise actor A Above Actor C which have different parents\n");
6160 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6161 actorA.RaiseAbove(actorC);
6162 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6164 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6165 application.SendNotification();
6167 application.ProcessEvent(touchEvent); // touch event
6169 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6170 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6171 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6173 ResetTouchCallbacks();
6178 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
6180 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
6182 TestApplication application;
6184 Integration::Scene stage(application.GetScene());
6186 Actor actorA = Actor::New();
6187 Actor actorB = Actor::New();
6188 Actor actorC = Actor::New();
6190 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6191 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6193 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6194 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6196 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6197 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6199 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6200 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6202 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6203 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6205 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6206 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6208 ResetTouchCallbacks();
6210 // Connect ChildOrderChangedSignal
6211 bool orderChangedSignal(false);
6212 Actor orderChangedActor;
6213 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6214 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6216 application.SendNotification();
6217 application.Render();
6219 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6220 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6221 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6223 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6224 // Only top actor will get touched.
6225 actorA.TouchedSignal().Connect(TestTouchCallback);
6226 actorB.TouchedSignal().Connect(TestTouchCallback2);
6227 actorC.TouchedSignal().Connect(TestTouchCallback3);
6229 Dali::Integration::Point point;
6230 point.SetDeviceId(1);
6231 point.SetState(PointState::DOWN);
6232 point.SetScreenPosition(Vector2(10.f, 10.f));
6233 Dali::Integration::TouchEvent touchEvent;
6234 touchEvent.AddPoint(point);
6236 tet_printf("Raise actor A Above Actor C which have no parents\n");
6238 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6239 actorA.RaiseAbove(actorC);
6240 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6242 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6243 application.SendNotification();
6245 application.ProcessEvent(touchEvent);
6247 tet_printf("Not parented so RaiseAbove should show no effect\n");
6249 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6250 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6251 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6253 ResetTouchCallbacks();
6255 orderChangedSignal = false;
6258 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6260 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6261 actorA.LowerBelow(actorC);
6262 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6264 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6265 application.SendNotification();
6266 application.Render();
6268 application.ProcessEvent(touchEvent);
6270 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6271 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6272 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6273 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6275 ResetTouchCallbacks();
6277 orderChangedSignal = false;
6279 tet_printf("Adding Actor A to stage, will be on top\n");
6282 application.SendNotification();
6283 application.Render();
6285 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6287 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6288 actorB.RaiseAbove(actorC);
6289 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6291 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6292 application.SendNotification();
6294 application.ProcessEvent(touchEvent);
6296 tet_printf("C not parented so RaiseAbove should show no effect\n");
6297 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6298 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6299 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6301 ResetTouchCallbacks();
6303 orderChangedSignal = false;
6305 tet_printf("Lower actor A below Actor C when only A has a parent\n");
6307 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6308 actorA.LowerBelow(actorC);
6309 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6311 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6312 application.SendNotification();
6314 application.ProcessEvent(touchEvent);
6316 tet_printf("C not parented so LowerBelow should show no effect\n");
6317 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6318 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6319 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6321 ResetTouchCallbacks();
6323 orderChangedSignal = false;
6327 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6328 actorA.RaiseAbove(actorC);
6329 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6330 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6332 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6333 application.SendNotification();
6334 application.Render();
6336 application.ProcessEvent(touchEvent);
6338 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6339 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6340 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6341 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6346 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6348 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6350 TestApplication application;
6352 Integration::Scene stage(application.GetScene());
6354 Actor actorA = Actor::New();
6355 Actor actorB = Actor::New();
6356 Actor actorC = Actor::New();
6358 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6359 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6361 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6362 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6364 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6365 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6367 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6368 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6370 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6371 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6373 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6374 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6376 ResetTouchCallbacks();
6378 // Connect ChildOrderChangedSignal
6379 bool orderChangedSignal(false);
6380 Actor orderChangedActor;
6381 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6382 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6384 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6385 // Only top actor will get touched.
6386 actorA.TouchedSignal().Connect(TestTouchCallback);
6387 actorB.TouchedSignal().Connect(TestTouchCallback2);
6388 actorC.TouchedSignal().Connect(TestTouchCallback3);
6390 Dali::Integration::Point point;
6391 point.SetDeviceId(1);
6392 point.SetState(PointState::DOWN);
6393 point.SetScreenPosition(Vector2(10.f, 10.f));
6394 Dali::Integration::TouchEvent touchEvent;
6395 touchEvent.AddPoint(point);
6398 tet_printf("Raise actor B Above Actor C but B not parented\n");
6400 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6402 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6404 application.SendNotification();
6405 application.Render();
6407 application.ProcessEvent(touchEvent);
6409 tet_printf("Not parented so RaiseAbove should show no effect\n");
6411 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6412 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6413 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6415 tet_printf("Raise actor B Above Actor C but B not parented\n");
6416 ResetTouchCallbacks();
6418 orderChangedSignal = false;
6420 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6422 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6424 // Sort actor tree before next touch event
6425 application.SendNotification();
6426 application.Render();
6428 application.ProcessEvent(touchEvent);
6430 tet_printf("Not parented so RaiseAbove should show no effect\n");
6432 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6433 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6434 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6435 ResetTouchCallbacks();
6437 orderChangedSignal = false;
6439 tet_printf("Lower actor C below B but C not parented\n");
6441 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6443 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6445 // Sort actor tree before next touch event
6446 application.SendNotification();
6447 application.Render();
6449 application.ProcessEvent(touchEvent);
6451 tet_printf("Not parented so Lower should show no effect\n");
6453 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6454 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6455 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6456 ResetTouchCallbacks();
6458 orderChangedSignal = false;
6460 tet_printf("Raise actor B to top\n");
6462 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6463 actorB.RaiseToTop();
6464 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6466 // Sort actor tree before next touch event
6467 application.SendNotification();
6468 application.Render();
6470 application.ProcessEvent(touchEvent);
6472 tet_printf("Not parented so RaiseToTop should show no effect\n");
6474 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6475 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6476 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6477 ResetTouchCallbacks();
6479 orderChangedSignal = false;
6481 tet_printf("Add ActorB to stage so only Actor C not parented\n");
6485 tet_printf("Lower actor C to Bottom, B stays at top\n");
6487 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6488 actorC.LowerToBottom();
6489 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6491 application.SendNotification();
6492 application.Render();
6494 application.ProcessEvent(touchEvent);
6496 tet_printf("Not parented so LowerToBottom should show no effect\n");
6498 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6499 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6500 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6501 ResetTouchCallbacks();
6506 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6508 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
6510 TestApplication application;
6512 Integration::Scene stage(application.GetScene());
6514 Actor actorA = Actor::New();
6515 Actor actorB = Actor::New();
6516 Actor actorC = Actor::New();
6518 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6519 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6521 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6522 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6524 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6525 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6527 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6528 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6530 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6531 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6533 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6534 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6540 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6541 // Only top actor will get touched.
6542 actorA.TouchedSignal().Connect(TestTouchCallback);
6543 actorB.TouchedSignal().Connect(TestTouchCallback2);
6544 actorC.TouchedSignal().Connect(TestTouchCallback3);
6546 ResetTouchCallbacks();
6548 // Connect ChildOrderChangedSignal
6549 bool orderChangedSignal(false);
6550 Actor orderChangedActor;
6551 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6552 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6554 application.SendNotification();
6555 application.Render();
6557 Dali::Integration::Point point;
6558 point.SetDeviceId(1);
6559 point.SetState(PointState::DOWN);
6560 point.SetScreenPosition(Vector2(10.f, 10.f));
6561 Dali::Integration::TouchEvent touchEvent;
6562 touchEvent.AddPoint(point);
6564 application.ProcessEvent(touchEvent);
6566 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6567 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6568 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6570 ResetTouchCallbacks();
6572 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6574 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6575 actorA.RaiseAbove(actorA);
6576 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6577 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6579 application.SendNotification();
6580 application.Render();
6582 application.ProcessEvent(touchEvent);
6584 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6586 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6587 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6588 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6590 ResetTouchCallbacks();
6592 orderChangedSignal = false;
6594 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6595 actorA.RaiseAbove(actorC);
6596 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6597 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6599 application.SendNotification();
6600 application.Render();
6602 application.ProcessEvent(touchEvent);
6604 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6605 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6606 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6607 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6612 int UtcDaliActorGetScreenPosition(void)
6614 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6616 TestApplication application;
6618 Integration::Scene stage(application.GetScene());
6620 Actor actorA = Actor::New();
6621 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6623 Vector2 size2(10.0f, 20.0f);
6624 actorA.SetProperty(Actor::Property::SIZE, size2);
6626 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6628 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6632 application.SendNotification();
6633 application.Render();
6635 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6636 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6638 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6639 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6641 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6642 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6644 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6646 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6648 application.SendNotification();
6649 application.Render();
6651 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6652 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6654 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6655 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6657 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6658 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6660 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6662 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6664 application.SendNotification();
6665 application.Render();
6667 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6668 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6670 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6671 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6673 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6674 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6676 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6678 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6680 application.SendNotification();
6681 application.Render();
6683 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6684 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6686 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6687 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6689 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6690 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6692 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6694 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6696 application.SendNotification();
6697 application.Render();
6699 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6700 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6702 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6703 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6705 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6706 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6708 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6710 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6711 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6713 Actor actorB = Actor::New();
6714 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6715 actorB.SetProperty(Actor::Property::SIZE, size2);
6716 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6719 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6721 application.SendNotification();
6722 application.Render();
6724 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6726 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6727 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6732 int UtcDaliActorGetScreenPositionAfterScaling(void)
6734 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6736 TestApplication application;
6738 Integration::Scene stage(application.GetScene());
6740 Actor actorA = Actor::New();
6741 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6743 Vector2 size2(10.0f, 20.0f);
6744 actorA.SetProperty(Actor::Property::SIZE, size2);
6745 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6746 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6748 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6752 application.SendNotification();
6753 application.Render();
6755 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6756 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6758 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6759 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6761 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6762 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6764 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6766 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6768 application.SendNotification();
6769 application.Render();
6771 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6772 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6774 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6775 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6777 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6778 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6783 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6785 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6787 TestApplication application;
6789 Integration::Scene stage(application.GetScene());
6791 Actor actorA = Actor::New();
6792 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6793 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6794 Vector2 size2(10.0f, 20.0f);
6795 actorA.SetProperty(Actor::Property::SIZE, size2);
6796 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6798 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6802 application.SendNotification();
6803 application.Render();
6805 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6806 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6808 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6809 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6811 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6812 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6814 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6816 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6817 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6819 application.SendNotification();
6820 application.Render();
6822 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6823 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6825 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6826 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6828 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6829 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6835 int UtcDaliActorGetScreenPositionWithChildActors(void)
6837 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6839 TestApplication application;
6841 Integration::Scene stage(application.GetScene());
6843 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6845 Actor actorA = Actor::New();
6846 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6847 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6848 Vector2 size1(10.0f, 20.0f);
6849 actorA.SetProperty(Actor::Property::SIZE, size1);
6850 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6852 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6854 Actor parentActorA = Actor::New();
6855 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6856 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6857 Vector2 size2(30.0f, 60.0f);
6858 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6859 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6861 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6863 stage.Add(parentActorA);
6864 parentActorA.Add(actorA);
6866 application.SendNotification();
6867 application.Render();
6869 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6870 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6872 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6873 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6875 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6876 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6878 tet_infoline("Test 2\n");
6880 tet_infoline("change parent anchor point and parent origin then check screen position \n");
6882 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6883 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6885 application.SendNotification();
6886 application.Render();
6888 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6889 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6891 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6892 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6894 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6895 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6900 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6902 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6904 TestApplication application;
6906 Integration::Scene stage(application.GetScene());
6908 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6910 Actor actorA = Actor::New();
6911 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6912 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6913 Vector2 size1(10.0f, 20.0f);
6914 actorA.SetProperty(Actor::Property::SIZE, size1);
6915 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6917 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6919 Actor parentActorA = Actor::New();
6920 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6921 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6922 Vector2 size2(30.0f, 60.0f);
6923 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6924 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6926 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6928 Actor grandParentActorA = Actor::New();
6929 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6930 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6931 Vector2 size3(60.0f, 120.0f);
6932 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6933 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6935 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6937 stage.Add(grandParentActorA);
6938 grandParentActorA.Add(parentActorA);
6940 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6942 parentActorA.Add(actorA);
6944 application.SendNotification();
6945 application.Render();
6947 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6948 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6950 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6951 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6953 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6954 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6959 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6961 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6963 TestApplication application;
6965 Integration::Scene stage(application.GetScene());
6967 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6969 Actor actorA = Actor::New();
6970 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6971 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6972 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6973 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6976 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6978 Actor actorB = Actor::New();
6979 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6980 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6981 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6982 Vector2 actorBSize(30.0f, 60.0f);
6983 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6986 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6988 Actor actorC = Actor::New();
6989 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6990 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6991 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6992 Vector2 actorCSize(60.0f, 120.0f);
6993 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6996 application.SendNotification();
6997 application.Render();
6999 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
7001 Vector2 center(stage.GetSize() * 0.5f);
7003 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7004 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7005 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
7007 tet_infoline("Add scale to all actors");
7009 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
7010 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
7011 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
7013 application.SendNotification();
7014 application.Render();
7016 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
7017 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
7018 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
7023 int utcDaliActorPositionUsesAnchorPoint(void)
7025 TestApplication application;
7026 tet_infoline("Check default behaviour\n");
7028 Actor actor = Actor::New();
7029 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7030 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7031 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7032 application.GetScene().Add(actor);
7034 application.SendNotification();
7035 application.Render();
7037 tet_infoline("Check that the world position is in the center\n");
7038 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7040 tet_infoline("Set the position uses anchor point property to false\n");
7041 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7043 application.SendNotification();
7044 application.Render();
7046 tet_infoline("Check that the world position has changed appropriately\n");
7047 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7052 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
7054 TestApplication application;
7055 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7057 Actor actor = Actor::New();
7058 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7059 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7060 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7061 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7062 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7063 application.GetScene().Add(actor);
7065 application.SendNotification();
7066 application.Render();
7068 tet_infoline("Check the world position is the same as it would be without a scale\n");
7069 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7071 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7072 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7073 application.SendNotification();
7074 application.Render();
7075 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
7077 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7078 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7079 application.SendNotification();
7080 application.Render();
7081 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
7086 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
7088 TestApplication application;
7089 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7091 Actor actor = Actor::New();
7092 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7093 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7094 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7095 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7096 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7097 application.GetScene().Add(actor);
7099 application.SendNotification();
7100 application.Render();
7102 tet_infoline("Check the world position is the same as it would be without a rotation\n");
7103 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7105 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7106 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7107 application.SendNotification();
7108 application.Render();
7109 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
7111 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7112 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7113 application.SendNotification();
7114 application.Render();
7115 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
7120 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
7122 TestApplication application;
7123 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7125 Actor actor = Actor::New();
7126 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7127 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7128 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7129 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
7130 actor.SetProperty(Actor::Property::SCALE, 2.0f);
7131 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7132 application.GetScene().Add(actor);
7134 application.SendNotification();
7135 application.Render();
7137 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
7138 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
7140 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
7141 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7142 application.SendNotification();
7143 application.Render();
7144 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
7146 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
7147 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7148 application.SendNotification();
7149 application.Render();
7150 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
7155 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
7157 TestApplication application;
7158 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
7160 Actor parent = Actor::New();
7162 application.GetScene().Add(parent);
7163 Vector2 stageSize(application.GetScene().GetSize());
7165 Actor actor = Actor::New();
7166 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
7167 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
7168 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7169 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
7170 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
7171 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
7174 application.SendNotification();
7175 application.Render();
7177 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
7179 tet_infoline("Check the world position is in the right place\n");
7180 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7182 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
7183 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7184 application.SendNotification();
7185 application.Render();
7186 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7188 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
7189 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
7190 application.SendNotification();
7191 application.Render();
7192 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7197 int utcDaliActorVisibilityChangeSignalSelf(void)
7199 TestApplication application;
7200 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7202 Actor actor = Actor::New();
7204 VisibilityChangedFunctorData data;
7205 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7207 actor.SetProperty(Actor::Property::VISIBLE, false);
7209 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7211 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7214 actor.SetProperty(Actor::Property::VISIBLE, false);
7215 data.Check(false /* not called */, TEST_LOCATION);
7217 tet_infoline("Change the visibility using properties, ensure called");
7220 actor.SetProperty(Actor::Property::VISIBLE, true);
7221 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7223 tet_infoline("Set the visibility to current using properties, ensure not called");
7226 actor.SetProperty(Actor::Property::VISIBLE, true);
7227 data.Check(false /* not called */, TEST_LOCATION);
7232 int utcDaliActorVisibilityChangeSignalChildren(void)
7234 TestApplication application;
7235 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7237 Actor parent = Actor::New();
7238 Actor child = Actor::New();
7241 Actor grandChild = Actor::New();
7242 child.Add(grandChild);
7244 VisibilityChangedFunctorData parentData;
7245 VisibilityChangedFunctorData childData;
7246 VisibilityChangedFunctorData grandChildData;
7248 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7249 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7250 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7252 parent.SetProperty(Actor::Property::VISIBLE, false);
7253 parentData.Check(false /* not called */, TEST_LOCATION);
7254 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7255 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7257 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7260 grandChildData.Reset();
7262 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7264 parent.SetProperty(Actor::Property::VISIBLE, true);
7265 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7266 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7267 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7269 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7272 grandChildData.Reset();
7274 parent.SetProperty(Actor::Property::VISIBLE, true);
7275 parentData.Check(false /* not called */, TEST_LOCATION);
7276 childData.Check(false /* not called */, TEST_LOCATION);
7277 grandChildData.Check(false /* not called */, TEST_LOCATION);
7282 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7284 TestApplication application;
7285 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7287 Actor actor = Actor::New();
7288 application.GetScene().Add(actor);
7290 application.SendNotification();
7291 application.Render();
7293 VisibilityChangedFunctorData data;
7294 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7296 Animation animation = Animation::New(1.0f);
7297 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7299 data.Check(false, TEST_LOCATION);
7300 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7301 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7303 tet_infoline("Play the animation and check the property value");
7306 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7307 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7309 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7310 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7312 application.SendNotification();
7313 application.Render(1100); // After the animation
7315 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7320 int utcDaliActorVisibilityChangeSignalByName(void)
7322 TestApplication application;
7323 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7325 Actor actor = Actor::New();
7327 bool signalCalled = false;
7328 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7329 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7330 actor.SetProperty(Actor::Property::VISIBLE, false);
7331 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7333 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7334 signalCalled = false;
7335 actor.SetProperty(Actor::Property::VISIBLE, false);
7336 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7338 tet_infoline("Change the visibility using properties, ensure called");
7339 actor.SetProperty(Actor::Property::VISIBLE, true);
7340 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7342 tet_infoline("Set the visibility to current using properties, ensure not called");
7343 signalCalled = false;
7345 actor.SetProperty(Actor::Property::VISIBLE, true);
7346 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7351 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7353 gLayoutDirectionType = type;
7356 int UtcDaliActorLayoutDirectionProperty(void)
7358 TestApplication application;
7359 tet_infoline("Check layout direction property");
7361 Actor actor0 = Actor::New();
7362 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7363 application.GetScene().Add(actor0);
7365 application.SendNotification();
7366 application.Render();
7368 Actor actor1 = Actor::New();
7369 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7370 Actor actor2 = Actor::New();
7371 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7372 Actor actor3 = Actor::New();
7373 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7374 Actor actor4 = Actor::New();
7375 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7376 Actor actor5 = Actor::New();
7377 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7378 Actor actor6 = Actor::New();
7379 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7380 Actor actor7 = Actor::New();
7381 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7382 Actor actor8 = Actor::New();
7383 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7384 Actor actor9 = Actor::New();
7385 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7388 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7389 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7391 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7392 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7393 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7395 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7396 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7397 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7399 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7401 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7402 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7404 application.GetScene().Add(actor3);
7411 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7412 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7414 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7415 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7416 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7418 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7420 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7421 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7422 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7423 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7424 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7425 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7426 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7428 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7429 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7430 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7432 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7433 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7434 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7435 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7437 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7438 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7439 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7444 struct LayoutDirectionFunctor
7446 LayoutDirectionFunctor(bool& signalCalled)
7447 : mSignalCalled(signalCalled)
7451 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7452 : mSignalCalled(rhs.mSignalCalled)
7458 mSignalCalled = true;
7461 bool& mSignalCalled;
7464 int UtcDaliActorLayoutDirectionSignal(void)
7466 TestApplication application;
7467 tet_infoline("Check changing layout direction property sends a signal");
7469 Actor actor = Actor::New();
7470 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7471 application.GetScene().Add(actor);
7472 bool signalCalled = false;
7473 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7475 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7476 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7478 // Test that writing the same value doesn't send a signal
7479 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7480 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7482 // Test that writing a different value sends the signal
7483 signalCalled = false;
7484 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7485 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7487 signalCalled = false;
7488 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7489 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7494 struct ChildAddedSignalCheck
7496 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7497 : mSignalReceived(signalReceived),
7498 mChildHandle(childHandle)
7502 void operator()(Actor childHandle)
7504 mSignalReceived = true;
7505 mChildHandle = childHandle;
7509 mSignalReceived = true;
7510 mChildHandle = Actor();
7513 bool& mSignalReceived;
7514 Actor& mChildHandle;
7517 int UtcDaliChildAddedSignalP1(void)
7519 TestApplication application;
7520 auto stage = application.GetScene();
7522 bool signalReceived = false;
7525 ChildAddedSignalCheck signal(signalReceived, childActor);
7526 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7527 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7529 auto actorA = Actor::New();
7531 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7532 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7533 signalReceived = false;
7535 auto actorB = Actor::New();
7537 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7538 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7543 int UtcDaliChildAddedSignalP2(void)
7545 TestApplication application;
7546 auto stage = application.GetScene();
7548 bool signalReceived = false;
7551 ChildAddedSignalCheck signal(signalReceived, childActor);
7552 tet_infoline("Connect to childAdded signal by name");
7554 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7555 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7557 auto actorA = Actor::New();
7559 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7561 // Can't test which actor was added; signal signature is void() when connecting via name.
7562 signalReceived = false;
7564 auto actorB = Actor::New();
7566 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7571 int UtcDaliChildAddedSignalN(void)
7573 TestApplication application;
7574 auto stage = application.GetScene();
7576 bool signalReceived = false;
7579 ChildAddedSignalCheck signal(signalReceived, childActor);
7580 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7581 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7583 auto actorA = Actor::New();
7585 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7586 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7587 signalReceived = false;
7589 auto actorB = Actor::New();
7591 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7595 struct ChildRemovedSignalCheck
7597 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7598 : mSignalReceived(signalReceived),
7599 mChildHandle(childHandle)
7603 void operator()(Actor childHandle)
7605 mSignalReceived = true;
7606 mChildHandle = childHandle;
7611 mSignalReceived = true;
7614 bool& mSignalReceived;
7615 Actor& mChildHandle;
7618 int UtcDaliChildRemovedSignalP1(void)
7620 TestApplication application;
7621 auto stage = application.GetScene();
7623 bool signalReceived = false;
7626 ChildRemovedSignalCheck signal(signalReceived, childActor);
7627 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7628 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7630 auto actorA = Actor::New();
7632 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7633 DALI_TEST_CHECK(!childActor);
7635 stage.Remove(actorA);
7636 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7637 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7639 signalReceived = false;
7640 auto actorB = Actor::New();
7642 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7644 stage.Remove(actorB);
7645 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7646 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7651 int UtcDaliChildRemovedSignalP2(void)
7653 TestApplication application;
7654 auto stage = application.GetScene();
7656 bool signalReceived = false;
7659 ChildAddedSignalCheck signal(signalReceived, childActor);
7660 tet_infoline("Connect to childRemoved signal by name");
7662 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7663 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7665 auto actorA = Actor::New();
7667 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7669 stage.Remove(actorA);
7670 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7672 signalReceived = false;
7673 auto actorB = Actor::New();
7675 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7677 stage.Remove(actorB);
7678 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7683 int UtcDaliChildRemovedSignalN(void)
7685 TestApplication application;
7686 auto stage = application.GetScene();
7688 bool signalReceived = false;
7691 ChildRemovedSignalCheck signal(signalReceived, childActor);
7692 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7693 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7695 auto actorA = Actor::New();
7698 auto actorB = Actor::New();
7701 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7702 DALI_TEST_CHECK(!childActor);
7704 actorA.Remove(actorB);
7705 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7709 int UtcDaliChildMovedSignalP(void)
7711 TestApplication application;
7712 auto stage = application.GetScene();
7714 bool addedASignalReceived = false;
7715 bool removedASignalReceived = false;
7716 bool addedBSignalReceived = false;
7717 bool removedBSignalReceived = false;
7720 auto actorA = Actor::New();
7721 auto actorB = Actor::New();
7725 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
7726 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7727 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
7728 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7730 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7731 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7732 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7733 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7735 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7736 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7737 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7738 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7740 // Create a child of A
7742 auto child = Actor::New();
7745 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7746 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7747 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7748 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7749 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7752 addedASignalReceived = false;
7753 addedBSignalReceived = false;
7754 removedASignalReceived = false;
7755 removedBSignalReceived = false;
7757 actorB.Add(child); // Expect this child to be re-parented
7758 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7759 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7760 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7761 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7763 // Move child back to A:
7764 addedASignalReceived = false;
7765 addedBSignalReceived = false;
7766 removedASignalReceived = false;
7767 removedBSignalReceived = false;
7769 actorA.Add(child); // Expect this child to be re-parented
7770 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7771 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7772 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7773 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7778 int UtcDaliActorSwitchParentP(void)
7780 tet_infoline("Testing Actor::UtcDaliActorSwitchParentP");
7781 TestApplication application;
7783 Actor parent1 = Actor::New();
7784 Actor child = Actor::New();
7786 application.GetScene().Add(parent1);
7788 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7790 child.OnSceneSignal().Connect(OnSceneCallback);
7791 child.OffSceneSignal().Connect(OffSceneCallback);
7794 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
7795 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7799 DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION);
7801 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7802 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7804 Actor parent2 = Actor::New();
7805 application.GetScene().Add(parent2);
7807 bool addSignalReceived = false;
7808 ChildAddedSignalCheck addedSignal(addSignalReceived, child);
7809 DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal);
7810 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7812 bool removedSignalReceived = false;
7813 ChildRemovedSignalCheck removedSignal(removedSignalReceived, child);
7814 DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal);
7815 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7817 DevelActor::SwitchParent(child, parent2);
7819 DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION);
7820 DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION);
7822 DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION);
7823 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
7825 DALI_TEST_CHECK(gOnSceneCallBackCalled == 1);
7826 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
7827 DALI_TEST_CHECK(child.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE));
7828 DALI_TEST_CHECK(child.GetParent() == parent2);
7833 int utcDaliActorCulled(void)
7835 TestApplication application;
7836 auto stage = application.GetScene();
7838 tet_infoline("Check that the actor is culled if the actor is out of the screen");
7840 Actor actor = Actor::New();
7841 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7843 Geometry geometry = CreateQuadGeometry();
7844 Shader shader = CreateShader();
7845 Renderer renderer = Renderer::New(geometry, shader);
7846 actor.AddRenderer(renderer);
7850 application.SendNotification();
7851 application.Render(0);
7853 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7855 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7856 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7858 // Connect NotifySignal
7859 bool propertyNotificationSignal(false);
7860 PropertyNotification source;
7861 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7862 notification.NotifySignal().Connect(&application, f);
7864 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7866 application.SendNotification();
7867 application.Render();
7869 application.SendNotification();
7871 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7873 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7874 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7875 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7880 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7882 TestApplication application;
7883 auto stage = application.GetScene();
7885 tet_infoline("Ensure we clear the screen when the last actor is removed");
7887 Actor actor = CreateRenderableActor();
7888 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7891 application.SendNotification();
7892 application.Render();
7894 auto& glAbstraction = application.GetGlAbstraction();
7895 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7899 application.SendNotification();
7900 application.Render();
7902 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7907 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7909 TestApplication application;
7910 auto stage = application.GetScene();
7912 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7914 Actor actor = CreateRenderableActor();
7915 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7918 application.SendNotification();
7919 application.Render();
7921 auto& glAbstraction = application.GetGlAbstraction();
7922 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7924 actor.SetProperty(Actor::Property::VISIBLE, false);
7926 application.SendNotification();
7927 application.Render();
7929 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7934 int utcDaliActorGetSizeAfterAnimation(void)
7936 TestApplication application;
7937 tet_infoline("Check the actor size before / after an animation is finished");
7939 Vector3 actorSize(100.0f, 100.0f, 0.0f);
7941 Actor actor = Actor::New();
7942 actor.SetProperty(Actor::Property::SIZE, actorSize);
7943 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7944 application.GetScene().Add(actor);
7946 // Size should be updated without rendering.
7947 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7948 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7950 application.SendNotification();
7951 application.Render();
7953 // Size and current size should be updated.
7954 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7955 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7956 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7957 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7958 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7960 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7961 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7962 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7963 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7964 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7967 actorSize = Vector3(200.0f, 200.0f, 0.0f);
7968 actor.SetProperty(Actor::Property::SIZE, actorSize);
7970 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7971 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7973 Vector3 targetValue(10.0f, 20.0f, 0.0f);
7975 Animation animation = Animation::New(1.0f);
7976 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7979 // Size should be updated without rendering.
7980 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7981 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7983 application.SendNotification();
7984 application.Render(1100); // After the animation
7986 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7987 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7988 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7989 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7990 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7992 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7993 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7994 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7995 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7996 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7998 targetValue.width = 50.0f;
8001 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
8004 application.SendNotification();
8005 application.Render(1100); // After the animation
8007 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8008 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8009 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8010 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8011 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8013 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8014 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8015 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8016 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8017 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8019 targetValue.height = 70.0f;
8022 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
8025 application.SendNotification();
8026 application.Render(1100); // After the animation
8028 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8029 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8030 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8031 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8032 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8034 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8035 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8036 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
8037 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
8038 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
8040 Vector3 offset(10.0f, 20.0f, 0.0f);
8043 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
8046 application.SendNotification();
8047 application.Render(1100); // After the animation
8049 targetValue += offset;
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 offset.width = 20.0f;
8066 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
8069 application.SendNotification();
8070 application.Render(1100); // After the animation
8072 targetValue.width += offset.width;
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.height = 10.0f;
8089 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
8092 application.SendNotification();
8093 application.Render(1100); // After the animation
8095 targetValue.height += offset.height;
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);
8110 actorSize = Vector3(300.0f, 300.0f, 0.0f);
8112 actor.SetProperty(Actor::Property::SIZE, actorSize);
8114 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8115 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8117 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8118 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8120 application.SendNotification();
8121 application.Render();
8123 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8124 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8126 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8127 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8132 int utcDaliActorRelayoutAndAnimation(void)
8134 TestApplication application;
8135 tet_infoline("Check the actor size when relayoutting and playing animation");
8137 Vector3 parentSize(300.0f, 300.0f, 0.0f);
8138 Vector3 actorSize(100.0f, 100.0f, 0.0f);
8141 Actor parentA = Actor::New();
8142 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8143 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8144 application.GetScene().Add(parentA);
8146 Actor parentB = Actor::New();
8147 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8148 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8149 application.GetScene().Add(parentB);
8151 Actor actor = Actor::New();
8152 actor.SetProperty(Actor::Property::SIZE, actorSize);
8153 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8156 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8157 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8159 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8161 Animation animation = Animation::New(1.0f);
8162 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8165 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8166 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8168 application.SendNotification();
8169 application.Render(1100); // After the animation
8171 // Size and current size should be updated.
8172 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8173 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8175 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8176 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8181 application.SendNotification();
8182 application.Render();
8184 // Size and current size should be same.
8185 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8186 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8188 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8189 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8197 Actor parentA = Actor::New();
8198 parentA.SetProperty(Actor::Property::SIZE, parentSize);
8199 parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8200 application.GetScene().Add(parentA);
8202 Actor parentB = Actor::New();
8203 parentB.SetProperty(Actor::Property::SIZE, parentSize);
8204 parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8205 application.GetScene().Add(parentB);
8207 Actor actor = Actor::New();
8208 actor.SetProperty(Actor::Property::SIZE, actorSize);
8209 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8212 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8213 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8215 application.SendNotification();
8216 application.Render();
8218 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8219 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8221 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8222 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8224 Vector3 targetValue(200.0f, 200.0f, 0.0f);
8226 // Make an animation
8227 Animation animation = Animation::New(1.0f);
8228 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
8231 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8232 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8234 application.SendNotification();
8235 application.Render(1100); // After the animation
8237 // Size and current size should be updated.
8238 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8239 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8241 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8242 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8247 application.SendNotification();
8248 application.Render();
8250 // Size and current size should be same.
8251 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
8252 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8254 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
8255 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
8265 int utcDaliActorPartialUpdate(void)
8267 TestApplication application(
8268 TestApplication::DEFAULT_SURFACE_WIDTH,
8269 TestApplication::DEFAULT_SURFACE_HEIGHT,
8270 TestApplication::DEFAULT_HORIZONTAL_DPI,
8271 TestApplication::DEFAULT_VERTICAL_DPI,
8275 tet_infoline("Check the damaged area");
8277 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8279 std::vector<Rect<int>> damagedRects;
8280 Rect<int> clippingRect;
8281 application.SendNotification();
8282 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8284 // First render pass, nothing to render, adaptor would just do swap buffer.
8285 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8287 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8288 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8290 Actor actor = CreateRenderableActor();
8291 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8292 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8293 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8294 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8295 application.GetScene().Add(actor);
8297 application.SendNotification();
8299 // 1. Actor added, damaged rect is added size of actor
8300 damagedRects.clear();
8301 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8302 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8305 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8306 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8307 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8308 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8309 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8310 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8311 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8314 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
8315 application.SendNotification();
8317 damagedRects.clear();
8318 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8319 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8322 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
8323 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8324 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8325 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8326 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8327 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8328 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8330 // 3. Set new position
8331 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
8332 application.SendNotification();
8334 damagedRects.clear();
8335 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8336 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8339 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
8340 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8341 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8342 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8343 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8344 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8345 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8347 application.GetScene().Remove(actor);
8348 application.SendNotification();
8350 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
8351 damagedRects.clear();
8352 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8353 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
8355 clippingRect = damagedRects[0];
8356 clippingRect.Merge(damagedRects[1]);
8357 clippingRect.Merge(damagedRects[2]);
8359 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
8360 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
8361 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
8363 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8364 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8365 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8366 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8367 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8372 int utcDaliActorPartialUpdateSetColor(void)
8374 TestApplication application(
8375 TestApplication::DEFAULT_SURFACE_WIDTH,
8376 TestApplication::DEFAULT_SURFACE_HEIGHT,
8377 TestApplication::DEFAULT_HORIZONTAL_DPI,
8378 TestApplication::DEFAULT_VERTICAL_DPI,
8382 tet_infoline("Check uniform update");
8384 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8386 std::vector<Rect<int>> damagedRects;
8387 Rect<int> clippingRect;
8388 application.SendNotification();
8389 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8391 // First render pass, nothing to render, adaptor would just do swap buffer.
8392 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8394 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8395 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8397 Actor actor = CreateRenderableActor();
8398 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8399 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8400 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8401 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8402 application.GetScene().Add(actor);
8404 application.SendNotification();
8406 // 1. Actor added, damaged rect is added size of actor
8407 damagedRects.clear();
8408 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8409 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8412 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8413 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8414 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8415 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8416 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8417 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8418 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8420 damagedRects.clear();
8421 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8423 damagedRects.clear();
8424 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8427 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8428 application.SendNotification();
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);
8446 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8447 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8448 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8449 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8450 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8451 " uniform mediump mat4 uLightCameraViewMatrix;\n"
8455 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8456 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
8457 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8460 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8461 "uniform lowp vec4 uShadowColor;\n"
8464 " lowp float alpha;\n"
8465 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8466 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8469 int utcDaliActorPartialUpdateSetProperty(void)
8471 TestApplication application(
8472 TestApplication::DEFAULT_SURFACE_WIDTH,
8473 TestApplication::DEFAULT_SURFACE_HEIGHT,
8474 TestApplication::DEFAULT_HORIZONTAL_DPI,
8475 TestApplication::DEFAULT_VERTICAL_DPI,
8479 tet_infoline("Set/Update property with partial update");
8481 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8483 std::vector<Rect<int>> damagedRects;
8484 Rect<int> clippingRect;
8485 application.SendNotification();
8486 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8488 // First render pass, nothing to render, adaptor would just do swap buffer.
8489 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8491 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8492 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8494 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8495 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8496 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8497 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8498 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8499 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8500 application.GetScene().Add(actor);
8502 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8504 damagedRects.clear();
8505 application.SendNotification();
8506 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8507 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8510 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8511 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8512 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8513 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8514 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8515 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8516 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8518 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8519 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8521 damagedRects.clear();
8522 application.SendNotification();
8523 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8524 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8526 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8527 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8528 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8529 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8530 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8531 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8533 // Should be no damage rects, nothing changed
8534 damagedRects.clear();
8535 application.SendNotification();
8536 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8537 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8539 // Should be 1 damage rect due to change in size
8540 damagedRects.clear();
8541 actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8542 application.SendNotification();
8543 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8544 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8546 clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8547 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8548 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8549 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8550 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8551 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8552 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8554 damagedRects.clear();
8555 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8556 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8561 int utcDaliActorPartialUpdateTwoActors(void)
8563 TestApplication application(
8564 TestApplication::DEFAULT_SURFACE_WIDTH,
8565 TestApplication::DEFAULT_SURFACE_HEIGHT,
8566 TestApplication::DEFAULT_HORIZONTAL_DPI,
8567 TestApplication::DEFAULT_VERTICAL_DPI,
8571 tet_infoline("Check the damaged rects with partial update and two actors");
8573 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8575 Actor actor = CreateRenderableActor();
8576 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8577 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8578 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8579 application.GetScene().Add(actor);
8581 Actor actor2 = CreateRenderableActor();
8582 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8583 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8584 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8585 application.GetScene().Add(actor2);
8587 application.SendNotification();
8588 std::vector<Rect<int>> damagedRects;
8589 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8591 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8592 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8593 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8595 // in screen coordinates, adaptor would calculate it using previous frames information
8596 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8597 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8599 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8600 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8601 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8602 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8604 // Change a Renderer of actor1
8605 Geometry geometry = CreateQuadGeometry();
8606 Shader shader = CreateShader();
8607 Renderer newRenderer = Renderer::New(geometry, shader);
8608 Renderer renderer = actor.GetRendererAt(0);
8610 actor.RemoveRenderer(renderer);
8611 actor.AddRenderer(newRenderer);
8613 damagedRects.clear();
8615 application.SendNotification();
8616 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8618 DALI_TEST_CHECK(damagedRects.size() > 0);
8619 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8621 // in screen coordinates, adaptor would calculate it using previous frames information
8622 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8624 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8625 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8626 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8627 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8632 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8634 TestApplication application(
8635 TestApplication::DEFAULT_SURFACE_WIDTH,
8636 TestApplication::DEFAULT_SURFACE_HEIGHT,
8637 TestApplication::DEFAULT_HORIZONTAL_DPI,
8638 TestApplication::DEFAULT_VERTICAL_DPI,
8642 tet_infoline("Check the damaged rect with partial update and actor size hint");
8644 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8646 Actor actor = CreateRenderableActor();
8647 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
8648 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
8649 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f));
8650 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8651 application.GetScene().Add(actor);
8653 application.SendNotification();
8654 std::vector<Rect<int>> damagedRects;
8655 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8657 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8659 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
8660 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8662 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8664 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8665 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8666 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8667 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8672 int utcDaliActorPartialUpdateAnimation(void)
8674 TestApplication application(
8675 TestApplication::DEFAULT_SURFACE_WIDTH,
8676 TestApplication::DEFAULT_SURFACE_HEIGHT,
8677 TestApplication::DEFAULT_HORIZONTAL_DPI,
8678 TestApplication::DEFAULT_VERTICAL_DPI,
8682 tet_infoline("Check the damaged area with partial update and animation");
8684 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8685 drawTrace.Enable(true);
8688 Actor actor1 = CreateRenderableActor();
8689 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8690 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8691 application.GetScene().Add(actor1);
8693 Actor actor2 = CreateRenderableActor();
8694 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8695 actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8696 application.GetScene().Add(actor2);
8698 std::vector<Rect<int>> damagedRects;
8699 Rect<int> clippingRect;
8700 Rect<int> expectedRect1, expectedRect2;
8702 application.SendNotification();
8703 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8705 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8708 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8709 expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
8710 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8711 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
8713 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8714 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8716 damagedRects.clear();
8717 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8718 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8719 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8721 // Make an animation
8722 Animation animation = Animation::New(1.0f);
8723 animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
8726 application.SendNotification();
8728 damagedRects.clear();
8729 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8730 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8731 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8734 damagedRects.clear();
8736 // In animation deley time
8737 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8738 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8739 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8742 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8745 damagedRects.clear();
8747 // Also in animation deley time
8748 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8749 application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
8750 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8753 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8755 // Unparent 2 actors and make a new actor
8759 Actor actor3 = CreateRenderableActor();
8760 actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8761 actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8762 application.GetScene().Add(actor3);
8764 application.SendNotification();
8766 // Started animation
8767 damagedRects.clear();
8768 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8769 DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION);
8771 // The first dirty rect is actor3's.
8772 // We don't know the exact dirty rect of actor2
8773 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8774 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
8776 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8777 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8779 // Finished animation, but the actor was already unparented
8780 damagedRects.clear();
8781 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8783 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8784 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8786 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8787 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8792 int utcDaliActorPartialUpdateChangeVisibility(void)
8794 TestApplication application(
8795 TestApplication::DEFAULT_SURFACE_WIDTH,
8796 TestApplication::DEFAULT_SURFACE_HEIGHT,
8797 TestApplication::DEFAULT_HORIZONTAL_DPI,
8798 TestApplication::DEFAULT_VERTICAL_DPI,
8802 tet_infoline("Check the damaged rect with partial update and visibility change");
8804 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8806 Actor actor = CreateRenderableActor();
8807 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8808 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8809 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8810 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8811 application.GetScene().Add(actor);
8813 application.SendNotification();
8815 std::vector<Rect<int>> damagedRects;
8816 Rect<int> clippingRect;
8818 // 1. Actor added, damaged rect is added size of actor
8819 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8820 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8823 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8824 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8825 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8826 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8827 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8828 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8829 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8831 damagedRects.clear();
8832 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8833 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8835 damagedRects.clear();
8836 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8837 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8839 // Ensure the damaged rect is empty
8840 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8842 // 2. Make the Actor invisible
8843 actor.SetProperty(Actor::Property::VISIBLE, false);
8844 application.SendNotification();
8846 damagedRects.clear();
8847 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8848 DALI_TEST_CHECK(damagedRects.size() > 0);
8849 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8851 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8852 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8853 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8854 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8855 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8857 // 3. Make the Actor visible again
8858 actor.SetProperty(Actor::Property::VISIBLE, true);
8859 application.SendNotification();
8861 damagedRects.clear();
8862 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8863 DALI_TEST_CHECK(damagedRects.size() > 0);
8864 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8866 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8867 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8868 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8869 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8870 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8875 int utcDaliActorPartialUpdateOnOffScene(void)
8877 TestApplication application(
8878 TestApplication::DEFAULT_SURFACE_WIDTH,
8879 TestApplication::DEFAULT_SURFACE_HEIGHT,
8880 TestApplication::DEFAULT_HORIZONTAL_DPI,
8881 TestApplication::DEFAULT_VERTICAL_DPI,
8885 tet_infoline("Check the damaged rect with partial update and on/off scene");
8887 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8889 Actor actor = CreateRenderableActor();
8890 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8891 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8892 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8893 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8894 application.GetScene().Add(actor);
8896 application.SendNotification();
8898 std::vector<Rect<int>> damagedRects;
8899 Rect<int> clippingRect;
8901 // 1. Actor added, damaged rect is added size of actor
8902 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8903 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8906 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8907 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8908 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8909 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8910 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8911 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8912 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8914 damagedRects.clear();
8915 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8916 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8918 damagedRects.clear();
8919 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8920 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8922 // Ensure the damaged rect is empty
8923 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8925 // 2. Remove the Actor from the Scene
8927 application.SendNotification();
8929 damagedRects.clear();
8930 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8931 DALI_TEST_CHECK(damagedRects.size() > 0);
8932 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8934 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8935 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8936 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8937 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8938 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8940 // 3. Add the Actor to the Scene again
8941 application.GetScene().Add(actor);
8942 application.SendNotification();
8944 damagedRects.clear();
8945 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8946 DALI_TEST_CHECK(damagedRects.size() > 0);
8947 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8949 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8950 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8951 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8952 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8953 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8958 int utcDaliActorPartialUpdateSkipRendering(void)
8960 TestApplication application(
8961 TestApplication::DEFAULT_SURFACE_WIDTH,
8962 TestApplication::DEFAULT_SURFACE_HEIGHT,
8963 TestApplication::DEFAULT_HORIZONTAL_DPI,
8964 TestApplication::DEFAULT_VERTICAL_DPI,
8968 tet_infoline("Check to skip rendering in case of the empty damaged rect");
8970 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8971 drawTrace.Enable(true);
8974 Actor actor1 = CreateRenderableActor();
8975 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8976 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8977 application.GetScene().Add(actor1);
8979 std::vector<Rect<int>> damagedRects;
8980 Rect<int> clippingRect;
8981 Rect<int> expectedRect1;
8983 application.SendNotification();
8984 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8986 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8989 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8990 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8992 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8993 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8995 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
8997 damagedRects.clear();
8998 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
8999 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9000 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9005 application.SendNotification();
9007 damagedRects.clear();
9008 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9010 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9012 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9013 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9015 // Render again without any change
9016 damagedRects.clear();
9018 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9020 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9022 clippingRect = Rect<int>();
9023 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9026 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
9028 // Add the actor again
9029 application.GetScene().Add(actor1);
9031 application.SendNotification();
9033 damagedRects.clear();
9035 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9037 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
9039 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9040 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9042 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9047 int utcDaliActorPartialUpdate3DNode(void)
9049 TestApplication application(
9050 TestApplication::DEFAULT_SURFACE_WIDTH,
9051 TestApplication::DEFAULT_SURFACE_HEIGHT,
9052 TestApplication::DEFAULT_HORIZONTAL_DPI,
9053 TestApplication::DEFAULT_VERTICAL_DPI,
9057 tet_infoline("Partial update should be ignored in case of 3d layer of 3d node");
9059 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
9060 drawTrace.Enable(true);
9063 Actor actor1 = CreateRenderableActor();
9064 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
9065 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
9066 application.GetScene().Add(actor1);
9068 std::vector<Rect<int>> damagedRects;
9069 Rect<int> clippingRect;
9071 application.SendNotification();
9072 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9074 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9076 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9077 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9079 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9081 // Change the layer to 3D
9082 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
9084 application.SendNotification();
9086 damagedRects.clear();
9087 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9089 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9090 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9092 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9094 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9096 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9098 // Change the layer to 2D
9099 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI);
9101 application.SendNotification();
9103 damagedRects.clear();
9104 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9106 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9108 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9109 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9111 // Make 3D transform
9112 actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS));
9114 application.SendNotification();
9116 damagedRects.clear();
9117 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9119 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9120 DALI_TEST_EQUALS<Rect<int>>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION);
9122 clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
9124 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9126 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
9131 int utcDaliActorPartialUpdateNotRenderableActor(void)
9133 TestApplication application(
9134 TestApplication::DEFAULT_SURFACE_WIDTH,
9135 TestApplication::DEFAULT_SURFACE_HEIGHT,
9136 TestApplication::DEFAULT_HORIZONTAL_DPI,
9137 TestApplication::DEFAULT_VERTICAL_DPI,
9141 tet_infoline("Check the damaged rect with not renderable parent actor");
9143 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9145 Actor parent = Actor::New();
9146 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9147 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9148 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9149 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9150 application.GetScene().Add(parent);
9152 Actor child = CreateRenderableActor();
9153 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9154 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9155 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9158 application.SendNotification();
9160 std::vector<Rect<int>> damagedRects;
9162 // 1. Actor added, damaged rect is added size of actor
9163 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9164 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9167 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9168 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9170 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9171 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9172 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9173 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9174 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9176 damagedRects.clear();
9177 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9178 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9180 damagedRects.clear();
9181 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9182 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9184 // Ensure the damaged rect is empty
9185 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9190 int utcDaliActorPartialUpdateChangeTransparency(void)
9192 TestApplication application(
9193 TestApplication::DEFAULT_SURFACE_WIDTH,
9194 TestApplication::DEFAULT_SURFACE_HEIGHT,
9195 TestApplication::DEFAULT_HORIZONTAL_DPI,
9196 TestApplication::DEFAULT_VERTICAL_DPI,
9200 tet_infoline("Check the damaged rect with changing transparency");
9202 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9204 Actor actor = CreateRenderableActor();
9205 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9206 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9207 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9208 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9209 application.GetScene().Add(actor);
9211 application.SendNotification();
9213 std::vector<Rect<int>> damagedRects;
9215 // Actor added, damaged rect is added size of actor
9216 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9217 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9220 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9221 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9223 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9224 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9225 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9226 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9227 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9229 damagedRects.clear();
9230 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9231 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9233 damagedRects.clear();
9234 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9235 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9237 // Make the actor transparent by changing opacity of the Renderer
9238 // It changes a uniform value
9239 Renderer renderer = actor.GetRendererAt(0);
9240 renderer[DevelRenderer::Property::OPACITY] = 0.0f;
9242 application.SendNotification();
9244 // The damaged rect should be same
9245 damagedRects.clear();
9246 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9247 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9248 DALI_TEST_CHECK(damagedRects.size() > 0);
9249 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9251 damagedRects.clear();
9252 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9253 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9255 // Ensure the damaged rect is empty
9256 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9258 // Make the actor opaque again
9259 renderer[DevelRenderer::Property::OPACITY] = 1.0f;
9261 application.SendNotification();
9263 // The damaged rect should not be empty
9264 damagedRects.clear();
9265 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9266 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9267 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9268 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9270 damagedRects.clear();
9271 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9272 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9274 damagedRects.clear();
9275 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9276 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9278 // Make the actor culled
9279 actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f);
9281 application.SendNotification();
9283 // The damaged rect should be same
9284 damagedRects.clear();
9285 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9286 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9287 DALI_TEST_CHECK(damagedRects.size() > 0);
9288 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9290 damagedRects.clear();
9291 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9292 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9294 // Ensure the damaged rect is empty
9295 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9297 // Make the actor not culled again
9298 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f);
9300 application.SendNotification();
9302 // The damaged rect should not be empty
9303 damagedRects.clear();
9304 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9305 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9306 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9307 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9312 int utcDaliActorPartialUpdateChangeParentOpacity(void)
9314 TestApplication application(
9315 TestApplication::DEFAULT_SURFACE_WIDTH,
9316 TestApplication::DEFAULT_SURFACE_HEIGHT,
9317 TestApplication::DEFAULT_HORIZONTAL_DPI,
9318 TestApplication::DEFAULT_VERTICAL_DPI,
9322 tet_infoline("Check the damaged rect with changing parent's opacity");
9324 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9326 Actor parent = Actor::New();
9327 parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9328 parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9329 parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9330 parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9331 application.GetScene().Add(parent);
9333 Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
9334 Actor child = CreateRenderableActor(texture);
9335 child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9336 child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9337 child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9340 application.SendNotification();
9342 std::vector<Rect<int>> damagedRects;
9344 // Actor added, damaged rect is added size of actor
9345 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9346 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9349 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9350 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9352 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9353 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9354 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9355 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9356 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9358 damagedRects.clear();
9359 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9360 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9362 damagedRects.clear();
9363 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9364 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9366 // Ensure the damaged rect is empty
9367 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9369 // Change the parent's opacity
9370 parent[Actor::Property::OPACITY] = 0.5f;
9372 application.SendNotification();
9374 // The damaged rect should be same
9375 damagedRects.clear();
9376 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9377 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9378 DALI_TEST_CHECK(damagedRects.size() > 0);
9379 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9384 int utcDaliActorPartialAddRemoveRenderer(void)
9386 TestApplication application(
9387 TestApplication::DEFAULT_SURFACE_WIDTH,
9388 TestApplication::DEFAULT_SURFACE_HEIGHT,
9389 TestApplication::DEFAULT_HORIZONTAL_DPI,
9390 TestApplication::DEFAULT_VERTICAL_DPI,
9394 tet_infoline("Check the damaged rect with adding / removing renderer");
9396 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
9398 Actor actor = CreateRenderableActor();
9399 actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
9400 actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f);
9401 actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f);
9402 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
9403 application.GetScene().Add(actor);
9405 application.SendNotification();
9407 std::vector<Rect<int>> damagedRects;
9409 // Actor added, damaged rect is added size of actor
9410 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9411 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9414 Rect<int> clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
9415 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9417 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9418 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
9419 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
9420 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
9421 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
9423 damagedRects.clear();
9424 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9425 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9427 damagedRects.clear();
9428 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9429 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9431 // Remove the Renderer
9432 Renderer renderer = actor.GetRendererAt(0);
9433 actor.RemoveRenderer(renderer);
9435 application.SendNotification();
9437 // The damaged rect should be the actor area
9438 damagedRects.clear();
9439 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9440 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9441 DALI_TEST_CHECK(damagedRects.size() > 0);
9442 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9444 damagedRects.clear();
9445 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9446 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9448 // Ensure the damaged rect is empty
9449 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
9451 // Add the Renderer again
9452 actor.AddRenderer(renderer);
9454 application.SendNotification();
9456 // The damaged rect should be the actor area
9457 damagedRects.clear();
9458 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
9459 application.RenderWithPartialUpdate(damagedRects, clippingRect);
9460 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
9461 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
9466 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
9468 TestApplication application;
9470 Actor actor = Actor::New();
9471 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
9472 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
9473 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
9474 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
9475 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
9476 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9477 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
9478 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
9482 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
9484 TestApplication application;
9486 Actor actor = Actor::New();
9488 // Make sure setting invalid types does not cause a crash
9491 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
9492 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
9493 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
9494 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
9495 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
9496 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
9497 tet_result(TET_PASS);
9501 tet_result(TET_FAIL);
9506 int UtcDaliActorTouchAreaOffsetPropertyP(void)
9508 TestApplication application;
9510 Actor actor = Actor::New();
9511 Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9512 DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
9513 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
9514 touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
9515 DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
9519 int UtcDaliActorTouchAreaOffsetPropertyN(void)
9521 TestApplication application;
9523 Actor actor = Actor::New();
9525 // Make sure setting invalid types does not cause a crash
9528 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
9529 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
9530 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
9531 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
9532 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
9533 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
9534 tet_result(TET_PASS);
9538 tet_result(TET_FAIL);
9543 int UtcDaliActorLowerBelowNegative(void)
9545 TestApplication application;
9546 Dali::Actor instance;
9550 instance.LowerBelow(arg1);
9551 DALI_TEST_CHECK(false); // Should not get here
9555 DALI_TEST_CHECK(true); // We expect an assert
9560 int UtcDaliActorRaiseAboveNegative(void)
9562 TestApplication application;
9563 Dali::Actor instance;
9567 instance.RaiseAbove(arg1);
9568 DALI_TEST_CHECK(false); // Should not get here
9572 DALI_TEST_CHECK(true); // We expect an assert
9577 int UtcDaliActorRaiseToTopNegative(void)
9579 TestApplication application;
9580 Dali::Actor instance;
9583 instance.RaiseToTop();
9584 DALI_TEST_CHECK(false); // Should not get here
9588 DALI_TEST_CHECK(true); // We expect an assert
9593 int UtcDaliActorAddRendererNegative(void)
9595 TestApplication application;
9596 Dali::Actor instance;
9599 Dali::Renderer arg1;
9600 instance.AddRenderer(arg1);
9601 DALI_TEST_CHECK(false); // Should not get here
9605 DALI_TEST_CHECK(true); // We expect an assert
9610 int UtcDaliActorTouchedSignalNegative(void)
9612 TestApplication application;
9613 Dali::Actor instance;
9616 instance.TouchedSignal();
9617 DALI_TEST_CHECK(false); // Should not get here
9621 DALI_TEST_CHECK(true); // We expect an assert
9626 int UtcDaliActorTranslateByNegative(void)
9628 TestApplication application;
9629 Dali::Actor instance;
9633 instance.TranslateBy(arg1);
9634 DALI_TEST_CHECK(false); // Should not get here
9638 DALI_TEST_CHECK(true); // We expect an assert
9643 int UtcDaliActorFindChildByIdNegative(void)
9645 TestApplication application;
9646 Dali::Actor instance;
9649 unsigned int arg1 = 0u;
9650 instance.FindChildById(arg1);
9651 DALI_TEST_CHECK(false); // Should not get here
9655 DALI_TEST_CHECK(true); // We expect an assert
9660 int UtcDaliActorGetRendererAtNegative(void)
9662 TestApplication application;
9663 Dali::Actor instance;
9666 unsigned int arg1 = 0u;
9667 instance.GetRendererAt(arg1);
9668 DALI_TEST_CHECK(false); // Should not get here
9672 DALI_TEST_CHECK(true); // We expect an assert
9677 int UtcDaliActorHoveredSignalNegative(void)
9679 TestApplication application;
9680 Dali::Actor instance;
9683 instance.HoveredSignal();
9684 DALI_TEST_CHECK(false); // Should not get here
9688 DALI_TEST_CHECK(true); // We expect an assert
9693 int UtcDaliActorLowerToBottomNegative(void)
9695 TestApplication application;
9696 Dali::Actor instance;
9699 instance.LowerToBottom();
9700 DALI_TEST_CHECK(false); // Should not get here
9704 DALI_TEST_CHECK(true); // We expect an assert
9709 int UtcDaliActorOnSceneSignalNegative(void)
9711 TestApplication application;
9712 Dali::Actor instance;
9715 instance.OnSceneSignal();
9716 DALI_TEST_CHECK(false); // Should not get here
9720 DALI_TEST_CHECK(true); // We expect an assert
9725 int UtcDaliActorOffSceneSignalNegative(void)
9727 TestApplication application;
9728 Dali::Actor instance;
9731 instance.OffSceneSignal();
9732 DALI_TEST_CHECK(false); // Should not get here
9736 DALI_TEST_CHECK(true); // We expect an assert
9741 int UtcDaliActorRemoveRendererNegative01(void)
9743 TestApplication application;
9744 Dali::Actor instance;
9747 unsigned int arg1 = 0u;
9748 instance.RemoveRenderer(arg1);
9749 DALI_TEST_CHECK(false); // Should not get here
9753 DALI_TEST_CHECK(true); // We expect an assert
9758 int UtcDaliActorRemoveRendererNegative02(void)
9760 TestApplication application;
9761 Dali::Actor instance;
9764 Dali::Renderer arg1;
9765 instance.RemoveRenderer(arg1);
9766 DALI_TEST_CHECK(false); // Should not get here
9770 DALI_TEST_CHECK(true); // We expect an assert
9775 int UtcDaliActorFindChildByNameNegative(void)
9777 TestApplication application;
9778 Dali::Actor instance;
9782 instance.FindChildByName(arg1);
9783 DALI_TEST_CHECK(false); // Should not get here
9787 DALI_TEST_CHECK(true); // We expect an assert
9792 int UtcDaliActorSetResizePolicyNegative(void)
9794 TestApplication application;
9795 Dali::Actor instance;
9798 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
9799 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
9800 instance.SetResizePolicy(arg1, arg2);
9801 DALI_TEST_CHECK(false); // Should not get here
9805 DALI_TEST_CHECK(true); // We expect an assert
9810 int UtcDaliActorOnRelayoutSignalNegative(void)
9812 TestApplication application;
9813 Dali::Actor instance;
9816 instance.OnRelayoutSignal();
9817 DALI_TEST_CHECK(false); // Should not get here
9821 DALI_TEST_CHECK(true); // We expect an assert
9826 int UtcDaliActorWheelEventSignalNegative(void)
9828 TestApplication application;
9829 Dali::Actor instance;
9832 instance.WheelEventSignal();
9833 DALI_TEST_CHECK(false); // Should not get here
9837 DALI_TEST_CHECK(true); // We expect an assert
9842 int UtcDaliActorGetHeightForWidthNegative(void)
9844 TestApplication application;
9845 Dali::Actor instance;
9849 instance.GetHeightForWidth(arg1);
9850 DALI_TEST_CHECK(false); // Should not get here
9854 DALI_TEST_CHECK(true); // We expect an assert
9859 int UtcDaliActorGetWidthForHeightNegative(void)
9861 TestApplication application;
9862 Dali::Actor instance;
9866 instance.GetWidthForHeight(arg1);
9867 DALI_TEST_CHECK(false); // Should not get here
9871 DALI_TEST_CHECK(true); // We expect an assert
9876 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
9878 TestApplication application;
9879 Dali::Actor instance;
9882 instance.LayoutDirectionChangedSignal();
9883 DALI_TEST_CHECK(false); // Should not get here
9887 DALI_TEST_CHECK(true); // We expect an assert
9892 int UtcDaliActorAddNegative(void)
9894 TestApplication application;
9895 Dali::Actor instance;
9900 DALI_TEST_CHECK(false); // Should not get here
9904 DALI_TEST_CHECK(true); // We expect an assert
9909 int UtcDaliActorLowerNegative(void)
9911 TestApplication application;
9912 Dali::Actor instance;
9916 DALI_TEST_CHECK(false); // Should not get here
9920 DALI_TEST_CHECK(true); // We expect an assert
9925 int UtcDaliActorRaiseNegative(void)
9927 TestApplication application;
9928 Dali::Actor instance;
9932 DALI_TEST_CHECK(false); // Should not get here
9936 DALI_TEST_CHECK(true); // We expect an assert
9941 int UtcDaliActorRemoveNegative(void)
9943 TestApplication application;
9944 Dali::Actor instance;
9948 instance.Remove(arg1);
9949 DALI_TEST_CHECK(false); // Should not get here
9953 DALI_TEST_CHECK(true); // We expect an assert
9958 int UtcDaliActorScaleByNegative(void)
9960 TestApplication application;
9961 Dali::Actor instance;
9965 instance.ScaleBy(arg1);
9966 DALI_TEST_CHECK(false); // Should not get here
9970 DALI_TEST_CHECK(true); // We expect an assert
9975 int UtcDaliActorGetLayerNegative(void)
9977 TestApplication application;
9978 Dali::Actor instance;
9981 instance.GetLayer();
9982 DALI_TEST_CHECK(false); // Should not get here
9986 DALI_TEST_CHECK(true); // We expect an assert
9991 int UtcDaliActorRotateByNegative01(void)
9993 TestApplication application;
9994 Dali::Actor instance;
9997 Dali::Quaternion arg1;
9998 instance.RotateBy(arg1);
9999 DALI_TEST_CHECK(false); // Should not get here
10003 DALI_TEST_CHECK(true); // We expect an assert
10008 int UtcDaliActorRotateByNegative02(void)
10010 TestApplication application;
10011 Dali::Actor instance;
10015 Dali::Vector3 arg2;
10016 instance.RotateBy(arg1, arg2);
10017 DALI_TEST_CHECK(false); // Should not get here
10021 DALI_TEST_CHECK(true); // We expect an assert
10026 int UtcDaliActorUnparentNegative(void)
10028 TestApplication application;
10029 Dali::Actor instance;
10032 instance.Unparent();
10033 DALI_TEST_CHECK(false); // Should not get here
10037 DALI_TEST_CHECK(true); // We expect an assert
10042 int UtcDaliActorGetChildAtNegative(void)
10044 TestApplication application;
10045 Dali::Actor instance;
10048 unsigned int arg1 = 0u;
10049 instance.GetChildAt(arg1);
10050 DALI_TEST_CHECK(false); // Should not get here
10054 DALI_TEST_CHECK(true); // We expect an assert
10059 int UtcDaliActorGetChildCountNegative(void)
10061 TestApplication application;
10062 Dali::Actor instance;
10065 instance.GetChildCount();
10066 DALI_TEST_CHECK(false); // Should not get here
10070 DALI_TEST_CHECK(true); // We expect an assert
10075 int UtcDaliActorGetTargetSizeNegative(void)
10077 TestApplication application;
10078 Dali::Actor instance;
10081 instance.GetTargetSize();
10082 DALI_TEST_CHECK(false); // Should not get here
10086 DALI_TEST_CHECK(true); // We expect an assert
10091 int UtcDaliActorScreenToLocalNegative(void)
10093 TestApplication application;
10094 Dali::Actor instance;
10101 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
10102 DALI_TEST_CHECK(false); // Should not get here
10106 DALI_TEST_CHECK(true); // We expect an assert
10111 int UtcDaliActorGetNaturalSizeNegative(void)
10113 TestApplication application;
10114 Dali::Actor instance;
10117 instance.GetNaturalSize();
10118 DALI_TEST_CHECK(false); // Should not get here
10122 DALI_TEST_CHECK(true); // We expect an assert
10127 int UtcDaliActorGetRelayoutSizeNegative(void)
10129 TestApplication application;
10130 Dali::Actor instance;
10133 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
10134 instance.GetRelayoutSize(arg1);
10135 DALI_TEST_CHECK(false); // Should not get here
10139 DALI_TEST_CHECK(true); // We expect an assert
10144 int UtcDaliActorGetResizePolicyNegative(void)
10146 TestApplication application;
10147 Dali::Actor instance;
10150 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
10151 instance.GetResizePolicy(arg1);
10152 DALI_TEST_CHECK(false); // Should not get here
10156 DALI_TEST_CHECK(true); // We expect an assert
10161 int UtcDaliActorGetRendererCountNegative(void)
10163 TestApplication application;
10164 Dali::Actor instance;
10167 instance.GetRendererCount();
10168 DALI_TEST_CHECK(false); // Should not get here
10172 DALI_TEST_CHECK(true); // We expect an assert
10177 int UtcDaliActorGetParentNegative(void)
10179 TestApplication application;
10180 Dali::Actor instance;
10183 instance.GetParent();
10184 DALI_TEST_CHECK(false); // Should not get here
10188 DALI_TEST_CHECK(true); // We expect an assert
10193 int UtcDaliActorPropertyBlendEquation(void)
10195 TestApplication application;
10197 tet_infoline("Test SetProperty AdvancedBlendEquation");
10199 Geometry geometry = CreateQuadGeometry();
10200 Shader shader = CreateShader();
10201 Renderer renderer1 = Renderer::New(geometry, shader);
10203 Actor actor = Actor::New();
10204 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
10206 actor.AddRenderer(renderer1);
10207 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
10208 application.GetScene().Add(actor);
10210 if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10212 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10213 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10214 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
10217 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
10219 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
10220 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
10221 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
10224 Renderer renderer2 = Renderer::New(geometry, shader);
10225 actor.AddRenderer(renderer2);
10230 int UtcDaliActorRegisterProperty(void)
10232 tet_infoline("Test property registration and uniform map update\n");
10234 TestApplication application;
10236 Geometry geometry = CreateQuadGeometry();
10237 Shader shader = CreateShader();
10238 Renderer renderer1 = Renderer::New(geometry, shader);
10239 Renderer renderer2 = Renderer::New(geometry, shader);
10241 Actor actor1 = Actor::New();
10242 actor1.AddRenderer(renderer1);
10243 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10244 actor1.RegisterProperty("uCustom", 1);
10245 application.GetScene().Add(actor1);
10247 Actor actor2 = Actor::New();
10248 actor2.AddRenderer(renderer2);
10249 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
10250 application.GetScene().Add(actor2);
10252 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
10253 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
10254 glAbstraction.EnableSetUniformCallTrace(true);
10256 application.SendNotification();
10257 application.Render();
10259 std::stringstream out;
10261 std::string params;
10263 // Test uniform value of the custom property
10264 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10265 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10268 actor1[Actor::Property::VISIBLE] = false;
10270 application.SendNotification();
10271 application.Render();
10273 // Make visible again
10274 actor1[Actor::Property::VISIBLE] = true;
10275 actor1["uCustom"] = 2;
10277 glAbstraction.ResetSetUniformCallStack();
10279 application.SendNotification();
10280 application.Render();
10284 // The uniform value should not be changed
10285 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
10286 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
10291 int UtcDaliActorDoesWantedHitTest(void)
10296 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
10298 mTouchPoint(touchPoint),
10304 Vector2 mTouchPoint;
10308 TestApplication application;
10309 tet_infoline(" UtcDaliActorDoesWantedHitTest");
10311 // Fill a vector with different hit tests.
10312 struct HitTestData* hitTestData[] = {
10313 // scale touch point result
10314 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
10315 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
10316 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.
10317 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
10318 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.
10322 // get the root layer
10323 Actor actor = Actor::New();
10324 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
10325 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
10327 Actor lowerActor = Actor::New();
10328 lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
10329 lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
10331 // actor and lowerActor have no relationship.
10332 application.GetScene().Add(lowerActor);
10333 application.GetScene().Add(actor);
10335 ResetTouchCallbacks();
10336 gHitTestTouchCallBackCalled = false;
10338 unsigned int index = 0;
10339 while(NULL != hitTestData[index])
10341 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
10342 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
10344 lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
10345 lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
10347 // flush the queue and render once
10348 application.SendNotification();
10349 application.Render();
10351 DALI_TEST_CHECK(!gTouchCallBackCalled);
10352 DALI_TEST_CHECK(!gTouchCallBackCalled2);
10353 DALI_TEST_CHECK(!gHitTestTouchCallBackCalled);
10355 // connect to its touch signal
10356 actor.TouchedSignal().Connect(TestTouchCallback);
10357 lowerActor.TouchedSignal().Connect(TestTouchCallback2);
10359 // connect to its hit-test signal
10360 Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback);
10362 Dali::Integration::Point point;
10363 point.SetState(PointState::DOWN);
10364 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
10365 Dali::Integration::TouchEvent event;
10366 event.AddPoint(point);
10368 // flush the queue and render once
10369 application.SendNotification();
10370 application.Render();
10371 application.ProcessEvent(event);
10373 // check hit-test events
10374 DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult);
10375 // Passed all hit-tests of actor.
10376 DALI_TEST_CHECK(gTouchCallBackCalled == false);
10377 // The lowerActor was hit-tested.
10378 DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult);
10380 if(gTouchCallBackCalled2 != hitTestData[index]->mResult)
10381 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
10382 hitTestData[index]->mScale.x,
10383 hitTestData[index]->mScale.y,
10384 hitTestData[index]->mScale.z,
10385 hitTestData[index]->mTouchPoint.x,
10386 hitTestData[index]->mTouchPoint.y,
10387 hitTestData[index]->mResult);
10389 ResetTouchCallbacks();
10390 gHitTestTouchCallBackCalled = false;