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 UtcDaliActorRaiseAbove2(void)
5294 tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5296 TestApplication application;
5298 Integration::Scene stage(application.GetScene());
5300 Actor actorA = Actor::New();
5301 Actor actorB = Actor::New();
5302 Actor actorC = Actor::New();
5304 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5305 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5307 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5308 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5310 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5311 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5313 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5314 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5316 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5317 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5319 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5320 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5326 ResetTouchCallbacks();
5328 application.SendNotification();
5329 application.Render();
5331 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5332 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5333 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5335 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5336 // Only top actor will get touched.
5337 actorA.TouchedSignal().Connect(TestTouchCallback);
5338 actorB.TouchedSignal().Connect(TestTouchCallback2);
5339 actorC.TouchedSignal().Connect(TestTouchCallback3);
5341 bool orderChangedSignal(false);
5342 Actor orderChangedActor;
5343 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5344 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5346 Dali::Integration::Point point;
5347 point.SetDeviceId(1);
5348 point.SetState(PointState::DOWN);
5349 point.SetScreenPosition(Vector2(10.f, 10.f));
5350 Dali::Integration::TouchEvent touchEvent;
5351 touchEvent.AddPoint(point);
5353 application.ProcessEvent(touchEvent);
5355 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5356 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5357 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5359 ResetTouchCallbacks();
5361 tet_printf("Raise actor B Above Actor C\n");
5363 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5364 int newOrder = actorC[DevelActor::Property::SIBLING_ORDER];
5365 actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5366 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5367 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5369 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5370 application.SendNotification();
5371 application.ProcessEvent(touchEvent);
5373 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5374 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5375 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5377 ResetTouchCallbacks();
5379 tet_printf("Raise actor A Above Actor B\n");
5381 orderChangedSignal = false;
5383 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5384 newOrder = actorB[DevelActor::Property::SIBLING_ORDER];
5385 actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5386 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5387 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5389 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5390 application.SendNotification();
5392 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5394 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5395 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5396 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5398 ResetTouchCallbacks();
5403 int UtcDaliActorLowerBelow(void)
5405 tet_infoline("UtcDaliActor LowerBelow test \n");
5407 TestApplication application;
5409 Integration::Scene stage(application.GetScene());
5411 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5412 // enables checking of which actor the uniform is assigned too
5413 Shader shaderA = CreateShader();
5414 shaderA.RegisterProperty("uRendererColor", 1.f);
5416 Shader shaderB = CreateShader();
5417 shaderB.RegisterProperty("uRendererColor", 2.f);
5419 Shader shaderC = CreateShader();
5420 shaderC.RegisterProperty("uRendererColor", 3.f);
5422 Actor actorA = Actor::New();
5423 Actor actorB = Actor::New();
5424 Actor actorC = Actor::New();
5426 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5427 Geometry geometry = CreateQuadGeometry();
5429 Renderer rendererA = Renderer::New(geometry, shaderA);
5430 actorA.AddRenderer(rendererA);
5432 Renderer rendererB = Renderer::New(geometry, shaderB);
5433 actorB.AddRenderer(rendererB);
5435 Renderer rendererC = Renderer::New(geometry, shaderC);
5436 actorC.AddRenderer(rendererC);
5438 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5439 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5441 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5442 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5444 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5445 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5447 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5448 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5450 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5451 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5453 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5454 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5456 Actor container = Actor::New();
5457 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5458 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5459 stage.Add(container);
5461 container.Add(actorA);
5462 container.Add(actorB);
5463 container.Add(actorC);
5465 ResetTouchCallbacks();
5467 // Connect ChildOrderChangedSignal
5468 bool orderChangedSignal(false);
5469 Actor orderChangedActor;
5470 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5471 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5473 // Set up gl abstraction trace so can query the set uniform order
5474 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5475 glAbstraction.EnableSetUniformCallTrace(true);
5476 glAbstraction.ResetSetUniformCallStack();
5477 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5479 glAbstraction.ResetSetUniformCallStack();
5481 application.SendNotification();
5482 application.Render();
5484 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5486 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5488 // Test order of uniforms in stack
5489 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5490 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5491 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5493 tet_infoline("Testing C above B and A at bottom\n");
5494 bool CBA = (indexC > indexB) && (indexB > indexA);
5496 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5498 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5499 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5500 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5502 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5503 // Only top actor will get touched.
5504 actorA.TouchedSignal().Connect(TestTouchCallback);
5505 actorB.TouchedSignal().Connect(TestTouchCallback2);
5506 actorC.TouchedSignal().Connect(TestTouchCallback3);
5508 Dali::Integration::Point point;
5509 point.SetDeviceId(1);
5510 point.SetState(PointState::DOWN);
5511 point.SetScreenPosition(Vector2(10.f, 10.f));
5512 Dali::Integration::TouchEvent touchEvent;
5513 touchEvent.AddPoint(point);
5515 tet_infoline("UtcDaliActor Test Set up completed \n");
5517 application.ProcessEvent(touchEvent);
5519 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5520 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5521 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5523 ResetTouchCallbacks();
5525 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");
5527 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5528 actorC.LowerBelow(actorB);
5529 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5530 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5532 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5533 application.SendNotification();
5534 application.Render();
5536 application.ProcessEvent(touchEvent); // touch event
5538 glAbstraction.ResetSetUniformCallStack();
5539 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5541 application.SendNotification();
5542 application.Render();
5544 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5546 // Test order of uniforms in stack
5547 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5548 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5549 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5551 tet_infoline("Testing render order is A, C, B");
5552 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5553 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5555 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5556 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5557 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5559 ResetTouchCallbacks();
5561 tet_printf("Lower actor C below Actor A leaving B on top\n");
5563 orderChangedSignal = false;
5565 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5566 actorC.LowerBelow(actorA);
5567 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5568 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5570 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5571 application.SendNotification();
5572 application.Render();
5574 application.ProcessEvent(touchEvent);
5576 glAbstraction.ResetSetUniformCallStack();
5577 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5579 application.Render();
5580 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5582 // Test order of uniforms in stack
5583 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5584 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5585 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5587 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5588 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5590 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5591 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5592 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5594 ResetTouchCallbacks();
5596 tet_printf("Lower actor B below Actor C leaving A on top\n");
5598 orderChangedSignal = false;
5600 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5601 actorB.LowerBelow(actorC);
5602 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5603 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5605 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5606 application.SendNotification();
5607 application.Render();
5609 application.ProcessEvent(touchEvent);
5611 glAbstraction.ResetSetUniformCallStack();
5612 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5614 application.Render();
5615 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5617 // Test order of uniforms in stack
5618 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5619 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5620 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5622 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5623 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5629 int UtcDaliActorLowerBelow2(void)
5631 tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
5633 TestApplication application;
5635 Integration::Scene stage(application.GetScene());
5637 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5638 // enables checking of which actor the uniform is assigned too
5639 Shader shaderA = CreateShader();
5640 shaderA.RegisterProperty("uRendererColor", 1.f);
5642 Shader shaderB = CreateShader();
5643 shaderB.RegisterProperty("uRendererColor", 2.f);
5645 Shader shaderC = CreateShader();
5646 shaderC.RegisterProperty("uRendererColor", 3.f);
5648 Actor actorA = Actor::New();
5649 Actor actorB = Actor::New();
5650 Actor actorC = Actor::New();
5652 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5653 Geometry geometry = CreateQuadGeometry();
5655 Renderer rendererA = Renderer::New(geometry, shaderA);
5656 actorA.AddRenderer(rendererA);
5658 Renderer rendererB = Renderer::New(geometry, shaderB);
5659 actorB.AddRenderer(rendererB);
5661 Renderer rendererC = Renderer::New(geometry, shaderC);
5662 actorC.AddRenderer(rendererC);
5664 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5665 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5667 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5668 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5670 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5671 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5673 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5674 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5676 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5677 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5679 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5680 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5682 Actor container = Actor::New();
5683 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5684 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5685 stage.Add(container);
5687 container.Add(actorA);
5688 container.Add(actorB);
5689 container.Add(actorC);
5691 ResetTouchCallbacks();
5693 // Connect ChildOrderChangedSignal
5694 bool orderChangedSignal(false);
5695 Actor orderChangedActor;
5696 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5697 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5699 // Set up gl abstraction trace so can query the set uniform order
5700 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5701 glAbstraction.EnableSetUniformCallTrace(true);
5702 glAbstraction.ResetSetUniformCallStack();
5703 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5705 glAbstraction.ResetSetUniformCallStack();
5707 application.SendNotification();
5708 application.Render();
5710 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5712 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5714 // Test order of uniforms in stack
5715 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5716 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5717 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5719 tet_infoline("Testing C above B and A at bottom\n");
5720 bool CBA = (indexC > indexB) && (indexB > indexA);
5722 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5724 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5725 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5726 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5728 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5729 // Only top actor will get touched.
5730 actorA.TouchedSignal().Connect(TestTouchCallback);
5731 actorB.TouchedSignal().Connect(TestTouchCallback2);
5732 actorC.TouchedSignal().Connect(TestTouchCallback3);
5734 Dali::Integration::Point point;
5735 point.SetDeviceId(1);
5736 point.SetState(PointState::DOWN);
5737 point.SetScreenPosition(Vector2(10.f, 10.f));
5738 Dali::Integration::TouchEvent touchEvent;
5739 touchEvent.AddPoint(point);
5741 tet_infoline("UtcDaliActor Test Set up completed \n");
5743 application.ProcessEvent(touchEvent);
5745 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5746 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5747 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5749 ResetTouchCallbacks();
5751 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");
5753 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5754 actorC[DevelActor::Property::SIBLING_ORDER] = 1;
5755 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5756 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5758 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5759 application.SendNotification();
5760 application.Render();
5762 application.ProcessEvent(touchEvent); // touch event
5764 glAbstraction.ResetSetUniformCallStack();
5765 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5767 application.SendNotification();
5768 application.Render();
5770 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5772 // Test order of uniforms in stack
5773 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5774 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5775 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5777 tet_infoline("Testing render order is A, C, B");
5778 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5779 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5781 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5782 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5783 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5785 ResetTouchCallbacks();
5787 tet_printf("Lower actor C below Actor A leaving B on top\n");
5789 orderChangedSignal = false;
5791 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5792 actorC[DevelActor::Property::SIBLING_ORDER] = 0;
5793 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5794 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5796 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5797 application.SendNotification();
5798 application.Render();
5800 application.ProcessEvent(touchEvent);
5802 glAbstraction.ResetSetUniformCallStack();
5803 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5805 application.Render();
5806 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5808 // Test order of uniforms in stack
5809 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5810 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5811 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5813 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5814 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5816 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5817 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5818 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5820 ResetTouchCallbacks();
5822 tet_printf("Lower actor B below Actor C leaving A on top\n");
5824 orderChangedSignal = false;
5826 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5827 actorB[DevelActor::Property::SIBLING_ORDER] = 0;
5828 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5829 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5831 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5832 application.SendNotification();
5833 application.Render();
5835 application.ProcessEvent(touchEvent);
5837 glAbstraction.ResetSetUniformCallStack();
5838 glSetUniformStack = glAbstraction.GetSetUniformTrace();
5840 application.Render();
5841 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5843 // Test order of uniforms in stack
5844 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3");
5845 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2");
5846 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1");
5848 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5849 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5854 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5856 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
5858 TestApplication application;
5860 Integration::Scene stage(application.GetScene());
5862 Actor parentA = Actor::New();
5863 Actor parentB = Actor::New();
5864 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5865 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5866 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5867 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5869 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5870 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5872 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5873 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5878 Actor actorA = Actor::New();
5879 Actor actorB = Actor::New();
5880 Actor actorC = Actor::New();
5882 parentA.Add(actorA);
5883 parentA.Add(actorB);
5885 tet_printf("Actor C added to different parent from A and B \n");
5886 parentB.Add(actorC);
5888 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5889 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5891 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5892 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5894 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5895 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5897 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5898 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5900 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5901 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5903 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5904 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5906 ResetTouchCallbacks();
5908 // Connect ChildOrderChangedSignal
5909 bool orderChangedSignal(false);
5910 Actor orderChangedActor;
5911 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5912 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5914 application.SendNotification();
5915 application.Render();
5917 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5918 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5919 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5921 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5922 // Only top actor will get touched.
5923 actorA.TouchedSignal().Connect(TestTouchCallback);
5924 actorB.TouchedSignal().Connect(TestTouchCallback2);
5925 actorC.TouchedSignal().Connect(TestTouchCallback3);
5927 Dali::Integration::Point point;
5928 point.SetDeviceId(1);
5929 point.SetState(PointState::DOWN);
5930 point.SetScreenPosition(Vector2(10.f, 10.f));
5931 Dali::Integration::TouchEvent touchEvent;
5932 touchEvent.AddPoint(point);
5934 application.ProcessEvent(touchEvent);
5936 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5937 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5938 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5940 ResetTouchCallbacks();
5942 tet_printf("Raise actor A Above Actor C which have different parents\n");
5944 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5945 actorA.RaiseAbove(actorC);
5946 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5948 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5949 application.SendNotification();
5951 application.ProcessEvent(touchEvent); // touch event
5953 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5954 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5955 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5957 ResetTouchCallbacks();
5962 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5964 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
5966 TestApplication application;
5968 Integration::Scene stage(application.GetScene());
5970 Actor actorA = Actor::New();
5971 Actor actorB = Actor::New();
5972 Actor actorC = Actor::New();
5974 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5975 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5977 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5978 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5980 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5981 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5983 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5984 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5986 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5987 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5989 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5990 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5992 ResetTouchCallbacks();
5994 // Connect ChildOrderChangedSignal
5995 bool orderChangedSignal(false);
5996 Actor orderChangedActor;
5997 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5998 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6000 application.SendNotification();
6001 application.Render();
6003 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6004 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6005 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6007 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6008 // Only top actor will get touched.
6009 actorA.TouchedSignal().Connect(TestTouchCallback);
6010 actorB.TouchedSignal().Connect(TestTouchCallback2);
6011 actorC.TouchedSignal().Connect(TestTouchCallback3);
6013 Dali::Integration::Point point;
6014 point.SetDeviceId(1);
6015 point.SetState(PointState::DOWN);
6016 point.SetScreenPosition(Vector2(10.f, 10.f));
6017 Dali::Integration::TouchEvent touchEvent;
6018 touchEvent.AddPoint(point);
6020 tet_printf("Raise actor A Above Actor C which have no parents\n");
6022 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6023 actorA.RaiseAbove(actorC);
6024 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6026 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6027 application.SendNotification();
6029 application.ProcessEvent(touchEvent);
6031 tet_printf("Not parented 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, false, TEST_LOCATION);
6037 ResetTouchCallbacks();
6039 orderChangedSignal = false;
6042 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6044 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6045 actorA.LowerBelow(actorC);
6046 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6048 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6049 application.SendNotification();
6050 application.Render();
6052 application.ProcessEvent(touchEvent);
6054 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6055 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6056 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6057 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6059 ResetTouchCallbacks();
6061 orderChangedSignal = false;
6063 tet_printf("Adding Actor A to stage, will be on top\n");
6066 application.SendNotification();
6067 application.Render();
6069 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6071 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6072 actorB.RaiseAbove(actorC);
6073 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6075 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6076 application.SendNotification();
6078 application.ProcessEvent(touchEvent);
6080 tet_printf("C not parented so RaiseAbove should show no effect\n");
6081 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6082 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6083 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6085 ResetTouchCallbacks();
6087 orderChangedSignal = false;
6089 tet_printf("Lower actor A below Actor C when only A has a parent\n");
6091 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6092 actorA.LowerBelow(actorC);
6093 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6095 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6096 application.SendNotification();
6098 application.ProcessEvent(touchEvent);
6100 tet_printf("C not parented so LowerBelow should show no effect\n");
6101 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6102 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6103 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6105 ResetTouchCallbacks();
6107 orderChangedSignal = false;
6111 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6112 actorA.RaiseAbove(actorC);
6113 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6114 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6116 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6117 application.SendNotification();
6118 application.Render();
6120 application.ProcessEvent(touchEvent);
6122 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6123 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6124 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6125 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6130 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6132 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6134 TestApplication application;
6136 Integration::Scene stage(application.GetScene());
6138 Actor actorA = Actor::New();
6139 Actor actorB = Actor::New();
6140 Actor actorC = Actor::New();
6142 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6143 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6145 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6146 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6148 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6149 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6151 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6152 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6154 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6155 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6157 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6158 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6160 ResetTouchCallbacks();
6162 // Connect ChildOrderChangedSignal
6163 bool orderChangedSignal(false);
6164 Actor orderChangedActor;
6165 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6166 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6168 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6169 // Only top actor will get touched.
6170 actorA.TouchedSignal().Connect(TestTouchCallback);
6171 actorB.TouchedSignal().Connect(TestTouchCallback2);
6172 actorC.TouchedSignal().Connect(TestTouchCallback3);
6174 Dali::Integration::Point point;
6175 point.SetDeviceId(1);
6176 point.SetState(PointState::DOWN);
6177 point.SetScreenPosition(Vector2(10.f, 10.f));
6178 Dali::Integration::TouchEvent touchEvent;
6179 touchEvent.AddPoint(point);
6182 tet_printf("Raise actor B Above Actor C but B not parented\n");
6184 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6186 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6188 application.SendNotification();
6189 application.Render();
6191 application.ProcessEvent(touchEvent);
6193 tet_printf("Not parented so RaiseAbove should show no effect\n");
6195 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6196 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6197 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6199 tet_printf("Raise actor B Above Actor C but B not parented\n");
6200 ResetTouchCallbacks();
6202 orderChangedSignal = false;
6204 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6206 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6208 // Sort actor tree before next touch event
6209 application.SendNotification();
6210 application.Render();
6212 application.ProcessEvent(touchEvent);
6214 tet_printf("Not parented so RaiseAbove should show no effect\n");
6216 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6217 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6218 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6219 ResetTouchCallbacks();
6221 orderChangedSignal = false;
6223 tet_printf("Lower actor C below B but C not parented\n");
6225 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6227 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6229 // Sort actor tree before next touch event
6230 application.SendNotification();
6231 application.Render();
6233 application.ProcessEvent(touchEvent);
6235 tet_printf("Not parented so Lower should show no effect\n");
6237 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6238 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6239 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6240 ResetTouchCallbacks();
6242 orderChangedSignal = false;
6244 tet_printf("Raise actor B to top\n");
6246 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6247 actorB.RaiseToTop();
6248 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6250 // Sort actor tree before next touch event
6251 application.SendNotification();
6252 application.Render();
6254 application.ProcessEvent(touchEvent);
6256 tet_printf("Not parented so RaiseToTop should show no effect\n");
6258 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6259 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6260 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6261 ResetTouchCallbacks();
6263 orderChangedSignal = false;
6265 tet_printf("Add ActorB to stage so only Actor C not parented\n");
6269 tet_printf("Lower actor C to Bottom, B stays at top\n");
6271 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6272 actorC.LowerToBottom();
6273 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6275 application.SendNotification();
6276 application.Render();
6278 application.ProcessEvent(touchEvent);
6280 tet_printf("Not parented so LowerToBottom should show no effect\n");
6282 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6283 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6284 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6285 ResetTouchCallbacks();
6290 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6292 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
6294 TestApplication application;
6296 Integration::Scene stage(application.GetScene());
6298 Actor actorA = Actor::New();
6299 Actor actorB = Actor::New();
6300 Actor actorC = Actor::New();
6302 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6303 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6305 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6306 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6308 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6309 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6311 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6312 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6314 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6315 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6317 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6318 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6324 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6325 // Only top actor will get touched.
6326 actorA.TouchedSignal().Connect(TestTouchCallback);
6327 actorB.TouchedSignal().Connect(TestTouchCallback2);
6328 actorC.TouchedSignal().Connect(TestTouchCallback3);
6330 ResetTouchCallbacks();
6332 // Connect ChildOrderChangedSignal
6333 bool orderChangedSignal(false);
6334 Actor orderChangedActor;
6335 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6336 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6338 application.SendNotification();
6339 application.Render();
6341 Dali::Integration::Point point;
6342 point.SetDeviceId(1);
6343 point.SetState(PointState::DOWN);
6344 point.SetScreenPosition(Vector2(10.f, 10.f));
6345 Dali::Integration::TouchEvent touchEvent;
6346 touchEvent.AddPoint(point);
6348 application.ProcessEvent(touchEvent);
6350 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6351 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6352 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6354 ResetTouchCallbacks();
6356 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6358 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6359 actorA.RaiseAbove(actorA);
6360 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6361 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6363 application.SendNotification();
6364 application.Render();
6366 application.ProcessEvent(touchEvent);
6368 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6370 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6371 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6372 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6374 ResetTouchCallbacks();
6376 orderChangedSignal = false;
6378 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6379 actorA.RaiseAbove(actorC);
6380 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6381 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6383 application.SendNotification();
6384 application.Render();
6386 application.ProcessEvent(touchEvent);
6388 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6389 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6390 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6391 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6396 int UtcDaliActorGetScreenPosition(void)
6398 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6400 TestApplication application;
6402 Integration::Scene stage(application.GetScene());
6404 Actor actorA = Actor::New();
6405 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6407 Vector2 size2(10.0f, 20.0f);
6408 actorA.SetProperty(Actor::Property::SIZE, size2);
6410 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6412 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6416 application.SendNotification();
6417 application.Render();
6419 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6420 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6422 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6423 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6425 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6426 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6428 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6430 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6432 application.SendNotification();
6433 application.Render();
6435 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6436 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6438 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6439 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6441 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6442 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6444 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6446 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6448 application.SendNotification();
6449 application.Render();
6451 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6452 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6454 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6455 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6457 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6458 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6460 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6462 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6464 application.SendNotification();
6465 application.Render();
6467 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6468 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6470 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6471 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6473 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6474 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6476 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6478 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6480 application.SendNotification();
6481 application.Render();
6483 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6484 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6486 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6487 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6489 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6490 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6492 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6494 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6495 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6497 Actor actorB = Actor::New();
6498 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6499 actorB.SetProperty(Actor::Property::SIZE, size2);
6500 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6503 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6505 application.SendNotification();
6506 application.Render();
6508 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6510 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6511 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6516 int UtcDaliActorGetScreenPositionAfterScaling(void)
6518 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6520 TestApplication application;
6522 Integration::Scene stage(application.GetScene());
6524 Actor actorA = Actor::New();
6525 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6527 Vector2 size2(10.0f, 20.0f);
6528 actorA.SetProperty(Actor::Property::SIZE, size2);
6529 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6530 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6532 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6536 application.SendNotification();
6537 application.Render();
6539 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6540 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6542 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6543 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6545 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6546 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6548 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6550 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6552 application.SendNotification();
6553 application.Render();
6555 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6556 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6558 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6559 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6561 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6562 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6567 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6569 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6571 TestApplication application;
6573 Integration::Scene stage(application.GetScene());
6575 Actor actorA = Actor::New();
6576 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6577 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6578 Vector2 size2(10.0f, 20.0f);
6579 actorA.SetProperty(Actor::Property::SIZE, size2);
6580 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6582 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6586 application.SendNotification();
6587 application.Render();
6589 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6590 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6592 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6593 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6595 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6596 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6598 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6600 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6601 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6603 application.SendNotification();
6604 application.Render();
6606 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6607 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6609 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6610 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6612 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6613 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6619 int UtcDaliActorGetScreenPositionWithChildActors(void)
6621 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6623 TestApplication application;
6625 Integration::Scene stage(application.GetScene());
6627 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6629 Actor actorA = Actor::New();
6630 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6631 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6632 Vector2 size1(10.0f, 20.0f);
6633 actorA.SetProperty(Actor::Property::SIZE, size1);
6634 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6636 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6638 Actor parentActorA = Actor::New();
6639 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6640 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6641 Vector2 size2(30.0f, 60.0f);
6642 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6643 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6645 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6647 stage.Add(parentActorA);
6648 parentActorA.Add(actorA);
6650 application.SendNotification();
6651 application.Render();
6653 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6654 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6656 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6657 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6659 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6660 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6662 tet_infoline("Test 2\n");
6664 tet_infoline("change parent anchor point and parent origin then check screen position \n");
6666 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6667 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6669 application.SendNotification();
6670 application.Render();
6672 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6673 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6675 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6676 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6678 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6679 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6684 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6686 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6688 TestApplication application;
6690 Integration::Scene stage(application.GetScene());
6692 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6694 Actor actorA = Actor::New();
6695 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6696 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6697 Vector2 size1(10.0f, 20.0f);
6698 actorA.SetProperty(Actor::Property::SIZE, size1);
6699 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6701 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6703 Actor parentActorA = Actor::New();
6704 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6705 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6706 Vector2 size2(30.0f, 60.0f);
6707 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6708 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6710 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6712 Actor grandParentActorA = Actor::New();
6713 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6714 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6715 Vector2 size3(60.0f, 120.0f);
6716 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6717 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6719 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6721 stage.Add(grandParentActorA);
6722 grandParentActorA.Add(parentActorA);
6724 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6726 parentActorA.Add(actorA);
6728 application.SendNotification();
6729 application.Render();
6731 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6732 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6734 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6735 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6737 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6738 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6743 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6745 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6747 TestApplication application;
6749 Integration::Scene stage(application.GetScene());
6751 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6753 Actor actorA = Actor::New();
6754 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6755 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6756 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6757 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6760 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6762 Actor actorB = Actor::New();
6763 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6764 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6765 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6766 Vector2 actorBSize(30.0f, 60.0f);
6767 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6770 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6772 Actor actorC = Actor::New();
6773 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6774 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6775 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6776 Vector2 actorCSize(60.0f, 120.0f);
6777 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6780 application.SendNotification();
6781 application.Render();
6783 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
6785 Vector2 center(stage.GetSize() * 0.5f);
6787 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6788 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6789 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6791 tet_infoline("Add scale to all actors");
6793 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6794 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
6795 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
6797 application.SendNotification();
6798 application.Render();
6800 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
6801 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
6802 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
6807 int utcDaliActorPositionUsesAnchorPoint(void)
6809 TestApplication application;
6810 tet_infoline("Check default behaviour\n");
6812 Actor actor = Actor::New();
6813 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6814 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6815 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6816 application.GetScene().Add(actor);
6818 application.SendNotification();
6819 application.Render();
6821 tet_infoline("Check that the world position is in the center\n");
6822 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6824 tet_infoline("Set the position uses anchor point property to false\n");
6825 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6827 application.SendNotification();
6828 application.Render();
6830 tet_infoline("Check that the world position has changed appropriately\n");
6831 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6836 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6838 TestApplication application;
6839 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6841 Actor actor = Actor::New();
6842 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6843 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6844 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6845 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6846 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6847 application.GetScene().Add(actor);
6849 application.SendNotification();
6850 application.Render();
6852 tet_infoline("Check the world position is the same as it would be without a scale\n");
6853 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6855 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6856 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6857 application.SendNotification();
6858 application.Render();
6859 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
6861 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6862 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6863 application.SendNotification();
6864 application.Render();
6865 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6870 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6872 TestApplication application;
6873 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6875 Actor actor = Actor::New();
6876 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6877 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6878 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6879 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6880 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6881 application.GetScene().Add(actor);
6883 application.SendNotification();
6884 application.Render();
6886 tet_infoline("Check the world position is the same as it would be without a rotation\n");
6887 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6889 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6890 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6891 application.SendNotification();
6892 application.Render();
6893 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
6895 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6896 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6897 application.SendNotification();
6898 application.Render();
6899 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
6904 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6906 TestApplication application;
6907 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6909 Actor actor = Actor::New();
6910 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6911 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6912 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6913 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6914 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6915 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6916 application.GetScene().Add(actor);
6918 application.SendNotification();
6919 application.Render();
6921 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
6922 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6924 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6925 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6926 application.SendNotification();
6927 application.Render();
6928 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
6930 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6931 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6932 application.SendNotification();
6933 application.Render();
6934 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
6939 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6941 TestApplication application;
6942 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6944 Actor parent = Actor::New();
6946 application.GetScene().Add(parent);
6947 Vector2 stageSize(application.GetScene().GetSize());
6949 Actor actor = Actor::New();
6950 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6951 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6952 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6953 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
6954 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
6955 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6958 application.SendNotification();
6959 application.Render();
6961 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
6963 tet_infoline("Check the world position is in the right place\n");
6964 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6966 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
6967 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6968 application.SendNotification();
6969 application.Render();
6970 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6972 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
6973 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6974 application.SendNotification();
6975 application.Render();
6976 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6981 int utcDaliActorVisibilityChangeSignalSelf(void)
6983 TestApplication application;
6984 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
6986 Actor actor = Actor::New();
6988 VisibilityChangedFunctorData data;
6989 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
6991 actor.SetProperty(Actor::Property::VISIBLE, false);
6993 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
6995 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
6998 actor.SetProperty(Actor::Property::VISIBLE, false);
6999 data.Check(false /* not called */, TEST_LOCATION);
7001 tet_infoline("Change the visibility using properties, ensure called");
7004 actor.SetProperty(Actor::Property::VISIBLE, true);
7005 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7007 tet_infoline("Set the visibility to current using properties, ensure not called");
7010 actor.SetProperty(Actor::Property::VISIBLE, true);
7011 data.Check(false /* not called */, TEST_LOCATION);
7016 int utcDaliActorVisibilityChangeSignalChildren(void)
7018 TestApplication application;
7019 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7021 Actor parent = Actor::New();
7022 Actor child = Actor::New();
7025 Actor grandChild = Actor::New();
7026 child.Add(grandChild);
7028 VisibilityChangedFunctorData parentData;
7029 VisibilityChangedFunctorData childData;
7030 VisibilityChangedFunctorData grandChildData;
7032 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7033 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7034 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7036 parent.SetProperty(Actor::Property::VISIBLE, false);
7037 parentData.Check(false /* not called */, TEST_LOCATION);
7038 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7039 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7041 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7044 grandChildData.Reset();
7046 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7048 parent.SetProperty(Actor::Property::VISIBLE, true);
7049 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7050 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7051 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7053 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7056 grandChildData.Reset();
7058 parent.SetProperty(Actor::Property::VISIBLE, true);
7059 parentData.Check(false /* not called */, TEST_LOCATION);
7060 childData.Check(false /* not called */, TEST_LOCATION);
7061 grandChildData.Check(false /* not called */, TEST_LOCATION);
7066 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7068 TestApplication application;
7069 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7071 Actor actor = Actor::New();
7072 application.GetScene().Add(actor);
7074 application.SendNotification();
7075 application.Render();
7077 VisibilityChangedFunctorData data;
7078 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7080 Animation animation = Animation::New(1.0f);
7081 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7083 data.Check(false, TEST_LOCATION);
7084 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7085 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7087 tet_infoline("Play the animation and check the property value");
7090 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7091 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7093 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7094 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7096 application.SendNotification();
7097 application.Render(1100); // After the animation
7099 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7104 int utcDaliActorVisibilityChangeSignalByName(void)
7106 TestApplication application;
7107 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7109 Actor actor = Actor::New();
7111 bool signalCalled = false;
7112 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7113 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7114 actor.SetProperty(Actor::Property::VISIBLE, false);
7115 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7117 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7118 signalCalled = false;
7119 actor.SetProperty(Actor::Property::VISIBLE, false);
7120 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7122 tet_infoline("Change the visibility using properties, ensure called");
7123 actor.SetProperty(Actor::Property::VISIBLE, true);
7124 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7126 tet_infoline("Set the visibility to current using properties, ensure not called");
7127 signalCalled = false;
7129 actor.SetProperty(Actor::Property::VISIBLE, true);
7130 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7135 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7137 gLayoutDirectionType = type;
7140 int UtcDaliActorLayoutDirectionProperty(void)
7142 TestApplication application;
7143 tet_infoline("Check layout direction property");
7145 Actor actor0 = Actor::New();
7146 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7147 application.GetScene().Add(actor0);
7149 application.SendNotification();
7150 application.Render();
7152 Actor actor1 = Actor::New();
7153 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7154 Actor actor2 = Actor::New();
7155 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7156 Actor actor3 = Actor::New();
7157 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7158 Actor actor4 = Actor::New();
7159 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7160 Actor actor5 = Actor::New();
7161 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7162 Actor actor6 = Actor::New();
7163 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7164 Actor actor7 = Actor::New();
7165 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7166 Actor actor8 = Actor::New();
7167 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7168 Actor actor9 = Actor::New();
7169 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7172 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7173 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7175 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7176 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7177 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7179 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7180 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7181 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7183 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7185 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7186 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7188 application.GetScene().Add(actor3);
7195 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7196 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7198 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7199 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7200 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7202 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7204 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7205 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7206 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7207 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7208 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7209 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7210 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7212 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7213 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7214 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7216 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7217 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7218 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7219 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7221 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7222 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7223 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7228 struct LayoutDirectionFunctor
7230 LayoutDirectionFunctor(bool& signalCalled)
7231 : mSignalCalled(signalCalled)
7235 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7236 : mSignalCalled(rhs.mSignalCalled)
7242 mSignalCalled = true;
7245 bool& mSignalCalled;
7248 int UtcDaliActorLayoutDirectionSignal(void)
7250 TestApplication application;
7251 tet_infoline("Check changing layout direction property sends a signal");
7253 Actor actor = Actor::New();
7254 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7255 application.GetScene().Add(actor);
7256 bool signalCalled = false;
7257 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7259 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7260 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7262 // Test that writing the same value doesn't send a signal
7263 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7264 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7266 // Test that writing a different value sends the signal
7267 signalCalled = false;
7268 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7269 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7271 signalCalled = false;
7272 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7273 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7278 struct ChildAddedSignalCheck
7280 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7281 : mSignalReceived(signalReceived),
7282 mChildHandle(childHandle)
7286 void operator()(Actor childHandle)
7288 mSignalReceived = true;
7289 mChildHandle = childHandle;
7293 mSignalReceived = true;
7294 mChildHandle = Actor();
7297 bool& mSignalReceived;
7298 Actor& mChildHandle;
7301 int UtcDaliChildAddedSignalP1(void)
7303 TestApplication application;
7304 auto stage = application.GetScene();
7306 bool signalReceived = false;
7309 ChildAddedSignalCheck signal(signalReceived, childActor);
7310 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7311 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7313 auto actorA = Actor::New();
7315 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7316 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7317 signalReceived = false;
7319 auto actorB = Actor::New();
7321 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7322 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7327 int UtcDaliChildAddedSignalP2(void)
7329 TestApplication application;
7330 auto stage = application.GetScene();
7332 bool signalReceived = false;
7335 ChildAddedSignalCheck signal(signalReceived, childActor);
7336 tet_infoline("Connect to childAdded signal by name");
7338 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7339 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7341 auto actorA = Actor::New();
7343 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7345 // Can't test which actor was added; signal signature is void() when connecting via name.
7346 signalReceived = false;
7348 auto actorB = Actor::New();
7350 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7355 int UtcDaliChildAddedSignalN(void)
7357 TestApplication application;
7358 auto stage = application.GetScene();
7360 bool signalReceived = false;
7363 ChildAddedSignalCheck signal(signalReceived, childActor);
7364 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7365 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7367 auto actorA = Actor::New();
7369 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7370 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7371 signalReceived = false;
7373 auto actorB = Actor::New();
7375 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7379 struct ChildRemovedSignalCheck
7381 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7382 : mSignalReceived(signalReceived),
7383 mChildHandle(childHandle)
7387 void operator()(Actor childHandle)
7389 mSignalReceived = true;
7390 mChildHandle = childHandle;
7395 mSignalReceived = true;
7398 bool& mSignalReceived;
7399 Actor& mChildHandle;
7402 int UtcDaliChildRemovedSignalP1(void)
7404 TestApplication application;
7405 auto stage = application.GetScene();
7407 bool signalReceived = false;
7410 ChildRemovedSignalCheck signal(signalReceived, childActor);
7411 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7412 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7414 auto actorA = Actor::New();
7416 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7417 DALI_TEST_CHECK(!childActor);
7419 stage.Remove(actorA);
7420 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7421 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7423 signalReceived = false;
7424 auto actorB = Actor::New();
7426 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7428 stage.Remove(actorB);
7429 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7430 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7435 int UtcDaliChildRemovedSignalP2(void)
7437 TestApplication application;
7438 auto stage = application.GetScene();
7440 bool signalReceived = false;
7443 ChildAddedSignalCheck signal(signalReceived, childActor);
7444 tet_infoline("Connect to childRemoved signal by name");
7446 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7447 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7449 auto actorA = Actor::New();
7451 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7453 stage.Remove(actorA);
7454 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7456 signalReceived = false;
7457 auto actorB = Actor::New();
7459 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7461 stage.Remove(actorB);
7462 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7467 int UtcDaliChildRemovedSignalN(void)
7469 TestApplication application;
7470 auto stage = application.GetScene();
7472 bool signalReceived = false;
7475 ChildRemovedSignalCheck signal(signalReceived, childActor);
7476 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7477 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7479 auto actorA = Actor::New();
7482 auto actorB = Actor::New();
7485 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7486 DALI_TEST_CHECK(!childActor);
7488 actorA.Remove(actorB);
7489 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7493 int UtcDaliChildMovedSignalP(void)
7495 TestApplication application;
7496 auto stage = application.GetScene();
7498 bool addedASignalReceived = false;
7499 bool removedASignalReceived = false;
7500 bool addedBSignalReceived = false;
7501 bool removedBSignalReceived = false;
7504 auto actorA = Actor::New();
7505 auto actorB = Actor::New();
7509 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
7510 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7511 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
7512 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7514 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7515 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7516 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7517 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7519 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7520 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7521 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7522 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7524 // Create a child of A
7526 auto child = Actor::New();
7529 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7530 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7531 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7532 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7533 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7536 addedASignalReceived = false;
7537 addedBSignalReceived = false;
7538 removedASignalReceived = false;
7539 removedBSignalReceived = false;
7541 actorB.Add(child); // Expect this child to be re-parented
7542 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7543 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7544 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7545 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7547 // Move child back to A:
7548 addedASignalReceived = false;
7549 addedBSignalReceived = false;
7550 removedASignalReceived = false;
7551 removedBSignalReceived = false;
7553 actorA.Add(child); // Expect this child to be re-parented
7554 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7555 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7556 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7557 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7562 int utcDaliActorCulled(void)
7564 TestApplication application;
7565 auto stage = application.GetScene();
7567 tet_infoline("Check that the actor is culled if the actor is out of the screen");
7569 Actor actor = Actor::New();
7570 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7572 Geometry geometry = CreateQuadGeometry();
7573 Shader shader = CreateShader();
7574 Renderer renderer = Renderer::New(geometry, shader);
7575 actor.AddRenderer(renderer);
7579 application.SendNotification();
7580 application.Render(0);
7582 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7584 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7585 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7587 // Connect NotifySignal
7588 bool propertyNotificationSignal(false);
7589 PropertyNotification source;
7590 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7591 notification.NotifySignal().Connect(&application, f);
7593 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7595 application.SendNotification();
7596 application.Render();
7598 application.SendNotification();
7600 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7602 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7603 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7604 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7609 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7611 TestApplication application;
7612 auto stage = application.GetScene();
7614 tet_infoline("Ensure we clear the screen when the last actor is removed");
7616 Actor actor = CreateRenderableActor();
7617 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7620 application.SendNotification();
7621 application.Render();
7623 auto& glAbstraction = application.GetGlAbstraction();
7624 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7628 application.SendNotification();
7629 application.Render();
7631 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7636 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7638 TestApplication application;
7639 auto stage = application.GetScene();
7641 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7643 Actor actor = CreateRenderableActor();
7644 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7647 application.SendNotification();
7648 application.Render();
7650 auto& glAbstraction = application.GetGlAbstraction();
7651 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7653 actor.SetProperty(Actor::Property::VISIBLE, false);
7655 application.SendNotification();
7656 application.Render();
7658 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7663 int utcDaliActorGetSizeAfterAnimation(void)
7665 TestApplication application;
7666 tet_infoline("Check the actor size before / after an animation is finished");
7668 Vector3 actorSize(100.0f, 100.0f, 0.0f);
7670 Actor actor = Actor::New();
7671 actor.SetProperty(Actor::Property::SIZE, actorSize);
7672 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7673 application.GetScene().Add(actor);
7675 // Size should be updated without rendering.
7676 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7677 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7679 application.SendNotification();
7680 application.Render();
7682 // Size and current size should be updated.
7683 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7684 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7685 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7686 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7687 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7689 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7690 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7691 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7692 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7693 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7696 actorSize = Vector3(200.0f, 200.0f, 0.0f);
7697 actor.SetProperty(Actor::Property::SIZE, actorSize);
7699 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7700 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7702 Vector3 targetValue(10.0f, 20.0f, 0.0f);
7704 Animation animation = Animation::New(1.0f);
7705 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7708 // Size should be updated without rendering.
7709 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7710 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7712 application.SendNotification();
7713 application.Render(1100); // After the animation
7715 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7716 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7717 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7718 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7719 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7721 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7722 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7723 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7724 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7725 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7727 targetValue.width = 50.0f;
7730 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
7733 application.SendNotification();
7734 application.Render(1100); // After the animation
7736 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7737 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7738 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7739 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7740 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7742 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7743 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7744 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7745 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7746 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7748 targetValue.height = 70.0f;
7751 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
7754 application.SendNotification();
7755 application.Render(1100); // After the animation
7757 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7758 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7759 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7760 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7761 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7763 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7764 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7765 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7766 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7767 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7769 Vector3 offset(10.0f, 20.0f, 0.0f);
7772 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
7775 application.SendNotification();
7776 application.Render(1100); // After the animation
7778 targetValue += offset;
7780 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7781 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7782 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7783 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7784 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7786 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7787 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7788 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7789 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7790 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7792 offset.width = 20.0f;
7795 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
7798 application.SendNotification();
7799 application.Render(1100); // After the animation
7801 targetValue.width += offset.width;
7803 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7804 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7805 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7806 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7807 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7809 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7810 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7811 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7812 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7813 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7815 offset.height = 10.0f;
7818 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
7821 application.SendNotification();
7822 application.Render(1100); // After the animation
7824 targetValue.height += offset.height;
7826 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7827 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7828 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7829 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7830 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7832 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7833 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7834 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7835 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7836 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7839 actorSize = Vector3(300.0f, 300.0f, 0.0f);
7841 actor.SetProperty(Actor::Property::SIZE, actorSize);
7843 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7844 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7846 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7847 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7849 application.SendNotification();
7850 application.Render();
7852 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7853 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7855 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7856 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7861 int utcDaliActorPartialUpdate(void)
7863 TestApplication application(
7864 TestApplication::DEFAULT_SURFACE_WIDTH,
7865 TestApplication::DEFAULT_SURFACE_HEIGHT,
7866 TestApplication::DEFAULT_HORIZONTAL_DPI,
7867 TestApplication::DEFAULT_VERTICAL_DPI,
7871 tet_infoline("Check the damaged area");
7873 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7875 std::vector<Rect<int>> damagedRects;
7876 Rect<int> clippingRect;
7877 application.SendNotification();
7878 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7880 // First render pass, nothing to render, adaptor would just do swap buffer.
7881 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7882 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7884 Actor actor = CreateRenderableActor();
7885 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7886 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7887 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7888 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7889 application.GetScene().Add(actor);
7891 application.SendNotification();
7893 // 1. Actor added, damaged rect is added size of actor
7894 damagedRects.clear();
7895 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7896 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7899 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7900 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7901 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7902 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7903 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7904 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7905 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7908 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7909 application.SendNotification();
7911 damagedRects.clear();
7912 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7913 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7916 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7917 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7918 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7919 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7920 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7921 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7922 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7924 // 3. Set new position
7925 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7926 application.SendNotification();
7928 damagedRects.clear();
7929 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7930 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7933 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7934 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7935 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7936 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7937 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7938 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7939 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7941 application.GetScene().Remove(actor);
7942 application.SendNotification();
7944 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7945 damagedRects.clear();
7946 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7947 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7949 clippingRect = damagedRects[0];
7950 clippingRect.Merge(damagedRects[1]);
7951 clippingRect.Merge(damagedRects[2]);
7953 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7954 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7955 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7957 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7958 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7959 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7960 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7961 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7966 int utcDaliActorPartialUpdateSetColor(void)
7968 TestApplication application(
7969 TestApplication::DEFAULT_SURFACE_WIDTH,
7970 TestApplication::DEFAULT_SURFACE_HEIGHT,
7971 TestApplication::DEFAULT_HORIZONTAL_DPI,
7972 TestApplication::DEFAULT_VERTICAL_DPI,
7976 tet_infoline("Check uniform update");
7978 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7980 std::vector<Rect<int>> damagedRects;
7981 Rect<int> clippingRect;
7982 application.SendNotification();
7983 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7985 // First render pass, nothing to render, adaptor would just do swap buffer.
7986 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7987 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7989 Actor actor = CreateRenderableActor();
7990 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7991 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7992 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7993 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7994 application.GetScene().Add(actor);
7996 application.SendNotification();
7998 // 1. Actor added, damaged rect is added size of actor
7999 damagedRects.clear();
8000 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8001 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8004 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8005 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8006 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8007 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8008 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8009 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8010 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8012 damagedRects.clear();
8013 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8015 damagedRects.clear();
8016 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8019 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8020 application.SendNotification();
8022 damagedRects.clear();
8023 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8024 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8027 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8028 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8029 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8030 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8031 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8032 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8033 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8038 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8039 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8040 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8041 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8042 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8043 " uniform mediump mat4 uLightCameraViewMatrix;\n"
8047 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8048 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
8049 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8052 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8053 "uniform lowp vec4 uShadowColor;\n"
8056 " lowp float alpha;\n"
8057 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8058 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8061 int utcDaliActorPartialUpdateSetProperty(void)
8063 TestApplication application(
8064 TestApplication::DEFAULT_SURFACE_WIDTH,
8065 TestApplication::DEFAULT_SURFACE_HEIGHT,
8066 TestApplication::DEFAULT_HORIZONTAL_DPI,
8067 TestApplication::DEFAULT_VERTICAL_DPI,
8071 tet_infoline("Set/Update property with partial update");
8073 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8075 std::vector<Rect<int>> damagedRects;
8076 Rect<int> clippingRect;
8077 application.SendNotification();
8078 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8080 // First render pass, nothing to render, adaptor would just do swap buffer.
8081 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8082 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8084 Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8085 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8086 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8087 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8088 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8089 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8090 application.GetScene().Add(actor);
8092 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8094 damagedRects.clear();
8095 application.SendNotification();
8096 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8097 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8100 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8101 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8102 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8103 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8104 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8105 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8106 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8108 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8109 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8111 damagedRects.clear();
8112 application.SendNotification();
8113 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8114 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8116 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8117 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8118 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8119 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8120 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8121 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8123 damagedRects.clear();
8124 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8125 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8127 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8128 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8129 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8130 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8131 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8132 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8134 damagedRects.clear();
8135 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8136 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8141 int utcDaliActorPartialUpdateTwoActors(void)
8143 TestApplication application(
8144 TestApplication::DEFAULT_SURFACE_WIDTH,
8145 TestApplication::DEFAULT_SURFACE_HEIGHT,
8146 TestApplication::DEFAULT_HORIZONTAL_DPI,
8147 TestApplication::DEFAULT_VERTICAL_DPI,
8151 tet_infoline("Check the damaged rects with partial update and two actors");
8153 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8155 Actor actor = CreateRenderableActor();
8156 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8157 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8158 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8159 application.GetScene().Add(actor);
8161 Actor actor2 = CreateRenderableActor();
8162 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8163 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8164 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8165 application.GetScene().Add(actor2);
8167 application.SendNotification();
8168 std::vector<Rect<int>> damagedRects;
8169 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8171 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8172 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8173 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8175 // in screen coordinates, adaptor would calculate it using previous frames information
8176 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8177 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8179 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8180 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8181 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8182 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8187 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8189 TestApplication application(
8190 TestApplication::DEFAULT_SURFACE_WIDTH,
8191 TestApplication::DEFAULT_SURFACE_HEIGHT,
8192 TestApplication::DEFAULT_HORIZONTAL_DPI,
8193 TestApplication::DEFAULT_VERTICAL_DPI,
8197 tet_infoline("Check the damaged rect with partial update and actor size hint");
8199 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8201 Actor actor = CreateRenderableActor();
8202 actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f));
8203 actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f));
8204 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0));
8205 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8206 application.GetScene().Add(actor);
8208 application.SendNotification();
8209 std::vector<Rect<int>> damagedRects;
8210 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8212 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8214 Rect<int> clippingRect = Rect<int>(0, 496, 160, 320);
8215 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8217 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8219 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8220 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8221 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8222 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8227 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
8229 TestApplication application;
8231 Actor actor = Actor::New();
8232 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
8233 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
8234 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
8235 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
8236 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
8237 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8238 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8239 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
8243 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
8245 TestApplication application;
8247 Actor actor = Actor::New();
8249 // Make sure setting invalid types does not cause a crash
8252 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
8253 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
8254 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
8255 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
8256 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
8257 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
8258 tet_result(TET_PASS);
8262 tet_result(TET_FAIL);
8267 int UtcDaliActorTouchAreaPropertyP(void)
8269 TestApplication application;
8271 Actor actor = Actor::New();
8272 Vector2 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
8273 DALI_TEST_EQUALS(touchArea, Vector2::ZERO, TEST_LOCATION);
8274 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(10.f, 10.f));
8275 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
8276 DALI_TEST_EQUALS(touchArea, Vector2(10.f, 10.f), TEST_LOCATION);
8280 int UtcDaliActorTouchAreaPropertyN(void)
8282 TestApplication application;
8284 Actor actor = Actor::New();
8286 // Make sure setting invalid types does not cause a crash
8289 actor.SetProperty(DevelActor::Property::TOUCH_AREA, 1.0f);
8290 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2::ONE);
8291 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector3::ONE);
8292 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector4::ONE);
8293 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Map());
8294 actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Array());
8295 tet_result(TET_PASS);
8299 tet_result(TET_FAIL);
8304 int UtcDaliActorLowerBelowNegative(void)
8306 TestApplication application;
8307 Dali::Actor instance;
8311 instance.LowerBelow(arg1);
8312 DALI_TEST_CHECK(false); // Should not get here
8316 DALI_TEST_CHECK(true); // We expect an assert
8321 int UtcDaliActorRaiseAboveNegative(void)
8323 TestApplication application;
8324 Dali::Actor instance;
8328 instance.RaiseAbove(arg1);
8329 DALI_TEST_CHECK(false); // Should not get here
8333 DALI_TEST_CHECK(true); // We expect an assert
8338 int UtcDaliActorRaiseToTopNegative(void)
8340 TestApplication application;
8341 Dali::Actor instance;
8344 instance.RaiseToTop();
8345 DALI_TEST_CHECK(false); // Should not get here
8349 DALI_TEST_CHECK(true); // We expect an assert
8354 int UtcDaliActorAddRendererNegative(void)
8356 TestApplication application;
8357 Dali::Actor instance;
8360 Dali::Renderer arg1;
8361 instance.AddRenderer(arg1);
8362 DALI_TEST_CHECK(false); // Should not get here
8366 DALI_TEST_CHECK(true); // We expect an assert
8371 int UtcDaliActorTouchedSignalNegative(void)
8373 TestApplication application;
8374 Dali::Actor instance;
8377 instance.TouchedSignal();
8378 DALI_TEST_CHECK(false); // Should not get here
8382 DALI_TEST_CHECK(true); // We expect an assert
8387 int UtcDaliActorTranslateByNegative(void)
8389 TestApplication application;
8390 Dali::Actor instance;
8394 instance.TranslateBy(arg1);
8395 DALI_TEST_CHECK(false); // Should not get here
8399 DALI_TEST_CHECK(true); // We expect an assert
8404 int UtcDaliActorFindChildByIdNegative(void)
8406 TestApplication application;
8407 Dali::Actor instance;
8410 unsigned int arg1 = 0u;
8411 instance.FindChildById(arg1);
8412 DALI_TEST_CHECK(false); // Should not get here
8416 DALI_TEST_CHECK(true); // We expect an assert
8421 int UtcDaliActorGetRendererAtNegative(void)
8423 TestApplication application;
8424 Dali::Actor instance;
8427 unsigned int arg1 = 0u;
8428 instance.GetRendererAt(arg1);
8429 DALI_TEST_CHECK(false); // Should not get here
8433 DALI_TEST_CHECK(true); // We expect an assert
8438 int UtcDaliActorHoveredSignalNegative(void)
8440 TestApplication application;
8441 Dali::Actor instance;
8444 instance.HoveredSignal();
8445 DALI_TEST_CHECK(false); // Should not get here
8449 DALI_TEST_CHECK(true); // We expect an assert
8454 int UtcDaliActorLowerToBottomNegative(void)
8456 TestApplication application;
8457 Dali::Actor instance;
8460 instance.LowerToBottom();
8461 DALI_TEST_CHECK(false); // Should not get here
8465 DALI_TEST_CHECK(true); // We expect an assert
8470 int UtcDaliActorOnSceneSignalNegative(void)
8472 TestApplication application;
8473 Dali::Actor instance;
8476 instance.OnSceneSignal();
8477 DALI_TEST_CHECK(false); // Should not get here
8481 DALI_TEST_CHECK(true); // We expect an assert
8486 int UtcDaliActorOffSceneSignalNegative(void)
8488 TestApplication application;
8489 Dali::Actor instance;
8492 instance.OffSceneSignal();
8493 DALI_TEST_CHECK(false); // Should not get here
8497 DALI_TEST_CHECK(true); // We expect an assert
8502 int UtcDaliActorRemoveRendererNegative01(void)
8504 TestApplication application;
8505 Dali::Actor instance;
8508 unsigned int arg1 = 0u;
8509 instance.RemoveRenderer(arg1);
8510 DALI_TEST_CHECK(false); // Should not get here
8514 DALI_TEST_CHECK(true); // We expect an assert
8519 int UtcDaliActorRemoveRendererNegative02(void)
8521 TestApplication application;
8522 Dali::Actor instance;
8525 Dali::Renderer arg1;
8526 instance.RemoveRenderer(arg1);
8527 DALI_TEST_CHECK(false); // Should not get here
8531 DALI_TEST_CHECK(true); // We expect an assert
8536 int UtcDaliActorFindChildByNameNegative(void)
8538 TestApplication application;
8539 Dali::Actor instance;
8543 instance.FindChildByName(arg1);
8544 DALI_TEST_CHECK(false); // Should not get here
8548 DALI_TEST_CHECK(true); // We expect an assert
8553 int UtcDaliActorSetResizePolicyNegative(void)
8555 TestApplication application;
8556 Dali::Actor instance;
8559 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
8560 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
8561 instance.SetResizePolicy(arg1, arg2);
8562 DALI_TEST_CHECK(false); // Should not get here
8566 DALI_TEST_CHECK(true); // We expect an assert
8571 int UtcDaliActorOnRelayoutSignalNegative(void)
8573 TestApplication application;
8574 Dali::Actor instance;
8577 instance.OnRelayoutSignal();
8578 DALI_TEST_CHECK(false); // Should not get here
8582 DALI_TEST_CHECK(true); // We expect an assert
8587 int UtcDaliActorWheelEventSignalNegative(void)
8589 TestApplication application;
8590 Dali::Actor instance;
8593 instance.WheelEventSignal();
8594 DALI_TEST_CHECK(false); // Should not get here
8598 DALI_TEST_CHECK(true); // We expect an assert
8603 int UtcDaliActorGetHeightForWidthNegative(void)
8605 TestApplication application;
8606 Dali::Actor instance;
8610 instance.GetHeightForWidth(arg1);
8611 DALI_TEST_CHECK(false); // Should not get here
8615 DALI_TEST_CHECK(true); // We expect an assert
8620 int UtcDaliActorGetWidthForHeightNegative(void)
8622 TestApplication application;
8623 Dali::Actor instance;
8627 instance.GetWidthForHeight(arg1);
8628 DALI_TEST_CHECK(false); // Should not get here
8632 DALI_TEST_CHECK(true); // We expect an assert
8637 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
8639 TestApplication application;
8640 Dali::Actor instance;
8643 instance.LayoutDirectionChangedSignal();
8644 DALI_TEST_CHECK(false); // Should not get here
8648 DALI_TEST_CHECK(true); // We expect an assert
8653 int UtcDaliActorAddNegative(void)
8655 TestApplication application;
8656 Dali::Actor instance;
8661 DALI_TEST_CHECK(false); // Should not get here
8665 DALI_TEST_CHECK(true); // We expect an assert
8670 int UtcDaliActorLowerNegative(void)
8672 TestApplication application;
8673 Dali::Actor instance;
8677 DALI_TEST_CHECK(false); // Should not get here
8681 DALI_TEST_CHECK(true); // We expect an assert
8686 int UtcDaliActorRaiseNegative(void)
8688 TestApplication application;
8689 Dali::Actor instance;
8693 DALI_TEST_CHECK(false); // Should not get here
8697 DALI_TEST_CHECK(true); // We expect an assert
8702 int UtcDaliActorRemoveNegative(void)
8704 TestApplication application;
8705 Dali::Actor instance;
8709 instance.Remove(arg1);
8710 DALI_TEST_CHECK(false); // Should not get here
8714 DALI_TEST_CHECK(true); // We expect an assert
8719 int UtcDaliActorScaleByNegative(void)
8721 TestApplication application;
8722 Dali::Actor instance;
8726 instance.ScaleBy(arg1);
8727 DALI_TEST_CHECK(false); // Should not get here
8731 DALI_TEST_CHECK(true); // We expect an assert
8736 int UtcDaliActorGetLayerNegative(void)
8738 TestApplication application;
8739 Dali::Actor instance;
8742 instance.GetLayer();
8743 DALI_TEST_CHECK(false); // Should not get here
8747 DALI_TEST_CHECK(true); // We expect an assert
8752 int UtcDaliActorRotateByNegative01(void)
8754 TestApplication application;
8755 Dali::Actor instance;
8758 Dali::Quaternion arg1;
8759 instance.RotateBy(arg1);
8760 DALI_TEST_CHECK(false); // Should not get here
8764 DALI_TEST_CHECK(true); // We expect an assert
8769 int UtcDaliActorRotateByNegative02(void)
8771 TestApplication application;
8772 Dali::Actor instance;
8777 instance.RotateBy(arg1, arg2);
8778 DALI_TEST_CHECK(false); // Should not get here
8782 DALI_TEST_CHECK(true); // We expect an assert
8787 int UtcDaliActorUnparentNegative(void)
8789 TestApplication application;
8790 Dali::Actor instance;
8793 instance.Unparent();
8794 DALI_TEST_CHECK(false); // Should not get here
8798 DALI_TEST_CHECK(true); // We expect an assert
8803 int UtcDaliActorGetChildAtNegative(void)
8805 TestApplication application;
8806 Dali::Actor instance;
8809 unsigned int arg1 = 0u;
8810 instance.GetChildAt(arg1);
8811 DALI_TEST_CHECK(false); // Should not get here
8815 DALI_TEST_CHECK(true); // We expect an assert
8820 int UtcDaliActorGetChildCountNegative(void)
8822 TestApplication application;
8823 Dali::Actor instance;
8826 instance.GetChildCount();
8827 DALI_TEST_CHECK(false); // Should not get here
8831 DALI_TEST_CHECK(true); // We expect an assert
8836 int UtcDaliActorGetTargetSizeNegative(void)
8838 TestApplication application;
8839 Dali::Actor instance;
8842 instance.GetTargetSize();
8843 DALI_TEST_CHECK(false); // Should not get here
8847 DALI_TEST_CHECK(true); // We expect an assert
8852 int UtcDaliActorScreenToLocalNegative(void)
8854 TestApplication application;
8855 Dali::Actor instance;
8862 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
8863 DALI_TEST_CHECK(false); // Should not get here
8867 DALI_TEST_CHECK(true); // We expect an assert
8872 int UtcDaliActorGetNaturalSizeNegative(void)
8874 TestApplication application;
8875 Dali::Actor instance;
8878 instance.GetNaturalSize();
8879 DALI_TEST_CHECK(false); // Should not get here
8883 DALI_TEST_CHECK(true); // We expect an assert
8888 int UtcDaliActorGetRelayoutSizeNegative(void)
8890 TestApplication application;
8891 Dali::Actor instance;
8894 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
8895 instance.GetRelayoutSize(arg1);
8896 DALI_TEST_CHECK(false); // Should not get here
8900 DALI_TEST_CHECK(true); // We expect an assert
8905 int UtcDaliActorGetResizePolicyNegative(void)
8907 TestApplication application;
8908 Dali::Actor instance;
8911 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
8912 instance.GetResizePolicy(arg1);
8913 DALI_TEST_CHECK(false); // Should not get here
8917 DALI_TEST_CHECK(true); // We expect an assert
8922 int UtcDaliActorGetRendererCountNegative(void)
8924 TestApplication application;
8925 Dali::Actor instance;
8928 instance.GetRendererCount();
8929 DALI_TEST_CHECK(false); // Should not get here
8933 DALI_TEST_CHECK(true); // We expect an assert
8938 int UtcDaliActorGetParentNegative(void)
8940 TestApplication application;
8941 Dali::Actor instance;
8944 instance.GetParent();
8945 DALI_TEST_CHECK(false); // Should not get here
8949 DALI_TEST_CHECK(true); // We expect an assert
8954 int UtcDaliActorPropertyBlendEquation(void)
8956 TestApplication application;
8958 tet_infoline("Test SetProperty AdvancedBlendEquation");
8960 Geometry geometry = CreateQuadGeometry();
8961 Shader shader = CreateShader();
8962 Renderer renderer1 = Renderer::New( geometry, shader );
8964 Actor actor = Actor::New();
8965 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
8967 actor.AddRenderer(renderer1);
8968 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
8969 application.GetScene().Add(actor);
8971 if( !Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
8973 actor.SetProperty( Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN );
8974 int equation = actor.GetProperty<int>( Dali::DevelActor::Property::BLEND_EQUATION );
8975 DALI_TEST_EQUALS( ( Dali::DevelBlendEquation::SCREEN == equation ), false, TEST_LOCATION );
8978 if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
8980 actor.SetProperty( Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN );
8981 int equation = actor.GetProperty<int>( Dali::DevelActor::Property::BLEND_EQUATION );
8982 DALI_TEST_EQUALS( ( Dali::DevelBlendEquation::SCREEN == equation ), true, TEST_LOCATION );
8985 Renderer renderer2 = Renderer::New( geometry, shader );
8986 actor.AddRenderer(renderer2);
8991 int UtcDaliActorRegisterProperty(void)
8993 tet_infoline("Test property registration and uniform map update\n");
8995 TestApplication application;
8997 Geometry geometry = CreateQuadGeometry();
8998 Shader shader = CreateShader();
8999 Renderer renderer1 = Renderer::New(geometry, shader);
9000 Renderer renderer2 = Renderer::New(geometry, shader);
9002 Actor actor1 = Actor::New();
9003 actor1.AddRenderer(renderer1);
9004 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9005 actor1.RegisterProperty("uCustom", 1);
9006 application.GetScene().Add(actor1);
9008 Actor actor2 = Actor::New();
9009 actor2.AddRenderer(renderer2);
9010 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9011 application.GetScene().Add(actor2);
9013 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
9014 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
9015 glAbstraction.EnableSetUniformCallTrace(true);
9017 application.SendNotification();
9018 application.Render();
9020 std::stringstream out;
9024 // Test uniform value of the custom property
9025 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9026 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
9029 actor1[Actor::Property::VISIBLE] = false;
9031 application.SendNotification();
9032 application.Render();
9034 // Make visible again
9035 actor1[Actor::Property::VISIBLE] = true;
9036 actor1["uCustom"] = 2;
9038 glAbstraction.ResetSetUniformCallStack();
9040 application.SendNotification();
9041 application.Render();
9045 // The uniform value should not be changed
9046 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9047 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);