2 * Copyright (c) 2020 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/integration-api/debug.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/devel-api/common/capabilities.h>
27 #include <dali/public-api/dali-core.h>
28 #include <mesh-builder.h>
30 #include <cfloat> // For FLT_MAX
40 void utc_dali_actor_startup(void)
42 test_return_value = TET_UNDEF;
45 void utc_dali_actor_cleanup(void)
47 test_return_value = TET_PASS;
52 bool gTouchCallBackCalled = false;
53 bool gTouchCallBackCalled2 = false;
54 bool gTouchCallBackCalled3 = false;
56 bool gHoverCallBackCalled = false;
58 static bool gTestConstraintCalled;
60 LayoutDirection::Type gLayoutDirectionType;
64 void operator()(Vector4& color, const PropertyInputContainer& /* inputs */)
66 gTestConstraintCalled = true;
71 * TestConstraint reference.
72 * When constraint is called, the resultRef is updated
73 * with the value supplied.
76 struct TestConstraintRef
78 TestConstraintRef(unsigned int& resultRef, unsigned int value)
79 : mResultRef(resultRef),
84 void operator()(T& current, const PropertyInputContainer& /* inputs */)
89 unsigned int& mResultRef;
93 static bool TestTouchCallback(Actor, const TouchEvent&)
95 gTouchCallBackCalled = true;
100 static bool TestTouchCallback2(Actor, const TouchEvent&)
102 gTouchCallBackCalled2 = true;
107 static bool TestTouchCallback3(Actor, const TouchEvent&)
109 gTouchCallBackCalled3 = true;
114 static void ResetTouchCallbacks()
116 gTouchCallBackCalled = false;
117 gTouchCallBackCalled2 = false;
118 gTouchCallBackCalled3 = false;
121 static bool TestCallback3(Actor actor, const HoverEvent& event)
123 gHoverCallBackCalled = true;
128 // validation stuff for onstage & offstage signals
129 static std::vector<std::string> gActorNamesOnOffScene;
130 static int gOnSceneCallBackCalled;
131 void OnSceneCallback(Actor actor)
133 ++gOnSceneCallBackCalled;
134 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
135 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
137 static int gOffSceneCallBackCalled;
138 void OffSceneCallback(Actor actor)
140 ++gOffSceneCallBackCalled;
141 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
142 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
145 struct PositionComponentConstraint
147 PositionComponentConstraint()
151 void operator()(Vector3& pos, const PropertyInputContainer& inputs)
153 const Matrix& m = inputs[0]->GetMatrix();
156 m.GetTransformComponents(pos, rot, scale);
160 struct OrientationComponentConstraint
162 OrientationComponentConstraint()
166 void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
168 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
171 orientation = parentOrientation;
176 static bool gOnRelayoutCallBackCalled = false;
177 static std::vector<std::string> gActorNamesRelayout;
179 void OnRelayoutCallback(Actor actor)
181 gOnRelayoutCallBackCalled = true;
182 gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
185 struct VisibilityChangedFunctorData
187 VisibilityChangedFunctorData()
190 type(DevelActor::VisibilityChange::SELF),
199 type = DevelActor::VisibilityChange::SELF;
203 void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
205 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
206 DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
207 DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
208 DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
211 void Check(bool compareCalled, const std::string& location)
213 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
218 DevelActor::VisibilityChange::Type type;
222 struct VisibilityChangedFunctor
224 VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
229 void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
232 data.visible = visible;
237 VisibilityChangedFunctorData& data;
240 struct VisibilityChangedVoidFunctor
242 VisibilityChangedVoidFunctor(bool& signalCalled)
243 : mSignalCalled(signalCalled)
249 mSignalCalled = true;
255 struct ChildOrderChangedFunctor
257 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
258 : mSignalCalled(signalCalled),
263 void operator()(Actor actor)
265 mSignalCalled = true;
273 struct CulledPropertyNotificationFunctor
275 CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
276 : mSignalCalled(signalCalled),
277 mPropertyNotification(propertyNotification)
281 void operator()(PropertyNotification& source)
283 mSignalCalled = true;
284 mPropertyNotification = source;
288 PropertyNotification& mPropertyNotification;
291 } // anonymous namespace
293 //& purpose: Testing New API
294 int UtcDaliActorNew(void)
296 TestApplication application;
298 Actor actor = Actor::New();
300 DALI_TEST_CHECK(actor);
304 //& purpose: Testing Dali::Actor::DownCast()
305 int UtcDaliActorDownCastP(void)
307 TestApplication application;
308 tet_infoline("Testing Dali::Actor::DownCast()");
310 Actor actor = Actor::New();
311 BaseHandle object(actor);
312 Actor actor2 = Actor::DownCast(object);
313 DALI_TEST_CHECK(actor2);
317 //& purpose: Testing Dali::Actor::DownCast()
318 int UtcDaliActorDownCastN(void)
320 TestApplication application;
321 tet_infoline("Testing Dali::Actor::DownCast()");
323 BaseHandle unInitializedObject;
324 Actor actor = Actor::DownCast(unInitializedObject);
325 DALI_TEST_CHECK(!actor);
329 int UtcDaliActorMoveConstructor(void)
331 TestApplication application;
333 Actor actor = Actor::New();
334 DALI_TEST_CHECK(actor);
336 int id = actor.GetProperty<int>(Actor::Property::ID);
338 Actor moved = std::move(actor);
339 DALI_TEST_CHECK(moved);
340 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
341 DALI_TEST_CHECK(!actor);
346 int UtcDaliActorMoveAssignment(void)
348 TestApplication application;
350 Actor actor = Actor::New();
351 DALI_TEST_CHECK(actor);
353 int id = actor.GetProperty<int>(Actor::Property::ID);
356 moved = std::move(actor);
357 DALI_TEST_CHECK(moved);
358 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
359 DALI_TEST_CHECK(!actor);
364 //& purpose: Testing Dali::Actor::GetName()
365 int UtcDaliActorGetName(void)
367 TestApplication application;
369 Actor actor = Actor::New();
371 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
375 //& purpose: Testing Dali::Actor::SetName()
376 int UtcDaliActorSetName(void)
378 TestApplication application;
380 string str("ActorName");
381 Actor actor = Actor::New();
383 actor.SetProperty(Actor::Property::NAME, str);
384 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
388 int UtcDaliActorGetId(void)
390 tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
391 TestApplication application;
393 Actor first = Actor::New();
394 Actor second = Actor::New();
395 Actor third = Actor::New();
397 DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
398 DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
402 int UtcDaliActorIsRoot(void)
404 TestApplication application;
406 Actor actor = Actor::New();
407 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
409 // get the root layer
410 actor = application.GetScene().GetLayer(0);
411 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
415 int UtcDaliActorOnScene(void)
417 TestApplication application;
419 Actor actor = Actor::New();
420 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
422 // get the root layer
423 actor = application.GetScene().GetLayer(0);
424 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
428 int UtcDaliActorIsLayer(void)
430 TestApplication application;
432 Actor actor = Actor::New();
433 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
435 // get the root layer
436 actor = application.GetScene().GetLayer(0);
437 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
441 int UtcDaliActorGetLayer(void)
443 TestApplication application;
445 Actor actor = Actor::New();
446 application.GetScene().Add(actor);
447 Layer layer = actor.GetLayer();
449 DALI_TEST_CHECK(layer);
451 // get the root layers layer
452 actor = application.GetScene().GetLayer(0);
453 DALI_TEST_CHECK(actor.GetLayer());
457 int UtcDaliActorAddP(void)
459 tet_infoline("Testing Actor::Add");
460 TestApplication application;
462 Actor parent = Actor::New();
463 Actor child = Actor::New();
465 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
469 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
471 Actor parent2 = Actor::New();
474 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
475 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
477 // try Adding to same parent again, works
479 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
481 // try reparenting an orphaned child
483 Actor temporaryParent = Actor::New();
484 temporaryParent.Add(child);
485 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
487 // temporaryParent has now died, reparent the orphaned child
489 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
494 int UtcDaliActorAddN(void)
496 tet_infoline("Testing Actor::Add");
497 TestApplication application;
499 Actor child = Actor::New();
501 Actor parent2 = Actor::New();
507 parent2.Add(parent2);
508 tet_printf("Assertion test failed - no Exception\n");
509 tet_result(TET_FAIL);
511 catch(Dali::DaliException& e)
513 DALI_TEST_PRINT_ASSERT(e);
514 DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION);
515 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
519 tet_printf("Assertion test failed - wrong Exception\n");
520 tet_result(TET_FAIL);
523 // try reparenting root
526 parent2.Add(application.GetScene().GetLayer(0));
527 tet_printf("Assertion test failed - no Exception\n");
528 tet_result(TET_FAIL);
530 catch(Dali::DaliException& e)
532 DALI_TEST_PRINT_ASSERT(e);
533 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
534 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
538 tet_printf("Assertion test failed - wrong Exception\n");
539 tet_result(TET_FAIL);
547 tet_printf("Assertion test failed - no Exception\n");
548 tet_result(TET_FAIL);
550 catch(Dali::DaliException& e)
552 DALI_TEST_PRINT_ASSERT(e);
553 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
554 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
558 tet_printf("Assertion test failed - wrong Exception\n");
559 tet_result(TET_FAIL);
565 int UtcDaliActorRemoveN(void)
567 tet_infoline("Testing Actor::Remove");
568 TestApplication application;
570 Actor parent = Actor::New();
571 Actor child = Actor::New();
572 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
575 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
577 parent.Remove(child);
578 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
580 // remove again, no problem
581 parent.Remove(child);
582 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
586 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
587 // try Remove self, its a no-op
588 parent.Remove(parent);
589 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
595 parent.Remove(empty);
596 tet_printf("Assertion test failed - no Exception\n");
597 tet_result(TET_FAIL);
599 catch(Dali::DaliException& e)
601 DALI_TEST_PRINT_ASSERT(e);
602 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
603 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
607 tet_printf("Assertion test failed - wrong Exception\n");
608 tet_result(TET_FAIL);
613 int UtcDaliActorRemoveP(void)
615 TestApplication application;
617 Actor parent = Actor::New();
618 Actor child = Actor::New();
619 Actor random = Actor::New();
621 application.GetScene().Add(parent);
623 DALI_TEST_CHECK(parent.GetChildCount() == 0);
627 DALI_TEST_CHECK(parent.GetChildCount() == 1);
629 parent.Remove(random);
631 DALI_TEST_CHECK(parent.GetChildCount() == 1);
633 application.GetScene().Remove(parent);
635 DALI_TEST_CHECK(parent.GetChildCount() == 1);
639 int UtcDaliActorGetChildCount(void)
641 TestApplication application;
643 Actor parent = Actor::New();
644 Actor child = Actor::New();
646 DALI_TEST_CHECK(parent.GetChildCount() == 0);
650 DALI_TEST_CHECK(parent.GetChildCount() == 1);
654 int UtcDaliActorGetChildren01(void)
656 TestApplication application;
658 Actor parent = Actor::New();
659 Actor first = Actor::New();
660 Actor second = Actor::New();
661 Actor third = Actor::New();
667 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
668 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
669 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
673 int UtcDaliActorGetChildren02(void)
675 TestApplication application;
677 Actor parent = Actor::New();
678 Actor first = Actor::New();
679 Actor second = Actor::New();
680 Actor third = Actor::New();
686 const Actor& constParent = parent;
688 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
689 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
690 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
694 int UtcDaliActorGetParent01(void)
696 TestApplication application;
698 Actor parent = Actor::New();
699 Actor child = Actor::New();
703 DALI_TEST_CHECK(child.GetParent() == parent);
707 int UtcDaliActorGetParent02(void)
709 TestApplication application;
711 Actor actor = Actor::New();
713 DALI_TEST_CHECK(!actor.GetParent());
717 int UtcDaliActorCustomProperty(void)
719 TestApplication application;
721 Actor actor = Actor::New();
722 application.GetScene().Add(actor);
724 float startValue(1.0f);
725 Property::Index index = actor.RegisterProperty("testProperty", startValue);
726 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
728 application.SendNotification();
729 application.Render(0);
730 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
732 actor.SetProperty(index, 5.0f);
734 application.SendNotification();
735 application.Render(0);
736 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
740 int UtcDaliActorCustomPropertyIntToFloat(void)
742 TestApplication application;
744 Actor actor = Actor::New();
745 application.GetScene().Add(actor);
747 float startValue(5.0f);
748 Property::Index index = actor.RegisterProperty("testProperty", startValue);
749 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
751 application.SendNotification();
752 application.Render(0);
753 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
755 actor.SetProperty(index, int(1));
757 application.SendNotification();
758 application.Render(0);
759 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
763 int UtcDaliActorCustomPropertyFloatToInt(void)
765 TestApplication application;
767 Actor actor = Actor::New();
768 application.GetScene().Add(actor);
771 Property::Index index = actor.RegisterProperty("testProperty", startValue);
772 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
774 application.SendNotification();
775 application.Render(0);
776 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
778 actor.SetProperty(index, float(1.5));
780 application.SendNotification();
781 application.Render(0);
782 DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
786 int UtcDaliActorSetParentOrigin(void)
788 TestApplication application;
790 Actor actor = Actor::New();
792 Vector3 vector(0.7f, 0.8f, 0.9f);
793 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
795 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
797 // flush the queue and render once
798 application.SendNotification();
799 application.Render();
801 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
803 application.GetScene().Add(actor);
805 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
807 // flush the queue and render once
808 application.SendNotification();
809 application.Render();
811 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
813 application.GetScene().Remove(actor);
817 int UtcDaliActorSetParentOriginIndividual(void)
819 TestApplication application;
821 Actor actor = Actor::New();
823 Vector3 vector(0.7f, 0.8f, 0.9f);
824 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
826 actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
828 // flush the queue and render once
829 application.SendNotification();
830 application.Render();
832 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
834 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
836 // flush the queue and render once
837 application.SendNotification();
838 application.Render();
840 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
842 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
844 // flush the queue and render once
845 application.SendNotification();
846 application.Render();
848 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
853 int UtcDaliActorGetCurrentParentOrigin(void)
855 TestApplication application;
857 Actor actor = Actor::New();
859 Vector3 vector(0.7f, 0.8f, 0.9f);
860 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
862 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
864 // flush the queue and render once
865 application.SendNotification();
866 application.Render();
868 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
872 int UtcDaliActorSetAnchorPoint(void)
874 TestApplication application;
876 Actor actor = Actor::New();
878 Vector3 vector(0.7f, 0.8f, 0.9f);
879 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
881 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
883 // flush the queue and render once
884 application.SendNotification();
885 application.Render();
887 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
889 application.GetScene().Add(actor);
891 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
892 // flush the queue and render once
893 application.SendNotification();
894 application.Render();
896 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
898 application.GetScene().Remove(actor);
902 int UtcDaliActorSetAnchorPointIndividual(void)
904 TestApplication application;
906 Actor actor = Actor::New();
908 Vector3 vector(0.7f, 0.8f, 0.9f);
909 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
911 actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
913 // flush the queue and render once
914 application.SendNotification();
915 application.Render();
917 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
919 actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
921 // flush the queue and render once
922 application.SendNotification();
923 application.Render();
925 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
927 actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
929 // flush the queue and render once
930 application.SendNotification();
931 application.Render();
933 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
938 int UtcDaliActorGetCurrentAnchorPoint(void)
940 TestApplication application;
942 Actor actor = Actor::New();
944 Vector3 vector(0.7f, 0.8f, 0.9f);
945 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
947 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
949 // flush the queue and render once
950 application.SendNotification();
951 application.Render();
953 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
957 int UtcDaliActorSetSize01(void)
959 TestApplication application;
961 Actor actor = Actor::New();
962 Vector3 vector(100.0f, 100.0f, 0.0f);
964 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
966 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
968 // Immediately retrieve the size after setting
969 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
970 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
971 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
972 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
973 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
975 // Flush the queue and render once
976 application.SendNotification();
977 application.Render();
979 // Check the size in the new frame
980 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
982 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
983 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
984 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
985 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
986 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
988 // Check async behaviour
989 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
990 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
991 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
992 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
993 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
995 // Change the resize policy and check whether the size stays the same
996 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
998 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
999 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1001 // Set a new size after resize policy is changed and check the new size
1002 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1004 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1005 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1007 // Change the resize policy again and check whether the new size stays the same
1008 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1010 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1011 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1013 // Set another new size after resize policy is changed and check the new size
1014 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1016 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1017 DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1022 int UtcDaliActorSetSize02(void)
1024 TestApplication application;
1026 Actor actor = Actor::New();
1027 Vector3 vector(100.0f, 100.0f, 100.0f);
1029 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1031 actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1033 // Immediately check the size after setting
1034 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1035 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1037 // flush the queue and render once
1038 application.SendNotification();
1039 application.Render();
1041 // Check the size in the new frame
1042 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1044 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1045 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1050 // SetSize(Vector2 size)
1051 int UtcDaliActorSetSize03(void)
1053 TestApplication application;
1055 Actor actor = Actor::New();
1056 Vector3 vector(100.0f, 100.0f, 0.0f);
1058 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1060 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1062 // Immediately check the size after setting
1063 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1064 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1066 // flush the queue and render once
1067 application.SendNotification();
1068 application.Render();
1070 // Check the size in the new frame
1071 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1073 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1074 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1079 // SetSize(Vector3 size)
1080 int UtcDaliActorSetSize04(void)
1082 TestApplication application;
1084 Actor actor = Actor::New();
1085 Vector3 vector(100.0f, 100.0f, 100.0f);
1087 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1089 actor.SetProperty(Actor::Property::SIZE, vector);
1091 // Immediately check the size after setting
1092 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1093 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1095 // flush the queue and render once
1096 application.SendNotification();
1097 application.Render();
1099 // Check the size in the new frame
1100 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1102 application.GetScene().Add(actor);
1103 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1105 // Immediately check the size after setting
1106 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1107 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1109 // flush the queue and render once
1110 application.SendNotification();
1111 application.Render();
1113 // Check the size in the new frame
1114 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1116 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1117 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1119 application.GetScene().Remove(actor);
1123 int UtcDaliActorSetSizeIndividual(void)
1125 TestApplication application;
1127 Actor actor = Actor::New();
1129 Vector3 vector(0.7f, 0.8f, 0.9f);
1130 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1132 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1134 // Immediately check the width after setting
1135 float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1136 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1138 // flush the queue and render once
1139 application.SendNotification();
1140 application.Render();
1142 // Check the width in the new frame
1143 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1145 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1146 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1148 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1150 // Immediately check the height after setting
1151 float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1152 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1154 // flush the queue and render once
1155 application.SendNotification();
1156 application.Render();
1158 // Check the height in the new frame
1159 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1161 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1162 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1164 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1166 // Immediately check the depth after setting
1167 float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1168 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1170 // flush the queue and render once
1171 application.SendNotification();
1172 application.Render();
1174 // Check the depth in the new frame
1175 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1177 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1178 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1180 // Change the resize policy and check whether the size stays the same
1181 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1183 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1184 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1186 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1187 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1189 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1190 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1192 // Change the resize policy again and check whether the size stays the same
1193 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1195 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1196 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1198 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1199 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1201 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1202 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1207 int UtcDaliActorSetSizeIndividual02(void)
1209 TestApplication application;
1211 Actor actor = Actor::New();
1212 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1213 application.GetScene().Add(actor);
1215 Vector3 vector(100.0f, 200.0f, 400.0f);
1216 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1218 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1219 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1221 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1222 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1224 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1225 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1227 // flush the queue and render once
1228 application.SendNotification();
1229 application.Render();
1231 // Check the width in the new frame
1232 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1233 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1238 int UtcDaliActorGetCurrentSize(void)
1240 TestApplication application;
1242 Actor actor = Actor::New();
1243 Vector3 vector(100.0f, 100.0f, 20.0f);
1245 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1247 actor.SetProperty(Actor::Property::SIZE, vector);
1249 // flush the queue and render once
1250 application.SendNotification();
1251 application.Render();
1253 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1257 int UtcDaliActorGetNaturalSize(void)
1259 TestApplication application;
1261 Actor actor = Actor::New();
1262 Vector3 vector(0.0f, 0.0f, 0.0f);
1264 DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1269 int UtcDaliActorGetCurrentSizeImmediate(void)
1271 TestApplication application;
1273 Actor actor = Actor::New();
1274 Vector3 vector(100.0f, 100.0f, 20.0f);
1276 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1277 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1279 actor.SetProperty(Actor::Property::SIZE, vector);
1281 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1282 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1284 // flush the queue and render once
1285 application.SendNotification();
1286 application.Render();
1288 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1289 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1292 // Build the animation
1293 const float durationSeconds = 2.0f;
1294 Animation animation = Animation::New(durationSeconds);
1295 const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1296 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1298 DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1300 application.GetScene().Add(actor);
1302 // Start the animation
1305 application.SendNotification();
1306 application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1308 DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1313 int UtcDaliActorCalculateScreenExtents(void)
1315 TestApplication application;
1317 Actor actor = Actor::New();
1319 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1320 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1322 application.SendNotification();
1323 application.Render();
1325 auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f};
1326 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1327 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1328 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1329 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1330 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1332 application.GetScene().Remove(actor);
1336 // SetPosition(float x, float y)
1337 int UtcDaliActorSetPosition01(void)
1339 TestApplication application;
1341 Actor actor = Actor::New();
1343 // Set to random to start off with
1344 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1346 Vector3 vector(100.0f, 100.0f, 0.0f);
1348 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1350 actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1351 // flush the queue and render once
1352 application.SendNotification();
1353 application.Render();
1354 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1356 application.GetScene().Add(actor);
1357 actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1358 // flush the queue and render once
1359 application.SendNotification();
1360 application.Render();
1361 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1363 actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1364 actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1365 actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1366 // flush the queue and render once
1367 application.SendNotification();
1368 application.Render();
1369 DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1371 actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1372 // flush the queue and render once
1373 application.SendNotification();
1374 application.Render();
1375 DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1377 application.GetScene().Remove(actor);
1381 // SetPosition(float x, float y, float z)
1382 int UtcDaliActorSetPosition02(void)
1384 TestApplication application;
1386 Actor actor = Actor::New();
1388 // Set to random to start off with
1389 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1391 Vector3 vector(100.0f, 100.0f, 100.0f);
1393 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1395 actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1397 // flush the queue and render once
1398 application.SendNotification();
1399 application.Render();
1401 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1405 // SetPosition(Vector3 position)
1406 int UtcDaliActorSetPosition03(void)
1408 TestApplication application;
1410 Actor actor = Actor::New();
1412 // Set to random to start off with
1413 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1415 Vector3 vector(100.0f, 100.0f, 100.0f);
1417 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1419 actor.SetProperty(Actor::Property::POSITION, vector);
1421 // flush the queue and render once
1422 application.SendNotification();
1423 application.Render();
1425 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1429 int UtcDaliActorSetX(void)
1431 TestApplication application;
1433 Actor actor = Actor::New();
1435 Vector3 vector(100.0f, 0.0f, 0.0f);
1437 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1439 actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1441 // flush the queue and render once
1442 application.SendNotification();
1443 application.Render();
1445 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1449 int UtcDaliActorSetY(void)
1451 TestApplication application;
1453 Actor actor = Actor::New();
1455 Vector3 vector(0.0f, 100.0f, 0.0f);
1457 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1459 actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1461 // flush the queue and render once
1462 application.SendNotification();
1463 application.Render();
1465 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1469 int UtcDaliActorSetZ(void)
1471 TestApplication application;
1473 Actor actor = Actor::New();
1475 Vector3 vector(0.0f, 0.0f, 100.0f);
1477 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1479 actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1481 // flush the queue and render once
1482 application.SendNotification();
1483 application.Render();
1485 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1489 int UtcDaliActorSetPositionProperties(void)
1491 TestApplication application;
1493 Actor actor = Actor::New();
1495 Vector3 vector(0.7f, 0.8f, 0.9f);
1496 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1498 actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1499 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1500 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1502 // flush the queue and render once
1503 application.SendNotification();
1504 application.Render();
1506 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1507 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1508 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1509 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1510 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1512 actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1513 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1514 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1516 // flush the queue and render once
1517 application.SendNotification();
1518 application.Render();
1520 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1521 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1522 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1523 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1524 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1526 actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1527 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1528 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1530 // flush the queue and render once
1531 application.SendNotification();
1532 application.Render();
1534 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1535 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1536 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1537 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1538 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1543 int UtcDaliActorTranslateBy(void)
1545 TestApplication application;
1547 Actor actor = Actor::New();
1548 Vector3 vector(100.0f, 100.0f, 100.0f);
1550 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1552 actor.SetProperty(Actor::Property::POSITION, vector);
1554 // flush the queue and render once
1555 application.SendNotification();
1556 application.Render();
1558 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1560 actor.TranslateBy(vector);
1562 // flush the queue and render once
1563 application.SendNotification();
1564 application.Render();
1566 DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1570 int UtcDaliActorGetCurrentPosition(void)
1572 TestApplication application;
1574 Actor actor = Actor::New();
1575 Vector3 setVector(100.0f, 100.0f, 0.0f);
1576 actor.SetProperty(Actor::Property::POSITION, setVector);
1578 // flush the queue and render once
1579 application.SendNotification();
1580 application.Render();
1582 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1586 int UtcDaliActorGetCurrentWorldPosition(void)
1588 TestApplication application;
1590 Actor parent = Actor::New();
1591 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1592 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1593 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1594 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1595 application.GetScene().Add(parent);
1597 Actor child = Actor::New();
1598 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1599 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1600 Vector3 childPosition(6.0f, 6.0f, 6.0f);
1601 child.SetProperty(Actor::Property::POSITION, childPosition);
1604 // The actors should not have a world position yet
1605 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1606 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1608 application.SendNotification();
1609 application.Render(0);
1611 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1612 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1614 // The actors should have a world position now
1615 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1616 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1620 int UtcDaliActorSetInheritPosition(void)
1622 tet_infoline("Testing Actor::SetInheritPosition");
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(10.0f, 11.0f, 12.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 // first test default, which is to inherit position
1644 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1645 application.SendNotification();
1646 application.Render(0); // should only really call Update as Render is not required to update scene
1647 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1648 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1649 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1650 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1652 //Change child position
1653 Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1654 child.SetProperty(Actor::Property::POSITION, childOffset);
1656 // Use local position as world postion
1657 child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1658 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1659 application.SendNotification();
1660 application.Render(0); // should only really call Update as Render is not required to update scene
1661 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1662 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1663 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1664 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1666 //Change back to inherit position from parent
1667 child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1668 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1669 application.SendNotification();
1670 application.Render(0); // should only really call Update as Render is not required to update scene
1671 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1672 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1673 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1674 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1678 int UtcDaliActorInheritOpacity(void)
1680 tet_infoline("Testing Actor::Inherit Opacity");
1681 TestApplication application;
1683 Actor parent = Actor::New();
1684 Actor child = Actor::New();
1686 application.GetScene().Add(parent);
1688 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1689 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1691 // flush the queue and render once
1692 application.SendNotification();
1693 application.Render();
1695 parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1697 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1698 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1700 application.SendNotification();
1701 application.Render();
1703 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1704 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1705 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1706 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1707 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1708 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1713 // SetOrientation(float angleRadians, Vector3 axis)
1714 int UtcDaliActorSetOrientation01(void)
1716 TestApplication application;
1718 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1719 Actor actor = Actor::New();
1721 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1723 // flush the queue and render once
1724 application.SendNotification();
1725 application.Render();
1727 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1731 int UtcDaliActorSetOrientation02(void)
1733 TestApplication application;
1735 Actor actor = Actor::New();
1737 Radian angle(0.785f);
1738 Vector3 axis(1.0f, 1.0f, 0.0f);
1740 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1741 Quaternion rotation(angle, axis);
1742 // flush the queue and render once
1743 application.SendNotification();
1744 application.Render();
1745 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1747 application.GetScene().Add(actor);
1748 actor.RotateBy(Degree(360), axis);
1749 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1751 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
1752 Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
1753 // flush the queue and render once
1754 application.SendNotification();
1755 application.Render();
1756 DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1758 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1759 // flush the queue and render once
1760 application.SendNotification();
1761 application.Render();
1762 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1764 application.GetScene().Remove(actor);
1768 // SetOrientation(float angleRadians, Vector3 axis)
1769 int UtcDaliActorSetOrientationProperty(void)
1771 TestApplication application;
1773 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1774 Actor actor = Actor::New();
1776 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1777 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1779 // flush the queue and render once
1780 application.SendNotification();
1781 application.Render();
1783 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1784 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1785 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1789 // RotateBy(float angleRadians, Vector3 axis)
1790 int UtcDaliActorRotateBy01(void)
1792 TestApplication application;
1794 Actor actor = Actor::New();
1796 Radian angle(M_PI * 0.25f);
1797 actor.RotateBy((angle), Vector3::ZAXIS);
1798 // flush the queue and render once
1799 application.SendNotification();
1800 application.Render();
1801 DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1803 application.GetScene().Add(actor);
1805 actor.RotateBy(angle, Vector3::ZAXIS);
1806 // flush the queue and render once
1807 application.SendNotification();
1808 application.Render();
1809 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1811 application.GetScene().Remove(actor);
1815 // RotateBy(Quaternion relativeRotation)
1816 int UtcDaliActorRotateBy02(void)
1818 TestApplication application;
1820 Actor actor = Actor::New();
1822 Radian angle(M_PI * 0.25f);
1823 Quaternion rotation(angle, Vector3::ZAXIS);
1824 actor.RotateBy(rotation);
1825 // flush the queue and render once
1826 application.SendNotification();
1827 application.Render();
1828 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1830 actor.RotateBy(rotation);
1831 // flush the queue and render once
1832 application.SendNotification();
1833 application.Render();
1834 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1838 int UtcDaliActorGetCurrentOrientation(void)
1840 TestApplication application;
1841 Actor actor = Actor::New();
1843 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1844 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1845 // flush the queue and render once
1846 application.SendNotification();
1847 application.Render();
1848 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1852 int UtcDaliActorGetCurrentWorldOrientation(void)
1854 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1855 TestApplication application;
1857 Actor parent = Actor::New();
1858 Radian rotationAngle(Degree(90.0f));
1859 Quaternion rotation(rotationAngle, Vector3::YAXIS);
1860 parent.SetProperty(Actor::Property::ORIENTATION, rotation);
1861 application.GetScene().Add(parent);
1863 Actor child = Actor::New();
1864 child.SetProperty(Actor::Property::ORIENTATION, rotation);
1867 // The actors should not have a world rotation yet
1868 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1869 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1871 application.SendNotification();
1872 application.Render(0);
1874 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1875 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1877 // The actors should have a world rotation now
1878 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1879 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
1881 // turn off child rotation inheritance
1882 child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
1883 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
1884 application.SendNotification();
1885 application.Render(0);
1887 // The actors should have a world rotation now
1888 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1889 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
1893 // SetScale(float scale)
1894 int UtcDaliActorSetScale01(void)
1896 TestApplication application;
1898 Actor actor = Actor::New();
1900 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1901 actor.SetProperty(Actor::Property::SCALE, 0.25f);
1903 Vector3 scale(10.0f, 10.0f, 10.0f);
1904 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1906 actor.SetProperty(Actor::Property::SCALE, scale.x);
1908 // flush the queue and render once
1909 application.SendNotification();
1910 application.Render();
1912 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1916 // SetScale(float scaleX, float scaleY, float scaleZ)
1917 int UtcDaliActorSetScale02(void)
1919 TestApplication application;
1920 Vector3 scale(10.0f, 10.0f, 10.0f);
1922 Actor actor = Actor::New();
1924 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1925 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1927 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1929 actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
1930 // flush the queue and render once
1931 application.SendNotification();
1932 application.Render();
1933 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1935 // add to stage and test
1936 application.GetScene().Add(actor);
1937 actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
1938 // flush the queue and render once
1939 application.SendNotification();
1940 application.Render();
1941 DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
1943 application.GetScene().Remove(actor);
1948 // SetScale(Vector3 scale)
1949 int UtcDaliActorSetScale03(void)
1951 TestApplication application;
1952 Vector3 scale(10.0f, 10.0f, 10.0f);
1954 Actor actor = Actor::New();
1956 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1957 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1959 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1961 actor.SetProperty(Actor::Property::SCALE, scale);
1963 // flush the queue and render once
1964 application.SendNotification();
1965 application.Render();
1967 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1971 int UtcDaliActorSetScaleIndividual(void)
1973 TestApplication application;
1975 Actor actor = Actor::New();
1977 Vector3 vector(0.7f, 0.8f, 0.9f);
1978 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
1980 actor.SetProperty(Actor::Property::SCALE_X, vector.x);
1981 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1983 // flush the queue and render once
1984 application.SendNotification();
1985 application.Render();
1987 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
1988 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1989 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1991 actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
1992 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
1994 // flush the queue and render once
1995 application.SendNotification();
1996 application.Render();
1998 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
1999 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2000 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2002 actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2003 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2005 // flush the queue and render once
2006 application.SendNotification();
2007 application.Render();
2009 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2010 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2011 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2013 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2014 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2019 int UtcDaliActorScaleBy(void)
2021 TestApplication application;
2022 Actor actor = Actor::New();
2023 Vector3 vector(100.0f, 100.0f, 100.0f);
2025 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2027 actor.SetProperty(Actor::Property::SCALE, vector);
2029 // flush the queue and render once
2030 application.SendNotification();
2031 application.Render();
2033 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2035 actor.ScaleBy(vector);
2037 // flush the queue and render once
2038 application.SendNotification();
2039 application.Render();
2041 DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2045 int UtcDaliActorGetCurrentScale(void)
2047 TestApplication application;
2048 Vector3 scale(12.0f, 1.0f, 2.0f);
2050 Actor actor = Actor::New();
2052 actor.SetProperty(Actor::Property::SCALE, scale);
2054 // flush the queue and render once
2055 application.SendNotification();
2056 application.Render();
2058 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2062 int UtcDaliActorGetCurrentWorldScale(void)
2064 TestApplication application;
2066 Actor parent = Actor::New();
2067 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2068 parent.SetProperty(Actor::Property::SCALE, parentScale);
2069 application.GetScene().Add(parent);
2071 Actor child = Actor::New();
2072 Vector3 childScale(2.0f, 2.0f, 2.0f);
2073 child.SetProperty(Actor::Property::SCALE, childScale);
2076 // The actors should not have a scale yet
2077 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2078 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2080 // The actors should not have a world scale yet
2081 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2082 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2084 application.SendNotification();
2085 application.Render(0);
2087 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2088 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2090 // The actors should have a world scale now
2091 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2092 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2096 int UtcDaliActorInheritScale(void)
2098 tet_infoline("Testing Actor::SetInheritScale");
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 application.SendNotification();
2112 application.Render(0);
2114 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2115 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2117 child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2118 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2120 application.SendNotification();
2121 application.Render(0);
2123 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2127 int UtcDaliActorSetVisible(void)
2129 TestApplication application;
2131 Actor actor = Actor::New();
2132 actor.SetProperty(Actor::Property::VISIBLE, false);
2133 // flush the queue and render once
2134 application.SendNotification();
2135 application.Render();
2136 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2138 actor.SetProperty(Actor::Property::VISIBLE, true);
2139 // flush the queue and render once
2140 application.SendNotification();
2141 application.Render();
2142 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2144 // put actor on stage
2145 application.GetScene().Add(actor);
2146 actor.SetProperty(Actor::Property::VISIBLE, false);
2147 // flush the queue and render once
2148 application.SendNotification();
2149 application.Render();
2150 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2154 int UtcDaliActorIsVisible(void)
2156 TestApplication application;
2158 Actor actor = Actor::New();
2160 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2164 int UtcDaliActorSetOpacity(void)
2166 TestApplication application;
2168 Actor actor = Actor::New();
2169 // initial opacity is 1
2170 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2172 actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2173 // flush the queue and render once
2174 application.SendNotification();
2175 application.Render();
2176 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2178 // change opacity, actor is on stage to change is not immediate
2179 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2180 // flush the queue and render once
2181 application.SendNotification();
2182 application.Render();
2183 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2185 // put actor on stage
2186 application.GetScene().Add(actor);
2188 // change opacity, actor is on stage to change is not immediate
2189 actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2190 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2191 // flush the queue and render once
2192 application.SendNotification();
2193 application.Render();
2194 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2196 // change opacity, actor is on stage to change is not immediate
2197 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2198 // flush the queue and render once
2199 application.SendNotification();
2200 application.Render();
2201 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2205 int UtcDaliActorGetCurrentOpacity(void)
2207 TestApplication application;
2209 Actor actor = Actor::New();
2210 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2212 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2213 // flush the queue and render once
2214 application.SendNotification();
2215 application.Render();
2216 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2220 int UtcDaliActorSetSensitive(void)
2222 TestApplication application;
2223 Actor actor = Actor::New();
2225 bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2227 actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2229 DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2233 int UtcDaliActorIsSensitive(void)
2235 TestApplication application;
2236 Actor actor = Actor::New();
2237 actor.SetProperty(Actor::Property::SENSITIVE, false);
2239 DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2243 int UtcDaliActorSetColor(void)
2245 TestApplication application;
2246 Actor actor = Actor::New();
2247 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2249 DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2251 actor.SetProperty(Actor::Property::COLOR, color);
2252 // flush the queue and render once
2253 application.SendNotification();
2254 application.Render();
2255 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2257 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2258 // flush the queue and render once
2259 application.SendNotification();
2260 application.Render();
2261 DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2263 application.GetScene().Add(actor);
2264 actor.SetProperty(Actor::Property::COLOR, color);
2265 // flush the queue and render once
2266 application.SendNotification();
2267 application.Render();
2268 DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2270 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2271 // flush the queue and render once
2272 application.SendNotification();
2273 application.Render();
2274 // Actor color is not clamped
2275 DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2276 // world color is clamped
2277 DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2279 actor.SetProperty(Actor::Property::COLOR, color);
2280 DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2282 Vector3 newColor(1.0f, 0.0f, 0.0f);
2283 actor.SetProperty(Actor::Property::COLOR, newColor);
2284 DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2286 application.GetScene().Remove(actor);
2290 int UtcDaliActorSetColorIndividual(void)
2292 TestApplication application;
2294 Actor actor = Actor::New();
2296 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2297 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2299 actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2300 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2302 // flush the queue and render once
2303 application.SendNotification();
2304 application.Render();
2306 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2307 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2308 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2310 actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2311 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2313 // flush the queue and render once
2314 application.SendNotification();
2315 application.Render();
2317 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2318 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2319 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2321 actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2322 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2324 // flush the queue and render once
2325 application.SendNotification();
2326 application.Render();
2328 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2329 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2330 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2332 actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2333 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2335 // flush the queue and render once
2336 application.SendNotification();
2337 application.Render();
2339 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2340 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2341 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2343 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2344 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2346 actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2348 // flush the queue and render once
2349 application.SendNotification();
2350 application.Render();
2352 DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2357 int UtcDaliActorGetCurrentColor(void)
2359 TestApplication application;
2360 Actor actor = Actor::New();
2361 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2363 actor.SetProperty(Actor::Property::COLOR, color);
2364 // flush the queue and render once
2365 application.SendNotification();
2366 application.Render();
2367 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2371 int UtcDaliActorGetCurrentWorldColor(void)
2373 tet_infoline("Actor::GetCurrentWorldColor");
2374 TestApplication application;
2376 Actor parent = Actor::New();
2377 Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2378 parent.SetProperty(Actor::Property::COLOR, parentColor);
2379 application.GetScene().Add(parent);
2381 Actor child = Actor::New();
2382 Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2383 child.SetProperty(Actor::Property::COLOR, childColor);
2386 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2387 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2389 // verify the default color mode
2390 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2392 // The actors should not have a world color yet
2393 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2394 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2396 application.SendNotification();
2397 application.Render(0);
2399 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2400 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2402 // The actors should have a world color now
2403 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2404 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2407 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2408 application.SendNotification();
2409 application.Render(0);
2410 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2413 child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2414 application.SendNotification();
2415 application.Render(0);
2416 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2417 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2420 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2421 application.SendNotification();
2422 application.Render(0);
2423 Vector4 expectedColor(childColor);
2424 expectedColor.a *= parentColor.a;
2425 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2426 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2430 int UtcDaliActorSetColorMode(void)
2432 tet_infoline("Actor::SetColorMode");
2433 TestApplication application;
2434 Actor actor = Actor::New();
2435 Actor child = Actor::New();
2438 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2439 DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2441 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2442 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2444 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2445 DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2447 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2448 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2452 int UtcDaliActorScreenToLocal(void)
2454 TestApplication application;
2455 Actor actor = Actor::New();
2456 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2457 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2458 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2459 application.GetScene().Add(actor);
2461 // flush the queue and render once
2462 application.SendNotification();
2463 application.Render();
2468 application.SendNotification();
2469 application.Render();
2471 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2473 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2474 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2478 int UtcDaliActorSetLeaveRequired(void)
2480 TestApplication application;
2482 Actor actor = Actor::New();
2484 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2485 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2487 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2488 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2492 int UtcDaliActorGetLeaveRequired(void)
2494 TestApplication application;
2496 Actor actor = Actor::New();
2498 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2502 int UtcDaliActorSetKeyboardFocusable(void)
2504 TestApplication application;
2506 Actor actor = Actor::New();
2508 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2509 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2511 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2512 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2516 int UtcDaliActorIsKeyboardFocusable(void)
2518 TestApplication application;
2520 Actor actor = Actor::New();
2522 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2526 int UtcDaliActorRemoveConstraints(void)
2528 tet_infoline(" UtcDaliActorRemoveConstraints");
2529 TestApplication application;
2531 gTestConstraintCalled = false;
2533 Actor actor = Actor::New();
2535 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2537 actor.RemoveConstraints();
2539 DALI_TEST_CHECK(gTestConstraintCalled == false);
2541 application.GetScene().Add(actor);
2544 // flush the queue and render once
2545 application.SendNotification();
2546 application.Render();
2548 actor.RemoveConstraints();
2550 DALI_TEST_CHECK(gTestConstraintCalled == true);
2554 int UtcDaliActorRemoveConstraintTag(void)
2556 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2557 TestApplication application;
2559 Actor actor = Actor::New();
2561 // 1. Apply Constraint1 and Constraint2, and test...
2562 unsigned int result1 = 0u;
2563 unsigned int result2 = 0u;
2565 unsigned constraint1Tag = 1u;
2566 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2567 constraint1.SetTag(constraint1Tag);
2568 constraint1.Apply();
2570 unsigned constraint2Tag = 2u;
2571 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2572 constraint2.SetTag(constraint2Tag);
2573 constraint2.Apply();
2575 application.GetScene().Add(actor);
2576 // flush the queue and render once
2577 application.SendNotification();
2578 application.Render();
2580 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2581 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2583 // 2. Remove Constraint1 and test...
2586 actor.RemoveConstraints(constraint1Tag);
2587 // make color property dirty, which will trigger constraints to be reapplied.
2588 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2589 // flush the queue and render once
2590 application.SendNotification();
2591 application.Render();
2593 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2594 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2596 // 3. Re-Apply Constraint1 and test...
2599 constraint1.Apply();
2600 // make color property dirty, which will trigger constraints to be reapplied.
2601 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2602 // flush the queue and render once
2603 application.SendNotification();
2604 application.Render();
2606 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2607 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2609 // 2. Remove Constraint2 and test...
2612 actor.RemoveConstraints(constraint2Tag);
2613 // make color property dirty, which will trigger constraints to be reapplied.
2614 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2615 // flush the queue and render once
2616 application.SendNotification();
2617 application.Render();
2619 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2620 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2622 // 2. Remove Constraint1 as well and test...
2625 actor.RemoveConstraints(constraint1Tag);
2626 // make color property dirty, which will trigger constraints to be reapplied.
2627 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2628 // flush the queue and render once
2629 application.SendNotification();
2630 application.Render();
2632 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2633 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2637 int UtcDaliActorTouchedSignal(void)
2639 TestApplication application;
2641 ResetTouchCallbacks();
2643 // get the root layer
2644 Actor actor = application.GetScene().GetRootLayer();
2645 DALI_TEST_CHECK(gTouchCallBackCalled == false);
2647 application.SendNotification();
2648 application.Render();
2650 // connect to its touch signal
2651 actor.TouchedSignal().Connect(TestTouchCallback);
2653 // simulate a touch event in the middle of the screen
2654 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2655 Dali::Integration::Point point;
2656 point.SetDeviceId(1);
2657 point.SetState(PointState::DOWN);
2658 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2659 Dali::Integration::TouchEvent touchEvent;
2660 touchEvent.AddPoint(point);
2661 application.ProcessEvent(touchEvent);
2663 DALI_TEST_CHECK(gTouchCallBackCalled == true);
2667 int UtcDaliActorHoveredSignal(void)
2669 TestApplication application;
2671 gHoverCallBackCalled = false;
2673 // get the root layer
2674 Actor actor = application.GetScene().GetRootLayer();
2675 DALI_TEST_CHECK(gHoverCallBackCalled == false);
2677 application.SendNotification();
2678 application.Render();
2680 // connect to its hover signal
2681 actor.HoveredSignal().Connect(TestCallback3);
2683 // simulate a hover event in the middle of the screen
2684 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2685 Dali::Integration::Point point;
2686 point.SetDeviceId(1);
2687 point.SetState(PointState::MOTION);
2688 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2689 Dali::Integration::HoverEvent hoverEvent;
2690 hoverEvent.AddPoint(point);
2691 application.ProcessEvent(hoverEvent);
2693 DALI_TEST_CHECK(gHoverCallBackCalled == true);
2697 int UtcDaliActorOnOffSceneSignal(void)
2699 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2701 TestApplication application;
2704 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2705 gActorNamesOnOffScene.clear();
2707 Actor parent = Actor::New();
2708 parent.SetProperty(Actor::Property::NAME, "parent");
2709 parent.OnSceneSignal().Connect(OnSceneCallback);
2710 parent.OffSceneSignal().Connect(OffSceneCallback);
2712 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2713 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2715 // add parent to the scene
2716 application.GetScene().Add(parent);
2717 // onstage emitted, offstage not
2718 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2719 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2720 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2722 // test adding a child, should get onstage emitted
2724 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2725 gActorNamesOnOffScene.clear();
2727 Actor child = Actor::New();
2728 child.SetProperty(Actor::Property::NAME, "child");
2729 child.OnSceneSignal().Connect(OnSceneCallback);
2730 child.OffSceneSignal().Connect(OffSceneCallback);
2731 parent.Add(child); // add child
2732 // onscene emitted, offscene not
2733 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2734 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2735 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2737 // test removing parent from the scene
2739 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2740 gActorNamesOnOffScene.clear();
2742 application.GetScene().Remove(parent);
2743 // onscene not emitted, offscene is
2744 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2745 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2746 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2747 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2749 // test adding parent back to the scene
2751 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2752 gActorNamesOnOffScene.clear();
2754 application.GetScene().Add(parent);
2755 // onscene emitted, offscene not
2756 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2757 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2758 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2759 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2761 // test removing child
2763 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2764 gActorNamesOnOffScene.clear();
2766 parent.Remove(child);
2767 // onscene not emitted, offscene is
2768 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2769 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2770 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2772 // test removing parent
2774 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2775 gActorNamesOnOffScene.clear();
2777 application.GetScene().Remove(parent);
2778 // onscene not emitted, offscene is
2779 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2780 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2781 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2785 int UtcDaliActorFindChildByName(void)
2787 tet_infoline("Testing Dali::Actor::FindChildByName()");
2788 TestApplication application;
2790 Actor parent = Actor::New();
2791 parent.SetProperty(Actor::Property::NAME, "parent");
2792 Actor first = Actor::New();
2793 first.SetProperty(Actor::Property::NAME, "first");
2794 Actor second = Actor::New();
2795 second.SetProperty(Actor::Property::NAME, "second");
2800 Actor found = parent.FindChildByName("foo");
2801 DALI_TEST_CHECK(!found);
2803 found = parent.FindChildByName("parent");
2804 DALI_TEST_CHECK(found == parent);
2806 found = parent.FindChildByName("first");
2807 DALI_TEST_CHECK(found == first);
2809 found = parent.FindChildByName("second");
2810 DALI_TEST_CHECK(found == second);
2814 int UtcDaliActorFindChildById(void)
2816 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2817 TestApplication application;
2819 Actor parent = Actor::New();
2820 Actor first = Actor::New();
2821 Actor second = Actor::New();
2826 Actor found = parent.FindChildById(100000);
2827 DALI_TEST_CHECK(!found);
2829 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2830 DALI_TEST_CHECK(found == parent);
2832 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2833 DALI_TEST_CHECK(found == first);
2835 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2836 DALI_TEST_CHECK(found == second);
2840 int UtcDaliActorHitTest(void)
2845 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2847 mTouchPoint(touchPoint),
2853 Vector2 mTouchPoint;
2857 TestApplication application;
2858 tet_infoline(" UtcDaliActorHitTest");
2860 // Fill a vector with different hit tests.
2861 struct HitTestData* hitTestData[] = {
2862 // scale touch point result
2863 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
2864 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2865 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.
2866 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2867 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.
2871 // get the root layer
2872 Actor actor = Actor::New();
2873 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2874 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2876 application.GetScene().Add(actor);
2878 ResetTouchCallbacks();
2880 unsigned int index = 0;
2881 while(NULL != hitTestData[index])
2883 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2884 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2886 // flush the queue and render once
2887 application.SendNotification();
2888 application.Render();
2890 DALI_TEST_CHECK(!gTouchCallBackCalled);
2892 // connect to its touch signal
2893 actor.TouchedSignal().Connect(TestTouchCallback);
2895 Dali::Integration::Point point;
2896 point.SetState(PointState::DOWN);
2897 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2898 Dali::Integration::TouchEvent event;
2899 event.AddPoint(point);
2901 // flush the queue and render once
2902 application.SendNotification();
2903 application.Render();
2904 application.ProcessEvent(event);
2906 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
2908 if(gTouchCallBackCalled != hitTestData[index]->mResult)
2909 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2910 hitTestData[index]->mScale.x,
2911 hitTestData[index]->mScale.y,
2912 hitTestData[index]->mScale.z,
2913 hitTestData[index]->mTouchPoint.x,
2914 hitTestData[index]->mTouchPoint.y,
2915 hitTestData[index]->mResult);
2917 ResetTouchCallbacks();
2923 int UtcDaliActorSetDrawMode(void)
2925 TestApplication application;
2926 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2928 Actor a = Actor::New();
2930 application.GetScene().Add(a);
2931 application.SendNotification();
2932 application.Render(0);
2933 application.SendNotification();
2934 application.Render(1);
2936 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
2938 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2939 application.SendNotification();
2940 application.Render(1);
2942 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
2944 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
2945 application.SendNotification();
2946 application.Render(1);
2948 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
2952 int UtcDaliActorSetDrawModeOverlayRender(void)
2954 TestApplication application;
2955 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2957 application.SendNotification();
2958 application.Render(1);
2960 std::vector<GLuint> ids;
2961 ids.push_back(8); // first rendered actor
2962 ids.push_back(9); // second rendered actor
2963 ids.push_back(10); // third rendered actor
2964 application.GetGlAbstraction().SetNextTextureIds(ids);
2966 Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2967 Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2968 Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2969 Actor a = CreateRenderableActor(imageA);
2970 Actor b = CreateRenderableActor(imageB);
2971 Actor c = CreateRenderableActor(imageC);
2973 application.SendNotification();
2974 application.Render(1);
2976 //Textures are bound when first created. Clear bound textures vector
2977 application.GetGlAbstraction().ClearBoundTextures();
2979 // Render a,b,c as regular non-overlays. so order will be:
2983 application.GetScene().Add(a);
2984 application.GetScene().Add(b);
2985 application.GetScene().Add(c);
2987 application.SendNotification();
2988 application.Render(1);
2990 // Should be 3 textures changes.
2991 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
2992 typedef std::vector<GLuint>::size_type TextureSize;
2993 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
2994 if(boundTextures.size() == 3)
2996 DALI_TEST_CHECK(boundTextures[0] == 8u);
2997 DALI_TEST_CHECK(boundTextures[1] == 9u);
2998 DALI_TEST_CHECK(boundTextures[2] == 10u);
3001 // Now texture ids have been set, we can monitor their render order.
3002 // render a as an overlay (last), so order will be:
3006 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3007 application.GetGlAbstraction().ClearBoundTextures();
3009 application.SendNotification();
3010 application.Render(1);
3012 // Should be 3 texture changes.
3013 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3014 if(boundTextures.size() == 3)
3016 DALI_TEST_CHECK(boundTextures[0] == 9u);
3017 DALI_TEST_CHECK(boundTextures[1] == 10u);
3018 DALI_TEST_CHECK(boundTextures[2] == 8u);
3023 int UtcDaliActorGetCurrentWorldMatrix(void)
3025 TestApplication application;
3026 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3028 Actor parent = Actor::New();
3029 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3030 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3031 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3032 Radian rotationAngle(Degree(85.0f));
3033 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3034 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3035 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3036 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3037 parent.SetProperty(Actor::Property::SCALE, parentScale);
3038 application.GetScene().Add(parent);
3040 Actor child = Actor::New();
3041 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3042 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3043 Radian childRotationAngle(Degree(23.0f));
3044 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3045 Vector3 childScale(2.0f, 2.0f, 2.0f);
3046 child.SetProperty(Actor::Property::POSITION, childPosition);
3047 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3048 child.SetProperty(Actor::Property::SCALE, childScale);
3051 application.SendNotification();
3052 application.Render(0);
3053 application.Render();
3054 application.SendNotification();
3056 Matrix parentMatrix(false);
3057 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3059 Matrix childMatrix(false);
3060 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3062 //Child matrix should be the composition of child and parent
3063 Matrix childWorldMatrix(false);
3064 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3066 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3067 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3071 int UtcDaliActorConstrainedToWorldMatrix(void)
3073 TestApplication application;
3074 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3076 Actor parent = Actor::New();
3077 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3078 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3079 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3080 Radian rotationAngle(Degree(85.0f));
3081 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3082 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3083 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3084 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3085 parent.SetProperty(Actor::Property::SCALE, parentScale);
3086 application.GetScene().Add(parent);
3088 Actor child = Actor::New();
3089 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3090 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3091 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3092 posConstraint.Apply();
3094 application.GetScene().Add(child);
3096 application.SendNotification();
3097 application.Render(0);
3098 application.Render();
3099 application.SendNotification();
3101 Matrix parentMatrix(false);
3102 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3104 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3105 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3109 int UtcDaliActorConstrainedToOrientation(void)
3111 TestApplication application;
3112 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3114 Actor parent = Actor::New();
3115 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3116 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3117 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3118 Radian rotationAngle(Degree(85.0f));
3119 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3120 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3121 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3122 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3123 parent.SetProperty(Actor::Property::SCALE, parentScale);
3124 application.GetScene().Add(parent);
3126 Actor child = Actor::New();
3127 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3128 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3129 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3130 posConstraint.Apply();
3132 application.GetScene().Add(child);
3134 application.SendNotification();
3135 application.Render(0);
3136 application.Render();
3137 application.SendNotification();
3139 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3143 int UtcDaliActorConstrainedToOpacity(void)
3145 TestApplication application;
3146 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3148 Actor parent = Actor::New();
3149 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3150 application.GetScene().Add(parent);
3152 Actor child = Actor::New();
3153 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3154 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3155 opacityConstraint.Apply();
3157 application.GetScene().Add(child);
3159 application.SendNotification();
3160 application.Render(0);
3161 application.Render();
3162 application.SendNotification();
3164 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3166 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3168 application.SendNotification();
3169 application.Render(0);
3170 application.Render();
3171 application.SendNotification();
3173 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3178 int UtcDaliActorUnparent(void)
3180 TestApplication application;
3181 tet_infoline(" UtcDaliActorUnparent");
3183 Actor parent = Actor::New();
3184 application.GetScene().Add(parent);
3186 Actor child = Actor::New();
3188 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3189 DALI_TEST_CHECK(!child.GetParent());
3191 // Test that calling Unparent with no parent is a NOOP
3194 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3195 DALI_TEST_CHECK(!child.GetParent());
3197 // Test that Unparent works
3200 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3201 DALI_TEST_CHECK(parent == child.GetParent());
3205 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3206 DALI_TEST_CHECK(!child.GetParent());
3208 // Test that UnparentAndReset works
3211 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3212 DALI_TEST_CHECK(parent == child.GetParent());
3214 UnparentAndReset(child);
3216 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3217 DALI_TEST_CHECK(!child);
3219 // Test that UnparentAndReset is a NOOP with empty handle
3220 UnparentAndReset(child);
3222 DALI_TEST_CHECK(!child);
3226 int UtcDaliActorGetChildAt(void)
3228 TestApplication application;
3229 tet_infoline(" UtcDaliActorGetChildAt");
3231 Actor parent = Actor::New();
3232 application.GetScene().Add(parent);
3234 Actor child0 = Actor::New();
3237 Actor child1 = Actor::New();
3240 Actor child2 = Actor::New();
3243 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3244 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3245 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3249 int UtcDaliActorSetGetOverlay(void)
3251 TestApplication application;
3252 tet_infoline(" UtcDaliActorSetGetOverlay");
3254 Actor parent = Actor::New();
3255 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3256 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3260 int UtcDaliActorCreateDestroy(void)
3262 Actor* actor = new Actor;
3263 DALI_TEST_CHECK(actor);
3270 struct PropertyStringIndex
3272 const char* const name;
3273 const Property::Index index;
3274 const Property::Type type;
3277 const PropertyStringIndex PROPERTY_TABLE[] =
3279 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3280 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3281 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3282 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3283 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3284 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3285 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3286 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3287 {"size", Actor::Property::SIZE, Property::VECTOR3},
3288 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3289 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3290 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3291 {"position", Actor::Property::POSITION, Property::VECTOR3},
3292 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3293 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3294 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3295 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3296 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3297 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3298 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3299 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3300 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3301 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3302 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3303 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3304 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3305 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3306 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3307 {"color", Actor::Property::COLOR, Property::VECTOR4},
3308 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3309 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3310 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3311 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3312 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3313 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3314 {"name", Actor::Property::NAME, Property::STRING},
3315 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3316 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3317 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3318 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3319 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3320 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3321 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3322 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3323 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3324 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3325 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3326 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3327 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3328 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3329 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3330 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3331 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3332 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3334 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3335 } // unnamed namespace
3337 int UtcDaliActorProperties(void)
3339 TestApplication application;
3341 Actor actor = Actor::New();
3343 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3345 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3346 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3347 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3348 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3353 int UtcDaliRelayoutProperties_ResizePolicies(void)
3355 TestApplication application;
3357 Actor actor = Actor::New();
3360 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3361 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3363 // Set resize policy for all dimensions
3364 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3365 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3367 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3370 // Set individual dimensions
3371 const char* const widthPolicy = "FILL_TO_PARENT";
3372 const char* const heightPolicy = "FIXED";
3374 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3375 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3377 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3378 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3380 // Set individual dimensions using enums
3381 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3382 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3384 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3385 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3387 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3388 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3393 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3395 TestApplication application;
3397 Actor actor = Actor::New();
3400 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3402 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3403 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3404 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3407 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3408 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3410 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3411 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3413 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3414 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3419 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3421 TestApplication application;
3423 Actor actor = Actor::New();
3426 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3427 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3429 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3430 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3431 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3434 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3436 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3437 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3442 int UtcDaliRelayoutProperties_DimensionDependency(void)
3444 TestApplication application;
3446 Actor actor = Actor::New();
3449 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3450 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3453 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3454 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3456 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3457 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3459 // Test setting another resize policy
3460 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3461 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3466 int UtcDaliRelayoutProperties_Padding(void)
3468 TestApplication application;
3470 Actor actor = Actor::New();
3473 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3476 actor.SetProperty(Actor::Property::PADDING, padding);
3477 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3479 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3484 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3486 TestApplication application;
3488 Actor actor = Actor::New();
3491 Vector2 minSize(1.0f, 2.0f);
3493 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3494 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3496 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3498 Vector2 maxSize(3.0f, 4.0f);
3500 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3501 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3503 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3508 int UtcDaliActorGetHeightForWidth(void)
3510 TestApplication application;
3512 Actor actor = Actor::New();
3514 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3519 int UtcDaliActorGetWidthForHeight(void)
3521 TestApplication application;
3523 Actor actor = Actor::New();
3525 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3530 int UtcDaliActorGetRelayoutSize(void)
3532 TestApplication application;
3534 Actor actor = Actor::New();
3536 // Add actor to stage
3537 application.GetScene().Add(actor);
3539 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3541 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3542 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3544 // Flush the queue and render once
3545 application.SendNotification();
3546 application.Render();
3548 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3553 int UtcDaliActorSetPadding(void)
3555 TestApplication application;
3557 Actor actor = Actor::New();
3560 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3562 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3563 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3564 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3565 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3567 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3568 actor.SetProperty(Actor::Property::PADDING, padding2);
3570 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3572 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3573 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3574 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3575 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3580 int UtcDaliActorSetMinimumSize(void)
3582 TestApplication application;
3584 Actor actor = Actor::New();
3586 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3588 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3589 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3591 Vector2 size2(1.0f, 2.0f);
3592 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3594 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3596 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3597 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3602 int UtcDaliActorSetMaximumSize(void)
3604 TestApplication application;
3606 Actor actor = Actor::New();
3608 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3610 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3611 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3613 Vector2 size2(1.0f, 2.0f);
3614 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3616 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3618 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3619 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3624 int UtcDaliActorOnRelayoutSignal(void)
3626 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3628 TestApplication application;
3631 gOnRelayoutCallBackCalled = false;
3632 gActorNamesRelayout.clear();
3634 Actor actor = Actor::New();
3635 actor.SetProperty(Actor::Property::NAME, "actor");
3636 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3639 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3641 // Add actor to stage
3642 application.GetScene().Add(actor);
3644 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3645 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3647 // Flush the queue and render once
3648 application.SendNotification();
3649 application.Render();
3651 // OnRelayout emitted
3652 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3653 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3658 int UtcDaliActorGetHierachyDepth(void)
3660 TestApplication application;
3661 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3663 /* Build tree of actors:
3673 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3675 Integration::Scene stage(application.GetScene());
3677 Actor actorA = Actor::New();
3678 Actor actorB = Actor::New();
3679 Actor actorC = Actor::New();
3680 Actor actorD = Actor::New();
3681 Actor actorE = Actor::New();
3682 Actor actorF = Actor::New();
3684 //Test that root actor has depth equal 0
3685 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3687 //Test actors return depth -1 when not connected to the tree
3688 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3689 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3690 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3691 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3692 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3693 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3695 //Create the hierarchy
3703 //Test actors return correct depth
3704 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3705 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3706 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3707 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3708 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3709 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3711 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3712 actorA.Remove(actorB);
3714 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3715 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3716 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3718 //Removing actorA from the stage. All actors should have depth equal -1
3719 stage.Remove(actorA);
3721 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3722 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3723 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3724 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3725 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3726 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3731 int UtcDaliActorAnchorPointPropertyAsString(void)
3733 TestApplication application;
3735 Actor actor = Actor::New();
3737 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3738 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3740 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3741 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3743 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3744 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3746 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3747 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3749 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3750 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3752 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3753 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3755 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3756 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3758 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3759 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3761 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3762 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3764 // Invalid should not change anything
3765 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3766 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3771 int UtcDaliActorParentOriginPropertyAsString(void)
3773 TestApplication application;
3775 Actor actor = Actor::New();
3777 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3778 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3780 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3781 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3783 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3784 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3786 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3787 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3789 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3790 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3792 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3793 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3795 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3796 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3798 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3799 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3801 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3802 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3804 // Invalid should not change anything
3805 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3806 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3811 int UtcDaliActorColorModePropertyAsString(void)
3813 TestApplication application;
3815 Actor actor = Actor::New();
3817 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3818 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3820 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3821 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3823 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3824 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3826 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3827 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3829 // Invalid should not change anything
3830 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3831 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3836 int UtcDaliActorDrawModePropertyAsString(void)
3838 TestApplication application;
3840 Actor actor = Actor::New();
3842 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3843 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3845 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3846 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3848 // Invalid should not change anything
3849 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3850 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3855 int UtcDaliActorColorModePropertyAsEnum(void)
3857 TestApplication application;
3859 Actor actor = Actor::New();
3861 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3862 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3864 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3865 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3867 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3868 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3870 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3871 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3876 int UtcDaliActorDrawModePropertyAsEnum(void)
3878 TestApplication application;
3880 Actor actor = Actor::New();
3882 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3883 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3885 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3886 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3891 int UtcDaliActorAddRendererP(void)
3893 tet_infoline("Testing Actor::AddRenderer");
3894 TestApplication application;
3896 Actor actor = Actor::New();
3898 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3900 Geometry geometry = CreateQuadGeometry();
3901 Shader shader = CreateShader();
3902 Renderer renderer = Renderer::New(geometry, shader);
3904 actor.AddRenderer(renderer);
3905 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3906 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
3911 int UtcDaliActorAddRendererN01(void)
3913 tet_infoline("Testing Actor::AddRenderer");
3914 TestApplication application;
3916 Actor actor = Actor::New();
3922 actor.AddRenderer(renderer);
3923 tet_printf("Assertion test failed - no Exception\n");
3924 tet_result(TET_FAIL);
3926 catch(Dali::DaliException& e)
3928 DALI_TEST_PRINT_ASSERT(e);
3929 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3930 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3934 tet_printf("Assertion test failed - wrong Exception\n");
3935 tet_result(TET_FAIL);
3941 int UtcDaliActorAddRendererN02(void)
3943 tet_infoline("UtcDaliActorAddRendererN02");
3949 TestApplication application;
3951 Geometry geometry = CreateQuadGeometry();
3952 Shader shader = CreateShader();
3953 renderer = Renderer::New(geometry, shader);
3955 actor = Actor::New();
3958 // try illegal AddRenderer
3961 actor.AddRenderer(renderer);
3962 tet_printf("Assertion test failed - no Exception\n");
3963 tet_result(TET_FAIL);
3965 catch(Dali::DaliException& e)
3967 DALI_TEST_PRINT_ASSERT(e);
3968 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
3972 tet_printf("Assertion test failed - wrong Exception\n");
3973 tet_result(TET_FAIL);
3979 int UtcDaliActorAddRendererOnScene(void)
3981 tet_infoline("Testing Actor::AddRenderer");
3982 TestApplication application;
3984 Actor actor = Actor::New();
3985 application.GetScene().Add(actor);
3987 application.SendNotification();
3988 application.Render(0);
3990 Geometry geometry = CreateQuadGeometry();
3991 Shader shader = CreateShader();
3992 Renderer renderer = Renderer::New(geometry, shader);
3994 application.SendNotification();
3995 application.Render(0);
3999 actor.AddRenderer(renderer);
4000 tet_result(TET_PASS);
4004 tet_result(TET_FAIL);
4010 int UtcDaliActorRemoveRendererP1(void)
4012 tet_infoline("Testing Actor::RemoveRenderer");
4013 TestApplication application;
4015 Actor actor = Actor::New();
4017 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4020 Geometry geometry = CreateQuadGeometry();
4021 Shader shader = CreateShader();
4022 Renderer renderer = Renderer::New(geometry, shader);
4024 actor.AddRenderer(renderer);
4025 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4026 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4028 application.SendNotification();
4029 application.Render();
4033 Renderer renderer = actor.GetRendererAt(0);
4034 actor.RemoveRenderer(renderer);
4035 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4037 application.SendNotification();
4038 application.Render();
4041 // Call one final time to ensure that the renderer is actually removed after
4042 // the handle goes out of scope, and excercises the deletion code path in
4043 // scene graph and render.
4044 application.SendNotification();
4045 application.Render();
4050 int UtcDaliActorRemoveRendererP2(void)
4052 tet_infoline("Testing Actor::RemoveRenderer");
4053 TestApplication application;
4055 Actor actor = Actor::New();
4057 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4059 Geometry geometry = CreateQuadGeometry();
4060 Shader shader = CreateShader();
4061 Renderer renderer = Renderer::New(geometry, shader);
4063 actor.AddRenderer(renderer);
4064 application.SendNotification();
4065 application.Render();
4067 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4068 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4070 actor.RemoveRenderer(0);
4071 application.SendNotification();
4072 application.Render();
4074 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4076 // Shut down whilst holding onto the renderer handle.
4080 int UtcDaliActorRemoveRendererN(void)
4082 tet_infoline("Testing Actor::RemoveRenderer");
4083 TestApplication application;
4085 Actor actor = Actor::New();
4087 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4089 Geometry geometry = CreateQuadGeometry();
4090 Shader shader = CreateShader();
4091 Renderer renderer = Renderer::New(geometry, shader);
4093 actor.AddRenderer(renderer);
4094 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4095 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4097 actor.RemoveRenderer(10);
4098 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4099 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4104 // Clipping test helper functions:
4105 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4107 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4108 Actor actor = CreateRenderableActor(image);
4110 // Setup dimensions and position so actor is not skipped by culling.
4111 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4112 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4113 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4114 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4119 Actor CreateActorWithContent16x16()
4121 return CreateActorWithContent(16, 16);
4124 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4126 enabledDisableTrace.Reset();
4127 stencilTrace.Reset();
4128 enabledDisableTrace.Enable(true);
4129 stencilTrace.Enable(true);
4131 application.SendNotification();
4132 application.Render();
4134 enabledDisableTrace.Enable(false);
4135 stencilTrace.Enable(false);
4138 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4140 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4142 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4143 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4144 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4145 DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4148 int UtcDaliActorPropertyClippingP(void)
4150 // This test checks the clippingMode property.
4151 tet_infoline("Testing Actor::Property::ClippingMode: P");
4152 TestApplication application;
4154 Actor actor = Actor::New();
4156 // Check default clippingEnabled value.
4157 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4160 bool getValueResult = getValue.Get(value);
4161 DALI_TEST_CHECK(getValueResult);
4165 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4168 // Check setting the property to the stencil mode.
4169 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4171 // Check the new value was set.
4172 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4173 getValueResult = getValue.Get(value);
4174 DALI_TEST_CHECK(getValueResult);
4178 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4181 // Check setting the property to the scissor mode.
4182 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4184 // Check the new value was set.
4185 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4186 getValueResult = getValue.Get(value);
4187 DALI_TEST_CHECK(getValueResult);
4191 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4196 int UtcDaliActorPropertyClippingN(void)
4198 // Negative test case for Clipping.
4199 tet_infoline("Testing Actor::Property::ClippingMode: N");
4200 TestApplication application;
4202 Actor actor = Actor::New();
4204 // Check default clippingEnabled value.
4205 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4208 bool getValueResult = getValue.Get(value);
4209 DALI_TEST_CHECK(getValueResult);
4213 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4216 // Check setting an invalid property value won't change the current property value.
4217 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4219 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4220 getValueResult = getValue.Get(value);
4221 DALI_TEST_CHECK(getValueResult);
4225 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4231 int UtcDaliActorPropertyClippingActor(void)
4233 // This test checks that an actor is correctly setup for clipping.
4234 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4235 TestApplication application;
4237 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4238 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4239 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4240 size_t startIndex = 0u;
4242 // Create a clipping actor.
4243 Actor actorDepth1Clip = CreateActorWithContent16x16();
4244 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4245 application.GetScene().Add(actorDepth1Clip);
4247 // Gather the call trace.
4248 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4250 // Check we are writing to the color buffer.
4251 CheckColorMask(glAbstraction, true);
4253 // Check the stencil buffer was enabled.
4254 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4256 // Check the stencil buffer was cleared.
4257 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4259 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4260 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4261 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4262 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4267 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4269 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4270 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4271 TestApplication application;
4273 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4274 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4275 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4276 size_t startIndex = 0u;
4278 // Create a clipping actor.
4279 Actor actorDepth1Clip = CreateActorWithContent16x16();
4280 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4281 application.GetScene().Add(actorDepth1Clip);
4283 // Gather the call trace.
4284 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4286 // Check we are writing to the color buffer.
4287 CheckColorMask(glAbstraction, true);
4289 // Check the stencil buffer was enabled.
4290 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4292 // Check the stencil buffer was cleared.
4293 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4295 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4296 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4297 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4298 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4300 // Now disable the clipping
4301 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4303 // Gather the call trace.
4304 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4306 // Check the stencil buffer was disabled.
4307 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", "2960")); // 2960 is GL_STENCIL_TEST
4309 // Ensure all values in stencil-mask are set to 1.
4311 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4316 int UtcDaliActorPropertyClippingNestedChildren(void)
4318 // This test checks that a hierarchy of actors are clipped correctly by
4319 // writing to and reading from the correct bit-planes of the stencil buffer.
4320 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4321 TestApplication application;
4322 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4323 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4324 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4326 // Create a clipping actor.
4327 Actor actorDepth1Clip = CreateActorWithContent16x16();
4328 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4329 application.GetScene().Add(actorDepth1Clip);
4331 // Create a child actor.
4332 Actor childDepth2 = CreateActorWithContent16x16();
4333 actorDepth1Clip.Add(childDepth2);
4335 // Create another clipping actor.
4336 Actor childDepth2Clip = CreateActorWithContent16x16();
4337 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4338 childDepth2.Add(childDepth2Clip);
4340 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4341 // This tests the sort algorithm.
4342 Actor childDepth3 = CreateActorWithContent16x16();
4343 childDepth2Clip.Add(childDepth3);
4344 Actor childDepth4 = CreateActorWithContent16x16();
4345 childDepth3.Add(childDepth4);
4347 // Gather the call trace.
4348 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4350 // Check we are writing to the color buffer.
4351 CheckColorMask(glAbstraction, true);
4353 // Check the stencil buffer was enabled.
4354 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4356 // Perform the test twice, once for 2D layer, and once for 3D.
4357 for(unsigned int i = 0u; i < 2u; ++i)
4359 size_t startIndex = 0u;
4361 // Check the stencil buffer was cleared.
4362 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4364 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4365 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4366 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4367 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4369 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4370 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 255", startIndex)); // 514 is GL_EQUAL
4371 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4373 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4374 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4375 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4376 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4378 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4379 // (Both must be set to pass the check).
4380 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 255", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4381 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4383 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4386 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4387 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4394 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4396 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4397 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4398 TestApplication application;
4399 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4400 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4402 /* We create a small tree of actors as follows:
4406 Clipping enabled -> B D
4410 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4413 for(int i = 0; i < 5; ++i)
4415 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4416 Actor actor = CreateRenderableActor(image);
4418 // Setup dimensions and position so actor is not skipped by culling.
4419 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4420 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4424 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4428 float b = i > 2 ? 1.0f : -1.0f;
4429 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4435 // Enable clipping on the actor at the top of the left branch.
4436 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4438 // Build the scene graph.
4439 application.GetScene().Add(actors[0]);
4442 actors[0].Add(actors[1]);
4443 actors[1].Add(actors[2]);
4446 actors[0].Add(actors[3]);
4447 actors[3].Add(actors[4]);
4449 // Gather the call trace.
4450 enabledDisableTrace.Reset();
4451 enabledDisableTrace.Enable(true);
4452 application.SendNotification();
4453 application.Render();
4454 enabledDisableTrace.Enable(false);
4456 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4458 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
4459 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4461 size_t startIndex = 0u;
4462 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "3042", startIndex));
4463 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); // 2960 is GL_STENCIL_TEST
4464 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
4466 // Swap the clipping actor from top of left branch to top of right branch.
4467 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4468 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4470 // Gather the call trace.
4471 enabledDisableTrace.Reset();
4472 enabledDisableTrace.Enable(true);
4473 application.SendNotification();
4474 application.Render();
4475 enabledDisableTrace.Enable(false);
4477 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4478 // This proves the draw order has remained the same.
4480 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex));
4481 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
4486 int UtcDaliActorPropertyScissorClippingActor(void)
4488 // This test checks that an actor is correctly setup for clipping.
4489 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4490 TestApplication application;
4492 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4493 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4494 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4496 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4497 const Vector2 imageSize(16.0f, 16.0f);
4499 // Create a clipping actor.
4500 Actor clippingActorA = CreateActorWithContent16x16();
4501 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4502 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4503 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4504 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4505 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4506 application.GetScene().Add(clippingActorA);
4508 // Gather the call trace.
4509 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4511 // Check we are writing to the color buffer.
4512 CheckColorMask(glAbstraction, true);
4514 // Check scissor test was enabled.
4515 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4517 // Check the scissor was set, and the coordinates are correct.
4518 std::stringstream compareParametersString;
4519 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4520 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4522 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4523 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4525 // Gather the call trace.
4526 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4528 // Check the scissor was set, and the coordinates are correct.
4529 compareParametersString.str(std::string());
4530 compareParametersString.clear();
4531 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4532 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4537 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4539 // This test checks that an actor is correctly setup for clipping.
4540 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4541 TestApplication application;
4543 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4544 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4545 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4547 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4548 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4549 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4551 // Create a clipping actors.
4552 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4553 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4555 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4556 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4557 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4559 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4560 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4561 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4563 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4564 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4566 application.GetScene().Add(clippingActorA);
4567 application.GetScene().Add(clippingActorB);
4569 // Gather the call trace.
4570 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4572 // Check we are writing to the color buffer.
4573 CheckColorMask(glAbstraction, true);
4575 // Check scissor test was enabled.
4576 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4578 // Check the scissor was set, and the coordinates are correct.
4579 std::stringstream compareParametersString;
4581 std::string clipA("0, 500, 480, 200");
4582 std::string clipB("0, 380, 480, 40");
4584 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4585 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4590 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4592 // This test checks that an actor is correctly setup for clipping.
4593 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4594 TestApplication application;
4596 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4597 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4598 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4600 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4601 const Vector2 imageSize(16.0f, 16.0f);
4603 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4605 A is drawn first - with scissor clipping on
4606 B is drawn second - also with scissor clipping on
4607 C is the generated clipping region, the intersection ( A ∩ B )
4611 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4612 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4613 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4617 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4620 // Create a clipping actor.
4621 Actor clippingActorA = CreateActorWithContent16x16();
4622 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4623 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4624 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4625 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4626 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4627 application.GetScene().Add(clippingActorA);
4629 // Create a child clipping actor.
4630 Actor clippingActorB = CreateActorWithContent16x16();
4631 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4632 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4633 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4634 clippingActorA.Add(clippingActorB);
4636 // positionModifiers is an array of positions to position B around.
4637 // expect is an array of expected scissor clip coordinate results.
4638 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4639 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4641 // Loop through each overlap combination.
4642 for(unsigned int test = 0u; test < 4u; ++test)
4644 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4645 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4646 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4648 // Gather the call trace.
4649 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4651 // Check we are writing to the color buffer.
4652 CheckColorMask(glAbstraction, true);
4654 // Check scissor test was enabled.
4655 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4657 // Check the scissor was set, and the coordinates are correct.
4658 const Vector4& expectResults(expect[test]);
4659 std::stringstream compareParametersString;
4660 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4661 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4667 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4669 // This test checks that an actor is correctly setup for clipping.
4670 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4671 TestApplication application;
4673 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4674 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4675 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4677 /* Create a nest of 2 scissors and siblings of the parent.
4687 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4688 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4689 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4690 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4691 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4692 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4694 // Create a clipping actors.
4695 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4696 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4697 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4698 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4699 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4701 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4702 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4703 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4705 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4706 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4707 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4709 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4710 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4711 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4713 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4714 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4715 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4717 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4718 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4720 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4721 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4722 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4723 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4724 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4726 application.GetScene().Add(clippingActorA);
4727 clippingActorA.Add(clippingActorB);
4728 application.GetScene().Add(clippingActorC);
4729 application.GetScene().Add(clippingActorD);
4730 clippingActorD.Add(clippingActorE);
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 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4741 // Check the scissor was set, and the coordinates are correct.
4742 std::string clipA("0, 500, 480, 200");
4743 std::string clipB("0, 580, 480, 40");
4744 std::string clipC("0, 200, 480, 200");
4745 std::string clipD("0, 300, 480, 200");
4747 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4748 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4749 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4750 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4751 DALI_TEST_CHECK(scissorTrace.CountMethod("Scissor") == 4); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4756 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4758 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4759 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4760 TestApplication application;
4762 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4763 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4764 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4766 // Create a clipping actor.
4767 Actor actorDepth1Clip = CreateActorWithContent16x16();
4768 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4769 application.GetScene().Add(actorDepth1Clip);
4771 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4772 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4774 // Gather the call trace.
4775 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4777 // Check we are writing to the color buffer.
4778 CheckColorMask(glAbstraction, true);
4780 // Check the stencil buffer was not enabled.
4781 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
4783 // Check stencil functions are not called.
4784 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4785 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask"));
4786 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4788 // Check that scissor clipping is overriden by the renderer properties.
4789 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4791 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4793 // Gather the call trace.
4794 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4796 // Check the stencil buffer was not enabled.
4797 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
4799 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4804 int UtcDaliGetPropertyN(void)
4806 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
4807 TestApplication application;
4809 Actor actor = Actor::New();
4811 unsigned int propertyCount = actor.GetPropertyCount();
4812 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
4816 int UtcDaliActorRaiseLower(void)
4818 tet_infoline("UtcDaliActor Raise and Lower test\n");
4820 TestApplication application;
4822 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
4824 Integration::Scene stage(application.GetScene());
4826 Actor actorA = Actor::New();
4827 Actor actorB = Actor::New();
4828 Actor actorC = Actor::New();
4830 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4831 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4833 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4834 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4836 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4837 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4839 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4840 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4842 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4843 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4845 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4846 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4852 ResetTouchCallbacks();
4854 application.SendNotification();
4855 application.Render();
4857 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4858 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4859 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4861 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4862 // Only top actor will get touched.
4863 actorA.TouchedSignal().Connect(TestTouchCallback);
4864 actorB.TouchedSignal().Connect(TestTouchCallback2);
4865 actorC.TouchedSignal().Connect(TestTouchCallback3);
4867 // Connect ChildOrderChangedSignal
4868 bool orderChangedSignal(false);
4869 Actor orderChangedActor;
4870 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
4871 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
4873 Dali::Integration::Point point;
4874 point.SetDeviceId(1);
4875 point.SetState(PointState::DOWN);
4876 point.SetScreenPosition(Vector2(10.f, 10.f));
4877 Dali::Integration::TouchEvent touchEvent;
4878 touchEvent.AddPoint(point);
4880 application.ProcessEvent(touchEvent);
4882 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4883 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4884 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4886 ResetTouchCallbacks();
4888 tet_printf("Testing Raising of Actor\n");
4890 int preActorOrder(0);
4891 int postActorOrder(0);
4893 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4894 value.Get(preActorOrder);
4896 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4898 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4899 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4901 // Ensure sort order is calculated before next touch event
4902 application.SendNotification();
4904 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4905 value.Get(postActorOrder);
4907 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4909 application.ProcessEvent(touchEvent);
4911 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4912 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
4913 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4915 ResetTouchCallbacks();
4917 tet_printf("Testing Lowering of Actor\n");
4919 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4920 value.Get(preActorOrder);
4922 orderChangedSignal = false;
4924 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4926 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4927 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4929 application.SendNotification(); // ensure sort order calculated before next touch event
4931 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4932 value.Get(postActorOrder);
4934 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4936 application.ProcessEvent(touchEvent);
4938 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4939 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4940 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4942 ResetTouchCallbacks();
4944 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
4949 int UtcDaliActorRaiseToTopLowerToBottom(void)
4951 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
4953 TestApplication application;
4955 Integration::Scene stage(application.GetScene());
4957 Actor actorA = Actor::New();
4958 Actor actorB = Actor::New();
4959 Actor actorC = Actor::New();
4961 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
4962 // enables checking of which actor the uniform is assigned too
4963 Shader shaderA = CreateShader();
4964 shaderA.RegisterProperty("uRendererColor", 1.f);
4966 Shader shaderB = CreateShader();
4967 shaderB.RegisterProperty("uRendererColor", 2.f);
4969 Shader shaderC = CreateShader();
4970 shaderC.RegisterProperty("uRendererColor", 3.f);
4972 Geometry geometry = CreateQuadGeometry();
4974 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
4975 Renderer rendererA = Renderer::New(geometry, shaderA);
4976 actorA.AddRenderer(rendererA);
4978 Renderer rendererB = Renderer::New(geometry, shaderB);
4979 actorB.AddRenderer(rendererB);
4981 Renderer rendererC = Renderer::New(geometry, shaderC);
4982 actorC.AddRenderer(rendererC);
4984 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4985 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4987 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4988 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4990 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4991 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4993 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4994 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4996 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4997 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4999 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5000 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5006 ResetTouchCallbacks();
5008 // Connect ChildOrderChangedSignal
5009 bool orderChangedSignal(false);
5010 Actor orderChangedActor;
5011 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5012 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5014 // Set up gl abstraction trace so can query the set uniform order
5015 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5016 glAbstraction.EnableSetUniformCallTrace(true);
5017 glAbstraction.ResetSetUniformCallStack();
5019 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5021 application.SendNotification();
5022 application.Render();
5024 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5026 // Test order of uniforms in stack
5027 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5028 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5029 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5031 bool CBA = (indexC > indexB) && (indexB > indexA);
5033 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5035 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5036 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5037 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5039 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5040 // Only top actor will get touched.
5041 actorA.TouchedSignal().Connect(TestTouchCallback);
5042 actorB.TouchedSignal().Connect(TestTouchCallback2);
5043 actorC.TouchedSignal().Connect(TestTouchCallback3);
5045 Dali::Integration::Point point;
5046 point.SetDeviceId(1);
5047 point.SetState(PointState::DOWN);
5048 point.SetScreenPosition(Vector2(10.f, 10.f));
5049 Dali::Integration::TouchEvent touchEvent;
5050 touchEvent.AddPoint(point);
5052 application.ProcessEvent(touchEvent);
5054 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5055 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5056 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5058 ResetTouchCallbacks();
5060 tet_printf("RaiseToTop ActorA\n");
5062 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5063 actorA.RaiseToTop();
5064 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5065 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5067 application.SendNotification(); // ensure sorting order is calculated before next touch event
5069 application.ProcessEvent(touchEvent);
5071 glAbstraction.ResetSetUniformCallStack();
5072 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5074 application.SendNotification();
5075 application.Render();
5077 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5079 // Test order of uniforms in stack
5080 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5081 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5082 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5084 tet_infoline("Testing A above C and B at bottom\n");
5085 bool ACB = (indexA > indexC) && (indexC > indexB);
5087 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5089 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5090 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5091 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5093 ResetTouchCallbacks();
5095 tet_printf("RaiseToTop ActorB\n");
5097 orderChangedSignal = false;
5099 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5100 actorB.RaiseToTop();
5101 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5102 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5104 application.SendNotification(); // Ensure sort order is calculated before next touch event
5106 application.ProcessEvent(touchEvent);
5108 glAbstraction.ResetSetUniformCallStack();
5109 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5111 application.SendNotification();
5112 application.Render();
5114 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5116 // Test order of uniforms in stack
5117 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5118 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5119 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5121 tet_infoline("Testing B above A and C at bottom\n");
5122 bool BAC = (indexB > indexA) && (indexA > indexC);
5124 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5126 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5127 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5128 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5130 ResetTouchCallbacks();
5132 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5134 orderChangedSignal = false;
5136 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5137 actorA.LowerToBottom();
5138 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5139 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5141 application.SendNotification();
5142 application.Render();
5144 orderChangedSignal = false;
5146 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5147 actorB.LowerToBottom();
5148 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5149 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5151 application.SendNotification();
5152 application.Render();
5154 application.ProcessEvent(touchEvent);
5156 glAbstraction.ResetSetUniformCallStack();
5157 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5159 application.SendNotification();
5160 application.Render();
5162 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5164 // Test order of uniforms in stack
5165 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5166 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5167 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5169 tet_infoline("Testing C above A and B at bottom\n");
5170 bool CAB = (indexC > indexA) && (indexA > indexB);
5172 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5174 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5175 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5176 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5178 ResetTouchCallbacks();
5183 int UtcDaliActorRaiseAbove(void)
5185 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5187 TestApplication application;
5189 Integration::Scene stage(application.GetScene());
5191 Actor actorA = Actor::New();
5192 Actor actorB = Actor::New();
5193 Actor actorC = Actor::New();
5195 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5196 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5198 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5199 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5201 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5202 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5204 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5205 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5207 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5208 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5210 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5211 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5217 ResetTouchCallbacks();
5219 application.SendNotification();
5220 application.Render();
5222 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5223 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5224 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5226 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5227 // Only top actor will get touched.
5228 actorA.TouchedSignal().Connect(TestTouchCallback);
5229 actorB.TouchedSignal().Connect(TestTouchCallback2);
5230 actorC.TouchedSignal().Connect(TestTouchCallback3);
5232 bool orderChangedSignal(false);
5233 Actor orderChangedActor;
5234 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5235 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5237 Dali::Integration::Point point;
5238 point.SetDeviceId(1);
5239 point.SetState(PointState::DOWN);
5240 point.SetScreenPosition(Vector2(10.f, 10.f));
5241 Dali::Integration::TouchEvent touchEvent;
5242 touchEvent.AddPoint(point);
5244 application.ProcessEvent(touchEvent);
5246 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5247 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5248 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5250 ResetTouchCallbacks();
5252 tet_printf("Raise actor B Above Actor C\n");
5254 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5255 actorB.RaiseAbove(actorC);
5256 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5257 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5259 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5260 application.SendNotification();
5261 application.ProcessEvent(touchEvent);
5263 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5264 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5265 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5267 ResetTouchCallbacks();
5269 tet_printf("Raise actor A Above Actor B\n");
5271 orderChangedSignal = false;
5273 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5274 actorA.RaiseAbove(actorB);
5275 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5276 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5278 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5279 application.SendNotification();
5281 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5283 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5284 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5285 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5287 ResetTouchCallbacks();
5292 int UtcDaliActorLowerBelow(void)
5294 tet_infoline("UtcDaliActor LowerBelow test \n");
5296 TestApplication application;
5298 Integration::Scene stage(application.GetScene());
5300 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5301 // enables checking of which actor the uniform is assigned too
5302 Shader shaderA = CreateShader();
5303 shaderA.RegisterProperty("uRendererColor", 1.f);
5305 Shader shaderB = CreateShader();
5306 shaderB.RegisterProperty("uRendererColor", 2.f);
5308 Shader shaderC = CreateShader();
5309 shaderC.RegisterProperty("uRendererColor", 3.f);
5311 Actor actorA = Actor::New();
5312 Actor actorB = Actor::New();
5313 Actor actorC = Actor::New();
5315 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5316 Geometry geometry = CreateQuadGeometry();
5318 Renderer rendererA = Renderer::New(geometry, shaderA);
5319 actorA.AddRenderer(rendererA);
5321 Renderer rendererB = Renderer::New(geometry, shaderB);
5322 actorB.AddRenderer(rendererB);
5324 Renderer rendererC = Renderer::New(geometry, shaderC);
5325 actorC.AddRenderer(rendererC);
5327 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5328 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5330 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5331 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5333 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5334 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5336 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5337 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5339 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5340 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5342 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5343 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5345 Actor container = Actor::New();
5346 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5347 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5348 stage.Add(container);
5350 container.Add(actorA);
5351 container.Add(actorB);
5352 container.Add(actorC);
5354 ResetTouchCallbacks();
5356 // Connect ChildOrderChangedSignal
5357 bool orderChangedSignal(false);
5358 Actor orderChangedActor;
5359 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5360 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5362 // Set up gl abstraction trace so can query the set uniform order
5363 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5364 glAbstraction.EnableSetUniformCallTrace(true);
5365 glAbstraction.ResetSetUniformCallStack();
5366 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5368 glAbstraction.ResetSetUniformCallStack();
5370 application.SendNotification();
5371 application.Render();
5373 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5375 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5377 // Test order of uniforms in stack
5378 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5379 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5380 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5382 tet_infoline("Testing C above B and A at bottom\n");
5383 bool CBA = (indexC > indexB) && (indexB > indexA);
5385 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5387 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5388 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5389 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5391 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5392 // Only top actor will get touched.
5393 actorA.TouchedSignal().Connect(TestTouchCallback);
5394 actorB.TouchedSignal().Connect(TestTouchCallback2);
5395 actorC.TouchedSignal().Connect(TestTouchCallback3);
5397 Dali::Integration::Point point;
5398 point.SetDeviceId(1);
5399 point.SetState(PointState::DOWN);
5400 point.SetScreenPosition(Vector2(10.f, 10.f));
5401 Dali::Integration::TouchEvent touchEvent;
5402 touchEvent.AddPoint(point);
5404 tet_infoline("UtcDaliActor Test Set up completed \n");
5406 application.ProcessEvent(touchEvent);
5408 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5409 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5410 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5412 ResetTouchCallbacks();
5414 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");
5416 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5417 actorC.LowerBelow(actorB);
5418 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5419 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5421 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5422 application.SendNotification();
5423 application.Render();
5425 application.ProcessEvent(touchEvent); // touch event
5427 glAbstraction.ResetSetUniformCallStack();
5428 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5430 application.SendNotification();
5431 application.Render();
5433 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5435 // Test order of uniforms in stack
5436 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5437 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5438 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5440 tet_infoline("Testing render order is A, C, B");
5441 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5442 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5444 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5445 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5446 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5448 ResetTouchCallbacks();
5450 tet_printf("Lower actor C below Actor A leaving B on top\n");
5452 orderChangedSignal = false;
5454 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5455 actorC.LowerBelow(actorA);
5456 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5457 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5459 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5460 application.SendNotification();
5461 application.Render();
5463 application.ProcessEvent(touchEvent);
5465 glAbstraction.ResetSetUniformCallStack();
5466 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5468 application.Render();
5469 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5471 // Test order of uniforms in stack
5472 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5473 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5474 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5476 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5477 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5479 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5480 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5481 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5483 ResetTouchCallbacks();
5485 tet_printf("Lower actor B below Actor C leaving A on top\n");
5487 orderChangedSignal = false;
5489 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5490 actorB.LowerBelow(actorC);
5491 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5492 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5494 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5495 application.SendNotification();
5496 application.Render();
5498 application.ProcessEvent(touchEvent);
5500 glAbstraction.ResetSetUniformCallStack();
5501 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5503 application.Render();
5504 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5506 // Test order of uniforms in stack
5507 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5508 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5509 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5511 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5512 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5517 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5519 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
5521 TestApplication application;
5523 Integration::Scene stage(application.GetScene());
5525 Actor parentA = Actor::New();
5526 Actor parentB = Actor::New();
5527 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5528 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5529 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5530 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5532 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5533 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5535 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5536 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5541 Actor actorA = Actor::New();
5542 Actor actorB = Actor::New();
5543 Actor actorC = Actor::New();
5545 parentA.Add(actorA);
5546 parentA.Add(actorB);
5548 tet_printf("Actor C added to different parent from A and B \n");
5549 parentB.Add(actorC);
5551 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5552 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5554 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5555 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5557 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5558 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5560 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5561 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5563 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5564 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5566 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5567 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5569 ResetTouchCallbacks();
5571 // Connect ChildOrderChangedSignal
5572 bool orderChangedSignal(false);
5573 Actor orderChangedActor;
5574 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5575 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5577 application.SendNotification();
5578 application.Render();
5580 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5581 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5582 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5584 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5585 // Only top actor will get touched.
5586 actorA.TouchedSignal().Connect(TestTouchCallback);
5587 actorB.TouchedSignal().Connect(TestTouchCallback2);
5588 actorC.TouchedSignal().Connect(TestTouchCallback3);
5590 Dali::Integration::Point point;
5591 point.SetDeviceId(1);
5592 point.SetState(PointState::DOWN);
5593 point.SetScreenPosition(Vector2(10.f, 10.f));
5594 Dali::Integration::TouchEvent touchEvent;
5595 touchEvent.AddPoint(point);
5597 application.ProcessEvent(touchEvent);
5599 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5600 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5601 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5603 ResetTouchCallbacks();
5605 tet_printf("Raise actor A Above Actor C which have different parents\n");
5607 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5608 actorA.RaiseAbove(actorC);
5609 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5611 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5612 application.SendNotification();
5614 application.ProcessEvent(touchEvent); // touch event
5616 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5617 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5618 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5620 ResetTouchCallbacks();
5625 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5627 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
5629 TestApplication application;
5631 Integration::Scene stage(application.GetScene());
5633 Actor actorA = Actor::New();
5634 Actor actorB = Actor::New();
5635 Actor actorC = Actor::New();
5637 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5638 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5640 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5641 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5643 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5644 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5646 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5647 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5649 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5650 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5652 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5653 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5655 ResetTouchCallbacks();
5657 // Connect ChildOrderChangedSignal
5658 bool orderChangedSignal(false);
5659 Actor orderChangedActor;
5660 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5661 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5663 application.SendNotification();
5664 application.Render();
5666 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5667 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5668 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5670 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5671 // Only top actor will get touched.
5672 actorA.TouchedSignal().Connect(TestTouchCallback);
5673 actorB.TouchedSignal().Connect(TestTouchCallback2);
5674 actorC.TouchedSignal().Connect(TestTouchCallback3);
5676 Dali::Integration::Point point;
5677 point.SetDeviceId(1);
5678 point.SetState(PointState::DOWN);
5679 point.SetScreenPosition(Vector2(10.f, 10.f));
5680 Dali::Integration::TouchEvent touchEvent;
5681 touchEvent.AddPoint(point);
5683 tet_printf("Raise actor A Above Actor C which have no parents\n");
5685 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5686 actorA.RaiseAbove(actorC);
5687 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5689 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5690 application.SendNotification();
5692 application.ProcessEvent(touchEvent);
5694 tet_printf("Not parented so RaiseAbove should show no effect\n");
5696 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5697 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5698 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5700 ResetTouchCallbacks();
5702 orderChangedSignal = false;
5705 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
5707 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5708 actorA.LowerBelow(actorC);
5709 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5711 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5712 application.SendNotification();
5713 application.Render();
5715 application.ProcessEvent(touchEvent);
5717 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
5718 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5719 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5720 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5722 ResetTouchCallbacks();
5724 orderChangedSignal = false;
5726 tet_printf("Adding Actor A to stage, will be on top\n");
5729 application.SendNotification();
5730 application.Render();
5732 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
5734 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5735 actorB.RaiseAbove(actorC);
5736 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5738 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5739 application.SendNotification();
5741 application.ProcessEvent(touchEvent);
5743 tet_printf("C not parented so RaiseAbove should show no effect\n");
5744 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5745 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5746 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5748 ResetTouchCallbacks();
5750 orderChangedSignal = false;
5752 tet_printf("Lower actor A below Actor C when only A has a parent\n");
5754 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5755 actorA.LowerBelow(actorC);
5756 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5758 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5759 application.SendNotification();
5761 application.ProcessEvent(touchEvent);
5763 tet_printf("C not parented so LowerBelow should show no effect\n");
5764 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5765 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5766 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5768 ResetTouchCallbacks();
5770 orderChangedSignal = false;
5774 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5775 actorA.RaiseAbove(actorC);
5776 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5777 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5779 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5780 application.SendNotification();
5781 application.Render();
5783 application.ProcessEvent(touchEvent);
5785 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
5786 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5787 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5788 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5793 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
5795 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
5797 TestApplication application;
5799 Integration::Scene stage(application.GetScene());
5801 Actor actorA = Actor::New();
5802 Actor actorB = Actor::New();
5803 Actor actorC = Actor::New();
5805 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5806 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5808 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5809 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5811 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5812 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5814 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5815 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5817 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5818 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5820 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5821 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5823 ResetTouchCallbacks();
5825 // Connect ChildOrderChangedSignal
5826 bool orderChangedSignal(false);
5827 Actor orderChangedActor;
5828 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5829 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5831 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5832 // Only top actor will get touched.
5833 actorA.TouchedSignal().Connect(TestTouchCallback);
5834 actorB.TouchedSignal().Connect(TestTouchCallback2);
5835 actorC.TouchedSignal().Connect(TestTouchCallback3);
5837 Dali::Integration::Point point;
5838 point.SetDeviceId(1);
5839 point.SetState(PointState::DOWN);
5840 point.SetScreenPosition(Vector2(10.f, 10.f));
5841 Dali::Integration::TouchEvent touchEvent;
5842 touchEvent.AddPoint(point);
5845 tet_printf("Raise actor B Above Actor C but B not parented\n");
5847 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5849 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5851 application.SendNotification();
5852 application.Render();
5854 application.ProcessEvent(touchEvent);
5856 tet_printf("Not parented so RaiseAbove should show no effect\n");
5858 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5859 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5860 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5862 tet_printf("Raise actor B Above Actor C but B not parented\n");
5863 ResetTouchCallbacks();
5865 orderChangedSignal = false;
5867 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5869 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5871 // Sort actor tree before next touch event
5872 application.SendNotification();
5873 application.Render();
5875 application.ProcessEvent(touchEvent);
5877 tet_printf("Not parented so RaiseAbove should show no effect\n");
5879 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5880 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5881 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5882 ResetTouchCallbacks();
5884 orderChangedSignal = false;
5886 tet_printf("Lower actor C below B but C not parented\n");
5888 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5890 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5892 // Sort actor tree before next touch event
5893 application.SendNotification();
5894 application.Render();
5896 application.ProcessEvent(touchEvent);
5898 tet_printf("Not parented so Lower should show no effect\n");
5900 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5901 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5902 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5903 ResetTouchCallbacks();
5905 orderChangedSignal = false;
5907 tet_printf("Raise actor B to top\n");
5909 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5910 actorB.RaiseToTop();
5911 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5913 // Sort actor tree before next touch event
5914 application.SendNotification();
5915 application.Render();
5917 application.ProcessEvent(touchEvent);
5919 tet_printf("Not parented so RaiseToTop should show no effect\n");
5921 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5922 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5923 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5924 ResetTouchCallbacks();
5926 orderChangedSignal = false;
5928 tet_printf("Add ActorB to stage so only Actor C not parented\n");
5932 tet_printf("Lower actor C to Bottom, B stays at top\n");
5934 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5935 actorC.LowerToBottom();
5936 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5938 application.SendNotification();
5939 application.Render();
5941 application.ProcessEvent(touchEvent);
5943 tet_printf("Not parented so LowerToBottom should show no effect\n");
5945 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5946 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5947 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5948 ResetTouchCallbacks();
5953 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
5955 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
5957 TestApplication application;
5959 Integration::Scene stage(application.GetScene());
5961 Actor actorA = Actor::New();
5962 Actor actorB = Actor::New();
5963 Actor actorC = Actor::New();
5965 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5966 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5968 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5969 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5971 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5972 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5974 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5975 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5977 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5978 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5980 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5981 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5987 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5988 // Only top actor will get touched.
5989 actorA.TouchedSignal().Connect(TestTouchCallback);
5990 actorB.TouchedSignal().Connect(TestTouchCallback2);
5991 actorC.TouchedSignal().Connect(TestTouchCallback3);
5993 ResetTouchCallbacks();
5995 // Connect ChildOrderChangedSignal
5996 bool orderChangedSignal(false);
5997 Actor orderChangedActor;
5998 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5999 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6001 application.SendNotification();
6002 application.Render();
6004 Dali::Integration::Point point;
6005 point.SetDeviceId(1);
6006 point.SetState(PointState::DOWN);
6007 point.SetScreenPosition(Vector2(10.f, 10.f));
6008 Dali::Integration::TouchEvent touchEvent;
6009 touchEvent.AddPoint(point);
6011 application.ProcessEvent(touchEvent);
6013 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6014 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6015 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6017 ResetTouchCallbacks();
6019 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6021 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6022 actorA.RaiseAbove(actorA);
6023 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6024 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6026 application.SendNotification();
6027 application.Render();
6029 application.ProcessEvent(touchEvent);
6031 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6033 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6034 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6035 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6037 ResetTouchCallbacks();
6039 orderChangedSignal = false;
6041 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6042 actorA.RaiseAbove(actorC);
6043 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6044 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6046 application.SendNotification();
6047 application.Render();
6049 application.ProcessEvent(touchEvent);
6051 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6052 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6053 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6054 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6059 int UtcDaliActorGetScreenPosition(void)
6061 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6063 TestApplication application;
6065 Integration::Scene stage(application.GetScene());
6067 Actor actorA = Actor::New();
6068 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6070 Vector2 size2(10.0f, 20.0f);
6071 actorA.SetProperty(Actor::Property::SIZE, size2);
6073 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6075 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6079 application.SendNotification();
6080 application.Render();
6082 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6083 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6085 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6086 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6088 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6089 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6091 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6093 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6095 application.SendNotification();
6096 application.Render();
6098 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6099 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6101 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6102 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6104 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6105 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6107 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6109 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6111 application.SendNotification();
6112 application.Render();
6114 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6115 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6117 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6118 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6120 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6121 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6123 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6125 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6127 application.SendNotification();
6128 application.Render();
6130 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6131 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6133 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6134 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6136 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6137 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6139 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6141 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6143 application.SendNotification();
6144 application.Render();
6146 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6147 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6149 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6150 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6152 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6153 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6155 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6157 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6158 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6160 Actor actorB = Actor::New();
6161 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6162 actorB.SetProperty(Actor::Property::SIZE, size2);
6163 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6166 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6168 application.SendNotification();
6169 application.Render();
6171 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6173 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6174 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6179 int UtcDaliActorGetScreenPositionAfterScaling(void)
6181 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6183 TestApplication application;
6185 Integration::Scene stage(application.GetScene());
6187 Actor actorA = Actor::New();
6188 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6190 Vector2 size2(10.0f, 20.0f);
6191 actorA.SetProperty(Actor::Property::SIZE, size2);
6192 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6193 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6195 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6199 application.SendNotification();
6200 application.Render();
6202 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6203 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6205 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6206 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6208 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6209 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6211 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6213 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6215 application.SendNotification();
6216 application.Render();
6218 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6219 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6221 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6222 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6224 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6225 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6230 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6232 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6234 TestApplication application;
6236 Integration::Scene stage(application.GetScene());
6238 Actor actorA = Actor::New();
6239 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6240 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6241 Vector2 size2(10.0f, 20.0f);
6242 actorA.SetProperty(Actor::Property::SIZE, size2);
6243 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6245 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6249 application.SendNotification();
6250 application.Render();
6252 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6253 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6255 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6256 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6258 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6259 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6261 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6263 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6264 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6266 application.SendNotification();
6267 application.Render();
6269 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6270 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6272 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6273 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6275 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6276 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6282 int UtcDaliActorGetScreenPositionWithChildActors(void)
6284 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6286 TestApplication application;
6288 Integration::Scene stage(application.GetScene());
6290 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6292 Actor actorA = Actor::New();
6293 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6294 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6295 Vector2 size1(10.0f, 20.0f);
6296 actorA.SetProperty(Actor::Property::SIZE, size1);
6297 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6299 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6301 Actor parentActorA = Actor::New();
6302 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6303 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6304 Vector2 size2(30.0f, 60.0f);
6305 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6306 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6308 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6310 stage.Add(parentActorA);
6311 parentActorA.Add(actorA);
6313 application.SendNotification();
6314 application.Render();
6316 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6317 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6319 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6320 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6322 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6323 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6325 tet_infoline("Test 2\n");
6327 tet_infoline("change parent anchor point and parent origin then check screen position \n");
6329 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6330 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6332 application.SendNotification();
6333 application.Render();
6335 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6336 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6338 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6339 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6341 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6342 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6347 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6349 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6351 TestApplication application;
6353 Integration::Scene stage(application.GetScene());
6355 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6357 Actor actorA = Actor::New();
6358 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6359 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6360 Vector2 size1(10.0f, 20.0f);
6361 actorA.SetProperty(Actor::Property::SIZE, size1);
6362 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6364 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6366 Actor parentActorA = Actor::New();
6367 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6368 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6369 Vector2 size2(30.0f, 60.0f);
6370 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6371 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6373 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6375 Actor grandParentActorA = Actor::New();
6376 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6377 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6378 Vector2 size3(60.0f, 120.0f);
6379 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6380 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6382 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6384 stage.Add(grandParentActorA);
6385 grandParentActorA.Add(parentActorA);
6387 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6389 parentActorA.Add(actorA);
6391 application.SendNotification();
6392 application.Render();
6394 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6395 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6397 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6398 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6400 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6401 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6406 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6408 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6410 TestApplication application;
6412 Integration::Scene stage(application.GetScene());
6414 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6416 Actor actorA = Actor::New();
6417 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6418 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6419 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6420 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6423 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6425 Actor actorB = Actor::New();
6426 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6427 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6428 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6429 Vector2 actorBSize(30.0f, 60.0f);
6430 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6433 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6435 Actor actorC = Actor::New();
6436 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6437 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6438 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6439 Vector2 actorCSize(60.0f, 120.0f);
6440 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6443 application.SendNotification();
6444 application.Render();
6446 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
6448 Vector2 center(stage.GetSize() * 0.5f);
6450 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6451 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6452 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6454 tet_infoline("Add scale to all actors");
6456 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6457 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
6458 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
6460 application.SendNotification();
6461 application.Render();
6463 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
6464 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
6465 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
6470 int utcDaliActorPositionUsesAnchorPoint(void)
6472 TestApplication application;
6473 tet_infoline("Check default behaviour\n");
6475 Actor actor = Actor::New();
6476 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6477 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6478 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6479 application.GetScene().Add(actor);
6481 application.SendNotification();
6482 application.Render();
6484 tet_infoline("Check that the world position is in the center\n");
6485 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6487 tet_infoline("Set the position uses anchor point property to false\n");
6488 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6490 application.SendNotification();
6491 application.Render();
6493 tet_infoline("Check that the world position has changed appropriately\n");
6494 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6499 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6501 TestApplication application;
6502 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6504 Actor actor = Actor::New();
6505 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6506 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6507 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6508 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6509 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6510 application.GetScene().Add(actor);
6512 application.SendNotification();
6513 application.Render();
6515 tet_infoline("Check the world position is the same as it would be without a scale\n");
6516 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6518 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6519 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6520 application.SendNotification();
6521 application.Render();
6522 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
6524 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6525 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6526 application.SendNotification();
6527 application.Render();
6528 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6533 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6535 TestApplication application;
6536 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6538 Actor actor = Actor::New();
6539 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6540 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6541 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6542 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6543 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6544 application.GetScene().Add(actor);
6546 application.SendNotification();
6547 application.Render();
6549 tet_infoline("Check the world position is the same as it would be without a rotation\n");
6550 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6552 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6553 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6554 application.SendNotification();
6555 application.Render();
6556 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
6558 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6559 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6560 application.SendNotification();
6561 application.Render();
6562 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
6567 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6569 TestApplication application;
6570 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6572 Actor actor = Actor::New();
6573 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6574 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6575 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6576 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6577 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6578 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6579 application.GetScene().Add(actor);
6581 application.SendNotification();
6582 application.Render();
6584 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
6585 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6587 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6588 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6589 application.SendNotification();
6590 application.Render();
6591 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
6593 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6594 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6595 application.SendNotification();
6596 application.Render();
6597 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
6602 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6604 TestApplication application;
6605 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6607 Actor parent = Actor::New();
6609 application.GetScene().Add(parent);
6610 Vector2 stageSize(application.GetScene().GetSize());
6612 Actor actor = Actor::New();
6613 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6614 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6615 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6616 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
6617 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
6618 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6621 application.SendNotification();
6622 application.Render();
6624 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
6626 tet_infoline("Check the world position is in the right place\n");
6627 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6629 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
6630 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6631 application.SendNotification();
6632 application.Render();
6633 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6635 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
6636 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6637 application.SendNotification();
6638 application.Render();
6639 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6644 int utcDaliActorVisibilityChangeSignalSelf(void)
6646 TestApplication application;
6647 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
6649 Actor actor = Actor::New();
6651 VisibilityChangedFunctorData data;
6652 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
6654 actor.SetProperty(Actor::Property::VISIBLE, false);
6656 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6658 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
6661 actor.SetProperty(Actor::Property::VISIBLE, false);
6662 data.Check(false /* not called */, TEST_LOCATION);
6664 tet_infoline("Change the visibility using properties, ensure called");
6667 actor.SetProperty(Actor::Property::VISIBLE, true);
6668 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6670 tet_infoline("Set the visibility to current using properties, ensure not called");
6673 actor.SetProperty(Actor::Property::VISIBLE, true);
6674 data.Check(false /* not called */, TEST_LOCATION);
6679 int utcDaliActorVisibilityChangeSignalChildren(void)
6681 TestApplication application;
6682 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
6684 Actor parent = Actor::New();
6685 Actor child = Actor::New();
6688 Actor grandChild = Actor::New();
6689 child.Add(grandChild);
6691 VisibilityChangedFunctorData parentData;
6692 VisibilityChangedFunctorData childData;
6693 VisibilityChangedFunctorData grandChildData;
6695 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
6696 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
6697 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
6699 parent.SetProperty(Actor::Property::VISIBLE, false);
6700 parentData.Check(false /* not called */, TEST_LOCATION);
6701 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6702 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6704 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
6707 grandChildData.Reset();
6709 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
6711 parent.SetProperty(Actor::Property::VISIBLE, true);
6712 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6713 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6714 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
6716 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
6719 grandChildData.Reset();
6721 parent.SetProperty(Actor::Property::VISIBLE, true);
6722 parentData.Check(false /* not called */, TEST_LOCATION);
6723 childData.Check(false /* not called */, TEST_LOCATION);
6724 grandChildData.Check(false /* not called */, TEST_LOCATION);
6729 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
6731 TestApplication application;
6732 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
6734 Actor actor = Actor::New();
6735 application.GetScene().Add(actor);
6737 application.SendNotification();
6738 application.Render();
6740 VisibilityChangedFunctorData data;
6741 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
6743 Animation animation = Animation::New(1.0f);
6744 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
6746 data.Check(false, TEST_LOCATION);
6747 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
6748 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
6750 tet_infoline("Play the animation and check the property value");
6753 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6754 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
6756 tet_infoline("Animation not currently finished, so the current visibility should still be true");
6757 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
6759 application.SendNotification();
6760 application.Render(1100); // After the animation
6762 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
6767 int utcDaliActorVisibilityChangeSignalByName(void)
6769 TestApplication application;
6770 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
6772 Actor actor = Actor::New();
6774 bool signalCalled = false;
6775 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
6776 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6777 actor.SetProperty(Actor::Property::VISIBLE, false);
6778 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
6780 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
6781 signalCalled = false;
6782 actor.SetProperty(Actor::Property::VISIBLE, false);
6783 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6785 tet_infoline("Change the visibility using properties, ensure called");
6786 actor.SetProperty(Actor::Property::VISIBLE, true);
6787 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
6789 tet_infoline("Set the visibility to current using properties, ensure not called");
6790 signalCalled = false;
6792 actor.SetProperty(Actor::Property::VISIBLE, true);
6793 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6798 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
6800 gLayoutDirectionType = type;
6803 int UtcDaliActorLayoutDirectionProperty(void)
6805 TestApplication application;
6806 tet_infoline("Check layout direction property");
6808 Actor actor0 = Actor::New();
6809 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6810 application.GetScene().Add(actor0);
6812 application.SendNotification();
6813 application.Render();
6815 Actor actor1 = Actor::New();
6816 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6817 Actor actor2 = Actor::New();
6818 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6819 Actor actor3 = Actor::New();
6820 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6821 Actor actor4 = Actor::New();
6822 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6823 Actor actor5 = Actor::New();
6824 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6825 Actor actor6 = Actor::New();
6826 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6827 Actor actor7 = Actor::New();
6828 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6829 Actor actor8 = Actor::New();
6830 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6831 Actor actor9 = Actor::New();
6832 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6835 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
6836 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
6838 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
6839 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
6840 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
6842 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6843 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6844 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
6846 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
6848 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6849 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6851 application.GetScene().Add(actor3);
6858 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
6859 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
6861 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
6862 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
6863 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
6865 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
6867 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6868 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6869 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6870 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6871 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6872 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6873 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6875 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
6876 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6877 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6879 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
6880 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6881 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6882 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
6884 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
6885 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6886 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6891 struct LayoutDirectionFunctor
6893 LayoutDirectionFunctor(bool& signalCalled)
6894 : mSignalCalled(signalCalled)
6898 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
6899 : mSignalCalled(rhs.mSignalCalled)
6905 mSignalCalled = true;
6908 bool& mSignalCalled;
6911 int UtcDaliActorLayoutDirectionSignal(void)
6913 TestApplication application;
6914 tet_infoline("Check changing layout direction property sends a signal");
6916 Actor actor = Actor::New();
6917 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
6918 application.GetScene().Add(actor);
6919 bool signalCalled = false;
6920 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
6922 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
6923 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6925 // Test that writing the same value doesn't send a signal
6926 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
6927 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6929 // Test that writing a different value sends the signal
6930 signalCalled = false;
6931 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
6932 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
6934 signalCalled = false;
6935 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
6936 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
6941 struct ChildAddedSignalCheck
6943 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
6944 : mSignalReceived(signalReceived),
6945 mChildHandle(childHandle)
6949 void operator()(Actor childHandle)
6951 mSignalReceived = true;
6952 mChildHandle = childHandle;
6956 mSignalReceived = true;
6957 mChildHandle = Actor();
6960 bool& mSignalReceived;
6961 Actor& mChildHandle;
6964 int UtcDaliChildAddedSignalP1(void)
6966 TestApplication application;
6967 auto stage = application.GetScene();
6969 bool signalReceived = false;
6972 ChildAddedSignalCheck signal(signalReceived, childActor);
6973 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
6974 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
6976 auto actorA = Actor::New();
6978 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
6979 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
6980 signalReceived = false;
6982 auto actorB = Actor::New();
6984 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
6985 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
6990 int UtcDaliChildAddedSignalP2(void)
6992 TestApplication application;
6993 auto stage = application.GetScene();
6995 bool signalReceived = false;
6998 ChildAddedSignalCheck signal(signalReceived, childActor);
6999 tet_infoline("Connect to childAdded signal by name");
7001 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7002 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7004 auto actorA = Actor::New();
7006 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7008 // Can't test which actor was added; signal signature is void() when connecting via name.
7009 signalReceived = false;
7011 auto actorB = Actor::New();
7013 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7018 int UtcDaliChildAddedSignalN(void)
7020 TestApplication application;
7021 auto stage = application.GetScene();
7023 bool signalReceived = false;
7026 ChildAddedSignalCheck signal(signalReceived, childActor);
7027 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7028 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7030 auto actorA = Actor::New();
7032 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7033 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7034 signalReceived = false;
7036 auto actorB = Actor::New();
7038 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7042 struct ChildRemovedSignalCheck
7044 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7045 : mSignalReceived(signalReceived),
7046 mChildHandle(childHandle)
7050 void operator()(Actor childHandle)
7052 mSignalReceived = true;
7053 mChildHandle = childHandle;
7058 mSignalReceived = true;
7061 bool& mSignalReceived;
7062 Actor& mChildHandle;
7065 int UtcDaliChildRemovedSignalP1(void)
7067 TestApplication application;
7068 auto stage = application.GetScene();
7070 bool signalReceived = false;
7073 ChildRemovedSignalCheck signal(signalReceived, childActor);
7074 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7075 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7077 auto actorA = Actor::New();
7079 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7080 DALI_TEST_CHECK(!childActor);
7082 stage.Remove(actorA);
7083 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7084 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7086 signalReceived = false;
7087 auto actorB = Actor::New();
7089 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7091 stage.Remove(actorB);
7092 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7093 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7098 int UtcDaliChildRemovedSignalP2(void)
7100 TestApplication application;
7101 auto stage = application.GetScene();
7103 bool signalReceived = false;
7106 ChildAddedSignalCheck signal(signalReceived, childActor);
7107 tet_infoline("Connect to childRemoved signal by name");
7109 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7110 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7112 auto actorA = Actor::New();
7114 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7116 stage.Remove(actorA);
7117 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7119 signalReceived = false;
7120 auto actorB = Actor::New();
7122 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7124 stage.Remove(actorB);
7125 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7130 int UtcDaliChildRemovedSignalN(void)
7132 TestApplication application;
7133 auto stage = application.GetScene();
7135 bool signalReceived = false;
7138 ChildRemovedSignalCheck signal(signalReceived, childActor);
7139 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7140 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7142 auto actorA = Actor::New();
7145 auto actorB = Actor::New();
7148 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7149 DALI_TEST_CHECK(!childActor);
7151 actorA.Remove(actorB);
7152 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7156 int UtcDaliChildMovedSignalP(void)
7158 TestApplication application;
7159 auto stage = application.GetScene();
7161 bool addedASignalReceived = false;
7162 bool removedASignalReceived = false;
7163 bool addedBSignalReceived = false;
7164 bool removedBSignalReceived = false;
7167 auto actorA = Actor::New();
7168 auto actorB = Actor::New();
7172 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
7173 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7174 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
7175 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7177 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7178 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7179 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7180 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7182 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7183 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7184 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7185 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7187 // Create a child of A
7189 auto child = Actor::New();
7192 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7193 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7194 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7195 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7196 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7199 addedASignalReceived = false;
7200 addedBSignalReceived = false;
7201 removedASignalReceived = false;
7202 removedBSignalReceived = false;
7204 actorB.Add(child); // Expect this child to be re-parented
7205 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7206 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7207 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7208 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7210 // Move child back to A:
7211 addedASignalReceived = false;
7212 addedBSignalReceived = false;
7213 removedASignalReceived = false;
7214 removedBSignalReceived = false;
7216 actorA.Add(child); // Expect this child to be re-parented
7217 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7218 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7219 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7220 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7225 int utcDaliActorCulled(void)
7227 TestApplication application;
7228 auto stage = application.GetScene();
7230 tet_infoline("Check that the actor is culled if the actor is out of the screen");
7232 Actor actor = Actor::New();
7233 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7235 Geometry geometry = CreateQuadGeometry();
7236 Shader shader = CreateShader();
7237 Renderer renderer = Renderer::New(geometry, shader);
7238 actor.AddRenderer(renderer);
7242 application.SendNotification();
7243 application.Render(0);
7245 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7247 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7248 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7250 // Connect NotifySignal
7251 bool propertyNotificationSignal(false);
7252 PropertyNotification source;
7253 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7254 notification.NotifySignal().Connect(&application, f);
7256 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7258 application.SendNotification();
7259 application.Render();
7261 application.SendNotification();
7263 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7265 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7266 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7267 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7272 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7274 TestApplication application;
7275 auto stage = application.GetScene();
7277 tet_infoline("Ensure we clear the screen when the last actor is removed");
7279 Actor actor = CreateRenderableActor();
7280 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7283 application.SendNotification();
7284 application.Render();
7286 auto& glAbstraction = application.GetGlAbstraction();
7287 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7291 application.SendNotification();
7292 application.Render();
7294 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7299 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7301 TestApplication application;
7302 auto stage = application.GetScene();
7304 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7306 Actor actor = CreateRenderableActor();
7307 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7310 application.SendNotification();
7311 application.Render();
7313 auto& glAbstraction = application.GetGlAbstraction();
7314 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7316 actor.SetProperty(Actor::Property::VISIBLE, false);
7318 application.SendNotification();
7319 application.Render();
7321 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7326 int utcDaliActorGetSizeAfterAnimation(void)
7328 TestApplication application;
7329 tet_infoline("Check the actor size before / after an animation is finished");
7331 Vector3 actorSize(100.0f, 100.0f, 0.0f);
7333 Actor actor = Actor::New();
7334 actor.SetProperty(Actor::Property::SIZE, actorSize);
7335 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7336 application.GetScene().Add(actor);
7338 // Size should be updated without rendering.
7339 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7340 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7342 application.SendNotification();
7343 application.Render();
7345 // Size and current size should be updated.
7346 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7347 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7348 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7349 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7350 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7352 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7353 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7354 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7355 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7356 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7359 actorSize = Vector3(200.0f, 200.0f, 0.0f);
7360 actor.SetProperty(Actor::Property::SIZE, actorSize);
7362 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7363 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7365 Vector3 targetValue(10.0f, 20.0f, 0.0f);
7367 Animation animation = Animation::New(1.0f);
7368 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7371 // Size should be updated without rendering.
7372 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7373 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7375 application.SendNotification();
7376 application.Render(1100); // After the animation
7378 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7379 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7380 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7381 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7382 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7384 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7385 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7386 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7387 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7388 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7390 targetValue.width = 50.0f;
7393 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
7396 application.SendNotification();
7397 application.Render(1100); // After the animation
7399 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7400 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7401 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7402 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7403 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7405 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7406 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7407 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7408 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7409 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7411 targetValue.height = 70.0f;
7414 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
7417 application.SendNotification();
7418 application.Render(1100); // After the animation
7420 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7421 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7422 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7423 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7424 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7426 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7427 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7428 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7429 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7430 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7432 Vector3 offset(10.0f, 20.0f, 0.0f);
7435 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
7438 application.SendNotification();
7439 application.Render(1100); // After the animation
7441 targetValue += offset;
7443 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7444 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7445 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7446 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7447 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7449 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7450 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7451 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7452 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7453 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7455 offset.width = 20.0f;
7458 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
7461 application.SendNotification();
7462 application.Render(1100); // After the animation
7464 targetValue.width += offset.width;
7466 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7467 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7468 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7469 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7470 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7472 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7473 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7474 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7475 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7476 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7478 offset.height = 10.0f;
7481 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
7484 application.SendNotification();
7485 application.Render(1100); // After the animation
7487 targetValue.height += offset.height;
7489 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7490 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7491 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7492 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7493 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7495 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7496 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7497 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7498 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7499 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7502 actorSize = Vector3(300.0f, 300.0f, 0.0f);
7504 actor.SetProperty(Actor::Property::SIZE, actorSize);
7506 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7507 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7509 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7510 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7512 application.SendNotification();
7513 application.Render();
7515 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7516 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7518 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7519 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7524 int utcDaliActorPartialUpdate(void)
7526 TestApplication application(
7527 TestApplication::DEFAULT_SURFACE_WIDTH,
7528 TestApplication::DEFAULT_SURFACE_HEIGHT,
7529 TestApplication::DEFAULT_HORIZONTAL_DPI,
7530 TestApplication::DEFAULT_VERTICAL_DPI,
7534 tet_infoline("Check the damaged area");
7536 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7538 std::vector<Rect<int>> damagedRects;
7539 Rect<int> clippingRect;
7540 application.SendNotification();
7541 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7543 // First render pass, nothing to render, adaptor would just do swap buffer.
7544 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7545 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7547 Actor actor = CreateRenderableActor();
7548 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7549 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7550 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7551 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7552 application.GetScene().Add(actor);
7554 application.SendNotification();
7556 // 1. Actor added, damaged rect is added size of actor
7557 damagedRects.clear();
7558 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7559 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7562 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7563 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7564 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7565 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7566 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7567 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7568 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7571 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7572 application.SendNotification();
7574 damagedRects.clear();
7575 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7576 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7579 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7580 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7581 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7582 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7583 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7584 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7585 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7587 // 3. Set new position
7588 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7589 application.SendNotification();
7591 damagedRects.clear();
7592 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7593 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7596 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7597 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7598 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7599 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7600 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7601 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7602 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7604 application.GetScene().Remove(actor);
7605 application.SendNotification();
7607 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7608 damagedRects.clear();
7609 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7610 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7612 clippingRect = damagedRects[0];
7613 clippingRect.Merge(damagedRects[1]);
7614 clippingRect.Merge(damagedRects[2]);
7616 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7617 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7618 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7620 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7621 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7622 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7623 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7624 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7629 int utcDaliActorPartialUpdateSetColor(void)
7631 TestApplication application(
7632 TestApplication::DEFAULT_SURFACE_WIDTH,
7633 TestApplication::DEFAULT_SURFACE_HEIGHT,
7634 TestApplication::DEFAULT_HORIZONTAL_DPI,
7635 TestApplication::DEFAULT_VERTICAL_DPI,
7639 tet_infoline("Check uniform update");
7641 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7643 std::vector<Rect<int>> damagedRects;
7644 Rect<int> clippingRect;
7645 application.SendNotification();
7646 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7648 // First render pass, nothing to render, adaptor would just do swap buffer.
7649 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7650 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7652 Actor actor = CreateRenderableActor();
7653 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7654 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7655 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7656 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7657 application.GetScene().Add(actor);
7659 application.SendNotification();
7661 // 1. Actor added, damaged rect is added size of actor
7662 damagedRects.clear();
7663 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7664 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7667 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7668 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7669 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7670 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7671 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7672 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7673 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7675 damagedRects.clear();
7676 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7678 damagedRects.clear();
7679 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7682 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
7683 application.SendNotification();
7685 damagedRects.clear();
7686 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7687 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7690 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7691 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7692 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7693 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7694 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7695 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7696 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7701 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
7702 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
7703 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
7704 const char* const RENDER_SHADOW_VERTEX_SOURCE =
7705 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
7706 " uniform mediump mat4 uLightCameraViewMatrix;\n"
7710 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
7711 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
7712 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
7715 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
7716 "uniform lowp vec4 uShadowColor;\n"
7719 " lowp float alpha;\n"
7720 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
7721 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
7724 int utcDaliActorPartialUpdateSetProperty(void)
7726 TestApplication application(
7727 TestApplication::DEFAULT_SURFACE_WIDTH,
7728 TestApplication::DEFAULT_SURFACE_HEIGHT,
7729 TestApplication::DEFAULT_HORIZONTAL_DPI,
7730 TestApplication::DEFAULT_VERTICAL_DPI,
7734 tet_infoline("Set/Update property with partial update");
7736 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7738 std::vector<Rect<int>> damagedRects;
7739 Rect<int> clippingRect;
7740 application.SendNotification();
7741 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7743 // First render pass, nothing to render, adaptor would just do swap buffer.
7744 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7745 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7747 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
7748 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
7749 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7750 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7751 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7752 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7753 application.GetScene().Add(actor);
7755 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
7757 damagedRects.clear();
7758 application.SendNotification();
7759 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7760 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7763 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7764 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7765 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7766 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7767 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7768 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7769 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7771 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
7772 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
7774 damagedRects.clear();
7775 application.SendNotification();
7776 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7777 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7779 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7780 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7781 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7782 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7783 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7784 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7786 damagedRects.clear();
7787 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7788 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7790 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7791 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7792 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7793 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7794 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7795 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7797 damagedRects.clear();
7798 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7799 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7804 int utcDaliActorPartialUpdateTwoActors(void)
7806 TestApplication application(
7807 TestApplication::DEFAULT_SURFACE_WIDTH,
7808 TestApplication::DEFAULT_SURFACE_HEIGHT,
7809 TestApplication::DEFAULT_HORIZONTAL_DPI,
7810 TestApplication::DEFAULT_VERTICAL_DPI,
7814 tet_infoline("Check the damaged rects with partial update and two actors");
7816 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7818 Actor actor = CreateRenderableActor();
7819 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
7820 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
7821 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7822 application.GetScene().Add(actor);
7824 Actor actor2 = CreateRenderableActor();
7825 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
7826 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
7827 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7828 application.GetScene().Add(actor2);
7830 application.SendNotification();
7831 std::vector<Rect<int>> damagedRects;
7832 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7834 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
7835 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
7836 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
7838 // in screen coordinates, adaptor would calculate it using previous frames information
7839 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
7840 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7842 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7843 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7844 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7845 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7850 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
7852 TestApplication application(
7853 TestApplication::DEFAULT_SURFACE_WIDTH,
7854 TestApplication::DEFAULT_SURFACE_HEIGHT,
7855 TestApplication::DEFAULT_HORIZONTAL_DPI,
7856 TestApplication::DEFAULT_VERTICAL_DPI,
7860 tet_infoline("Check the damaged rect with partial update and actor size hint");
7862 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7864 Actor actor = CreateRenderableActor();
7865 actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f));
7866 actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f));
7867 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0));
7868 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7869 application.GetScene().Add(actor);
7871 application.SendNotification();
7872 std::vector<Rect<int>> damagedRects;
7873 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
7875 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7877 Rect<int> clippingRect = Rect<int>(0, 496, 160, 320);
7878 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7880 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7882 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7883 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7884 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7885 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7890 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
7892 TestApplication application;
7894 Actor actor = Actor::New();
7895 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
7896 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
7897 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
7898 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
7899 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
7900 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7901 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
7902 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
7906 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
7908 TestApplication application;
7910 Actor actor = Actor::New();
7912 // Make sure setting invalid types does not cause a crash
7915 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
7916 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
7917 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
7918 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
7919 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
7920 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
7921 tet_result(TET_PASS);
7925 tet_result(TET_FAIL);
7930 int UtcDaliActorTouchAreaPropertyP(void)
7932 TestApplication application;
7934 Actor actor = Actor::New();
7935 Vector2 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
7936 DALI_TEST_EQUALS(touchArea, Vector2::ZERO, TEST_LOCATION);
7937 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(10.f, 10.f));
7938 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
7939 DALI_TEST_EQUALS(touchArea, Vector2(10.f, 10.f), TEST_LOCATION);
7943 int UtcDaliActorTouchAreaPropertyN(void)
7945 TestApplication application;
7947 Actor actor = Actor::New();
7949 // Make sure setting invalid types does not cause a crash
7952 actor.SetProperty(DevelActor::Property::TOUCH_AREA, 1.0f);
7953 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2::ONE);
7954 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector3::ONE);
7955 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector4::ONE);
7956 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Map());
7957 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Array());
7958 tet_result(TET_PASS);
7962 tet_result(TET_FAIL);
7967 int UtcDaliActorLowerBelowNegative(void)
7969 TestApplication application;
7970 Dali::Actor instance;
7974 instance.LowerBelow(arg1);
7975 DALI_TEST_CHECK(false); // Should not get here
7979 DALI_TEST_CHECK(true); // We expect an assert
7984 int UtcDaliActorRaiseAboveNegative(void)
7986 TestApplication application;
7987 Dali::Actor instance;
7991 instance.RaiseAbove(arg1);
7992 DALI_TEST_CHECK(false); // Should not get here
7996 DALI_TEST_CHECK(true); // We expect an assert
8001 int UtcDaliActorRaiseToTopNegative(void)
8003 TestApplication application;
8004 Dali::Actor instance;
8007 instance.RaiseToTop();
8008 DALI_TEST_CHECK(false); // Should not get here
8012 DALI_TEST_CHECK(true); // We expect an assert
8017 int UtcDaliActorAddRendererNegative(void)
8019 TestApplication application;
8020 Dali::Actor instance;
8023 Dali::Renderer arg1;
8024 instance.AddRenderer(arg1);
8025 DALI_TEST_CHECK(false); // Should not get here
8029 DALI_TEST_CHECK(true); // We expect an assert
8034 int UtcDaliActorTouchedSignalNegative(void)
8036 TestApplication application;
8037 Dali::Actor instance;
8040 instance.TouchedSignal();
8041 DALI_TEST_CHECK(false); // Should not get here
8045 DALI_TEST_CHECK(true); // We expect an assert
8050 int UtcDaliActorTranslateByNegative(void)
8052 TestApplication application;
8053 Dali::Actor instance;
8057 instance.TranslateBy(arg1);
8058 DALI_TEST_CHECK(false); // Should not get here
8062 DALI_TEST_CHECK(true); // We expect an assert
8067 int UtcDaliActorFindChildByIdNegative(void)
8069 TestApplication application;
8070 Dali::Actor instance;
8073 unsigned int arg1 = 0u;
8074 instance.FindChildById(arg1);
8075 DALI_TEST_CHECK(false); // Should not get here
8079 DALI_TEST_CHECK(true); // We expect an assert
8084 int UtcDaliActorGetRendererAtNegative(void)
8086 TestApplication application;
8087 Dali::Actor instance;
8090 unsigned int arg1 = 0u;
8091 instance.GetRendererAt(arg1);
8092 DALI_TEST_CHECK(false); // Should not get here
8096 DALI_TEST_CHECK(true); // We expect an assert
8101 int UtcDaliActorHoveredSignalNegative(void)
8103 TestApplication application;
8104 Dali::Actor instance;
8107 instance.HoveredSignal();
8108 DALI_TEST_CHECK(false); // Should not get here
8112 DALI_TEST_CHECK(true); // We expect an assert
8117 int UtcDaliActorLowerToBottomNegative(void)
8119 TestApplication application;
8120 Dali::Actor instance;
8123 instance.LowerToBottom();
8124 DALI_TEST_CHECK(false); // Should not get here
8128 DALI_TEST_CHECK(true); // We expect an assert
8133 int UtcDaliActorOnSceneSignalNegative(void)
8135 TestApplication application;
8136 Dali::Actor instance;
8139 instance.OnSceneSignal();
8140 DALI_TEST_CHECK(false); // Should not get here
8144 DALI_TEST_CHECK(true); // We expect an assert
8149 int UtcDaliActorOffSceneSignalNegative(void)
8151 TestApplication application;
8152 Dali::Actor instance;
8155 instance.OffSceneSignal();
8156 DALI_TEST_CHECK(false); // Should not get here
8160 DALI_TEST_CHECK(true); // We expect an assert
8165 int UtcDaliActorRemoveRendererNegative01(void)
8167 TestApplication application;
8168 Dali::Actor instance;
8171 unsigned int arg1 = 0u;
8172 instance.RemoveRenderer(arg1);
8173 DALI_TEST_CHECK(false); // Should not get here
8177 DALI_TEST_CHECK(true); // We expect an assert
8182 int UtcDaliActorRemoveRendererNegative02(void)
8184 TestApplication application;
8185 Dali::Actor instance;
8188 Dali::Renderer arg1;
8189 instance.RemoveRenderer(arg1);
8190 DALI_TEST_CHECK(false); // Should not get here
8194 DALI_TEST_CHECK(true); // We expect an assert
8199 int UtcDaliActorFindChildByNameNegative(void)
8201 TestApplication application;
8202 Dali::Actor instance;
8206 instance.FindChildByName(arg1);
8207 DALI_TEST_CHECK(false); // Should not get here
8211 DALI_TEST_CHECK(true); // We expect an assert
8216 int UtcDaliActorSetResizePolicyNegative(void)
8218 TestApplication application;
8219 Dali::Actor instance;
8222 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
8223 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
8224 instance.SetResizePolicy(arg1, arg2);
8225 DALI_TEST_CHECK(false); // Should not get here
8229 DALI_TEST_CHECK(true); // We expect an assert
8234 int UtcDaliActorOnRelayoutSignalNegative(void)
8236 TestApplication application;
8237 Dali::Actor instance;
8240 instance.OnRelayoutSignal();
8241 DALI_TEST_CHECK(false); // Should not get here
8245 DALI_TEST_CHECK(true); // We expect an assert
8250 int UtcDaliActorWheelEventSignalNegative(void)
8252 TestApplication application;
8253 Dali::Actor instance;
8256 instance.WheelEventSignal();
8257 DALI_TEST_CHECK(false); // Should not get here
8261 DALI_TEST_CHECK(true); // We expect an assert
8266 int UtcDaliActorGetHeightForWidthNegative(void)
8268 TestApplication application;
8269 Dali::Actor instance;
8273 instance.GetHeightForWidth(arg1);
8274 DALI_TEST_CHECK(false); // Should not get here
8278 DALI_TEST_CHECK(true); // We expect an assert
8283 int UtcDaliActorGetWidthForHeightNegative(void)
8285 TestApplication application;
8286 Dali::Actor instance;
8290 instance.GetWidthForHeight(arg1);
8291 DALI_TEST_CHECK(false); // Should not get here
8295 DALI_TEST_CHECK(true); // We expect an assert
8300 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
8302 TestApplication application;
8303 Dali::Actor instance;
8306 instance.LayoutDirectionChangedSignal();
8307 DALI_TEST_CHECK(false); // Should not get here
8311 DALI_TEST_CHECK(true); // We expect an assert
8316 int UtcDaliActorAddNegative(void)
8318 TestApplication application;
8319 Dali::Actor instance;
8324 DALI_TEST_CHECK(false); // Should not get here
8328 DALI_TEST_CHECK(true); // We expect an assert
8333 int UtcDaliActorLowerNegative(void)
8335 TestApplication application;
8336 Dali::Actor instance;
8340 DALI_TEST_CHECK(false); // Should not get here
8344 DALI_TEST_CHECK(true); // We expect an assert
8349 int UtcDaliActorRaiseNegative(void)
8351 TestApplication application;
8352 Dali::Actor instance;
8356 DALI_TEST_CHECK(false); // Should not get here
8360 DALI_TEST_CHECK(true); // We expect an assert
8365 int UtcDaliActorRemoveNegative(void)
8367 TestApplication application;
8368 Dali::Actor instance;
8372 instance.Remove(arg1);
8373 DALI_TEST_CHECK(false); // Should not get here
8377 DALI_TEST_CHECK(true); // We expect an assert
8382 int UtcDaliActorScaleByNegative(void)
8384 TestApplication application;
8385 Dali::Actor instance;
8389 instance.ScaleBy(arg1);
8390 DALI_TEST_CHECK(false); // Should not get here
8394 DALI_TEST_CHECK(true); // We expect an assert
8399 int UtcDaliActorGetLayerNegative(void)
8401 TestApplication application;
8402 Dali::Actor instance;
8405 instance.GetLayer();
8406 DALI_TEST_CHECK(false); // Should not get here
8410 DALI_TEST_CHECK(true); // We expect an assert
8415 int UtcDaliActorRotateByNegative01(void)
8417 TestApplication application;
8418 Dali::Actor instance;
8421 Dali::Quaternion arg1;
8422 instance.RotateBy(arg1);
8423 DALI_TEST_CHECK(false); // Should not get here
8427 DALI_TEST_CHECK(true); // We expect an assert
8432 int UtcDaliActorRotateByNegative02(void)
8434 TestApplication application;
8435 Dali::Actor instance;
8440 instance.RotateBy(arg1, arg2);
8441 DALI_TEST_CHECK(false); // Should not get here
8445 DALI_TEST_CHECK(true); // We expect an assert
8450 int UtcDaliActorUnparentNegative(void)
8452 TestApplication application;
8453 Dali::Actor instance;
8456 instance.Unparent();
8457 DALI_TEST_CHECK(false); // Should not get here
8461 DALI_TEST_CHECK(true); // We expect an assert
8466 int UtcDaliActorGetChildAtNegative(void)
8468 TestApplication application;
8469 Dali::Actor instance;
8472 unsigned int arg1 = 0u;
8473 instance.GetChildAt(arg1);
8474 DALI_TEST_CHECK(false); // Should not get here
8478 DALI_TEST_CHECK(true); // We expect an assert
8483 int UtcDaliActorGetChildCountNegative(void)
8485 TestApplication application;
8486 Dali::Actor instance;
8489 instance.GetChildCount();
8490 DALI_TEST_CHECK(false); // Should not get here
8494 DALI_TEST_CHECK(true); // We expect an assert
8499 int UtcDaliActorGetTargetSizeNegative(void)
8501 TestApplication application;
8502 Dali::Actor instance;
8505 instance.GetTargetSize();
8506 DALI_TEST_CHECK(false); // Should not get here
8510 DALI_TEST_CHECK(true); // We expect an assert
8515 int UtcDaliActorScreenToLocalNegative(void)
8517 TestApplication application;
8518 Dali::Actor instance;
8525 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
8526 DALI_TEST_CHECK(false); // Should not get here
8530 DALI_TEST_CHECK(true); // We expect an assert
8535 int UtcDaliActorGetNaturalSizeNegative(void)
8537 TestApplication application;
8538 Dali::Actor instance;
8541 instance.GetNaturalSize();
8542 DALI_TEST_CHECK(false); // Should not get here
8546 DALI_TEST_CHECK(true); // We expect an assert
8551 int UtcDaliActorGetRelayoutSizeNegative(void)
8553 TestApplication application;
8554 Dali::Actor instance;
8557 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
8558 instance.GetRelayoutSize(arg1);
8559 DALI_TEST_CHECK(false); // Should not get here
8563 DALI_TEST_CHECK(true); // We expect an assert
8568 int UtcDaliActorGetResizePolicyNegative(void)
8570 TestApplication application;
8571 Dali::Actor instance;
8574 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
8575 instance.GetResizePolicy(arg1);
8576 DALI_TEST_CHECK(false); // Should not get here
8580 DALI_TEST_CHECK(true); // We expect an assert
8585 int UtcDaliActorGetRendererCountNegative(void)
8587 TestApplication application;
8588 Dali::Actor instance;
8591 instance.GetRendererCount();
8592 DALI_TEST_CHECK(false); // Should not get here
8596 DALI_TEST_CHECK(true); // We expect an assert
8601 int UtcDaliActorGetParentNegative(void)
8603 TestApplication application;
8604 Dali::Actor instance;
8607 instance.GetParent();
8608 DALI_TEST_CHECK(false); // Should not get here
8612 DALI_TEST_CHECK(true); // We expect an assert
8617 int UtcDaliActorPropertyBlendEquation(void)
8619 TestApplication application;
8621 tet_infoline("Test SetProperty AdvancedBlendEquation");
8623 Geometry geometry = CreateQuadGeometry();
8624 Shader shader = CreateShader();
8625 Renderer renderer1 = Renderer::New( geometry, shader );
8627 Actor actor = Actor::New();
8628 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
8630 actor.AddRenderer(renderer1);
8631 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
8632 application.GetScene().Add(actor);
8634 if( !Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
8636 actor.SetProperty( Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN );
8637 int equation = actor.GetProperty<int>( Dali::DevelActor::Property::BLEND_EQUATION );
8638 DALI_TEST_EQUALS( ( Dali::DevelBlendEquation::SCREEN == equation ), false, TEST_LOCATION );
8641 if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
8643 actor.SetProperty( Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN );
8644 int equation = actor.GetProperty<int>( Dali::DevelActor::Property::BLEND_EQUATION );
8645 DALI_TEST_EQUALS( ( Dali::DevelBlendEquation::SCREEN == equation ), true, TEST_LOCATION );
8648 Renderer renderer2 = Renderer::New( geometry, shader );
8649 actor.AddRenderer(renderer2);