2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
21 #include <dali-test-suite-utils.h>
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/devel-api/common/capabilities.h>
24 #include <dali/integration-api/debug.h>
25 #include <dali/integration-api/events/hover-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali/public-api/dali-core.h>
28 #include <mesh-builder.h>
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;
62 Texture CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height)
64 Texture texture = Texture::New(type, format, width, height);
66 int bufferSize = width * height * 2;
67 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
68 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, format, PixelData::FREE);
69 texture.Upload(pixelData, 0u, 0u, 0u, 0u, width, height);
75 void operator()(Vector4& color, const PropertyInputContainer& /* inputs */)
77 gTestConstraintCalled = true;
82 * TestConstraint reference.
83 * When constraint is called, the resultRef is updated
84 * with the value supplied.
87 struct TestConstraintRef
89 TestConstraintRef(unsigned int& resultRef, unsigned int value)
90 : mResultRef(resultRef),
95 void operator()(T& current, const PropertyInputContainer& /* inputs */)
100 unsigned int& mResultRef;
104 static bool TestTouchCallback(Actor, const TouchEvent&)
106 gTouchCallBackCalled = true;
111 static bool TestTouchCallback2(Actor, const TouchEvent&)
113 gTouchCallBackCalled2 = true;
118 static bool TestTouchCallback3(Actor, const TouchEvent&)
120 gTouchCallBackCalled3 = true;
125 static void ResetTouchCallbacks()
127 gTouchCallBackCalled = false;
128 gTouchCallBackCalled2 = false;
129 gTouchCallBackCalled3 = false;
132 static bool TestCallback3(Actor actor, const HoverEvent& event)
134 gHoverCallBackCalled = true;
139 // validation stuff for onstage & offstage signals
140 static std::vector<std::string> gActorNamesOnOffScene;
141 static int gOnSceneCallBackCalled;
142 void OnSceneCallback(Actor actor)
144 ++gOnSceneCallBackCalled;
145 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
146 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
148 static int gOffSceneCallBackCalled;
149 void OffSceneCallback(Actor actor)
151 ++gOffSceneCallBackCalled;
152 gActorNamesOnOffScene.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
153 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == false);
156 struct PositionComponentConstraint
158 PositionComponentConstraint()
162 void operator()(Vector3& pos, const PropertyInputContainer& inputs)
164 const Matrix& m = inputs[0]->GetMatrix();
167 m.GetTransformComponents(pos, rot, scale);
171 struct OrientationComponentConstraint
173 OrientationComponentConstraint()
177 void operator()(Quaternion& orientation, const PropertyInputContainer& inputs)
179 const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
182 orientation = parentOrientation;
187 static bool gOnRelayoutCallBackCalled = false;
188 static std::vector<std::string> gActorNamesRelayout;
190 void OnRelayoutCallback(Actor actor)
192 gOnRelayoutCallBackCalled = true;
193 gActorNamesRelayout.push_back(actor.GetProperty<std::string>(Actor::Property::NAME));
196 struct VisibilityChangedFunctorData
198 VisibilityChangedFunctorData()
201 type(DevelActor::VisibilityChange::SELF),
210 type = DevelActor::VisibilityChange::SELF;
214 void Check(bool compareCalled, Actor compareActor, bool compareVisible, DevelActor::VisibilityChange::Type compareType, const char* location)
216 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
217 DALI_TEST_EQUALS(actor, compareActor, TEST_INNER_LOCATION(location));
218 DALI_TEST_EQUALS(visible, compareVisible, TEST_INNER_LOCATION(location));
219 DALI_TEST_EQUALS((int)type, (int)compareType, TEST_INNER_LOCATION(location));
222 void Check(bool compareCalled, const std::string& location)
224 DALI_TEST_EQUALS(called, compareCalled, TEST_INNER_LOCATION(location));
229 DevelActor::VisibilityChange::Type type;
233 struct VisibilityChangedFunctor
235 VisibilityChangedFunctor(VisibilityChangedFunctorData& dataVar)
240 void operator()(Actor actor, bool visible, DevelActor::VisibilityChange::Type type)
243 data.visible = visible;
248 VisibilityChangedFunctorData& data;
251 struct VisibilityChangedVoidFunctor
253 VisibilityChangedVoidFunctor(bool& signalCalled)
254 : mSignalCalled(signalCalled)
260 mSignalCalled = true;
266 struct ChildOrderChangedFunctor
268 ChildOrderChangedFunctor(bool& signalCalled, Actor& actor)
269 : mSignalCalled(signalCalled),
274 void operator()(Actor actor)
276 mSignalCalled = true;
284 struct CulledPropertyNotificationFunctor
286 CulledPropertyNotificationFunctor(bool& signalCalled, PropertyNotification& propertyNotification)
287 : mSignalCalled(signalCalled),
288 mPropertyNotification(propertyNotification)
292 void operator()(PropertyNotification& source)
294 mSignalCalled = true;
295 mPropertyNotification = source;
299 PropertyNotification& mPropertyNotification;
302 } // anonymous namespace
304 //& purpose: Testing New API
305 int UtcDaliActorNew(void)
307 TestApplication application;
309 Actor actor = Actor::New();
311 DALI_TEST_CHECK(actor);
315 //& purpose: Testing Dali::Actor::DownCast()
316 int UtcDaliActorDownCastP(void)
318 TestApplication application;
319 tet_infoline("Testing Dali::Actor::DownCast()");
321 Actor actor = Actor::New();
322 BaseHandle object(actor);
323 Actor actor2 = Actor::DownCast(object);
324 DALI_TEST_CHECK(actor2);
328 //& purpose: Testing Dali::Actor::DownCast()
329 int UtcDaliActorDownCastN(void)
331 TestApplication application;
332 tet_infoline("Testing Dali::Actor::DownCast()");
334 BaseHandle unInitializedObject;
335 Actor actor = Actor::DownCast(unInitializedObject);
336 DALI_TEST_CHECK(!actor);
340 int UtcDaliActorMoveConstructor(void)
342 TestApplication application;
344 Actor actor = Actor::New();
345 DALI_TEST_CHECK(actor);
347 int id = actor.GetProperty<int>(Actor::Property::ID);
349 Actor moved = std::move(actor);
350 DALI_TEST_CHECK(moved);
351 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
352 DALI_TEST_CHECK(!actor);
357 int UtcDaliActorMoveAssignment(void)
359 TestApplication application;
361 Actor actor = Actor::New();
362 DALI_TEST_CHECK(actor);
364 int id = actor.GetProperty<int>(Actor::Property::ID);
367 moved = std::move(actor);
368 DALI_TEST_CHECK(moved);
369 DALI_TEST_EQUALS(id, moved.GetProperty<int>(Actor::Property::ID), TEST_LOCATION);
370 DALI_TEST_CHECK(!actor);
375 //& purpose: Testing Dali::Actor::GetName()
376 int UtcDaliActorGetName(void)
378 TestApplication application;
380 Actor actor = Actor::New();
382 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME).empty());
386 //& purpose: Testing Dali::Actor::SetName()
387 int UtcDaliActorSetName(void)
389 TestApplication application;
391 string str("ActorName");
392 Actor actor = Actor::New();
394 actor.SetProperty(Actor::Property::NAME, str);
395 DALI_TEST_CHECK(actor.GetProperty<std::string>(Actor::Property::NAME) == str);
399 int UtcDaliActorGetId(void)
401 tet_infoline("Testing Dali::Actor::UtcDaliActo.GetProperty< int >( Actor::Property::ID )");
402 TestApplication application;
404 Actor first = Actor::New();
405 Actor second = Actor::New();
406 Actor third = Actor::New();
408 DALI_TEST_CHECK(first.GetProperty<int>(Actor::Property::ID) != second.GetProperty<int>(Actor::Property::ID));
409 DALI_TEST_CHECK(second.GetProperty<int>(Actor::Property::ID) != third.GetProperty<int>(Actor::Property::ID));
413 int UtcDaliActorIsRoot(void)
415 TestApplication application;
417 Actor actor = Actor::New();
418 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_ROOT));
420 // get the root layer
421 actor = application.GetScene().GetLayer(0);
422 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_ROOT));
426 int UtcDaliActorOnScene(void)
428 TestApplication application;
430 Actor actor = Actor::New();
431 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
433 // get the root layer
434 actor = application.GetScene().GetLayer(0);
435 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
439 int UtcDaliActorIsLayer(void)
441 TestApplication application;
443 Actor actor = Actor::New();
444 DALI_TEST_CHECK(!actor.GetProperty<bool>(Actor::Property::IS_LAYER));
446 // get the root layer
447 actor = application.GetScene().GetLayer(0);
448 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::IS_LAYER));
452 int UtcDaliActorGetLayer(void)
454 TestApplication application;
456 Actor actor = Actor::New();
457 application.GetScene().Add(actor);
458 Layer layer = actor.GetLayer();
460 DALI_TEST_CHECK(layer);
462 // get the root layers layer
463 actor = application.GetScene().GetLayer(0);
464 DALI_TEST_CHECK(actor.GetLayer());
468 int UtcDaliActorAddP(void)
470 tet_infoline("Testing Actor::Add");
471 TestApplication application;
473 Actor parent = Actor::New();
474 Actor child = Actor::New();
476 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
480 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
482 Actor parent2 = Actor::New();
485 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
486 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
488 // try Adding to same parent again, works
490 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
492 // try reparenting an orphaned child
494 Actor temporaryParent = Actor::New();
495 temporaryParent.Add(child);
496 DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION);
498 // temporaryParent has now died, reparent the orphaned child
500 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
505 int UtcDaliActorAddN(void)
507 tet_infoline("Testing Actor::Add");
508 TestApplication application;
510 Actor child = Actor::New();
512 Actor parent2 = Actor::New();
518 parent2.Add(parent2);
519 tet_printf("Assertion test failed - no Exception\n");
520 tet_result(TET_FAIL);
522 catch(Dali::DaliException& e)
524 DALI_TEST_PRINT_ASSERT(e);
525 DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION);
526 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
530 tet_printf("Assertion test failed - wrong Exception\n");
531 tet_result(TET_FAIL);
534 // try reparenting root
537 parent2.Add(application.GetScene().GetLayer(0));
538 tet_printf("Assertion test failed - no Exception\n");
539 tet_result(TET_FAIL);
541 catch(Dali::DaliException& e)
543 DALI_TEST_PRINT_ASSERT(e);
544 DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION);
545 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
549 tet_printf("Assertion test failed - wrong Exception\n");
550 tet_result(TET_FAIL);
558 tet_printf("Assertion test failed - no Exception\n");
559 tet_result(TET_FAIL);
561 catch(Dali::DaliException& e)
563 DALI_TEST_PRINT_ASSERT(e);
564 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
565 DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION);
569 tet_printf("Assertion test failed - wrong Exception\n");
570 tet_result(TET_FAIL);
576 int UtcDaliActorRemoveN(void)
578 tet_infoline("Testing Actor::Remove");
579 TestApplication application;
581 Actor parent = Actor::New();
582 Actor child = Actor::New();
583 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
586 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
588 parent.Remove(child);
589 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
591 // remove again, no problem
592 parent.Remove(child);
593 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
597 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
598 // try Remove self, its a no-op
599 parent.Remove(parent);
600 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
606 parent.Remove(empty);
607 tet_printf("Assertion test failed - no Exception\n");
608 tet_result(TET_FAIL);
610 catch(Dali::DaliException& e)
612 DALI_TEST_PRINT_ASSERT(e);
613 DALI_TEST_ASSERT(e, "actor", TEST_LOCATION);
614 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
618 tet_printf("Assertion test failed - wrong Exception\n");
619 tet_result(TET_FAIL);
624 int UtcDaliActorRemoveP(void)
626 TestApplication application;
628 Actor parent = Actor::New();
629 Actor child = Actor::New();
630 Actor random = Actor::New();
632 application.GetScene().Add(parent);
634 DALI_TEST_CHECK(parent.GetChildCount() == 0);
638 DALI_TEST_CHECK(parent.GetChildCount() == 1);
640 parent.Remove(random);
642 DALI_TEST_CHECK(parent.GetChildCount() == 1);
644 application.GetScene().Remove(parent);
646 DALI_TEST_CHECK(parent.GetChildCount() == 1);
650 int UtcDaliActorGetChildCount(void)
652 TestApplication application;
654 Actor parent = Actor::New();
655 Actor child = Actor::New();
657 DALI_TEST_CHECK(parent.GetChildCount() == 0);
661 DALI_TEST_CHECK(parent.GetChildCount() == 1);
665 int UtcDaliActorGetChildren01(void)
667 TestApplication application;
669 Actor parent = Actor::New();
670 Actor first = Actor::New();
671 Actor second = Actor::New();
672 Actor third = Actor::New();
678 DALI_TEST_CHECK(parent.GetChildAt(0) == first);
679 DALI_TEST_CHECK(parent.GetChildAt(1) == second);
680 DALI_TEST_CHECK(parent.GetChildAt(2) == third);
684 int UtcDaliActorGetChildren02(void)
686 TestApplication application;
688 Actor parent = Actor::New();
689 Actor first = Actor::New();
690 Actor second = Actor::New();
691 Actor third = Actor::New();
697 const Actor& constParent = parent;
699 DALI_TEST_CHECK(constParent.GetChildAt(0) == first);
700 DALI_TEST_CHECK(constParent.GetChildAt(1) == second);
701 DALI_TEST_CHECK(constParent.GetChildAt(2) == third);
705 int UtcDaliActorGetParent01(void)
707 TestApplication application;
709 Actor parent = Actor::New();
710 Actor child = Actor::New();
714 DALI_TEST_CHECK(child.GetParent() == parent);
718 int UtcDaliActorGetParent02(void)
720 TestApplication application;
722 Actor actor = Actor::New();
724 DALI_TEST_CHECK(!actor.GetParent());
728 int UtcDaliActorCustomProperty(void)
730 TestApplication application;
732 Actor actor = Actor::New();
733 application.GetScene().Add(actor);
735 float startValue(1.0f);
736 Property::Index index = actor.RegisterProperty("testProperty", startValue);
737 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
739 application.SendNotification();
740 application.Render(0);
741 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
743 actor.SetProperty(index, 5.0f);
745 application.SendNotification();
746 application.Render(0);
747 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 5.0f);
751 int UtcDaliActorCustomPropertyIntToFloat(void)
753 TestApplication application;
755 Actor actor = Actor::New();
756 application.GetScene().Add(actor);
758 float startValue(5.0f);
759 Property::Index index = actor.RegisterProperty("testProperty", startValue);
760 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
762 application.SendNotification();
763 application.Render(0);
764 DALI_TEST_CHECK(actor.GetProperty<float>(index) == startValue);
766 actor.SetProperty(index, int(1));
768 application.SendNotification();
769 application.Render(0);
770 DALI_TEST_CHECK(actor.GetProperty<float>(index) == 1.0f);
774 int UtcDaliActorCustomPropertyFloatToInt(void)
776 TestApplication application;
778 Actor actor = Actor::New();
779 application.GetScene().Add(actor);
782 Property::Index index = actor.RegisterProperty("testProperty", startValue);
783 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
785 application.SendNotification();
786 application.Render(0);
787 DALI_TEST_CHECK(actor.GetProperty<int>(index) == startValue);
789 actor.SetProperty(index, float(1.5));
791 application.SendNotification();
792 application.Render(0);
793 DALI_TEST_CHECK(actor.GetProperty<int>(index) == 1);
797 int UtcDaliActorSetParentOrigin(void)
799 TestApplication application;
801 Actor actor = Actor::New();
803 Vector3 vector(0.7f, 0.8f, 0.9f);
804 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
806 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
808 // flush the queue and render once
809 application.SendNotification();
810 application.Render();
812 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
814 application.GetScene().Add(actor);
816 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.1f, 0.2f, 0.3f));
818 // flush the queue and render once
819 application.SendNotification();
820 application.Render();
822 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), TEST_LOCATION);
824 application.GetScene().Remove(actor);
828 int UtcDaliActorSetParentOriginIndividual(void)
830 TestApplication application;
832 Actor actor = Actor::New();
834 Vector3 vector(0.7f, 0.8f, 0.9f);
835 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
837 actor.SetProperty(Actor::Property::PARENT_ORIGIN_X, vector.x);
839 // flush the queue and render once
840 application.SendNotification();
841 application.Render();
843 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).x, TEST_LOCATION);
845 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Y, vector.y);
847 // flush the queue and render once
848 application.SendNotification();
849 application.Render();
851 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).y, TEST_LOCATION);
853 actor.SetProperty(Actor::Property::PARENT_ORIGIN_Z, vector.z);
855 // flush the queue and render once
856 application.SendNotification();
857 application.Render();
859 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN).z, TEST_LOCATION);
864 int UtcDaliActorGetCurrentParentOrigin(void)
866 TestApplication application;
868 Actor actor = Actor::New();
870 Vector3 vector(0.7f, 0.8f, 0.9f);
871 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
873 actor.SetProperty(Actor::Property::PARENT_ORIGIN, vector);
875 // flush the queue and render once
876 application.SendNotification();
877 application.Render();
879 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN));
883 int UtcDaliActorSetAnchorPoint(void)
885 TestApplication application;
887 Actor actor = Actor::New();
889 Vector3 vector(0.7f, 0.8f, 0.9f);
890 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
892 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
894 // flush the queue and render once
895 application.SendNotification();
896 application.Render();
898 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
900 application.GetScene().Add(actor);
902 actor.SetProperty(Actor::Property::ANCHOR_POINT, Vector3(0.1f, 0.2f, 0.3f));
903 // flush the queue and render once
904 application.SendNotification();
905 application.Render();
907 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), TEST_LOCATION);
909 application.GetScene().Remove(actor);
913 int UtcDaliActorSetAnchorPointIndividual(void)
915 TestApplication application;
917 Actor actor = Actor::New();
919 Vector3 vector(0.7f, 0.8f, 0.9f);
920 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
922 actor.SetProperty(Actor::Property::ANCHOR_POINT_X, vector.x);
924 // flush the queue and render once
925 application.SendNotification();
926 application.Render();
928 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).x, TEST_LOCATION);
930 actor.SetProperty(Actor::Property::ANCHOR_POINT_Y, vector.y);
932 // flush the queue and render once
933 application.SendNotification();
934 application.Render();
936 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).y, TEST_LOCATION);
938 actor.SetProperty(Actor::Property::ANCHOR_POINT_Z, vector.z);
940 // flush the queue and render once
941 application.SendNotification();
942 application.Render();
944 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT).z, TEST_LOCATION);
949 int UtcDaliActorGetCurrentAnchorPoint(void)
951 TestApplication application;
953 Actor actor = Actor::New();
955 Vector3 vector(0.7f, 0.8f, 0.9f);
956 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
958 actor.SetProperty(Actor::Property::ANCHOR_POINT, vector);
960 // flush the queue and render once
961 application.SendNotification();
962 application.Render();
964 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT));
968 int UtcDaliActorSetSize01(void)
970 TestApplication application;
972 Actor actor = Actor::New();
973 Vector3 vector(100.0f, 100.0f, 0.0f);
975 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
977 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
979 // Immediately retrieve the size after setting
980 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
981 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
982 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
983 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
984 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
986 // Flush the queue and render once
987 application.SendNotification();
988 application.Render();
990 // Check the size in the new frame
991 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
993 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
994 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
995 DALI_TEST_EQUALS(vector.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
996 DALI_TEST_EQUALS(vector.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
997 DALI_TEST_EQUALS(vector.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
999 // Check async behaviour
1000 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
1001 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1002 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
1003 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
1004 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
1006 // Change the resize policy and check whether the size stays the same
1007 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1009 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1010 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1012 // Set a new size after resize policy is changed and check the new size
1013 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.0f));
1015 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1016 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1018 // Change the resize policy again and check whether the new size stays the same
1019 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1021 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1022 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1024 // Set another new size after resize policy is changed and check the new size
1025 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 60.0f, 0.0f));
1027 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1028 DALI_TEST_EQUALS(currentSize, Vector3(50.0f, 60.0f, 0.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1033 int UtcDaliActorSetSize02(void)
1035 TestApplication application;
1037 Actor actor = Actor::New();
1038 Vector3 vector(100.0f, 100.0f, 100.0f);
1040 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1042 actor.SetProperty(Actor::Property::SIZE, Vector3(vector.x, vector.y, vector.z));
1044 // Immediately check the size after setting
1045 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1046 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1048 // flush the queue and render once
1049 application.SendNotification();
1050 application.Render();
1052 // Check the size in the new frame
1053 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1055 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1056 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1061 // SetSize(Vector2 size)
1062 int UtcDaliActorSetSize03(void)
1064 TestApplication application;
1066 Actor actor = Actor::New();
1067 Vector3 vector(100.0f, 100.0f, 0.0f);
1069 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1071 actor.SetProperty(Actor::Property::SIZE, Vector2(vector.x, vector.y));
1073 // Immediately check the size after setting
1074 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1075 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1077 // flush the queue and render once
1078 application.SendNotification();
1079 application.Render();
1081 // Check the size in the new frame
1082 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1084 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1085 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1090 // SetSize(Vector3 size)
1091 int UtcDaliActorSetSize04(void)
1093 TestApplication application;
1095 Actor actor = Actor::New();
1096 Vector3 vector(100.0f, 100.0f, 100.0f);
1098 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1100 actor.SetProperty(Actor::Property::SIZE, vector);
1102 // Immediately check the size after setting
1103 Vector3 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1104 DALI_TEST_EQUALS(currentSize, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1106 // flush the queue and render once
1107 application.SendNotification();
1108 application.Render();
1110 // Check the size in the new frame
1111 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1113 application.GetScene().Add(actor);
1114 actor.SetProperty(Actor::Property::SIZE, Vector3(0.1f, 0.2f, 0.3f));
1116 // Immediately check the size after setting
1117 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1118 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1120 // flush the queue and render once
1121 application.SendNotification();
1122 application.Render();
1124 // Check the size in the new frame
1125 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
1127 currentSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
1128 DALI_TEST_EQUALS(currentSize, Vector3(0.1f, 0.2f, 0.3f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1130 application.GetScene().Remove(actor);
1134 int UtcDaliActorSetSizeIndividual(void)
1136 TestApplication application;
1138 Actor actor = Actor::New();
1140 Vector3 vector(0.7f, 0.8f, 0.9f);
1141 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1143 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1145 // Immediately check the width after setting
1146 float sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1147 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1149 // flush the queue and render once
1150 application.SendNotification();
1151 application.Render();
1153 // Check the width in the new frame
1154 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1156 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1157 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1159 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1161 // Immediately check the height after setting
1162 float sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1163 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1165 // flush the queue and render once
1166 application.SendNotification();
1167 application.Render();
1169 // Check the height in the new frame
1170 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1172 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1173 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1175 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1177 // Immediately check the depth after setting
1178 float sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1179 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1181 // flush the queue and render once
1182 application.SendNotification();
1183 application.Render();
1185 // Check the depth in the new frame
1186 DALI_TEST_EQUALS(vector.depth, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).depth, TEST_LOCATION);
1188 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1189 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1191 // Change the resize policy and check whether the size stays the same
1192 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1194 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1195 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1197 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1198 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1200 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1201 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1203 // Change the resize policy again and check whether the size stays the same
1204 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1206 sizeWidth = actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1207 DALI_TEST_EQUALS(sizeWidth, vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1209 sizeHeight = actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>();
1210 DALI_TEST_EQUALS(sizeHeight, vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1212 sizeDepth = actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>();
1213 DALI_TEST_EQUALS(sizeDepth, vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1218 int UtcDaliActorSetSizeIndividual02(void)
1220 TestApplication application;
1222 Actor actor = Actor::New();
1223 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1224 application.GetScene().Add(actor);
1226 Vector3 vector(100.0f, 200.0f, 400.0f);
1227 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1229 actor.SetProperty(Actor::Property::SIZE_WIDTH, vector.width);
1230 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1232 actor.SetProperty(Actor::Property::SIZE_HEIGHT, vector.height);
1233 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_HEIGHT).Get<float>(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1235 actor.SetProperty(Actor::Property::SIZE_DEPTH, vector.depth);
1236 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_DEPTH).Get<float>(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1238 // flush the queue and render once
1239 application.SendNotification();
1240 application.Render();
1242 // Check the width in the new frame
1243 DALI_TEST_EQUALS(vector.width, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width, TEST_LOCATION);
1244 DALI_TEST_EQUALS(vector.height, actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, TEST_LOCATION);
1249 int UtcDaliActorGetCurrentSize(void)
1251 TestApplication application;
1253 Actor actor = Actor::New();
1254 Vector3 vector(100.0f, 100.0f, 20.0f);
1256 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1258 actor.SetProperty(Actor::Property::SIZE, vector);
1260 // flush the queue and render once
1261 application.SendNotification();
1262 application.Render();
1264 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1268 int UtcDaliActorGetNaturalSize(void)
1270 TestApplication application;
1272 Actor actor = Actor::New();
1273 Vector3 vector(0.0f, 0.0f, 0.0f);
1275 DALI_TEST_CHECK(actor.GetNaturalSize() == vector);
1280 int UtcDaliActorGetCurrentSizeImmediate(void)
1282 TestApplication application;
1284 Actor actor = Actor::New();
1285 Vector3 vector(100.0f, 100.0f, 20.0f);
1287 DALI_TEST_CHECK(vector != actor.GetTargetSize());
1288 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1290 actor.SetProperty(Actor::Property::SIZE, vector);
1292 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1293 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1295 // flush the queue and render once
1296 application.SendNotification();
1297 application.Render();
1299 DALI_TEST_CHECK(vector == actor.GetTargetSize());
1300 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE));
1303 // Build the animation
1304 const float durationSeconds = 2.0f;
1305 Animation animation = Animation::New(durationSeconds);
1306 const Vector3 targetValue(10.0f, 20.0f, 30.0f);
1307 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
1309 DALI_TEST_CHECK(actor.GetTargetSize() == vector);
1311 application.GetScene().Add(actor);
1313 // Start the animation
1316 application.SendNotification();
1317 application.Render(static_cast<unsigned int>(durationSeconds * 1000.0f));
1319 DALI_TEST_CHECK(actor.GetTargetSize() == targetValue);
1324 int UtcDaliActorCalculateScreenExtents(void)
1326 TestApplication application;
1328 Actor actor = Actor::New();
1330 actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f));
1331 actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f});
1333 application.SendNotification();
1334 application.Render();
1336 auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f};
1337 auto actualExtent = DevelActor::CalculateScreenExtents(actor);
1338 DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1339 DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1340 DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1341 DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1343 application.GetScene().Remove(actor);
1347 // SetPosition(float x, float y)
1348 int UtcDaliActorSetPosition01(void)
1350 TestApplication application;
1352 Actor actor = Actor::New();
1354 // Set to random to start off with
1355 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 0.0f));
1357 Vector3 vector(100.0f, 100.0f, 0.0f);
1359 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1361 actor.SetProperty(Actor::Property::POSITION, Vector2(vector.x, vector.y));
1362 // flush the queue and render once
1363 application.SendNotification();
1364 application.Render();
1365 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1367 application.GetScene().Add(actor);
1368 actor.SetProperty(Actor::Property::POSITION, Vector3(0.1f, 0.2f, 0.3f));
1369 // flush the queue and render once
1370 application.SendNotification();
1371 application.Render();
1372 DALI_TEST_EQUALS(Vector3(0.1f, 0.2f, 0.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1374 actor.SetProperty(Actor::Property::POSITION_X, 1.0f);
1375 actor.SetProperty(Actor::Property::POSITION_Y, 1.1f);
1376 actor.SetProperty(Actor::Property::POSITION_Z, 1.2f);
1377 // flush the queue and render once
1378 application.SendNotification();
1379 application.Render();
1380 DALI_TEST_EQUALS(Vector3(1.0f, 1.1f, 1.2f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
1382 actor.TranslateBy(Vector3(0.1f, 0.1f, 0.1f));
1383 // flush the queue and render once
1384 application.SendNotification();
1385 application.Render();
1386 DALI_TEST_EQUALS(Vector3(1.1f, 1.2f, 1.3f), actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Math::MACHINE_EPSILON_10000, TEST_LOCATION);
1388 application.GetScene().Remove(actor);
1392 // SetPosition(float x, float y, float z)
1393 int UtcDaliActorSetPosition02(void)
1395 TestApplication application;
1397 Actor actor = Actor::New();
1399 // Set to random to start off with
1400 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1402 Vector3 vector(100.0f, 100.0f, 100.0f);
1404 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1406 actor.SetProperty(Actor::Property::POSITION, Vector3(vector.x, vector.y, vector.z));
1408 // flush the queue and render once
1409 application.SendNotification();
1410 application.Render();
1412 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1416 // SetPosition(Vector3 position)
1417 int UtcDaliActorSetPosition03(void)
1419 TestApplication application;
1421 Actor actor = Actor::New();
1423 // Set to random to start off with
1424 actor.SetProperty(Actor::Property::POSITION, Vector3(120.0f, 120.0f, 120.0f));
1426 Vector3 vector(100.0f, 100.0f, 100.0f);
1428 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1430 actor.SetProperty(Actor::Property::POSITION, vector);
1432 // flush the queue and render once
1433 application.SendNotification();
1434 application.Render();
1436 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1440 int UtcDaliActorSetX(void)
1442 TestApplication application;
1444 Actor actor = Actor::New();
1446 Vector3 vector(100.0f, 0.0f, 0.0f);
1448 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1450 actor.SetProperty(Actor::Property::POSITION_X, 100.0f);
1452 // flush the queue and render once
1453 application.SendNotification();
1454 application.Render();
1456 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1460 int UtcDaliActorSetY(void)
1462 TestApplication application;
1464 Actor actor = Actor::New();
1466 Vector3 vector(0.0f, 100.0f, 0.0f);
1468 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1470 actor.SetProperty(Actor::Property::POSITION_Y, 100.0f);
1472 // flush the queue and render once
1473 application.SendNotification();
1474 application.Render();
1476 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1480 int UtcDaliActorSetZ(void)
1482 TestApplication application;
1484 Actor actor = Actor::New();
1486 Vector3 vector(0.0f, 0.0f, 100.0f);
1488 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1490 actor.SetProperty(Actor::Property::POSITION_Z, 100.0f);
1492 // flush the queue and render once
1493 application.SendNotification();
1494 application.Render();
1496 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1500 int UtcDaliActorSetPositionProperties(void)
1502 TestApplication application;
1504 Actor actor = Actor::New();
1506 Vector3 vector(0.7f, 0.8f, 0.9f);
1507 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1509 actor.SetProperty(Actor::Property::POSITION_X, vector.x);
1510 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1511 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1513 // flush the queue and render once
1514 application.SendNotification();
1515 application.Render();
1517 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1518 DALI_TEST_EQUALS(vector.x, actor.GetProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1519 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1520 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).x, TEST_LOCATION);
1521 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::POSITION_X), TEST_LOCATION);
1523 actor.SetProperty(Actor::Property::POSITION_Y, vector.y);
1524 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1525 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1527 // flush the queue and render once
1528 application.SendNotification();
1529 application.Render();
1531 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1532 DALI_TEST_EQUALS(vector.y, actor.GetProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1533 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1534 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y, TEST_LOCATION);
1535 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Y), TEST_LOCATION);
1537 actor.SetProperty(Actor::Property::POSITION_Z, vector.z);
1538 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1539 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1541 // flush the queue and render once
1542 application.SendNotification();
1543 application.Render();
1545 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1546 DALI_TEST_EQUALS(vector.z, actor.GetProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1547 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1548 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION).z, TEST_LOCATION);
1549 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::POSITION_Z), TEST_LOCATION);
1554 int UtcDaliActorTranslateBy(void)
1556 TestApplication application;
1558 Actor actor = Actor::New();
1559 Vector3 vector(100.0f, 100.0f, 100.0f);
1561 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1563 actor.SetProperty(Actor::Property::POSITION, vector);
1565 // flush the queue and render once
1566 application.SendNotification();
1567 application.Render();
1569 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1571 actor.TranslateBy(vector);
1573 // flush the queue and render once
1574 application.SendNotification();
1575 application.Render();
1577 DALI_TEST_CHECK(vector * 2.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION));
1581 int UtcDaliActorGetCurrentPosition(void)
1583 TestApplication application;
1585 Actor actor = Actor::New();
1586 Vector3 setVector(100.0f, 100.0f, 0.0f);
1587 actor.SetProperty(Actor::Property::POSITION, setVector);
1589 // flush the queue and render once
1590 application.SendNotification();
1591 application.Render();
1593 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::POSITION) == setVector);
1597 int UtcDaliActorGetCurrentWorldPosition(void)
1599 TestApplication application;
1601 Actor parent = Actor::New();
1602 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1603 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1604 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1605 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1606 application.GetScene().Add(parent);
1608 Actor child = Actor::New();
1609 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1610 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1611 Vector3 childPosition(6.0f, 6.0f, 6.0f);
1612 child.SetProperty(Actor::Property::POSITION, childPosition);
1615 // The actors should not have a world position yet
1616 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1617 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1619 application.SendNotification();
1620 application.Render(0);
1622 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1623 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1625 // The actors should have a world position now
1626 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1627 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1631 int UtcDaliActorSetInheritPosition(void)
1633 tet_infoline("Testing Actor::SetInheritPosition");
1634 TestApplication application;
1636 Actor parent = Actor::New();
1637 Vector3 parentPosition(1.0f, 2.0f, 3.0f);
1638 parent.SetProperty(Actor::Property::POSITION, parentPosition);
1639 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1640 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1641 application.GetScene().Add(parent);
1643 Actor child = Actor::New();
1644 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1645 child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1646 Vector3 childPosition(10.0f, 11.0f, 12.0f);
1647 child.SetProperty(Actor::Property::POSITION, childPosition);
1650 // The actors should not have a world position yet
1651 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1652 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3::ZERO, TEST_LOCATION);
1654 // first test default, which is to inherit position
1655 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1656 application.SendNotification();
1657 application.Render(0); // should only really call Update as Render is not required to update scene
1658 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1659 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childPosition, TEST_LOCATION);
1660 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1661 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childPosition, TEST_LOCATION);
1663 //Change child position
1664 Vector3 childOffset(-1.0f, 1.0f, 0.0f);
1665 child.SetProperty(Actor::Property::POSITION, childOffset);
1667 // Use local position as world postion
1668 child.SetProperty(Actor::Property::INHERIT_POSITION, false);
1669 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), false, TEST_LOCATION);
1670 application.SendNotification();
1671 application.Render(0); // should only really call Update as Render is not required to update scene
1672 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1673 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1674 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1675 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), childOffset, TEST_LOCATION);
1677 //Change back to inherit position from parent
1678 child.SetProperty(Actor::Property::INHERIT_POSITION, true);
1679 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_POSITION), true, TEST_LOCATION);
1680 application.SendNotification();
1681 application.Render(0); // should only really call Update as Render is not required to update scene
1682 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parentPosition, TEST_LOCATION);
1683 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), childOffset, TEST_LOCATION);
1684 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition, TEST_LOCATION);
1685 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), parentPosition + childOffset, TEST_LOCATION);
1689 int UtcDaliActorInheritOpacity(void)
1691 tet_infoline("Testing Actor::Inherit Opacity");
1692 TestApplication application;
1694 Actor parent = Actor::New();
1695 Actor child = Actor::New();
1697 application.GetScene().Add(parent);
1699 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1700 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1702 // flush the queue and render once
1703 application.SendNotification();
1704 application.Render();
1706 parent.SetProperty(Actor::Property::OPACITY, 0.1f);
1708 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1709 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.0f, 0.0001f, TEST_LOCATION);
1711 application.SendNotification();
1712 application.Render();
1714 DALI_TEST_EQUALS(parent.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1715 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 0.1f, 0.0001f, TEST_LOCATION);
1716 DALI_TEST_EQUALS(parent.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1717 DALI_TEST_EQUALS(child.GetProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1718 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::WORLD_COLOR).Get<Vector4>(), Vector4(1.f, 1.f, 1.f, 0.1f), 0.0001f, TEST_LOCATION);
1719 DALI_TEST_EQUALS(child.GetCurrentProperty(Actor::Property::COLOR_ALPHA).Get<float>(), 1.f, 0.0001f, TEST_LOCATION);
1724 // SetOrientation(float angleRadians, Vector3 axis)
1725 int UtcDaliActorSetOrientation01(void)
1727 TestApplication application;
1729 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1730 Actor actor = Actor::New();
1732 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1734 // flush the queue and render once
1735 application.SendNotification();
1736 application.Render();
1738 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1742 int UtcDaliActorSetOrientation02(void)
1744 TestApplication application;
1746 Actor actor = Actor::New();
1748 Radian angle(0.785f);
1749 Vector3 axis(1.0f, 1.0f, 0.0f);
1751 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1752 Quaternion rotation(angle, axis);
1753 // flush the queue and render once
1754 application.SendNotification();
1755 application.Render();
1756 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1758 application.GetScene().Add(actor);
1759 actor.RotateBy(Degree(360), axis);
1760 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1762 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(0), Vector3(1.0f, 0.0f, 0.0f)));
1763 Quaternion result(Radian(0), Vector3(1.0f, 0.0f, 0.0f));
1764 // flush the queue and render once
1765 application.SendNotification();
1766 application.Render();
1767 DALI_TEST_EQUALS(result, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1769 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(angle, axis));
1770 // flush the queue and render once
1771 application.SendNotification();
1772 application.Render();
1773 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1775 application.GetScene().Remove(actor);
1779 // SetOrientation(float angleRadians, Vector3 axis)
1780 int UtcDaliActorSetOrientationProperty(void)
1782 TestApplication application;
1784 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1785 Actor actor = Actor::New();
1787 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1788 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1790 // flush the queue and render once
1791 application.SendNotification();
1792 application.Render();
1794 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1795 DALI_TEST_EQUALS(rotation, actor.GetProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1796 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1800 // RotateBy(float angleRadians, Vector3 axis)
1801 int UtcDaliActorRotateBy01(void)
1803 TestApplication application;
1805 Actor actor = Actor::New();
1807 Radian angle(M_PI * 0.25f);
1808 actor.RotateBy((angle), Vector3::ZAXIS);
1809 // flush the queue and render once
1810 application.SendNotification();
1811 application.Render();
1812 DALI_TEST_EQUALS(Quaternion(angle, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1814 application.GetScene().Add(actor);
1816 actor.RotateBy(angle, Vector3::ZAXIS);
1817 // flush the queue and render once
1818 application.SendNotification();
1819 application.Render();
1820 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1822 application.GetScene().Remove(actor);
1826 // RotateBy(Quaternion relativeRotation)
1827 int UtcDaliActorRotateBy02(void)
1829 TestApplication application;
1831 Actor actor = Actor::New();
1833 Radian angle(M_PI * 0.25f);
1834 Quaternion rotation(angle, Vector3::ZAXIS);
1835 actor.RotateBy(rotation);
1836 // flush the queue and render once
1837 application.SendNotification();
1838 application.Render();
1839 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1841 actor.RotateBy(rotation);
1842 // flush the queue and render once
1843 application.SendNotification();
1844 application.Render();
1845 DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1849 int UtcDaliActorGetCurrentOrientation(void)
1851 TestApplication application;
1852 Actor actor = Actor::New();
1854 Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
1855 actor.SetProperty(Actor::Property::ORIENTATION, rotation);
1856 // flush the queue and render once
1857 application.SendNotification();
1858 application.Render();
1859 DALI_TEST_EQUALS(rotation, actor.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
1863 int UtcDaliActorGetCurrentWorldOrientation(void)
1865 tet_infoline("Testing Actor::GetCurrentWorldRotation");
1866 TestApplication application;
1868 Actor parent = Actor::New();
1869 Radian rotationAngle(Degree(90.0f));
1870 Quaternion rotation(rotationAngle, Vector3::YAXIS);
1871 parent.SetProperty(Actor::Property::ORIENTATION, rotation);
1872 application.GetScene().Add(parent);
1874 Actor child = Actor::New();
1875 child.SetProperty(Actor::Property::ORIENTATION, rotation);
1878 // The actors should not have a world rotation yet
1879 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1880 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION);
1882 application.SendNotification();
1883 application.Render(0);
1885 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1886 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), rotation, 0.001, TEST_LOCATION);
1888 // The actors should have a world rotation now
1889 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1890 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle * 2.0f, Vector3::YAXIS), 0.001, TEST_LOCATION);
1892 // turn off child rotation inheritance
1893 child.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
1894 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_ORIENTATION), false, TEST_LOCATION);
1895 application.SendNotification();
1896 application.Render(0);
1898 // The actors should have a world rotation now
1899 DALI_TEST_EQUALS(parent.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), Quaternion(rotationAngle, Vector3::YAXIS), 0.001, TEST_LOCATION);
1900 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::WORLD_ORIENTATION), rotation, 0.001, TEST_LOCATION);
1904 // SetScale(float scale)
1905 int UtcDaliActorSetScale01(void)
1907 TestApplication application;
1909 Actor actor = Actor::New();
1911 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1912 actor.SetProperty(Actor::Property::SCALE, 0.25f);
1914 Vector3 scale(10.0f, 10.0f, 10.0f);
1915 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1917 actor.SetProperty(Actor::Property::SCALE, scale.x);
1919 // flush the queue and render once
1920 application.SendNotification();
1921 application.Render();
1923 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1927 // SetScale(float scaleX, float scaleY, float scaleZ)
1928 int UtcDaliActorSetScale02(void)
1930 TestApplication application;
1931 Vector3 scale(10.0f, 10.0f, 10.0f);
1933 Actor actor = Actor::New();
1935 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1936 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1938 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1940 actor.SetProperty(Actor::Property::SCALE, Vector3(scale.x, scale.y, scale.z));
1941 // flush the queue and render once
1942 application.SendNotification();
1943 application.Render();
1944 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1946 // add to stage and test
1947 application.GetScene().Add(actor);
1948 actor.SetProperty(Actor::Property::SCALE, Vector3(2.0f, 2.0f, 2.0f));
1949 // flush the queue and render once
1950 application.SendNotification();
1951 application.Render();
1952 DALI_TEST_EQUALS(Vector3(2.0f, 2.0f, 2.0f), actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), 0.001, TEST_LOCATION);
1954 application.GetScene().Remove(actor);
1959 // SetScale(Vector3 scale)
1960 int UtcDaliActorSetScale03(void)
1962 TestApplication application;
1963 Vector3 scale(10.0f, 10.0f, 10.0f);
1965 Actor actor = Actor::New();
1967 // Set to random value first -.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) asserts if called before SetScale()
1968 actor.SetProperty(Actor::Property::SCALE, Vector3(12.0f, 1.0f, 2.0f));
1970 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) != scale);
1972 actor.SetProperty(Actor::Property::SCALE, scale);
1974 // flush the queue and render once
1975 application.SendNotification();
1976 application.Render();
1978 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
1982 int UtcDaliActorSetScaleIndividual(void)
1984 TestApplication application;
1986 Actor actor = Actor::New();
1988 Vector3 vector(0.7f, 0.8f, 0.9f);
1989 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
1991 actor.SetProperty(Actor::Property::SCALE_X, vector.x);
1992 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
1994 // flush the queue and render once
1995 application.SendNotification();
1996 application.Render();
1998 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).x, TEST_LOCATION);
1999 DALI_TEST_EQUALS(vector.x, actor.GetProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2000 DALI_TEST_EQUALS(vector.x, actor.GetCurrentProperty<float>(Actor::Property::SCALE_X), TEST_LOCATION);
2002 actor.SetProperty(Actor::Property::SCALE_Y, vector.y);
2003 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2005 // flush the queue and render once
2006 application.SendNotification();
2007 application.Render();
2009 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).y, TEST_LOCATION);
2010 DALI_TEST_EQUALS(vector.y, actor.GetProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2011 DALI_TEST_EQUALS(vector.y, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Y), TEST_LOCATION);
2013 actor.SetProperty(Actor::Property::SCALE_Z, vector.z);
2014 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2016 // flush the queue and render once
2017 application.SendNotification();
2018 application.Render();
2020 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE).z, TEST_LOCATION);
2021 DALI_TEST_EQUALS(vector.z, actor.GetProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2022 DALI_TEST_EQUALS(vector.z, actor.GetCurrentProperty<float>(Actor::Property::SCALE_Z), TEST_LOCATION);
2024 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2025 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
2030 int UtcDaliActorScaleBy(void)
2032 TestApplication application;
2033 Actor actor = Actor::New();
2034 Vector3 vector(100.0f, 100.0f, 100.0f);
2036 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2038 actor.SetProperty(Actor::Property::SCALE, vector);
2040 // flush the queue and render once
2041 application.SendNotification();
2042 application.Render();
2044 DALI_TEST_CHECK(vector == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2046 actor.ScaleBy(vector);
2048 // flush the queue and render once
2049 application.SendNotification();
2050 application.Render();
2052 DALI_TEST_CHECK(vector * 100.0f == actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE));
2056 int UtcDaliActorGetCurrentScale(void)
2058 TestApplication application;
2059 Vector3 scale(12.0f, 1.0f, 2.0f);
2061 Actor actor = Actor::New();
2063 actor.SetProperty(Actor::Property::SCALE, scale);
2065 // flush the queue and render once
2066 application.SendNotification();
2067 application.Render();
2069 DALI_TEST_CHECK(actor.GetCurrentProperty<Vector3>(Actor::Property::SCALE) == scale);
2073 int UtcDaliActorGetCurrentWorldScale(void)
2075 TestApplication application;
2077 Actor parent = Actor::New();
2078 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2079 parent.SetProperty(Actor::Property::SCALE, parentScale);
2080 application.GetScene().Add(parent);
2082 Actor child = Actor::New();
2083 Vector3 childScale(2.0f, 2.0f, 2.0f);
2084 child.SetProperty(Actor::Property::SCALE, childScale);
2087 // The actors should not have a scale yet
2088 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2089 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), Vector3::ONE, TEST_LOCATION);
2091 // The actors should not have a world scale yet
2092 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2093 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), Vector3::ONE, TEST_LOCATION);
2095 application.SendNotification();
2096 application.Render(0);
2098 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::SCALE), parentScale, TEST_LOCATION);
2099 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::SCALE), childScale, TEST_LOCATION);
2101 // The actors should have a world scale now
2102 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale, TEST_LOCATION);
2103 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2107 int UtcDaliActorInheritScale(void)
2109 tet_infoline("Testing Actor::SetInheritScale");
2110 TestApplication application;
2112 Actor parent = Actor::New();
2113 Vector3 parentScale(1.0f, 2.0f, 3.0f);
2114 parent.SetProperty(Actor::Property::SCALE, parentScale);
2115 application.GetScene().Add(parent);
2117 Actor child = Actor::New();
2118 Vector3 childScale(2.0f, 2.0f, 2.0f);
2119 child.SetProperty(Actor::Property::SCALE, childScale);
2122 application.SendNotification();
2123 application.Render(0);
2125 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), true, TEST_LOCATION);
2126 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), parentScale * childScale, TEST_LOCATION);
2128 child.SetProperty(Actor::Property::INHERIT_SCALE, false);
2129 DALI_TEST_EQUALS(child.GetProperty<bool>(Actor::Property::INHERIT_SCALE), false, TEST_LOCATION);
2131 application.SendNotification();
2132 application.Render(0);
2134 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE), childScale, TEST_LOCATION);
2138 int UtcDaliActorSetVisible(void)
2140 TestApplication application;
2142 Actor actor = Actor::New();
2143 actor.SetProperty(Actor::Property::VISIBLE, false);
2144 // flush the queue and render once
2145 application.SendNotification();
2146 application.Render();
2147 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2149 actor.SetProperty(Actor::Property::VISIBLE, true);
2150 // flush the queue and render once
2151 application.SendNotification();
2152 application.Render();
2153 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2155 // put actor on stage
2156 application.GetScene().Add(actor);
2157 actor.SetProperty(Actor::Property::VISIBLE, false);
2158 // flush the queue and render once
2159 application.SendNotification();
2160 application.Render();
2161 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == false);
2165 int UtcDaliActorIsVisible(void)
2167 TestApplication application;
2169 Actor actor = Actor::New();
2171 DALI_TEST_CHECK(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) == true);
2175 int UtcDaliActorSetOpacity(void)
2177 TestApplication application;
2179 Actor actor = Actor::New();
2180 // initial opacity is 1
2181 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
2183 actor.SetProperty(Actor::Property::OPACITY, 0.4f);
2184 // flush the queue and render once
2185 application.SendNotification();
2186 application.Render();
2187 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.4f, TEST_LOCATION);
2189 // change opacity, actor is on stage to change is not immediate
2190 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) + 0.1f);
2191 // flush the queue and render once
2192 application.SendNotification();
2193 application.Render();
2194 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2196 // put actor on stage
2197 application.GetScene().Add(actor);
2199 // change opacity, actor is on stage to change is not immediate
2200 actor.SetProperty(Actor::Property::OPACITY, 0.9f);
2201 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, TEST_LOCATION);
2202 // flush the queue and render once
2203 application.SendNotification();
2204 application.Render();
2205 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.9f, TEST_LOCATION);
2207 // change opacity, actor is on stage to change is not immediate
2208 actor.SetProperty(Actor::Property::OPACITY, actor.GetCurrentProperty<float>(Actor::Property::OPACITY) - 0.9f);
2209 // flush the queue and render once
2210 application.SendNotification();
2211 application.Render();
2212 DALI_TEST_EQUALS(actor.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
2216 int UtcDaliActorGetCurrentOpacity(void)
2218 TestApplication application;
2220 Actor actor = Actor::New();
2221 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.5f);
2223 actor.SetProperty(Actor::Property::OPACITY, 0.5f);
2224 // flush the queue and render once
2225 application.SendNotification();
2226 application.Render();
2227 DALI_TEST_CHECK(actor.GetCurrentProperty<float>(Actor::Property::OPACITY) == 0.5f);
2231 int UtcDaliActorSetSensitive(void)
2233 TestApplication application;
2234 Actor actor = Actor::New();
2236 bool sensitive = !actor.GetProperty<bool>(Actor::Property::SENSITIVE);
2238 actor.SetProperty(Actor::Property::SENSITIVE, sensitive);
2240 DALI_TEST_CHECK(sensitive == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2244 int UtcDaliActorIsSensitive(void)
2246 TestApplication application;
2247 Actor actor = Actor::New();
2248 actor.SetProperty(Actor::Property::SENSITIVE, false);
2250 DALI_TEST_CHECK(false == actor.GetProperty<bool>(Actor::Property::SENSITIVE));
2254 int UtcDaliActorSetColor(void)
2256 TestApplication application;
2257 Actor actor = Actor::New();
2258 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2260 DALI_TEST_CHECK(color != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2262 actor.SetProperty(Actor::Property::COLOR, color);
2263 // flush the queue and render once
2264 application.SendNotification();
2265 application.Render();
2266 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2268 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(-0.4f, -0.5f, -0.6f, -0.4f));
2269 // flush the queue and render once
2270 application.SendNotification();
2271 application.Render();
2272 DALI_TEST_EQUALS(Vector4(0.6f, 0.5f, 0.4f, 0.1f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2274 application.GetScene().Add(actor);
2275 actor.SetProperty(Actor::Property::COLOR, color);
2276 // flush the queue and render once
2277 application.SendNotification();
2278 application.Render();
2279 DALI_TEST_EQUALS(color, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2281 actor.SetProperty(Actor::Property::COLOR, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR) + Vector4(1.1f, 1.1f, 1.1f, 1.1f));
2282 // flush the queue and render once
2283 application.SendNotification();
2284 application.Render();
2285 // Actor color is not clamped
2286 DALI_TEST_EQUALS(Vector4(2.1f, 2.1f, 2.1f, 1.6f), actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2287 // world color is clamped
2288 DALI_TEST_EQUALS(Vector4(1.0f, 1.0f, 1.0f, 1.0f), actor.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), TEST_LOCATION);
2290 actor.SetProperty(Actor::Property::COLOR, color);
2291 DALI_TEST_EQUALS(color, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2293 Vector3 newColor(1.0f, 0.0f, 0.0f);
2294 actor.SetProperty(Actor::Property::COLOR, newColor);
2295 DALI_TEST_EQUALS(Vector4(newColor.r, newColor.g, newColor.b, 1.0f), actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2297 application.GetScene().Remove(actor);
2301 int UtcDaliActorSetColorIndividual(void)
2303 TestApplication application;
2305 Actor actor = Actor::New();
2307 Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f);
2308 DALI_TEST_CHECK(vector != actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2310 actor.SetProperty(Actor::Property::COLOR_RED, vector.r);
2311 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2313 // flush the queue and render once
2314 application.SendNotification();
2315 application.Render();
2317 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).r, TEST_LOCATION);
2318 DALI_TEST_EQUALS(vector.r, actor.GetProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2319 DALI_TEST_EQUALS(vector.r, actor.GetCurrentProperty<float>(Actor::Property::COLOR_RED), TEST_LOCATION);
2321 actor.SetProperty(Actor::Property::COLOR_GREEN, vector.g);
2322 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2324 // flush the queue and render once
2325 application.SendNotification();
2326 application.Render();
2328 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).g, TEST_LOCATION);
2329 DALI_TEST_EQUALS(vector.g, actor.GetProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2330 DALI_TEST_EQUALS(vector.g, actor.GetCurrentProperty<float>(Actor::Property::COLOR_GREEN), TEST_LOCATION);
2332 actor.SetProperty(Actor::Property::COLOR_BLUE, vector.b);
2333 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2335 // flush the queue and render once
2336 application.SendNotification();
2337 application.Render();
2339 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).b, TEST_LOCATION);
2340 DALI_TEST_EQUALS(vector.b, actor.GetProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2341 DALI_TEST_EQUALS(vector.b, actor.GetCurrentProperty<float>(Actor::Property::COLOR_BLUE), TEST_LOCATION);
2343 actor.SetProperty(Actor::Property::COLOR_ALPHA, vector.a);
2344 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2346 // flush the queue and render once
2347 application.SendNotification();
2348 application.Render();
2350 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2351 DALI_TEST_EQUALS(vector.a, actor.GetProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2352 DALI_TEST_EQUALS(vector.a, actor.GetCurrentProperty<float>(Actor::Property::COLOR_ALPHA), TEST_LOCATION);
2354 DALI_TEST_EQUALS(vector, actor.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2355 DALI_TEST_EQUALS(vector, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
2357 actor.SetProperty(Actor::Property::OPACITY, 0.2f);
2359 // flush the queue and render once
2360 application.SendNotification();
2361 application.Render();
2363 DALI_TEST_EQUALS(0.2f, actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR).a, TEST_LOCATION);
2368 int UtcDaliActorGetCurrentColor(void)
2370 TestApplication application;
2371 Actor actor = Actor::New();
2372 Vector4 color(1.0f, 1.0f, 1.0f, 0.5f);
2374 actor.SetProperty(Actor::Property::COLOR, color);
2375 // flush the queue and render once
2376 application.SendNotification();
2377 application.Render();
2378 DALI_TEST_CHECK(color == actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR));
2382 int UtcDaliActorGetCurrentWorldColor(void)
2384 tet_infoline("Actor::GetCurrentWorldColor");
2385 TestApplication application;
2387 Actor parent = Actor::New();
2388 Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f);
2389 parent.SetProperty(Actor::Property::COLOR, parentColor);
2390 application.GetScene().Add(parent);
2392 Actor child = Actor::New();
2393 Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f);
2394 child.SetProperty(Actor::Property::COLOR, childColor);
2397 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2398 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
2400 // verify the default color mode
2401 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2403 // The actors should not have a world color yet
2404 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2405 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Color::WHITE, TEST_LOCATION);
2407 application.SendNotification();
2408 application.Render(0);
2410 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::COLOR), parentColor, TEST_LOCATION);
2411 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2413 // The actors should have a world color now
2414 DALI_TEST_EQUALS(parent.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2415 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), Vector4(childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION);
2418 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2419 application.SendNotification();
2420 application.Render(0);
2421 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), childColor, TEST_LOCATION);
2424 child.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2425 application.SendNotification();
2426 application.Render(0);
2427 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2428 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), parentColor, TEST_LOCATION);
2431 child.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2432 application.SendNotification();
2433 application.Render(0);
2434 Vector4 expectedColor(childColor);
2435 expectedColor.a *= parentColor.a;
2436 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::COLOR), childColor, TEST_LOCATION);
2437 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector4>(Actor::Property::WORLD_COLOR), expectedColor, TEST_LOCATION);
2441 int UtcDaliActorSetColorMode(void)
2443 tet_infoline("Actor::SetColorMode");
2444 TestApplication application;
2445 Actor actor = Actor::New();
2446 Actor child = Actor::New();
2449 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
2450 DALI_TEST_EQUALS(USE_OWN_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2452 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
2453 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2455 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
2456 DALI_TEST_EQUALS(USE_PARENT_COLOR, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2458 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
2459 DALI_TEST_EQUALS(USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), TEST_LOCATION);
2463 int UtcDaliActorScreenToLocal(void)
2465 TestApplication application;
2466 Actor actor = Actor::New();
2467 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2468 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
2469 actor.SetProperty(Actor::Property::POSITION, Vector2(10.0f, 10.0f));
2470 application.GetScene().Add(actor);
2472 // flush the queue and render once
2473 application.SendNotification();
2474 application.Render();
2479 application.SendNotification();
2480 application.Render();
2482 DALI_TEST_CHECK(actor.ScreenToLocal(localX, localY, 50.0f, 50.0f));
2484 DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
2485 DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION);
2489 int UtcDaliActorSetLeaveRequired(void)
2491 TestApplication application;
2493 Actor actor = Actor::New();
2495 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, false);
2496 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2498 actor.SetProperty(Actor::Property::LEAVE_REQUIRED, true);
2499 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == true);
2503 int UtcDaliActorGetLeaveRequired(void)
2505 TestApplication application;
2507 Actor actor = Actor::New();
2509 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::LEAVE_REQUIRED) == false);
2513 int UtcDaliActorSetKeyboardFocusable(void)
2515 TestApplication application;
2517 Actor actor = Actor::New();
2519 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
2520 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == true);
2522 actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, false);
2523 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2527 int UtcDaliActorIsKeyboardFocusable(void)
2529 TestApplication application;
2531 Actor actor = Actor::New();
2533 DALI_TEST_CHECK(actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) == false);
2537 int UtcDaliActorRemoveConstraints(void)
2539 tet_infoline(" UtcDaliActorRemoveConstraints");
2540 TestApplication application;
2542 gTestConstraintCalled = false;
2544 Actor actor = Actor::New();
2546 Constraint constraint = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraint());
2548 actor.RemoveConstraints();
2550 DALI_TEST_CHECK(gTestConstraintCalled == false);
2552 application.GetScene().Add(actor);
2555 // flush the queue and render once
2556 application.SendNotification();
2557 application.Render();
2559 actor.RemoveConstraints();
2561 DALI_TEST_CHECK(gTestConstraintCalled == true);
2565 int UtcDaliActorRemoveConstraintTag(void)
2567 tet_infoline(" UtcDaliActorRemoveConstraintTag");
2568 TestApplication application;
2570 Actor actor = Actor::New();
2572 // 1. Apply Constraint1 and Constraint2, and test...
2573 unsigned int result1 = 0u;
2574 unsigned int result2 = 0u;
2576 unsigned constraint1Tag = 1u;
2577 Constraint constraint1 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result1, 1));
2578 constraint1.SetTag(constraint1Tag);
2579 constraint1.Apply();
2581 unsigned constraint2Tag = 2u;
2582 Constraint constraint2 = Constraint::New<Vector4>(actor, Actor::Property::COLOR, TestConstraintRef<Vector4>(result2, 2));
2583 constraint2.SetTag(constraint2Tag);
2584 constraint2.Apply();
2586 application.GetScene().Add(actor);
2587 // flush the queue and render once
2588 application.SendNotification();
2589 application.Render();
2591 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2592 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2594 // 2. Remove Constraint1 and test...
2597 actor.RemoveConstraints(constraint1Tag);
2598 // make color property dirty, which will trigger constraints to be reapplied.
2599 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2600 // flush the queue and render once
2601 application.SendNotification();
2602 application.Render();
2604 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2605 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2607 // 3. Re-Apply Constraint1 and test...
2610 constraint1.Apply();
2611 // make color property dirty, which will trigger constraints to be reapplied.
2612 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2613 // flush the queue and render once
2614 application.SendNotification();
2615 application.Render();
2617 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2618 DALI_TEST_EQUALS(result2, 2u, TEST_LOCATION);
2620 // 2. Remove Constraint2 and test...
2623 actor.RemoveConstraints(constraint2Tag);
2624 // make color property dirty, which will trigger constraints to be reapplied.
2625 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2626 // flush the queue and render once
2627 application.SendNotification();
2628 application.Render();
2630 DALI_TEST_EQUALS(result1, 1u, TEST_LOCATION);
2631 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2633 // 2. Remove Constraint1 as well and test...
2636 actor.RemoveConstraints(constraint1Tag);
2637 // make color property dirty, which will trigger constraints to be reapplied.
2638 actor.SetProperty(Actor::Property::COLOR, Color::WHITE);
2639 // flush the queue and render once
2640 application.SendNotification();
2641 application.Render();
2643 DALI_TEST_EQUALS(result1, 0u, TEST_LOCATION); ///< constraint 1 should not apply now.
2644 DALI_TEST_EQUALS(result2, 0u, TEST_LOCATION); ///< constraint 2 should not apply now.
2648 int UtcDaliActorTouchedSignal(void)
2650 TestApplication application;
2652 ResetTouchCallbacks();
2654 // get the root layer
2655 Actor actor = application.GetScene().GetRootLayer();
2656 DALI_TEST_CHECK(gTouchCallBackCalled == false);
2658 application.SendNotification();
2659 application.Render();
2661 // connect to its touch signal
2662 actor.TouchedSignal().Connect(TestTouchCallback);
2664 // simulate a touch event in the middle of the screen
2665 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2666 Dali::Integration::Point point;
2667 point.SetDeviceId(1);
2668 point.SetState(PointState::DOWN);
2669 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2670 Dali::Integration::TouchEvent touchEvent;
2671 touchEvent.AddPoint(point);
2672 application.ProcessEvent(touchEvent);
2674 DALI_TEST_CHECK(gTouchCallBackCalled == true);
2678 int UtcDaliActorHoveredSignal(void)
2680 TestApplication application;
2682 gHoverCallBackCalled = false;
2684 // get the root layer
2685 Actor actor = application.GetScene().GetRootLayer();
2686 DALI_TEST_CHECK(gHoverCallBackCalled == false);
2688 application.SendNotification();
2689 application.Render();
2691 // connect to its hover signal
2692 actor.HoveredSignal().Connect(TestCallback3);
2694 // simulate a hover event in the middle of the screen
2695 Vector2 touchPoint(application.GetScene().GetSize() * 0.5);
2696 Dali::Integration::Point point;
2697 point.SetDeviceId(1);
2698 point.SetState(PointState::MOTION);
2699 point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y));
2700 Dali::Integration::HoverEvent hoverEvent;
2701 hoverEvent.AddPoint(point);
2702 application.ProcessEvent(hoverEvent);
2704 DALI_TEST_CHECK(gHoverCallBackCalled == true);
2708 int UtcDaliActorOnOffSceneSignal(void)
2710 tet_infoline("Testing Dali::Actor::OnSceneSignal() and OffSceneSignal()");
2712 TestApplication application;
2715 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2716 gActorNamesOnOffScene.clear();
2718 Actor parent = Actor::New();
2719 parent.SetProperty(Actor::Property::NAME, "parent");
2720 parent.OnSceneSignal().Connect(OnSceneCallback);
2721 parent.OffSceneSignal().Connect(OffSceneCallback);
2723 DALI_TEST_CHECK(gOnSceneCallBackCalled == 0);
2724 DALI_TEST_CHECK(gOffSceneCallBackCalled == 0);
2726 // add parent to the scene
2727 application.GetScene().Add(parent);
2728 // onstage emitted, offstage not
2729 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2730 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2731 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2733 // test adding a child, should get onstage emitted
2735 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2736 gActorNamesOnOffScene.clear();
2738 Actor child = Actor::New();
2739 child.SetProperty(Actor::Property::NAME, "child");
2740 child.OnSceneSignal().Connect(OnSceneCallback);
2741 child.OffSceneSignal().Connect(OffSceneCallback);
2742 parent.Add(child); // add child
2743 // onscene emitted, offscene not
2744 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 1, TEST_LOCATION);
2745 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2746 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2748 // test removing parent from the scene
2750 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2751 gActorNamesOnOffScene.clear();
2753 application.GetScene().Remove(parent);
2754 // onscene not emitted, offscene is
2755 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2756 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 2, TEST_LOCATION);
2757 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2758 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[1], TEST_LOCATION);
2760 // test adding parent back to the scene
2762 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2763 gActorNamesOnOffScene.clear();
2765 application.GetScene().Add(parent);
2766 // onscene emitted, offscene not
2767 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 2, TEST_LOCATION);
2768 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 0, TEST_LOCATION);
2769 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2770 DALI_TEST_EQUALS("child", gActorNamesOnOffScene[1], TEST_LOCATION);
2772 // test removing child
2774 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2775 gActorNamesOnOffScene.clear();
2777 parent.Remove(child);
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("child", gActorNamesOnOffScene[0], TEST_LOCATION);
2783 // test removing parent
2785 gOnSceneCallBackCalled = gOffSceneCallBackCalled = 0;
2786 gActorNamesOnOffScene.clear();
2788 application.GetScene().Remove(parent);
2789 // onscene not emitted, offscene is
2790 DALI_TEST_EQUALS(gOnSceneCallBackCalled, 0, TEST_LOCATION);
2791 DALI_TEST_EQUALS(gOffSceneCallBackCalled, 1, TEST_LOCATION);
2792 DALI_TEST_EQUALS("parent", gActorNamesOnOffScene[0], TEST_LOCATION);
2796 int UtcDaliActorFindChildByName(void)
2798 tet_infoline("Testing Dali::Actor::FindChildByName()");
2799 TestApplication application;
2801 Actor parent = Actor::New();
2802 parent.SetProperty(Actor::Property::NAME, "parent");
2803 Actor first = Actor::New();
2804 first.SetProperty(Actor::Property::NAME, "first");
2805 Actor second = Actor::New();
2806 second.SetProperty(Actor::Property::NAME, "second");
2811 Actor found = parent.FindChildByName("foo");
2812 DALI_TEST_CHECK(!found);
2814 found = parent.FindChildByName("parent");
2815 DALI_TEST_CHECK(found == parent);
2817 found = parent.FindChildByName("first");
2818 DALI_TEST_CHECK(found == first);
2820 found = parent.FindChildByName("second");
2821 DALI_TEST_CHECK(found == second);
2825 int UtcDaliActorFindChildById(void)
2827 tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()");
2828 TestApplication application;
2830 Actor parent = Actor::New();
2831 Actor first = Actor::New();
2832 Actor second = Actor::New();
2837 Actor found = parent.FindChildById(100000);
2838 DALI_TEST_CHECK(!found);
2840 found = parent.FindChildById(parent.GetProperty<int>(Actor::Property::ID));
2841 DALI_TEST_CHECK(found == parent);
2843 found = parent.FindChildById(first.GetProperty<int>(Actor::Property::ID));
2844 DALI_TEST_CHECK(found == first);
2846 found = parent.FindChildById(second.GetProperty<int>(Actor::Property::ID));
2847 DALI_TEST_CHECK(found == second);
2851 int UtcDaliActorHitTest(void)
2856 HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result)
2858 mTouchPoint(touchPoint),
2864 Vector2 mTouchPoint;
2868 TestApplication application;
2869 tet_infoline(" UtcDaliActorHitTest");
2871 // Fill a vector with different hit tests.
2872 struct HitTestData* hitTestData[] = {
2873 // scale touch point result
2874 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside)
2875 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside)
2876 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.
2877 new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside)
2878 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.
2882 // get the root layer
2883 Actor actor = Actor::New();
2884 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2885 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2887 application.GetScene().Add(actor);
2889 ResetTouchCallbacks();
2891 unsigned int index = 0;
2892 while(NULL != hitTestData[index])
2894 actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f));
2895 actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z));
2897 // flush the queue and render once
2898 application.SendNotification();
2899 application.Render();
2901 DALI_TEST_CHECK(!gTouchCallBackCalled);
2903 // connect to its touch signal
2904 actor.TouchedSignal().Connect(TestTouchCallback);
2906 Dali::Integration::Point point;
2907 point.SetState(PointState::DOWN);
2908 point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y));
2909 Dali::Integration::TouchEvent event;
2910 event.AddPoint(point);
2912 // flush the queue and render once
2913 application.SendNotification();
2914 application.Render();
2915 application.ProcessEvent(event);
2917 DALI_TEST_CHECK(gTouchCallBackCalled == hitTestData[index]->mResult);
2919 if(gTouchCallBackCalled != hitTestData[index]->mResult)
2920 tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n",
2921 hitTestData[index]->mScale.x,
2922 hitTestData[index]->mScale.y,
2923 hitTestData[index]->mScale.z,
2924 hitTestData[index]->mTouchPoint.x,
2925 hitTestData[index]->mTouchPoint.y,
2926 hitTestData[index]->mResult);
2928 ResetTouchCallbacks();
2934 int UtcDaliActorSetDrawMode(void)
2936 TestApplication application;
2937 tet_infoline(" UtcDaliActorSetDrawModeOverlay");
2939 Actor a = Actor::New();
2941 application.GetScene().Add(a);
2942 application.SendNotification();
2943 application.Render(0);
2944 application.SendNotification();
2945 application.Render(1);
2947 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Ensure overlay is off by default
2949 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
2950 application.SendNotification();
2951 application.Render(1);
2953 DALI_TEST_CHECK(DrawMode::OVERLAY_2D == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is overlay
2955 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
2956 application.SendNotification();
2957 application.Render(1);
2959 DALI_TEST_CHECK(DrawMode::NORMAL == a.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE)); // Check Actor is normal
2963 int UtcDaliActorSetDrawModeOverlayRender(void)
2965 TestApplication application;
2966 tet_infoline(" UtcDaliActorSetDrawModeOverlayRender");
2968 application.SendNotification();
2969 application.Render(1);
2971 std::vector<GLuint> ids;
2972 ids.push_back(8); // first rendered actor
2973 ids.push_back(9); // second rendered actor
2974 ids.push_back(10); // third rendered actor
2975 application.GetGlAbstraction().SetNextTextureIds(ids);
2977 Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2978 Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2979 Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16);
2980 Actor a = CreateRenderableActor(imageA);
2981 Actor b = CreateRenderableActor(imageB);
2982 Actor c = CreateRenderableActor(imageC);
2984 application.SendNotification();
2985 application.Render(1);
2987 //Textures are bound when first created. Clear bound textures vector
2988 application.GetGlAbstraction().ClearBoundTextures();
2990 // Render a,b,c as regular non-overlays. so order will be:
2994 application.GetScene().Add(a);
2995 application.GetScene().Add(b);
2996 application.GetScene().Add(c);
2998 application.SendNotification();
2999 application.Render(1);
3001 // Should be 3 textures changes.
3002 const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0);
3003 typedef std::vector<GLuint>::size_type TextureSize;
3004 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3005 if(boundTextures.size() == 3)
3007 DALI_TEST_CHECK(boundTextures[0] == 8u);
3008 DALI_TEST_CHECK(boundTextures[1] == 9u);
3009 DALI_TEST_CHECK(boundTextures[2] == 10u);
3012 // Now texture ids have been set, we can monitor their render order.
3013 // render a as an overlay (last), so order will be:
3017 a.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3018 application.GetGlAbstraction().ClearBoundTextures();
3020 application.SendNotification();
3021 application.Render(1);
3023 // Should be 3 texture changes.
3024 DALI_TEST_EQUALS(boundTextures.size(), static_cast<TextureSize>(3), TEST_LOCATION);
3025 if(boundTextures.size() == 3)
3027 DALI_TEST_CHECK(boundTextures[0] == 9u);
3028 DALI_TEST_CHECK(boundTextures[1] == 10u);
3029 DALI_TEST_CHECK(boundTextures[2] == 8u);
3034 int UtcDaliActorGetCurrentWorldMatrix(void)
3036 TestApplication application;
3037 tet_infoline(" UtcDaliActorGetCurrentWorldMatrix");
3039 Actor parent = Actor::New();
3040 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3041 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3042 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3043 Radian rotationAngle(Degree(85.0f));
3044 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3045 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3046 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3047 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3048 parent.SetProperty(Actor::Property::SCALE, parentScale);
3049 application.GetScene().Add(parent);
3051 Actor child = Actor::New();
3052 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3053 Vector3 childPosition(0.0f, 0.0f, 100.0f);
3054 Radian childRotationAngle(Degree(23.0f));
3055 Quaternion childRotation(childRotationAngle, Vector3::YAXIS);
3056 Vector3 childScale(2.0f, 2.0f, 2.0f);
3057 child.SetProperty(Actor::Property::POSITION, childPosition);
3058 child.SetProperty(Actor::Property::ORIENTATION, childRotation);
3059 child.SetProperty(Actor::Property::SCALE, childScale);
3062 application.SendNotification();
3063 application.Render(0);
3064 application.Render();
3065 application.SendNotification();
3067 Matrix parentMatrix(false);
3068 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3070 Matrix childMatrix(false);
3071 childMatrix.SetTransformComponents(childScale, childRotation, childPosition);
3073 //Child matrix should be the composition of child and parent
3074 Matrix childWorldMatrix(false);
3075 Matrix::Multiply(childWorldMatrix, childMatrix, parentMatrix);
3077 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3078 DALI_TEST_EQUALS(child.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), childWorldMatrix, 0.001, TEST_LOCATION);
3082 int UtcDaliActorConstrainedToWorldMatrix(void)
3084 TestApplication application;
3085 tet_infoline(" UtcDaliActorConstrainedToWorldMatrix");
3087 Actor parent = Actor::New();
3088 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3089 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3090 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3091 Radian rotationAngle(Degree(85.0f));
3092 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3093 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3094 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3095 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3096 parent.SetProperty(Actor::Property::SCALE, parentScale);
3097 application.GetScene().Add(parent);
3099 Actor child = Actor::New();
3100 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3101 Constraint posConstraint = Constraint::New<Vector3>(child, Actor::Property::POSITION, PositionComponentConstraint());
3102 posConstraint.AddSource(Source(parent, Actor::Property::WORLD_MATRIX));
3103 posConstraint.Apply();
3105 application.GetScene().Add(child);
3107 application.SendNotification();
3108 application.Render(0);
3109 application.Render();
3110 application.SendNotification();
3112 Matrix parentMatrix(false);
3113 parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
3115 DALI_TEST_EQUALS(parent.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX), parentMatrix, 0.001, TEST_LOCATION);
3116 DALI_TEST_EQUALS(child.GetCurrentProperty<Vector3>(Actor::Property::POSITION), parent.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.001, TEST_LOCATION);
3120 int UtcDaliActorConstrainedToOrientation(void)
3122 TestApplication application;
3123 tet_infoline(" UtcDaliActorConstrainedToOrientation");
3125 Actor parent = Actor::New();
3126 parent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3127 parent.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3128 Vector3 parentPosition(10.0f, 20.0f, 30.0f);
3129 Radian rotationAngle(Degree(85.0f));
3130 Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
3131 Vector3 parentScale(1.0f, 2.0f, 3.0f);
3132 parent.SetProperty(Actor::Property::POSITION, parentPosition);
3133 parent.SetProperty(Actor::Property::ORIENTATION, parentRotation);
3134 parent.SetProperty(Actor::Property::SCALE, parentScale);
3135 application.GetScene().Add(parent);
3137 Actor child = Actor::New();
3138 child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3139 Constraint posConstraint = Constraint::New<Quaternion>(child, Actor::Property::ORIENTATION, OrientationComponentConstraint());
3140 posConstraint.AddSource(Source(parent, Actor::Property::ORIENTATION));
3141 posConstraint.Apply();
3143 application.GetScene().Add(child);
3145 application.SendNotification();
3146 application.Render(0);
3147 application.Render();
3148 application.SendNotification();
3150 DALI_TEST_EQUALS(child.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), parent.GetCurrentProperty<Quaternion>(Actor::Property::ORIENTATION), 0.001, TEST_LOCATION);
3154 int UtcDaliActorConstrainedToOpacity(void)
3156 TestApplication application;
3157 tet_infoline(" UtcDaliActorConstrainedToOpacity");
3159 Actor parent = Actor::New();
3160 parent.SetProperty(Actor::Property::OPACITY, 0.7f);
3161 application.GetScene().Add(parent);
3163 Actor child = Actor::New();
3164 Constraint opacityConstraint = Constraint::New<float>(child, Actor::Property::OPACITY, EqualToConstraint());
3165 opacityConstraint.AddSource(Source(parent, Actor::Property::OPACITY));
3166 opacityConstraint.Apply();
3168 application.GetScene().Add(child);
3170 application.SendNotification();
3171 application.Render(0);
3172 application.Render();
3173 application.SendNotification();
3175 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3177 parent.SetProperty(Actor::Property::OPACITY, 0.3f);
3179 application.SendNotification();
3180 application.Render(0);
3181 application.Render();
3182 application.SendNotification();
3184 DALI_TEST_EQUALS(child.GetCurrentProperty<float>(Actor::Property::OPACITY), parent.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.001f, TEST_LOCATION);
3189 int UtcDaliActorUnparent(void)
3191 TestApplication application;
3192 tet_infoline(" UtcDaliActorUnparent");
3194 Actor parent = Actor::New();
3195 application.GetScene().Add(parent);
3197 Actor child = Actor::New();
3199 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3200 DALI_TEST_CHECK(!child.GetParent());
3202 // Test that calling Unparent with no parent is a NOOP
3205 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3206 DALI_TEST_CHECK(!child.GetParent());
3208 // Test that Unparent works
3211 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3212 DALI_TEST_CHECK(parent == child.GetParent());
3216 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3217 DALI_TEST_CHECK(!child.GetParent());
3219 // Test that UnparentAndReset works
3222 DALI_TEST_EQUALS(parent.GetChildCount(), 1u, TEST_LOCATION);
3223 DALI_TEST_CHECK(parent == child.GetParent());
3225 UnparentAndReset(child);
3227 DALI_TEST_EQUALS(parent.GetChildCount(), 0u, TEST_LOCATION);
3228 DALI_TEST_CHECK(!child);
3230 // Test that UnparentAndReset is a NOOP with empty handle
3231 UnparentAndReset(child);
3233 DALI_TEST_CHECK(!child);
3237 int UtcDaliActorGetChildAt(void)
3239 TestApplication application;
3240 tet_infoline(" UtcDaliActorGetChildAt");
3242 Actor parent = Actor::New();
3243 application.GetScene().Add(parent);
3245 Actor child0 = Actor::New();
3248 Actor child1 = Actor::New();
3251 Actor child2 = Actor::New();
3254 DALI_TEST_EQUALS(parent.GetChildAt(0), child0, TEST_LOCATION);
3255 DALI_TEST_EQUALS(parent.GetChildAt(1), child1, TEST_LOCATION);
3256 DALI_TEST_EQUALS(parent.GetChildAt(2), child2, TEST_LOCATION);
3260 int UtcDaliActorSetGetOverlay(void)
3262 TestApplication application;
3263 tet_infoline(" UtcDaliActorSetGetOverlay");
3265 Actor parent = Actor::New();
3266 parent.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3267 DALI_TEST_CHECK(parent.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE) == DrawMode::OVERLAY_2D);
3271 int UtcDaliActorCreateDestroy(void)
3273 Actor* actor = new Actor;
3274 DALI_TEST_CHECK(actor);
3281 struct PropertyStringIndex
3283 const char* const name;
3284 const Property::Index index;
3285 const Property::Type type;
3288 const PropertyStringIndex PROPERTY_TABLE[] =
3290 {"parentOrigin", Actor::Property::PARENT_ORIGIN, Property::VECTOR3},
3291 {"parentOriginX", Actor::Property::PARENT_ORIGIN_X, Property::FLOAT},
3292 {"parentOriginY", Actor::Property::PARENT_ORIGIN_Y, Property::FLOAT},
3293 {"parentOriginZ", Actor::Property::PARENT_ORIGIN_Z, Property::FLOAT},
3294 {"anchorPoint", Actor::Property::ANCHOR_POINT, Property::VECTOR3},
3295 {"anchorPointX", Actor::Property::ANCHOR_POINT_X, Property::FLOAT},
3296 {"anchorPointY", Actor::Property::ANCHOR_POINT_Y, Property::FLOAT},
3297 {"anchorPointZ", Actor::Property::ANCHOR_POINT_Z, Property::FLOAT},
3298 {"size", Actor::Property::SIZE, Property::VECTOR3},
3299 {"sizeWidth", Actor::Property::SIZE_WIDTH, Property::FLOAT},
3300 {"sizeHeight", Actor::Property::SIZE_HEIGHT, Property::FLOAT},
3301 {"sizeDepth", Actor::Property::SIZE_DEPTH, Property::FLOAT},
3302 {"position", Actor::Property::POSITION, Property::VECTOR3},
3303 {"positionX", Actor::Property::POSITION_X, Property::FLOAT},
3304 {"positionY", Actor::Property::POSITION_Y, Property::FLOAT},
3305 {"positionZ", Actor::Property::POSITION_Z, Property::FLOAT},
3306 {"worldPosition", Actor::Property::WORLD_POSITION, Property::VECTOR3},
3307 {"worldPositionX", Actor::Property::WORLD_POSITION_X, Property::FLOAT},
3308 {"worldPositionY", Actor::Property::WORLD_POSITION_Y, Property::FLOAT},
3309 {"worldPositionZ", Actor::Property::WORLD_POSITION_Z, Property::FLOAT},
3310 {"orientation", Actor::Property::ORIENTATION, Property::ROTATION},
3311 {"worldOrientation", Actor::Property::WORLD_ORIENTATION, Property::ROTATION},
3312 {"scale", Actor::Property::SCALE, Property::VECTOR3},
3313 {"scaleX", Actor::Property::SCALE_X, Property::FLOAT},
3314 {"scaleY", Actor::Property::SCALE_Y, Property::FLOAT},
3315 {"scaleZ", Actor::Property::SCALE_Z, Property::FLOAT},
3316 {"worldScale", Actor::Property::WORLD_SCALE, Property::VECTOR3},
3317 {"visible", Actor::Property::VISIBLE, Property::BOOLEAN},
3318 {"color", Actor::Property::COLOR, Property::VECTOR4},
3319 {"colorRed", Actor::Property::COLOR_RED, Property::FLOAT},
3320 {"colorGreen", Actor::Property::COLOR_GREEN, Property::FLOAT},
3321 {"colorBlue", Actor::Property::COLOR_BLUE, Property::FLOAT},
3322 {"colorAlpha", Actor::Property::COLOR_ALPHA, Property::FLOAT},
3323 {"worldColor", Actor::Property::WORLD_COLOR, Property::VECTOR4},
3324 {"worldMatrix", Actor::Property::WORLD_MATRIX, Property::MATRIX},
3325 {"name", Actor::Property::NAME, Property::STRING},
3326 {"sensitive", Actor::Property::SENSITIVE, Property::BOOLEAN},
3327 {"leaveRequired", Actor::Property::LEAVE_REQUIRED, Property::BOOLEAN},
3328 {"inheritOrientation", Actor::Property::INHERIT_ORIENTATION, Property::BOOLEAN},
3329 {"inheritScale", Actor::Property::INHERIT_SCALE, Property::BOOLEAN},
3330 {"colorMode", Actor::Property::COLOR_MODE, Property::INTEGER},
3331 {"drawMode", Actor::Property::DRAW_MODE, Property::INTEGER},
3332 {"sizeModeFactor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3},
3333 {"widthResizePolicy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING},
3334 {"heightResizePolicy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING},
3335 {"sizeScalePolicy", Actor::Property::SIZE_SCALE_POLICY, Property::INTEGER},
3336 {"widthForHeight", Actor::Property::WIDTH_FOR_HEIGHT, Property::BOOLEAN},
3337 {"heightForWidth", Actor::Property::HEIGHT_FOR_WIDTH, Property::BOOLEAN},
3338 {"padding", Actor::Property::PADDING, Property::VECTOR4},
3339 {"minimumSize", Actor::Property::MINIMUM_SIZE, Property::VECTOR2},
3340 {"maximumSize", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2},
3341 {"inheritPosition", Actor::Property::INHERIT_POSITION, Property::BOOLEAN},
3342 {"clippingMode", Actor::Property::CLIPPING_MODE, Property::STRING},
3343 {"opacity", Actor::Property::OPACITY, Property::FLOAT},
3345 const unsigned int PROPERTY_TABLE_COUNT = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
3346 } // unnamed namespace
3348 int UtcDaliActorProperties(void)
3350 TestApplication application;
3352 Actor actor = Actor::New();
3354 for(unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i)
3356 tet_printf("Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index);
3357 DALI_TEST_EQUALS(actor.GetPropertyName(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].name, TEST_LOCATION);
3358 DALI_TEST_EQUALS(actor.GetPropertyIndex(PROPERTY_TABLE[i].name), PROPERTY_TABLE[i].index, TEST_LOCATION);
3359 DALI_TEST_EQUALS(actor.GetPropertyType(PROPERTY_TABLE[i].index), PROPERTY_TABLE[i].type, TEST_LOCATION);
3364 int UtcDaliRelayoutProperties_ResizePolicies(void)
3366 TestApplication application;
3368 Actor actor = Actor::New();
3371 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3372 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), "USE_NATURAL_SIZE", TEST_LOCATION);
3374 // Set resize policy for all dimensions
3375 actor.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
3376 for(unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i)
3378 DALI_TEST_EQUALS(actor.GetResizePolicy(static_cast<Dimension::Type>(1 << i)), ResizePolicy::USE_NATURAL_SIZE, TEST_LOCATION);
3381 // Set individual dimensions
3382 const char* const widthPolicy = "FILL_TO_PARENT";
3383 const char* const heightPolicy = "FIXED";
3385 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicy);
3386 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicy);
3388 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_RESIZE_POLICY).Get<std::string>(), widthPolicy, TEST_LOCATION);
3389 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_RESIZE_POLICY).Get<std::string>(), heightPolicy, TEST_LOCATION);
3391 // Set individual dimensions using enums
3392 ResizePolicy::Type widthPolicyEnum = ResizePolicy::USE_ASSIGNED_SIZE;
3393 ResizePolicy::Type heightPolicyEnum = ResizePolicy::SIZE_RELATIVE_TO_PARENT;
3395 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, widthPolicyEnum);
3396 actor.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, heightPolicyEnum);
3398 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::WIDTH)), static_cast<int>(widthPolicyEnum), TEST_LOCATION);
3399 DALI_TEST_EQUALS(static_cast<int>(actor.GetResizePolicy(Dimension::HEIGHT)), static_cast<int>(heightPolicyEnum), TEST_LOCATION);
3404 int UtcDaliRelayoutProperties_SizeScalePolicy(void)
3406 TestApplication application;
3408 Actor actor = Actor::New();
3411 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), SizeScalePolicy::USE_SIZE_SET, TEST_LOCATION);
3413 SizeScalePolicy::Type policy = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3414 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy);
3415 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy, TEST_LOCATION);
3418 const SizeScalePolicy::Type policy1 = SizeScalePolicy::FIT_WITH_ASPECT_RATIO;
3419 const SizeScalePolicy::Type policy2 = SizeScalePolicy::FILL_WITH_ASPECT_RATIO;
3421 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy1);
3422 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy1, TEST_LOCATION);
3424 actor.SetProperty(Actor::Property::SIZE_SCALE_POLICY, policy2);
3425 DALI_TEST_EQUALS(actor.GetProperty<SizeScalePolicy::Type>(Actor::Property::SIZE_SCALE_POLICY), policy2, TEST_LOCATION);
3430 int UtcDaliRelayoutProperties_SizeModeFactor(void)
3432 TestApplication application;
3434 Actor actor = Actor::New();
3437 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3438 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), Vector3(1.0f, 1.0f, 1.0f), TEST_LOCATION);
3440 Vector3 sizeMode(1.0f, 2.0f, 3.0f);
3441 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode);
3442 DALI_TEST_EQUALS(actor.GetProperty<Vector3>(Actor::Property::SIZE_MODE_FACTOR), sizeMode, TEST_LOCATION);
3445 Vector3 sizeMode1(2.0f, 3.0f, 4.0f);
3447 actor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, sizeMode1);
3448 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE_MODE_FACTOR).Get<Vector3>(), sizeMode1, TEST_LOCATION);
3453 int UtcDaliRelayoutProperties_DimensionDependency(void)
3455 TestApplication application;
3457 Actor actor = Actor::New();
3460 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3461 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), false, TEST_LOCATION);
3464 actor.SetProperty(Actor::Property::WIDTH_FOR_HEIGHT, true);
3465 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), true, TEST_LOCATION);
3467 actor.SetProperty(Actor::Property::HEIGHT_FOR_WIDTH, true);
3468 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::HEIGHT_FOR_WIDTH).Get<bool>(), true, TEST_LOCATION);
3470 // Test setting another resize policy
3471 actor.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FIXED");
3472 DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::WIDTH_FOR_HEIGHT).Get<bool>(), false, TEST_LOCATION);
3477 int UtcDaliRelayoutProperties_Padding(void)
3479 TestApplication application;
3481 Actor actor = Actor::New();
3484 Vector4 padding(1.0f, 2.0f, 3.0f, 4.0f);
3487 actor.SetProperty(Actor::Property::PADDING, padding);
3488 Vector4 paddingResult = actor.GetProperty(Actor::Property::PADDING).Get<Vector4>();
3490 DALI_TEST_EQUALS(paddingResult, padding, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3495 int UtcDaliRelayoutProperties_MinimumMaximumSize(void)
3497 TestApplication application;
3499 Actor actor = Actor::New();
3502 Vector2 minSize(1.0f, 2.0f);
3504 actor.SetProperty(Actor::Property::MINIMUM_SIZE, minSize);
3505 Vector2 resultMin = actor.GetProperty(Actor::Property::MINIMUM_SIZE).Get<Vector2>();
3507 DALI_TEST_EQUALS(resultMin, minSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3509 Vector2 maxSize(3.0f, 4.0f);
3511 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, maxSize);
3512 Vector2 resultMax = actor.GetProperty(Actor::Property::MAXIMUM_SIZE).Get<Vector2>();
3514 DALI_TEST_EQUALS(resultMax, maxSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
3519 int UtcDaliActorGetHeightForWidth(void)
3521 TestApplication application;
3523 Actor actor = Actor::New();
3525 DALI_TEST_EQUALS(actor.GetHeightForWidth(1.0f), 1.0f, TEST_LOCATION);
3530 int UtcDaliActorGetWidthForHeight(void)
3532 TestApplication application;
3534 Actor actor = Actor::New();
3536 DALI_TEST_EQUALS(actor.GetWidthForHeight(1.0f), 1.0f, TEST_LOCATION);
3541 int UtcDaliActorGetRelayoutSize(void)
3543 TestApplication application;
3545 Actor actor = Actor::New();
3547 // Add actor to stage
3548 application.GetScene().Add(actor);
3550 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 0.0f, TEST_LOCATION);
3552 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
3553 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 0.0f));
3555 // Flush the queue and render once
3556 application.SendNotification();
3557 application.Render();
3559 DALI_TEST_EQUALS(actor.GetRelayoutSize(Dimension::WIDTH), 1.0f, TEST_LOCATION);
3564 int UtcDaliActorSetPadding(void)
3566 TestApplication application;
3568 Actor actor = Actor::New();
3571 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3573 DALI_TEST_EQUALS(padding.left, 0.0f, TEST_LOCATION);
3574 DALI_TEST_EQUALS(padding.right, 0.0f, TEST_LOCATION);
3575 DALI_TEST_EQUALS(padding.bottom, 0.0f, TEST_LOCATION);
3576 DALI_TEST_EQUALS(padding.top, 0.0f, TEST_LOCATION);
3578 Padding padding2(1.0f, 2.0f, 3.0f, 4.0f);
3579 actor.SetProperty(Actor::Property::PADDING, padding2);
3581 padding = actor.GetProperty<Vector4>(Actor::Property::PADDING);
3583 DALI_TEST_EQUALS(padding.left, padding2.left, TEST_LOCATION);
3584 DALI_TEST_EQUALS(padding.right, padding2.right, TEST_LOCATION);
3585 DALI_TEST_EQUALS(padding.bottom, padding2.bottom, TEST_LOCATION);
3586 DALI_TEST_EQUALS(padding.top, padding2.top, TEST_LOCATION);
3591 int UtcDaliActorSetMinimumSize(void)
3593 TestApplication application;
3595 Actor actor = Actor::New();
3597 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3599 DALI_TEST_EQUALS(size.width, 0.0f, TEST_LOCATION);
3600 DALI_TEST_EQUALS(size.height, 0.0f, TEST_LOCATION);
3602 Vector2 size2(1.0f, 2.0f);
3603 actor.SetProperty(Actor::Property::MINIMUM_SIZE, size2);
3605 size = actor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE);
3607 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3608 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3613 int UtcDaliActorSetMaximumSize(void)
3615 TestApplication application;
3617 Actor actor = Actor::New();
3619 Vector2 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3621 DALI_TEST_EQUALS(size.width, FLT_MAX, TEST_LOCATION);
3622 DALI_TEST_EQUALS(size.height, FLT_MAX, TEST_LOCATION);
3624 Vector2 size2(1.0f, 2.0f);
3625 actor.SetProperty(Actor::Property::MAXIMUM_SIZE, size2);
3627 size = actor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE);
3629 DALI_TEST_EQUALS(size.width, size2.width, TEST_LOCATION);
3630 DALI_TEST_EQUALS(size.height, size2.height, TEST_LOCATION);
3635 int UtcDaliActorOnRelayoutSignal(void)
3637 tet_infoline("Testing Dali::Actor::OnRelayoutSignal()");
3639 TestApplication application;
3642 gOnRelayoutCallBackCalled = false;
3643 gActorNamesRelayout.clear();
3645 Actor actor = Actor::New();
3646 actor.SetProperty(Actor::Property::NAME, "actor");
3647 actor.OnRelayoutSignal().Connect(OnRelayoutCallback);
3650 DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
3652 // Add actor to stage
3653 application.GetScene().Add(actor);
3655 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3656 actor.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 2.0));
3658 // Flush the queue and render once
3659 application.SendNotification();
3660 application.Render();
3662 // OnRelayout emitted
3663 DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
3664 DALI_TEST_EQUALS("actor", gActorNamesRelayout[0], TEST_LOCATION);
3669 int UtcDaliActorGetHierachyDepth(void)
3671 TestApplication application;
3672 tet_infoline("Testing Dali::Actor::GetHierarchyDepth()");
3674 /* Build tree of actors:
3684 * GetHierarchyDepth should return 1 for A, 2 for B and C, and 3 for D, E and F.
3686 Integration::Scene stage(application.GetScene());
3688 Actor actorA = Actor::New();
3689 Actor actorB = Actor::New();
3690 Actor actorC = Actor::New();
3691 Actor actorD = Actor::New();
3692 Actor actorE = Actor::New();
3693 Actor actorF = Actor::New();
3695 //Test that root actor has depth equal 0
3696 DALI_TEST_EQUALS(0, stage.GetRootLayer().GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3698 //Test actors return depth -1 when not connected to the tree
3699 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3700 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3701 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3702 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3703 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3704 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3706 //Create the hierarchy
3714 //Test actors return correct depth
3715 DALI_TEST_EQUALS(1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3716 DALI_TEST_EQUALS(2, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3717 DALI_TEST_EQUALS(2, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3718 DALI_TEST_EQUALS(3, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3719 DALI_TEST_EQUALS(3, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3720 DALI_TEST_EQUALS(3, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3722 //Removing actorB from the hierarchy. actorB, actorD and actorE should now have depth equal -1
3723 actorA.Remove(actorB);
3725 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3726 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3727 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3729 //Removing actorA from the stage. All actors should have depth equal -1
3730 stage.Remove(actorA);
3732 DALI_TEST_EQUALS(-1, actorA.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3733 DALI_TEST_EQUALS(-1, actorB.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3734 DALI_TEST_EQUALS(-1, actorC.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3735 DALI_TEST_EQUALS(-1, actorD.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3736 DALI_TEST_EQUALS(-1, actorE.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3737 DALI_TEST_EQUALS(-1, actorF.GetProperty<int>(Actor::Property::HIERARCHY_DEPTH), TEST_LOCATION);
3742 int UtcDaliActorAnchorPointPropertyAsString(void)
3744 TestApplication application;
3746 Actor actor = Actor::New();
3748 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_LEFT");
3749 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3751 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_CENTER");
3752 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3754 actor.SetProperty(Actor::Property::ANCHOR_POINT, "TOP_RIGHT");
3755 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3757 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_LEFT");
3758 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3760 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER");
3761 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER, TEST_LOCATION);
3763 actor.SetProperty(Actor::Property::ANCHOR_POINT, "CENTER_RIGHT");
3764 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3766 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT");
3767 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3769 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER");
3770 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3772 actor.SetProperty(Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT");
3773 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3775 // Invalid should not change anything
3776 actor.SetProperty(Actor::Property::ANCHOR_POINT, "INVALID_ARG");
3777 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3782 int UtcDaliActorParentOriginPropertyAsString(void)
3784 TestApplication application;
3786 Actor actor = Actor::New();
3788 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_LEFT");
3789 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
3791 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_CENTER");
3792 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_CENTER, TEST_LOCATION);
3794 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "TOP_RIGHT");
3795 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_RIGHT, TEST_LOCATION);
3797 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_LEFT");
3798 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_LEFT, TEST_LOCATION);
3800 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER");
3801 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER, TEST_LOCATION);
3803 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT");
3804 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::CENTER_RIGHT, TEST_LOCATION);
3806 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT");
3807 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION);
3809 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER");
3810 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION);
3812 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT");
3813 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3815 // Invalid should not change anything
3816 actor.SetProperty(Actor::Property::PARENT_ORIGIN, "INVALID_ARG");
3817 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION);
3822 int UtcDaliActorColorModePropertyAsString(void)
3824 TestApplication application;
3826 Actor actor = Actor::New();
3828 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_COLOR");
3829 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3831 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_PARENT_COLOR");
3832 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3834 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR");
3835 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3837 actor.SetProperty(Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA");
3838 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3840 // Invalid should not change anything
3841 actor.SetProperty(Actor::Property::COLOR_MODE, "INVALID_ARG");
3842 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3847 int UtcDaliActorDrawModePropertyAsString(void)
3849 TestApplication application;
3851 Actor actor = Actor::New();
3853 actor.SetProperty(Actor::Property::DRAW_MODE, "NORMAL");
3854 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3856 actor.SetProperty(Actor::Property::DRAW_MODE, "OVERLAY_2D");
3857 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3859 // Invalid should not change anything
3860 actor.SetProperty(Actor::Property::DRAW_MODE, "INVALID_ARG");
3861 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3866 int UtcDaliActorColorModePropertyAsEnum(void)
3868 TestApplication application;
3870 Actor actor = Actor::New();
3872 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_COLOR);
3873 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_COLOR, TEST_LOCATION);
3875 actor.SetProperty(Actor::Property::COLOR_MODE, USE_PARENT_COLOR);
3876 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_PARENT_COLOR, TEST_LOCATION);
3878 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR);
3879 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION);
3881 actor.SetProperty(Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_ALPHA);
3882 DALI_TEST_EQUALS(actor.GetProperty<ColorMode>(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION);
3887 int UtcDaliActorDrawModePropertyAsEnum(void)
3889 TestApplication application;
3891 Actor actor = Actor::New();
3893 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::NORMAL);
3894 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::NORMAL, TEST_LOCATION);
3896 actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
3897 DALI_TEST_EQUALS(actor.GetProperty<DrawMode::Type>(Actor::Property::DRAW_MODE), DrawMode::OVERLAY_2D, TEST_LOCATION);
3902 int UtcDaliActorAddRendererP(void)
3904 tet_infoline("Testing Actor::AddRenderer");
3905 TestApplication application;
3907 Actor actor = Actor::New();
3909 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3911 Geometry geometry = CreateQuadGeometry();
3912 Shader shader = CreateShader();
3913 Renderer renderer = Renderer::New(geometry, shader);
3915 actor.AddRenderer(renderer);
3916 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3917 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
3922 int UtcDaliActorAddRendererN01(void)
3924 tet_infoline("Testing Actor::AddRenderer");
3925 TestApplication application;
3927 Actor actor = Actor::New();
3933 actor.AddRenderer(renderer);
3934 tet_printf("Assertion test failed - no Exception\n");
3935 tet_result(TET_FAIL);
3937 catch(Dali::DaliException& e)
3939 DALI_TEST_PRINT_ASSERT(e);
3940 DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
3941 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3945 tet_printf("Assertion test failed - wrong Exception\n");
3946 tet_result(TET_FAIL);
3952 int UtcDaliActorAddRendererN02(void)
3954 tet_infoline("UtcDaliActorAddRendererN02");
3960 TestApplication application;
3962 Geometry geometry = CreateQuadGeometry();
3963 Shader shader = CreateShader();
3964 renderer = Renderer::New(geometry, shader);
3966 actor = Actor::New();
3969 // try illegal AddRenderer
3972 actor.AddRenderer(renderer);
3973 tet_printf("Assertion test failed - no Exception\n");
3974 tet_result(TET_FAIL);
3976 catch(Dali::DaliException& e)
3978 DALI_TEST_PRINT_ASSERT(e);
3979 DALI_TEST_ASSERT(e, "EventThreadServices::IsCoreRunning()", TEST_LOCATION);
3983 tet_printf("Assertion test failed - wrong Exception\n");
3984 tet_result(TET_FAIL);
3990 int UtcDaliActorAddRendererOnScene(void)
3992 tet_infoline("Testing Actor::AddRenderer");
3993 TestApplication application;
3995 Actor actor = Actor::New();
3996 application.GetScene().Add(actor);
3998 application.SendNotification();
3999 application.Render(0);
4001 Geometry geometry = CreateQuadGeometry();
4002 Shader shader = CreateShader();
4003 Renderer renderer = Renderer::New(geometry, shader);
4005 application.SendNotification();
4006 application.Render(0);
4010 actor.AddRenderer(renderer);
4011 tet_result(TET_PASS);
4015 tet_result(TET_FAIL);
4021 int UtcDaliActorRemoveRendererP1(void)
4023 tet_infoline("Testing Actor::RemoveRenderer");
4024 TestApplication application;
4026 Actor actor = Actor::New();
4028 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4031 Geometry geometry = CreateQuadGeometry();
4032 Shader shader = CreateShader();
4033 Renderer renderer = Renderer::New(geometry, shader);
4035 actor.AddRenderer(renderer);
4036 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4037 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4039 application.SendNotification();
4040 application.Render();
4044 Renderer renderer = actor.GetRendererAt(0);
4045 actor.RemoveRenderer(renderer);
4046 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4048 application.SendNotification();
4049 application.Render();
4052 // Call one final time to ensure that the renderer is actually removed after
4053 // the handle goes out of scope, and excercises the deletion code path in
4054 // scene graph and render.
4055 application.SendNotification();
4056 application.Render();
4061 int UtcDaliActorRemoveRendererP2(void)
4063 tet_infoline("Testing Actor::RemoveRenderer");
4064 TestApplication application;
4066 Actor actor = Actor::New();
4068 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4070 Geometry geometry = CreateQuadGeometry();
4071 Shader shader = CreateShader();
4072 Renderer renderer = Renderer::New(geometry, shader);
4074 actor.AddRenderer(renderer);
4075 application.SendNotification();
4076 application.Render();
4078 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4079 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4081 actor.RemoveRenderer(0);
4082 application.SendNotification();
4083 application.Render();
4085 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4087 // Shut down whilst holding onto the renderer handle.
4091 int UtcDaliActorRemoveRendererN(void)
4093 tet_infoline("Testing Actor::RemoveRenderer");
4094 TestApplication application;
4096 Actor actor = Actor::New();
4098 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
4100 Geometry geometry = CreateQuadGeometry();
4101 Shader shader = CreateShader();
4102 Renderer renderer = Renderer::New(geometry, shader);
4104 actor.AddRenderer(renderer);
4105 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4106 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4108 actor.RemoveRenderer(10);
4109 DALI_TEST_EQUALS(actor.GetRendererAt(0), renderer, TEST_LOCATION);
4110 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
4115 // Clipping test helper functions:
4116 Actor CreateActorWithContent(uint32_t width, uint32_t height)
4118 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
4119 Actor actor = CreateRenderableActor(image);
4121 // Setup dimensions and position so actor is not skipped by culling.
4122 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4123 actor.SetProperty(Actor::Property::SIZE, Vector2(width, height));
4124 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4125 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4130 Actor CreateActorWithContent16x16()
4132 return CreateActorWithContent(16, 16);
4135 void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace)
4137 enabledDisableTrace.Reset();
4138 stencilTrace.Reset();
4139 enabledDisableTrace.Enable(true);
4140 stencilTrace.Enable(true);
4142 application.SendNotification();
4143 application.Render();
4145 enabledDisableTrace.Enable(false);
4146 stencilTrace.Enable(false);
4149 void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue)
4151 const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams();
4153 DALI_TEST_EQUALS<bool>(colorMaskParams.red, maskValue, TEST_LOCATION);
4154 DALI_TEST_EQUALS<bool>(colorMaskParams.green, maskValue, TEST_LOCATION);
4155 DALI_TEST_EQUALS<bool>(colorMaskParams.blue, maskValue, TEST_LOCATION);
4156 DALI_TEST_EQUALS<bool>(colorMaskParams.alpha, maskValue, TEST_LOCATION);
4159 int UtcDaliActorPropertyClippingP(void)
4161 // This test checks the clippingMode property.
4162 tet_infoline("Testing Actor::Property::ClippingMode: P");
4163 TestApplication application;
4165 Actor actor = Actor::New();
4167 // Check default clippingEnabled value.
4168 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4171 bool getValueResult = getValue.Get(value);
4172 DALI_TEST_CHECK(getValueResult);
4176 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4179 // Check setting the property to the stencil mode.
4180 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4182 // Check the new value was set.
4183 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4184 getValueResult = getValue.Get(value);
4185 DALI_TEST_CHECK(getValueResult);
4189 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_CHILDREN, TEST_LOCATION);
4192 // Check setting the property to the scissor mode.
4193 actor.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4195 // Check the new value was set.
4196 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4197 getValueResult = getValue.Get(value);
4198 DALI_TEST_CHECK(getValueResult);
4202 DALI_TEST_EQUALS<int>(value, ClippingMode::CLIP_TO_BOUNDING_BOX, TEST_LOCATION);
4207 int UtcDaliActorPropertyClippingN(void)
4209 // Negative test case for Clipping.
4210 tet_infoline("Testing Actor::Property::ClippingMode: N");
4211 TestApplication application;
4213 Actor actor = Actor::New();
4215 // Check default clippingEnabled value.
4216 Property::Value getValue(actor.GetProperty(Actor::Property::CLIPPING_MODE));
4219 bool getValueResult = getValue.Get(value);
4220 DALI_TEST_CHECK(getValueResult);
4224 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4227 // Check setting an invalid property value won't change the current property value.
4228 actor.SetProperty(Actor::Property::CLIPPING_MODE, "INVALID_PROPERTY");
4230 getValue = actor.GetProperty(Actor::Property::CLIPPING_MODE);
4231 getValueResult = getValue.Get(value);
4232 DALI_TEST_CHECK(getValueResult);
4236 DALI_TEST_EQUALS<int>(value, ClippingMode::DISABLED, TEST_LOCATION);
4242 int UtcDaliActorPropertyClippingActor(void)
4244 // This test checks that an actor is correctly setup for clipping.
4245 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor");
4246 TestApplication application;
4248 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4249 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4250 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4251 size_t startIndex = 0u;
4253 // Create a clipping actor.
4254 Actor actorDepth1Clip = CreateActorWithContent16x16();
4255 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4256 application.GetScene().Add(actorDepth1Clip);
4258 // Gather the call trace.
4259 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4261 // Check we are writing to the color buffer.
4262 CheckColorMask(glAbstraction, true);
4264 // Check the stencil buffer was enabled.
4265 std::ostringstream oss;
4266 oss << std::hex << GL_STENCIL_TEST;
4267 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4269 // Check the stencil buffer was cleared.
4270 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4272 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4273 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4274 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4275 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4280 int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
4282 // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled
4283 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN actor enable and then disable");
4284 TestApplication application;
4286 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4287 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4288 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4289 size_t startIndex = 0u;
4291 // Create a clipping actor.
4292 Actor actorDepth1Clip = CreateActorWithContent16x16();
4293 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4294 application.GetScene().Add(actorDepth1Clip);
4296 // Gather the call trace.
4297 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4299 // Check we are writing to the color buffer.
4300 CheckColorMask(glAbstraction, true);
4302 // Check the stencil buffer was enabled.
4303 std::ostringstream oss;
4304 oss << std::hex << GL_STENCIL_TEST;
4305 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4307 // Check the stencil buffer was cleared.
4308 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4310 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4311 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4312 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex));
4313 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4315 // Now disable the clipping
4316 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4318 // Gather the call trace.
4319 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4321 // Check the stencil buffer was disabled.
4322 std::ostringstream stencil;
4323 stencil << std::hex << GL_STENCIL_TEST;
4324 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
4326 // Ensure all values in stencil-mask are set to 1.
4328 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "255", startIndex));
4333 int UtcDaliActorPropertyClippingNestedChildren(void)
4335 // This test checks that a hierarchy of actors are clipped correctly by
4336 // writing to and reading from the correct bit-planes of the stencil buffer.
4337 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN nested children");
4338 TestApplication application;
4339 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4340 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4341 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4343 // Create a clipping actor.
4344 Actor actorDepth1Clip = CreateActorWithContent16x16();
4345 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4346 application.GetScene().Add(actorDepth1Clip);
4348 // Create a child actor.
4349 Actor childDepth2 = CreateActorWithContent16x16();
4350 actorDepth1Clip.Add(childDepth2);
4352 // Create another clipping actor.
4353 Actor childDepth2Clip = CreateActorWithContent16x16();
4354 childDepth2Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4355 childDepth2.Add(childDepth2Clip);
4357 // Create another 2 child actors. We do this so 2 nodes will have the same clipping ID.
4358 // This tests the sort algorithm.
4359 Actor childDepth3 = CreateActorWithContent16x16();
4360 childDepth2Clip.Add(childDepth3);
4361 Actor childDepth4 = CreateActorWithContent16x16();
4362 childDepth3.Add(childDepth4);
4364 // Gather the call trace.
4365 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4367 // Check we are writing to the color buffer.
4368 CheckColorMask(glAbstraction, true);
4370 // Check the stencil buffer was enabled.
4371 std::ostringstream oss;
4372 oss << std::hex << GL_STENCIL_TEST;
4373 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
4375 // Perform the test twice, once for 2D layer, and once for 3D.
4376 for(unsigned int i = 0u; i < 2u; ++i)
4378 size_t startIndex = 0u;
4380 // Check the stencil buffer was cleared.
4381 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
4383 // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer.
4384 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 0", startIndex)); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node.
4385 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "1", startIndex)); // Write to the first bit-plane
4386 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4388 // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
4389 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
4390 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4392 // Check we are set up to write to the second bitplane of the stencil buffer (only).
4393 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 1", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4394 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilMask", "3", startIndex)); // Write to second (and previous) bit-planes
4395 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
4397 // Check we are set up to test against both the first and second bit-planes of the stencil buffer.
4398 // (Both must be set to pass the check).
4399 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
4400 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
4402 // If we are on the first loop, set the layer to 3D and loop to perform the test again.
4405 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
4406 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4413 int UtcDaliActorPropertyClippingActorDrawOrder(void)
4415 // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
4416 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_CHILDREN draw order");
4417 TestApplication application;
4418 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4419 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4421 /* We create a small tree of actors as follows:
4425 Clipping enabled -> B D
4429 The correct draw order is "ABCDE" (the same as if clipping was not enabled).
4432 for(int i = 0; i < 5; ++i)
4434 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u);
4435 Actor actor = CreateRenderableActor(image);
4437 // Setup dimensions and position so actor is not skipped by culling.
4438 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
4439 actor.SetProperty(Actor::Property::SIZE, Vector2(16.0f, 16.0f));
4443 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4447 float b = i > 2 ? 1.0f : -1.0f;
4448 actor.SetProperty(Actor::Property::PARENT_ORIGIN, Vector3(0.5 + (0.2f * b), 0.8f, 0.8f));
4454 // Enable clipping on the actor at the top of the left branch.
4455 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4457 // Build the scene graph.
4458 application.GetScene().Add(actors[0]);
4461 actors[0].Add(actors[1]);
4462 actors[1].Add(actors[2]);
4465 actors[0].Add(actors[3]);
4466 actors[3].Add(actors[4]);
4468 // Gather the call trace.
4469 enabledDisableTrace.Reset();
4470 enabledDisableTrace.Enable(true);
4471 application.SendNotification();
4472 application.Render();
4473 enabledDisableTrace.Enable(false);
4475 /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
4477 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
4478 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
4480 size_t startIndex = 0u;
4481 std::ostringstream blend;
4482 blend << std::hex << GL_BLEND;
4483 std::ostringstream stencil;
4484 stencil << std::hex << GL_STENCIL_TEST;
4486 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
4487 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4488 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4490 // Swap the clipping actor from top of left branch to top of right branch.
4491 actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
4492 actors[3].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4494 // Gather the call trace.
4495 enabledDisableTrace.Reset();
4496 enabledDisableTrace.Enable(true);
4497 application.SendNotification();
4498 application.Render();
4499 enabledDisableTrace.Enable(false);
4501 // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
4502 // This proves the draw order has remained the same.
4504 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
4505 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
4510 int UtcDaliActorPropertyScissorClippingActor(void)
4512 // This test checks that an actor is correctly setup for clipping.
4513 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor");
4514 TestApplication application;
4516 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4517 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4518 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4520 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4521 const Vector2 imageSize(16.0f, 16.0f);
4523 // Create a clipping actor.
4524 Actor clippingActorA = CreateActorWithContent16x16();
4525 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4526 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4527 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
4528 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
4529 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4530 application.GetScene().Add(clippingActorA);
4532 // Gather the call trace.
4533 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4535 // Check we are writing to the color buffer.
4536 CheckColorMask(glAbstraction, true);
4538 // Check scissor test was enabled.
4540 std::ostringstream scissor;
4541 scissor << std::hex << GL_SCISSOR_TEST;
4542 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4544 // Check the scissor was set, and the coordinates are correct.
4545 std::stringstream compareParametersString;
4546 compareParametersString << "0, 0, " << imageSize.x << ", " << imageSize.y;
4547 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16
4549 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
4550 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT);
4552 // Gather the call trace.
4553 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4555 // Check the scissor was set, and the coordinates are correct.
4556 compareParametersString.str(std::string());
4557 compareParametersString.clear();
4558 compareParametersString << (stageSize.x - imageSize.x) << ", " << (stageSize.y - imageSize.y) << ", " << imageSize.x << ", " << imageSize.y;
4559 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16
4564 int UtcDaliActorPropertyScissorClippingActorSiblings(void)
4566 // This test checks that an actor is correctly setup for clipping.
4567 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actors which are siblings");
4568 TestApplication application;
4570 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4571 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4572 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4574 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4575 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4576 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4578 // Create a clipping actors.
4579 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4580 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4582 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4583 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4584 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4586 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4587 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4588 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4590 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4591 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4593 application.GetScene().Add(clippingActorA);
4594 application.GetScene().Add(clippingActorB);
4596 // Gather the call trace.
4597 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4599 // Check we are writing to the color buffer.
4600 CheckColorMask(glAbstraction, true);
4602 // Check scissor test was enabled.
4603 std::ostringstream scissor;
4604 scissor << std::hex << GL_SCISSOR_TEST;
4605 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4607 // Check the scissor was set, and the coordinates are correct.
4608 std::stringstream compareParametersString;
4610 std::string clipA("0, 500, 480, 200");
4611 std::string clipB("0, 380, 480, 40");
4613 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4614 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4619 int UtcDaliActorPropertyScissorClippingActorNested01(void)
4621 // This test checks that an actor is correctly setup for clipping.
4622 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4623 TestApplication application;
4625 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4626 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4627 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4629 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4630 const Vector2 imageSize(16.0f, 16.0f);
4632 /* Create a nest of 2 scissors to test nesting (intersecting clips).
4634 A is drawn first - with scissor clipping on
4635 B is drawn second - also with scissor clipping on
4636 C is the generated clipping region, the intersection ( A ∩ B )
4640 ┌───╂┄┄┄┐ ┃ ┌┄┄┄╆━━━┓ │
4641 │ ┃ ┊ ┃ ━━━━━> ┊ ┃ C ┃ │
4642 │ ┗━━━┿━━━┛ ┊ ┗━━━╃───┘
4646 We then reposition B around each corner of A to test the 4 overlap combinations (thus testing intersecting works correctly).
4649 // Create a clipping actor.
4650 Actor clippingActorA = CreateActorWithContent16x16();
4651 // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
4652 // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
4653 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4654 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4655 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4656 application.GetScene().Add(clippingActorA);
4658 // Create a child clipping actor.
4659 Actor clippingActorB = CreateActorWithContent16x16();
4660 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4661 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4662 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4663 clippingActorA.Add(clippingActorB);
4665 // positionModifiers is an array of positions to position B around.
4666 // expect is an array of expected scissor clip coordinate results.
4667 const Vector2 positionModifiers[4] = {Vector2(1.0f, 1.0f), Vector2(-1.0f, 1.0f), Vector2(-1.0f, -1.0f), Vector2(1.0f, -1.0f)};
4668 const Vector4 expect[4] = {Vector4(240, 392, 8, 8), Vector4(232, 392, 8, 8), Vector4(232, 400, 8, 8), Vector4(240, 400, 8, 8)};
4670 // Loop through each overlap combination.
4671 for(unsigned int test = 0u; test < 4u; ++test)
4673 // Position the child clipping actor so it intersects with the 1st clipping actor. This changes each loop.
4674 const Vector2 position = (imageSize / 2.0f) * positionModifiers[test];
4675 clippingActorB.SetProperty(Actor::Property::POSITION, Vector2(position.x, position.y));
4677 // Gather the call trace.
4678 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4680 // Check we are writing to the color buffer.
4681 CheckColorMask(glAbstraction, true);
4683 // Check scissor test was enabled.
4684 std::ostringstream scissor;
4685 scissor << std::hex << GL_SCISSOR_TEST;
4686 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4688 // Check the scissor was set, and the coordinates are correct.
4689 const Vector4& expectResults(expect[test]);
4690 std::stringstream compareParametersString;
4691 compareParametersString << expectResults.x << ", " << expectResults.y << ", " << expectResults.z << ", " << expectResults.w;
4692 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with the expected result
4698 int UtcDaliActorPropertyScissorClippingActorNested02(void)
4700 // This test checks that an actor is correctly setup for clipping.
4701 tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor nested");
4702 TestApplication application;
4704 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4705 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4706 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4708 /* Create a nest of 2 scissors and siblings of the parent.
4718 const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
4719 const Vector2 sizeA{stageSize.width, stageSize.height * 0.25f};
4720 const Vector2 sizeB{stageSize.width, stageSize.height * 0.05f};
4721 const Vector2 sizeC{stageSize.width, stageSize.height * 0.25f};
4722 const Vector2 sizeD{stageSize.width, stageSize.height * 0.25f};
4723 const Vector2 sizeE{stageSize.width, stageSize.height * 0.05f};
4725 // Create a clipping actors.
4726 Actor clippingActorA = CreateActorWithContent(sizeA.width, sizeA.height);
4727 Actor clippingActorB = CreateActorWithContent(sizeB.width, sizeB.height);
4728 Actor clippingActorC = CreateActorWithContent(sizeC.width, sizeC.height);
4729 Actor clippingActorD = CreateActorWithContent(sizeD.width, sizeD.height);
4730 Actor clippingActorE = CreateActorWithContent(sizeE.width, sizeE.height);
4732 clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4733 clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4734 clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4736 clippingActorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4737 clippingActorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4738 clippingActorB.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4740 clippingActorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4741 clippingActorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4742 clippingActorC.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4744 clippingActorD.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4745 clippingActorD.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4746 clippingActorD.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4748 clippingActorE.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT);
4749 clippingActorE.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
4751 clippingActorA.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -200.0f, 0.0f));
4752 clippingActorB.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4753 clippingActorC.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 100.0f, 0.0f));
4754 clippingActorD.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4755 clippingActorE.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
4757 application.GetScene().Add(clippingActorA);
4758 clippingActorA.Add(clippingActorB);
4759 application.GetScene().Add(clippingActorC);
4760 application.GetScene().Add(clippingActorD);
4761 clippingActorD.Add(clippingActorE);
4763 // Gather the call trace.
4764 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4766 // Check we are writing to the color buffer.
4767 CheckColorMask(glAbstraction, true);
4769 // Check scissor test was enabled.
4770 std::ostringstream scissor;
4771 scissor << std::hex << GL_SCISSOR_TEST;
4772 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4774 // Check the scissor was set, and the coordinates are correct.
4775 std::string clipA("0, 500, 480, 200");
4776 std::string clipB("0, 580, 480, 40");
4777 std::string clipC("0, 200, 480, 200");
4778 std::string clipD("0, 300, 480, 200");
4780 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipA));
4781 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB));
4782 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC));
4783 DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD));
4784 DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4.
4789 int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
4791 // This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
4792 tet_infoline("Testing Actor::Property::CLIPPING_MODE actor with renderer override");
4793 TestApplication application;
4795 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
4796 TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace();
4797 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
4799 // Create a clipping actor.
4800 Actor actorDepth1Clip = CreateActorWithContent16x16();
4801 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
4802 application.GetScene().Add(actorDepth1Clip);
4804 // Turn the RenderMode to just "COLOR" at the Renderer level to ignore the clippingMode.
4805 actorDepth1Clip.GetRendererAt(0).SetProperty(Renderer::Property::RENDER_MODE, RenderMode::COLOR);
4807 // Gather the call trace.
4808 GenerateTrace(application, enabledDisableTrace, stencilTrace);
4810 // Check we are writing to the color buffer.
4811 CheckColorMask(glAbstraction, true);
4813 // Check the stencil buffer was not enabled.
4814 std::ostringstream stencil;
4815 stencil << std::hex << GL_STENCIL_TEST;
4816 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
4818 // Check stencil functions are not called.
4819 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
4820 // TODO: Temporarily commented out the line below when caching is disabled. Will need to add it back.
4821 // DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask"));
4822 DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp"));
4824 // Check that scissor clipping is overriden by the renderer properties.
4825 TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
4827 actorDepth1Clip.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
4829 // Gather the call trace.
4830 GenerateTrace(application, enabledDisableTrace, scissorTrace);
4832 // Check the stencil buffer was not enabled.
4833 std::ostringstream scissor;
4834 scissor << std::hex << GL_SCISSOR_TEST;
4835 DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
4837 DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
4842 int UtcDaliGetPropertyN(void)
4844 tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range");
4845 TestApplication application;
4847 Actor actor = Actor::New();
4849 unsigned int propertyCount = actor.GetPropertyCount();
4850 DALI_TEST_EQUALS(actor.GetProperty(Property::Index(propertyCount)).GetType(), Property::NONE, TEST_LOCATION);
4854 int UtcDaliActorRaiseLower(void)
4856 tet_infoline("UtcDaliActor Raise and Lower test\n");
4858 TestApplication application;
4860 Debug::Filter::SetGlobalLogLevel(Debug::Verbose);
4862 Integration::Scene stage(application.GetScene());
4864 Actor actorA = Actor::New();
4865 Actor actorB = Actor::New();
4866 Actor actorC = Actor::New();
4868 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4869 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4871 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4872 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4874 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
4875 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
4877 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4878 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4880 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4881 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4883 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
4884 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
4890 ResetTouchCallbacks();
4892 application.SendNotification();
4893 application.Render();
4895 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4896 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4897 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4899 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
4900 // Only top actor will get touched.
4901 actorA.TouchedSignal().Connect(TestTouchCallback);
4902 actorB.TouchedSignal().Connect(TestTouchCallback2);
4903 actorC.TouchedSignal().Connect(TestTouchCallback3);
4905 // Connect ChildOrderChangedSignal
4906 bool orderChangedSignal(false);
4907 Actor orderChangedActor;
4908 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
4909 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
4911 Dali::Integration::Point point;
4912 point.SetDeviceId(1);
4913 point.SetState(PointState::DOWN);
4914 point.SetScreenPosition(Vector2(10.f, 10.f));
4915 Dali::Integration::TouchEvent touchEvent;
4916 touchEvent.AddPoint(point);
4918 application.ProcessEvent(touchEvent);
4920 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4921 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4922 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4924 ResetTouchCallbacks();
4926 tet_printf("Testing Raising of Actor\n");
4928 int preActorOrder(0);
4929 int postActorOrder(0);
4931 Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4932 value.Get(preActorOrder);
4934 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4936 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4937 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4939 // Ensure sort order is calculated before next touch event
4940 application.SendNotification();
4942 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4943 value.Get(postActorOrder);
4945 tet_printf("Raised ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4947 application.ProcessEvent(touchEvent);
4949 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4950 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
4951 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
4953 ResetTouchCallbacks();
4955 tet_printf("Testing Lowering of Actor\n");
4957 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4958 value.Get(preActorOrder);
4960 orderChangedSignal = false;
4962 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
4964 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
4965 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
4967 application.SendNotification(); // ensure sort order calculated before next touch event
4969 value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER);
4970 value.Get(postActorOrder);
4972 tet_printf("Lowered ActorB from (%d) to (%d) \n", preActorOrder, postActorOrder);
4974 application.ProcessEvent(touchEvent);
4976 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
4977 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
4978 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
4980 ResetTouchCallbacks();
4982 Debug::Filter::SetGlobalLogLevel(Debug::NoLogging);
4987 int UtcDaliActorRaiseToTopLowerToBottom(void)
4989 tet_infoline("UtcDaliActorRaiseToTop and LowerToBottom test \n");
4991 TestApplication application;
4993 Integration::Scene stage(application.GetScene());
4995 Actor actorA = Actor::New();
4996 Actor actorB = Actor::New();
4997 Actor actorC = Actor::New();
4999 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5000 // enables checking of which actor the uniform is assigned too
5001 Shader shaderA = CreateShader();
5002 shaderA.RegisterProperty("uRendererColor", 1.f);
5004 Shader shaderB = CreateShader();
5005 shaderB.RegisterProperty("uRendererColor", 2.f);
5007 Shader shaderC = CreateShader();
5008 shaderC.RegisterProperty("uRendererColor", 3.f);
5010 Geometry geometry = CreateQuadGeometry();
5012 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5013 Renderer rendererA = Renderer::New(geometry, shaderA);
5014 actorA.AddRenderer(rendererA);
5016 Renderer rendererB = Renderer::New(geometry, shaderB);
5017 actorB.AddRenderer(rendererB);
5019 Renderer rendererC = Renderer::New(geometry, shaderC);
5020 actorC.AddRenderer(rendererC);
5022 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5023 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5025 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5026 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5028 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5029 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5031 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5032 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5034 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5035 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5037 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5038 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5044 ResetTouchCallbacks();
5046 // Connect ChildOrderChangedSignal
5047 bool orderChangedSignal(false);
5048 Actor orderChangedActor;
5049 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5050 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5052 // Set up gl abstraction trace so can query the set uniform order
5053 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5054 glAbstraction.EnableSetUniformCallTrace(true);
5055 glAbstraction.ResetSetUniformCallStack();
5057 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5059 application.SendNotification();
5060 application.Render();
5062 tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str());
5064 // Test order of uniforms in stack
5065 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5066 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5067 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5069 bool CBA = (indexC > indexB) && (indexB > indexA);
5071 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5073 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5074 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5075 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5077 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5078 // Only top actor will get touched.
5079 actorA.TouchedSignal().Connect(TestTouchCallback);
5080 actorB.TouchedSignal().Connect(TestTouchCallback2);
5081 actorC.TouchedSignal().Connect(TestTouchCallback3);
5083 Dali::Integration::Point point;
5084 point.SetDeviceId(1);
5085 point.SetState(PointState::DOWN);
5086 point.SetScreenPosition(Vector2(10.f, 10.f));
5087 Dali::Integration::TouchEvent touchEvent;
5088 touchEvent.AddPoint(point);
5090 application.ProcessEvent(touchEvent);
5092 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5093 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5094 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5096 ResetTouchCallbacks();
5098 tet_printf("RaiseToTop ActorA\n");
5100 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5101 actorA.RaiseToTop();
5102 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5103 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5105 application.SendNotification(); // ensure sorting order is calculated before next touch event
5107 application.ProcessEvent(touchEvent);
5109 glSetUniformStack.Reset();
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.000000");
5118 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5119 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5121 tet_infoline("Testing A above C and B at bottom\n");
5122 bool ACB = (indexA > indexC) && (indexC > indexB);
5124 DALI_TEST_EQUALS(ACB, true, TEST_LOCATION);
5126 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5127 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5128 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5130 ResetTouchCallbacks();
5132 tet_printf("RaiseToTop ActorB\n");
5134 orderChangedSignal = false;
5136 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5137 actorB.RaiseToTop();
5138 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5139 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5141 application.SendNotification(); // Ensure sort order is calculated before next touch event
5143 application.ProcessEvent(touchEvent);
5145 glSetUniformStack.Reset();
5147 application.SendNotification();
5148 application.Render();
5150 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5152 // Test order of uniforms in stack
5153 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5154 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5155 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5157 tet_infoline("Testing B above A and C at bottom\n");
5158 bool BAC = (indexB > indexA) && (indexA > indexC);
5160 DALI_TEST_EQUALS(BAC, true, TEST_LOCATION);
5162 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5163 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5164 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5166 ResetTouchCallbacks();
5168 tet_printf("LowerToBottom ActorA then ActorB leaving Actor C at Top\n");
5170 orderChangedSignal = false;
5172 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5173 actorA.LowerToBottom();
5174 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5175 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5177 application.SendNotification();
5178 application.Render();
5180 orderChangedSignal = false;
5182 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5183 actorB.LowerToBottom();
5184 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5185 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5187 application.SendNotification();
5188 application.Render();
5190 application.ProcessEvent(touchEvent);
5192 glSetUniformStack.Reset();
5194 application.SendNotification();
5195 application.Render();
5197 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5199 // Test order of uniforms in stack
5200 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5201 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5202 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5204 tet_infoline("Testing C above A and B at bottom\n");
5205 bool CAB = (indexC > indexA) && (indexA > indexB);
5207 DALI_TEST_EQUALS(CAB, true, TEST_LOCATION);
5209 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5210 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5211 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5213 ResetTouchCallbacks();
5218 int UtcDaliActorRaiseAbove(void)
5220 tet_infoline("UtcDaliActor RaiseToAbove test \n");
5222 TestApplication application;
5224 Integration::Scene stage(application.GetScene());
5226 Actor actorA = Actor::New();
5227 Actor actorB = Actor::New();
5228 Actor actorC = Actor::New();
5230 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5231 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5233 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5234 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5236 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5237 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5239 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5240 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5242 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5243 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5245 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5246 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5252 ResetTouchCallbacks();
5254 application.SendNotification();
5255 application.Render();
5257 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5258 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5259 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5261 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5262 // Only top actor will get touched.
5263 actorA.TouchedSignal().Connect(TestTouchCallback);
5264 actorB.TouchedSignal().Connect(TestTouchCallback2);
5265 actorC.TouchedSignal().Connect(TestTouchCallback3);
5267 bool orderChangedSignal(false);
5268 Actor orderChangedActor;
5269 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5270 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5272 Dali::Integration::Point point;
5273 point.SetDeviceId(1);
5274 point.SetState(PointState::DOWN);
5275 point.SetScreenPosition(Vector2(10.f, 10.f));
5276 Dali::Integration::TouchEvent touchEvent;
5277 touchEvent.AddPoint(point);
5279 application.ProcessEvent(touchEvent);
5281 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5282 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5283 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5285 ResetTouchCallbacks();
5287 tet_printf("Raise actor B Above Actor C\n");
5289 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5290 actorB.RaiseAbove(actorC);
5291 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5292 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5294 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5295 application.SendNotification();
5296 application.ProcessEvent(touchEvent);
5298 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5299 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5300 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5302 ResetTouchCallbacks();
5304 tet_printf("Raise actor A Above Actor B\n");
5306 orderChangedSignal = false;
5308 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5309 actorA.RaiseAbove(actorB);
5310 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5311 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5313 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5314 application.SendNotification();
5316 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5318 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5319 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5320 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5322 ResetTouchCallbacks();
5327 int UtcDaliActorRaiseAbove2(void)
5329 tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n");
5331 TestApplication application;
5333 Integration::Scene stage(application.GetScene());
5335 Actor actorA = Actor::New();
5336 Actor actorB = Actor::New();
5337 Actor actorC = Actor::New();
5339 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5340 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5342 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5343 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5345 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5346 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5348 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5349 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5351 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5352 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5354 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5355 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5361 ResetTouchCallbacks();
5363 application.SendNotification();
5364 application.Render();
5366 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5367 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5368 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5370 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5371 // Only top actor will get touched.
5372 actorA.TouchedSignal().Connect(TestTouchCallback);
5373 actorB.TouchedSignal().Connect(TestTouchCallback2);
5374 actorC.TouchedSignal().Connect(TestTouchCallback3);
5376 bool orderChangedSignal(false);
5377 Actor orderChangedActor;
5378 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5379 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5381 Dali::Integration::Point point;
5382 point.SetDeviceId(1);
5383 point.SetState(PointState::DOWN);
5384 point.SetScreenPosition(Vector2(10.f, 10.f));
5385 Dali::Integration::TouchEvent touchEvent;
5386 touchEvent.AddPoint(point);
5388 application.ProcessEvent(touchEvent);
5390 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5391 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5392 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5394 ResetTouchCallbacks();
5396 tet_printf("Raise actor B Above Actor C\n");
5398 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5399 int newOrder = actorC[DevelActor::Property::SIBLING_ORDER];
5400 actorB[DevelActor::Property::SIBLING_ORDER] = newOrder;
5401 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5402 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5404 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5405 application.SendNotification();
5406 application.ProcessEvent(touchEvent);
5408 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5409 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5410 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5412 ResetTouchCallbacks();
5414 tet_printf("Raise actor A Above Actor B\n");
5416 orderChangedSignal = false;
5418 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5419 newOrder = actorB[DevelActor::Property::SIBLING_ORDER];
5420 actorA[DevelActor::Property::SIBLING_ORDER] = newOrder;
5421 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5422 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
5424 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5425 application.SendNotification();
5427 application.ProcessEvent(touchEvent); // process a touch event on ordered actors.
5429 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
5430 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5431 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5433 ResetTouchCallbacks();
5438 int UtcDaliActorLowerBelow(void)
5440 tet_infoline("UtcDaliActor LowerBelow test \n");
5442 TestApplication application;
5444 Integration::Scene stage(application.GetScene());
5446 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5447 // enables checking of which actor the uniform is assigned too
5448 Shader shaderA = CreateShader();
5449 shaderA.RegisterProperty("uRendererColor", 1.f);
5451 Shader shaderB = CreateShader();
5452 shaderB.RegisterProperty("uRendererColor", 2.f);
5454 Shader shaderC = CreateShader();
5455 shaderC.RegisterProperty("uRendererColor", 3.f);
5457 Actor actorA = Actor::New();
5458 Actor actorB = Actor::New();
5459 Actor actorC = Actor::New();
5461 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5462 Geometry geometry = CreateQuadGeometry();
5464 Renderer rendererA = Renderer::New(geometry, shaderA);
5465 actorA.AddRenderer(rendererA);
5467 Renderer rendererB = Renderer::New(geometry, shaderB);
5468 actorB.AddRenderer(rendererB);
5470 Renderer rendererC = Renderer::New(geometry, shaderC);
5471 actorC.AddRenderer(rendererC);
5473 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5474 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5476 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5477 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5479 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5480 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5482 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5483 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5485 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5486 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5488 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5489 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5491 Actor container = Actor::New();
5492 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5493 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5494 stage.Add(container);
5496 container.Add(actorA);
5497 container.Add(actorB);
5498 container.Add(actorC);
5500 ResetTouchCallbacks();
5502 // Connect ChildOrderChangedSignal
5503 bool orderChangedSignal(false);
5504 Actor orderChangedActor;
5505 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5506 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5508 // Set up gl abstraction trace so can query the set uniform order
5509 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5510 glAbstraction.EnableSetUniformCallTrace(true);
5511 glAbstraction.ResetSetUniformCallStack();
5512 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5514 glAbstraction.ResetSetUniformCallStack();
5516 application.SendNotification();
5517 application.Render();
5519 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5521 // Test order of uniforms in stack
5522 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5523 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5524 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5526 tet_infoline("Testing C above B and A at bottom\n");
5527 bool CBA = (indexC > indexB) && (indexB > indexA);
5529 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5531 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5532 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5533 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5535 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5536 // Only top actor will get touched.
5537 actorA.TouchedSignal().Connect(TestTouchCallback);
5538 actorB.TouchedSignal().Connect(TestTouchCallback2);
5539 actorC.TouchedSignal().Connect(TestTouchCallback3);
5541 Dali::Integration::Point point;
5542 point.SetDeviceId(1);
5543 point.SetState(PointState::DOWN);
5544 point.SetScreenPosition(Vector2(10.f, 10.f));
5545 Dali::Integration::TouchEvent touchEvent;
5546 touchEvent.AddPoint(point);
5548 tet_infoline("UtcDaliActor Test Set up completed \n");
5550 application.ProcessEvent(touchEvent);
5552 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5553 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5554 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5556 ResetTouchCallbacks();
5558 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");
5560 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5561 actorC.LowerBelow(actorB);
5562 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5563 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5565 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5566 application.SendNotification();
5567 application.Render();
5569 application.ProcessEvent(touchEvent); // touch event
5571 glSetUniformStack.Reset();
5573 application.SendNotification();
5574 application.Render();
5576 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5578 // Test order of uniforms in stack
5579 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5580 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5581 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5583 tet_infoline("Testing render order is A, C, B");
5584 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5585 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5587 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5588 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5589 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5591 ResetTouchCallbacks();
5593 tet_printf("Lower actor C below Actor A leaving B on top\n");
5595 orderChangedSignal = false;
5597 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5598 actorC.LowerBelow(actorA);
5599 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5600 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5602 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5603 application.SendNotification();
5604 application.Render();
5606 application.ProcessEvent(touchEvent);
5608 glSetUniformStack.Reset();
5610 application.Render();
5611 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5613 // Test order of uniforms in stack
5614 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5615 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5616 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5618 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5619 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5621 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5622 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5623 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5625 ResetTouchCallbacks();
5627 tet_printf("Lower actor B below Actor C leaving A on top\n");
5629 orderChangedSignal = false;
5631 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5632 actorB.LowerBelow(actorC);
5633 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5634 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5636 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5637 application.SendNotification();
5638 application.Render();
5640 application.ProcessEvent(touchEvent);
5642 glSetUniformStack.Reset();
5644 application.Render();
5645 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5647 // Test order of uniforms in stack
5648 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5649 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5650 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5652 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5653 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5658 int UtcDaliActorLowerBelow2(void)
5660 tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n");
5662 TestApplication application;
5664 Integration::Scene stage(application.GetScene());
5666 // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each
5667 // enables checking of which actor the uniform is assigned too
5668 Shader shaderA = CreateShader();
5669 shaderA.RegisterProperty("uRendererColor", 1.f);
5671 Shader shaderB = CreateShader();
5672 shaderB.RegisterProperty("uRendererColor", 2.f);
5674 Shader shaderC = CreateShader();
5675 shaderC.RegisterProperty("uRendererColor", 3.f);
5677 Actor actorA = Actor::New();
5678 Actor actorB = Actor::New();
5679 Actor actorC = Actor::New();
5681 // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C,
5682 Geometry geometry = CreateQuadGeometry();
5684 Renderer rendererA = Renderer::New(geometry, shaderA);
5685 actorA.AddRenderer(rendererA);
5687 Renderer rendererB = Renderer::New(geometry, shaderB);
5688 actorB.AddRenderer(rendererB);
5690 Renderer rendererC = Renderer::New(geometry, shaderC);
5691 actorC.AddRenderer(rendererC);
5693 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5694 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5696 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5697 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5699 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5700 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5702 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5703 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5705 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5706 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5708 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5709 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5711 Actor container = Actor::New();
5712 container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5713 container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
5714 stage.Add(container);
5716 container.Add(actorA);
5717 container.Add(actorB);
5718 container.Add(actorC);
5720 ResetTouchCallbacks();
5722 // Connect ChildOrderChangedSignal
5723 bool orderChangedSignal(false);
5724 Actor orderChangedActor;
5725 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5726 DevelActor::ChildOrderChangedSignal(container).Connect(&application, f);
5728 // Set up gl abstraction trace so can query the set uniform order
5729 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
5730 glAbstraction.EnableSetUniformCallTrace(true);
5731 glAbstraction.ResetSetUniformCallStack();
5732 TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace();
5734 glAbstraction.ResetSetUniformCallStack();
5736 application.SendNotification();
5737 application.Render();
5739 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5741 // Test order of uniforms in stack
5742 int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5743 int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5744 int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5746 tet_infoline("Testing C above B and A at bottom\n");
5747 bool CBA = (indexC > indexB) && (indexB > indexA);
5749 DALI_TEST_EQUALS(CBA, true, TEST_LOCATION);
5751 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5752 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5753 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5755 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5756 // Only top actor will get touched.
5757 actorA.TouchedSignal().Connect(TestTouchCallback);
5758 actorB.TouchedSignal().Connect(TestTouchCallback2);
5759 actorC.TouchedSignal().Connect(TestTouchCallback3);
5761 Dali::Integration::Point point;
5762 point.SetDeviceId(1);
5763 point.SetState(PointState::DOWN);
5764 point.SetScreenPosition(Vector2(10.f, 10.f));
5765 Dali::Integration::TouchEvent touchEvent;
5766 touchEvent.AddPoint(point);
5768 tet_infoline("UtcDaliActor Test Set up completed \n");
5770 application.ProcessEvent(touchEvent);
5772 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5773 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5774 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5776 ResetTouchCallbacks();
5778 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");
5780 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5781 actorC[DevelActor::Property::SIBLING_ORDER] = 1;
5782 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5783 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5785 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5786 application.SendNotification();
5787 application.Render();
5789 application.ProcessEvent(touchEvent); // touch event
5791 glSetUniformStack.Reset();
5793 application.SendNotification();
5794 application.Render();
5796 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5798 // Test order of uniforms in stack
5799 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5800 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5801 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5803 tet_infoline("Testing render order is A, C, B");
5804 DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION);
5805 DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION);
5807 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5808 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5809 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5811 ResetTouchCallbacks();
5813 tet_printf("Lower actor C below Actor A leaving B on top\n");
5815 orderChangedSignal = false;
5817 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5818 actorC[DevelActor::Property::SIBLING_ORDER] = 0;
5819 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5820 DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION);
5822 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5823 application.SendNotification();
5824 application.Render();
5826 application.ProcessEvent(touchEvent);
5828 glSetUniformStack.Reset();
5830 application.Render();
5831 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5833 // Test order of uniforms in stack
5834 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5835 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5836 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5838 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5839 DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION);
5841 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5842 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
5843 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5845 ResetTouchCallbacks();
5847 tet_printf("Lower actor B below Actor C leaving A on top\n");
5849 orderChangedSignal = false;
5851 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5852 actorB[DevelActor::Property::SIBLING_ORDER] = 0;
5853 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
5854 DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION);
5856 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5857 application.SendNotification();
5858 application.Render();
5860 application.ProcessEvent(touchEvent);
5862 glSetUniformStack.Reset();
5864 application.Render();
5865 tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str());
5867 // Test order of uniforms in stack
5868 indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000");
5869 indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000");
5870 indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000");
5872 DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION);
5873 DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION);
5878 int UtcDaliActorRaiseAboveDifferentParentsN(void)
5880 tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n");
5882 TestApplication application;
5884 Integration::Scene stage(application.GetScene());
5886 Actor parentA = Actor::New();
5887 Actor parentB = Actor::New();
5888 parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5889 parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5890 parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5891 parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5893 parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5894 parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5896 parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5897 parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5902 Actor actorA = Actor::New();
5903 Actor actorB = Actor::New();
5904 Actor actorC = Actor::New();
5906 parentA.Add(actorA);
5907 parentA.Add(actorB);
5909 tet_printf("Actor C added to different parent from A and B \n");
5910 parentB.Add(actorC);
5912 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5913 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5915 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5916 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5918 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5919 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
5921 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5922 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5924 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5925 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5927 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
5928 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
5930 ResetTouchCallbacks();
5932 // Connect ChildOrderChangedSignal
5933 bool orderChangedSignal(false);
5934 Actor orderChangedActor;
5935 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
5936 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
5938 application.SendNotification();
5939 application.Render();
5941 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5942 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5943 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
5945 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
5946 // Only top actor will get touched.
5947 actorA.TouchedSignal().Connect(TestTouchCallback);
5948 actorB.TouchedSignal().Connect(TestTouchCallback2);
5949 actorC.TouchedSignal().Connect(TestTouchCallback3);
5951 Dali::Integration::Point point;
5952 point.SetDeviceId(1);
5953 point.SetState(PointState::DOWN);
5954 point.SetScreenPosition(Vector2(10.f, 10.f));
5955 Dali::Integration::TouchEvent touchEvent;
5956 touchEvent.AddPoint(point);
5958 application.ProcessEvent(touchEvent);
5960 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5961 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5962 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5964 ResetTouchCallbacks();
5966 tet_printf("Raise actor A Above Actor C which have different parents\n");
5968 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5969 actorA.RaiseAbove(actorC);
5970 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
5972 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
5973 application.SendNotification();
5975 application.ProcessEvent(touchEvent); // touch event
5977 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
5978 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
5979 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
5981 ResetTouchCallbacks();
5986 int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void)
5988 tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n");
5990 TestApplication application;
5992 Integration::Scene stage(application.GetScene());
5994 Actor actorA = Actor::New();
5995 Actor actorB = Actor::New();
5996 Actor actorC = Actor::New();
5998 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
5999 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6001 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6002 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6004 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6005 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6007 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6008 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6010 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6011 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6013 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6014 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6016 ResetTouchCallbacks();
6018 // Connect ChildOrderChangedSignal
6019 bool orderChangedSignal(false);
6020 Actor orderChangedActor;
6021 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6022 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6024 application.SendNotification();
6025 application.Render();
6027 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6028 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6029 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6031 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6032 // Only top actor will get touched.
6033 actorA.TouchedSignal().Connect(TestTouchCallback);
6034 actorB.TouchedSignal().Connect(TestTouchCallback2);
6035 actorC.TouchedSignal().Connect(TestTouchCallback3);
6037 Dali::Integration::Point point;
6038 point.SetDeviceId(1);
6039 point.SetState(PointState::DOWN);
6040 point.SetScreenPosition(Vector2(10.f, 10.f));
6041 Dali::Integration::TouchEvent touchEvent;
6042 touchEvent.AddPoint(point);
6044 tet_printf("Raise actor A Above Actor C which have no parents\n");
6046 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6047 actorA.RaiseAbove(actorC);
6048 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6050 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6051 application.SendNotification();
6053 application.ProcessEvent(touchEvent);
6055 tet_printf("Not parented so RaiseAbove should show no effect\n");
6057 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6058 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6059 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6061 ResetTouchCallbacks();
6063 orderChangedSignal = false;
6066 tet_printf("Lower actor A below Actor C when only A is not on stage \n");
6068 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6069 actorA.LowerBelow(actorC);
6070 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6072 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6073 application.SendNotification();
6074 application.Render();
6076 application.ProcessEvent(touchEvent);
6078 tet_printf("Actor A not parented so LowerBelow should show no effect\n");
6079 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6080 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6081 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6083 ResetTouchCallbacks();
6085 orderChangedSignal = false;
6087 tet_printf("Adding Actor A to stage, will be on top\n");
6090 application.SendNotification();
6091 application.Render();
6093 tet_printf("Raise actor B Above Actor C when only B has a parent\n");
6095 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6096 actorB.RaiseAbove(actorC);
6097 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6099 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6100 application.SendNotification();
6102 application.ProcessEvent(touchEvent);
6104 tet_printf("C not parented so RaiseAbove should show no effect\n");
6105 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6106 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6107 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6109 ResetTouchCallbacks();
6111 orderChangedSignal = false;
6113 tet_printf("Lower actor A below Actor C when only A has a parent\n");
6115 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6116 actorA.LowerBelow(actorC);
6117 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6119 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6120 application.SendNotification();
6122 application.ProcessEvent(touchEvent);
6124 tet_printf("C not parented so LowerBelow should show no effect\n");
6125 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6126 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6127 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6129 ResetTouchCallbacks();
6131 orderChangedSignal = false;
6135 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6136 actorA.RaiseAbove(actorC);
6137 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6138 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6140 // Ensure sorting happens at end of Core::ProcessEvents() before next touch
6141 application.SendNotification();
6142 application.Render();
6144 application.ProcessEvent(touchEvent);
6146 tet_printf("Raise actor A Above Actor C, now both have same parent \n");
6147 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6148 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6149 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6154 int UtcDaliActorTestAllAPIwhenActorNotParented(void)
6156 tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n");
6158 TestApplication application;
6160 Integration::Scene stage(application.GetScene());
6162 Actor actorA = Actor::New();
6163 Actor actorB = Actor::New();
6164 Actor actorC = Actor::New();
6166 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6167 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6169 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6170 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6172 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6173 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6175 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6176 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6178 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6179 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6181 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6182 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6184 ResetTouchCallbacks();
6186 // Connect ChildOrderChangedSignal
6187 bool orderChangedSignal(false);
6188 Actor orderChangedActor;
6189 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6190 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6192 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6193 // Only top actor will get touched.
6194 actorA.TouchedSignal().Connect(TestTouchCallback);
6195 actorB.TouchedSignal().Connect(TestTouchCallback2);
6196 actorC.TouchedSignal().Connect(TestTouchCallback3);
6198 Dali::Integration::Point point;
6199 point.SetDeviceId(1);
6200 point.SetState(PointState::DOWN);
6201 point.SetScreenPosition(Vector2(10.f, 10.f));
6202 Dali::Integration::TouchEvent touchEvent;
6203 touchEvent.AddPoint(point);
6206 tet_printf("Raise actor B Above Actor C but B not parented\n");
6208 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6210 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6212 application.SendNotification();
6213 application.Render();
6215 application.ProcessEvent(touchEvent);
6217 tet_printf("Not parented so RaiseAbove should show no effect\n");
6219 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6220 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6221 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6223 tet_printf("Raise actor B Above Actor C but B not parented\n");
6224 ResetTouchCallbacks();
6226 orderChangedSignal = false;
6228 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6230 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6232 // Sort actor tree before next touch event
6233 application.SendNotification();
6234 application.Render();
6236 application.ProcessEvent(touchEvent);
6238 tet_printf("Not parented so RaiseAbove should show no effect\n");
6240 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6241 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6242 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6243 ResetTouchCallbacks();
6245 orderChangedSignal = false;
6247 tet_printf("Lower actor C below B but C not parented\n");
6249 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6251 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6253 // Sort actor tree before next touch event
6254 application.SendNotification();
6255 application.Render();
6257 application.ProcessEvent(touchEvent);
6259 tet_printf("Not parented so Lower should show no effect\n");
6261 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6262 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6263 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6264 ResetTouchCallbacks();
6266 orderChangedSignal = false;
6268 tet_printf("Raise actor B to top\n");
6270 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6271 actorB.RaiseToTop();
6272 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6274 // Sort actor tree before next touch event
6275 application.SendNotification();
6276 application.Render();
6278 application.ProcessEvent(touchEvent);
6280 tet_printf("Not parented so RaiseToTop should show no effect\n");
6282 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6283 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6284 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6285 ResetTouchCallbacks();
6287 orderChangedSignal = false;
6289 tet_printf("Add ActorB to stage so only Actor C not parented\n");
6293 tet_printf("Lower actor C to Bottom, B stays at top\n");
6295 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6296 actorC.LowerToBottom();
6297 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6299 application.SendNotification();
6300 application.Render();
6302 application.ProcessEvent(touchEvent);
6304 tet_printf("Not parented so LowerToBottom should show no effect\n");
6306 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6307 DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION);
6308 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6309 ResetTouchCallbacks();
6314 int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void)
6316 tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n");
6318 TestApplication application;
6320 Integration::Scene stage(application.GetScene());
6322 Actor actorA = Actor::New();
6323 Actor actorB = Actor::New();
6324 Actor actorC = Actor::New();
6326 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6327 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6329 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6330 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6332 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6333 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6335 actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6336 actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6338 actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6339 actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6341 actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT");
6342 actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT");
6348 // connect to actor touch signals, will use touch callbacks to determine which actor is on top.
6349 // Only top actor will get touched.
6350 actorA.TouchedSignal().Connect(TestTouchCallback);
6351 actorB.TouchedSignal().Connect(TestTouchCallback2);
6352 actorC.TouchedSignal().Connect(TestTouchCallback3);
6354 ResetTouchCallbacks();
6356 // Connect ChildOrderChangedSignal
6357 bool orderChangedSignal(false);
6358 Actor orderChangedActor;
6359 ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor);
6360 DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f);
6362 application.SendNotification();
6363 application.Render();
6365 Dali::Integration::Point point;
6366 point.SetDeviceId(1);
6367 point.SetState(PointState::DOWN);
6368 point.SetScreenPosition(Vector2(10.f, 10.f));
6369 Dali::Integration::TouchEvent touchEvent;
6370 touchEvent.AddPoint(point);
6372 application.ProcessEvent(touchEvent);
6374 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6375 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6376 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6378 ResetTouchCallbacks();
6380 tet_infoline("Raise actor A Above Actor A which is the same actor!!\n");
6382 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6383 actorA.RaiseAbove(actorA);
6384 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6385 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6387 application.SendNotification();
6388 application.Render();
6390 application.ProcessEvent(touchEvent);
6392 tet_infoline("No target is source Actor so RaiseAbove should show no effect\n");
6394 DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION);
6395 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6396 DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION);
6398 ResetTouchCallbacks();
6400 orderChangedSignal = false;
6402 DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION);
6403 actorA.RaiseAbove(actorC);
6404 DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION);
6405 DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION);
6407 application.SendNotification();
6408 application.Render();
6410 application.ProcessEvent(touchEvent);
6412 tet_infoline("Raise actor A Above Actor C which will now be successful \n");
6413 DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION);
6414 DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION);
6415 DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION);
6420 int UtcDaliActorGetScreenPosition(void)
6422 tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n");
6424 TestApplication application;
6426 Integration::Scene stage(application.GetScene());
6428 Actor actorA = Actor::New();
6429 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6431 Vector2 size2(10.0f, 20.0f);
6432 actorA.SetProperty(Actor::Property::SIZE, size2);
6434 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6436 tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n");
6440 application.SendNotification();
6441 application.Render();
6443 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6444 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6446 tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6447 tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y);
6449 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6450 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6452 tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n");
6454 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6456 application.SendNotification();
6457 application.Render();
6459 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6460 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6462 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6463 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y);
6465 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6466 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6468 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n");
6470 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6472 application.SendNotification();
6473 application.Render();
6475 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6476 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6478 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6479 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y);
6481 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6482 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6484 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n");
6486 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0));
6488 application.SendNotification();
6489 application.Render();
6491 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6492 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6494 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y);
6495 tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6497 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6498 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6500 tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n");
6502 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0));
6504 application.SendNotification();
6505 application.Render();
6507 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6508 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6510 DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION);
6511 DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION);
6513 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y);
6514 tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y);
6516 tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n");
6518 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6519 actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0));
6521 Actor actorB = Actor::New();
6522 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6523 actorB.SetProperty(Actor::Property::SIZE, size2);
6524 actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f));
6527 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6529 application.SendNotification();
6530 application.Render();
6532 actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6534 DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION);
6535 DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION);
6540 int UtcDaliActorGetScreenPositionAfterScaling(void)
6542 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n");
6544 TestApplication application;
6546 Integration::Scene stage(application.GetScene());
6548 Actor actorA = Actor::New();
6549 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6551 Vector2 size2(10.0f, 20.0f);
6552 actorA.SetProperty(Actor::Property::SIZE, size2);
6553 actorA.SetProperty(Actor::Property::SCALE, 1.5f);
6554 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6556 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n");
6560 application.SendNotification();
6561 application.Render();
6563 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6564 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6566 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6567 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6569 DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION);
6570 DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION);
6572 tet_infoline("UtcDaliActorGetScreenPositionAfterScaling BOTTOM_RIGHT Anchor Point, scale 1.5f and 0,0 position \n");
6574 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6576 application.SendNotification();
6577 application.Render();
6579 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6580 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6582 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6583 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6585 DALI_TEST_EQUALS(actorScreenPosition.x, 0.0f, TEST_LOCATION);
6586 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6591 int UtcDaliActorGetScreenPositionWithDifferentParentOrigin(void)
6593 tet_infoline("UtcDaliActorGetScreenPositionWithDifferentParentOrigin Changes parent origin which should not effect result \n");
6595 TestApplication application;
6597 Integration::Scene stage(application.GetScene());
6599 Actor actorA = Actor::New();
6600 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6601 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6602 Vector2 size2(10.0f, 20.0f);
6603 actorA.SetProperty(Actor::Property::SIZE, size2);
6604 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6606 tet_infoline(" TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6610 application.SendNotification();
6611 application.Render();
6613 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6614 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6616 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6617 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6619 DALI_TEST_EQUALS(actorScreenPosition.x, 240.0f, TEST_LOCATION);
6620 DALI_TEST_EQUALS(actorScreenPosition.y, 400.0f, TEST_LOCATION);
6622 tet_infoline(" BOTTOM_RIGHT Anchor Point, ParentOrigin::TOP_RIGHT and 0,0 position \n");
6624 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT);
6625 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6627 application.SendNotification();
6628 application.Render();
6630 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6631 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6633 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT ParentOrigin::TOP_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y);
6634 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6636 DALI_TEST_EQUALS(actorScreenPosition.x, 480.0f, TEST_LOCATION);
6637 DALI_TEST_EQUALS(actorScreenPosition.y, 0.0f, TEST_LOCATION);
6643 int UtcDaliActorGetScreenPositionWithChildActors(void)
6645 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors Check screen position with a tree of actors \n");
6647 TestApplication application;
6649 Integration::Scene stage(application.GetScene());
6651 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6653 Actor actorA = Actor::New();
6654 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6655 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6656 Vector2 size1(10.0f, 20.0f);
6657 actorA.SetProperty(Actor::Property::SIZE, size1);
6658 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6660 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6662 Actor parentActorA = Actor::New();
6663 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6664 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6665 Vector2 size2(30.0f, 60.0f);
6666 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6667 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6669 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6671 stage.Add(parentActorA);
6672 parentActorA.Add(actorA);
6674 application.SendNotification();
6675 application.Render();
6677 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6678 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6680 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6681 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6683 DALI_TEST_EQUALS(actorScreenPosition.x, 255.0f, TEST_LOCATION);
6684 DALI_TEST_EQUALS(actorScreenPosition.y, 430.0f, TEST_LOCATION);
6686 tet_infoline("Test 2\n");
6688 tet_infoline("change parent anchor point and parent origin then check screen position \n");
6690 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6691 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
6693 application.SendNotification();
6694 application.Render();
6696 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6697 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6699 tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_LEFT ParentOrigin::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y);
6700 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6702 DALI_TEST_EQUALS(actorScreenPosition.x, 15.0f, TEST_LOCATION);
6703 DALI_TEST_EQUALS(actorScreenPosition.y, -30.0f, TEST_LOCATION);
6708 int UtcDaliActorGetScreenPositionWithChildActors02(void)
6710 tet_infoline("UtcDaliActorGetScreenPositionWithChildActors02 Check screen position with a tree of actors \n");
6712 TestApplication application;
6714 Integration::Scene stage(application.GetScene());
6716 tet_infoline("Create Child Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6718 Actor actorA = Actor::New();
6719 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6720 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6721 Vector2 size1(10.0f, 20.0f);
6722 actorA.SetProperty(Actor::Property::SIZE, size1);
6723 actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6725 tet_infoline("Create Parent Actor 1 TOP_LEFT Anchor Point, ParentOrigin::CENTER and 0,0 position \n");
6727 Actor parentActorA = Actor::New();
6728 parentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6729 parentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6730 Vector2 size2(30.0f, 60.0f);
6731 parentActorA.SetProperty(Actor::Property::SIZE, size2);
6732 parentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6734 tet_infoline("Create Grand Parent Actor 1 BOTTOM_LEFT Anchor Point, ParentOrigin::BOTTOM_LEFT and 0,0 position \n");
6736 Actor grandParentActorA = Actor::New();
6737 grandParentActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT);
6738 grandParentActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT);
6739 Vector2 size3(60.0f, 120.0f);
6740 grandParentActorA.SetProperty(Actor::Property::SIZE, size3);
6741 grandParentActorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
6743 tet_infoline("Add Parent 1 to Grand Parent 1 \n");
6745 stage.Add(grandParentActorA);
6746 grandParentActorA.Add(parentActorA);
6748 tet_infoline("Add child 1 to Parent 1 and check screen position \n");
6750 parentActorA.Add(actorA);
6752 application.SendNotification();
6753 application.Render();
6755 Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get<Vector3>();
6756 Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
6758 tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT ParentOrigin::CENTER \n", actorWorldPosition.x, actorWorldPosition.y);
6759 tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y);
6761 DALI_TEST_EQUALS(actorScreenPosition.x, 45.0f, TEST_LOCATION);
6762 DALI_TEST_EQUALS(actorScreenPosition.y, 770.0f, TEST_LOCATION);
6767 int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void)
6769 tet_infoline("UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse Check screen position where the position does not use the anchor point");
6771 TestApplication application;
6773 Integration::Scene stage(application.GetScene());
6775 tet_infoline("Create an actor with AnchorPoint::TOP_LEFT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6777 Actor actorA = Actor::New();
6778 actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6779 actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6780 actorA.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6781 actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 20.0f));
6784 tet_infoline("Create an Actor with AnchorPoint::BOTTOM_RIGHT, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6786 Actor actorB = Actor::New();
6787 actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6788 actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6789 actorB.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6790 Vector2 actorBSize(30.0f, 60.0f);
6791 actorB.SetProperty(Actor::Property::SIZE, actorBSize);
6794 tet_infoline("Create an actor with AnchorPoint::CENTER, ParentOrigin::CENTER and 0,0 position, POSITION_USES_ANCHOR false");
6796 Actor actorC = Actor::New();
6797 actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6798 actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6799 actorC.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6800 Vector2 actorCSize(60.0f, 120.0f);
6801 actorC.SetProperty(Actor::Property::SIZE, actorCSize);
6804 application.SendNotification();
6805 application.Render();
6807 tet_infoline("Despite differing sizes and anchor-points, the screen position for all actors is the same");
6809 Vector2 center(stage.GetSize() * 0.5f);
6811 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6812 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6813 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center, TEST_LOCATION);
6815 tet_infoline("Add scale to all actors");
6817 actorA.SetProperty(Actor::Property::SCALE, 2.0f);
6818 actorB.SetProperty(Actor::Property::SCALE, 2.0f);
6819 actorC.SetProperty(Actor::Property::SCALE, 2.0f);
6821 application.SendNotification();
6822 application.Render();
6824 DALI_TEST_EQUALS(actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center /* TOP_LEFT Anchor */, TEST_LOCATION);
6825 DALI_TEST_EQUALS(actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorBSize /* BOTTOM_RIGHT Anchor */, TEST_LOCATION);
6826 DALI_TEST_EQUALS(actorC.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>(), center - actorCSize * 0.5f /* CENTER Anchor*/, TEST_LOCATION);
6831 int utcDaliActorPositionUsesAnchorPoint(void)
6833 TestApplication application;
6834 tet_infoline("Check default behaviour\n");
6836 Actor actor = Actor::New();
6837 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6838 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6839 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6840 application.GetScene().Add(actor);
6842 application.SendNotification();
6843 application.Render();
6845 tet_infoline("Check that the world position is in the center\n");
6846 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6848 tet_infoline("Set the position uses anchor point property to false\n");
6849 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6851 application.SendNotification();
6852 application.Render();
6854 tet_infoline("Check that the world position has changed appropriately\n");
6855 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6860 int utcDaliActorPositionUsesAnchorPointCheckScale(void)
6862 TestApplication application;
6863 tet_infoline("Check that the scale is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6865 Actor actor = Actor::New();
6866 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6867 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6868 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6869 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6870 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6871 application.GetScene().Add(actor);
6873 application.SendNotification();
6874 application.Render();
6876 tet_infoline("Check the world position is the same as it would be without a scale\n");
6877 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6879 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6880 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6881 application.SendNotification();
6882 application.Render();
6883 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION);
6885 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6886 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6887 application.SendNotification();
6888 application.Render();
6889 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
6894 int utcDaliActorPositionUsesAnchorPointCheckRotation(void)
6896 TestApplication application;
6897 tet_infoline("Check that the rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6899 Actor actor = Actor::New();
6900 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6901 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6902 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6903 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6904 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6905 application.GetScene().Add(actor);
6907 application.SendNotification();
6908 application.Render();
6910 tet_infoline("Check the world position is the same as it would be without a rotation\n");
6911 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6913 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6914 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6915 application.SendNotification();
6916 application.Render();
6917 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-50.0f, 50.0f, 0.0f), TEST_LOCATION);
6919 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6920 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6921 application.SendNotification();
6922 application.Render();
6923 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(150.0f, 50.0f, 0.0f), TEST_LOCATION);
6928 int utcDaliActorPositionUsesAnchorPointCheckScaleAndRotation(void)
6930 TestApplication application;
6931 tet_infoline("Check that the scale and rotation is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6933 Actor actor = Actor::New();
6934 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6935 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6936 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6937 actor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::ZAXIS));
6938 actor.SetProperty(Actor::Property::SCALE, 2.0f);
6939 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6940 application.GetScene().Add(actor);
6942 application.SendNotification();
6943 application.Render();
6945 tet_infoline("Check the world position is the same as it would be without a scale and rotation\n");
6946 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(50.0f, 50.0f, 0.0f), TEST_LOCATION);
6948 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure the world position changes accordingly");
6949 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6950 application.SendNotification();
6951 application.Render();
6952 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(-100.0f, 100.0f, 0.0f), TEST_LOCATION);
6954 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure the world position changes accordingly");
6955 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6956 application.SendNotification();
6957 application.Render();
6958 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), Vector3(200.0f, 0.0f, 0.0f), TEST_LOCATION);
6963 int utcDaliActorPositionUsesAnchorPointOnlyInheritPosition(void)
6965 TestApplication application;
6966 tet_infoline("Check that if not inheriting scale and position, then the position is adjusted appropriately when setting the positionUsesAnchorPoint to false\n");
6968 Actor parent = Actor::New();
6970 application.GetScene().Add(parent);
6971 Vector2 stageSize(application.GetScene().GetSize());
6973 Actor actor = Actor::New();
6974 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
6975 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
6976 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
6977 actor.SetProperty(Actor::Property::INHERIT_SCALE, false);
6978 actor.SetProperty(Actor::Property::INHERIT_ORIENTATION, false);
6979 actor.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false);
6982 application.SendNotification();
6983 application.Render();
6985 const Vector3 expectedWorldPosition(-stageSize.width * 0.5f + 50.0f, -stageSize.height * 0.5f + 50.0f, 0.0f);
6987 tet_infoline("Check the world position is in the right place\n");
6988 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6990 tet_infoline("Change the Anchor Point to TOP_LEFT and ensure world position hasn't changed");
6991 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
6992 application.SendNotification();
6993 application.Render();
6994 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
6996 tet_infoline("Change the Anchor Point to BOTTOM_RIGHT and ensure world position hasn't changed");
6997 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT);
6998 application.SendNotification();
6999 application.Render();
7000 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), expectedWorldPosition, TEST_LOCATION);
7005 int utcDaliActorVisibilityChangeSignalSelf(void)
7007 TestApplication application;
7008 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7010 Actor actor = Actor::New();
7012 VisibilityChangedFunctorData data;
7013 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7015 actor.SetProperty(Actor::Property::VISIBLE, false);
7017 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7019 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7022 actor.SetProperty(Actor::Property::VISIBLE, false);
7023 data.Check(false /* not called */, TEST_LOCATION);
7025 tet_infoline("Change the visibility using properties, ensure called");
7028 actor.SetProperty(Actor::Property::VISIBLE, true);
7029 data.Check(true /* called */, actor, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7031 tet_infoline("Set the visibility to current using properties, ensure not called");
7034 actor.SetProperty(Actor::Property::VISIBLE, true);
7035 data.Check(false /* not called */, TEST_LOCATION);
7040 int utcDaliActorVisibilityChangeSignalChildren(void)
7042 TestApplication application;
7043 tet_infoline("Check that the visibility change signal is called for the children when the visibility changes for the parent");
7045 Actor parent = Actor::New();
7046 Actor child = Actor::New();
7049 Actor grandChild = Actor::New();
7050 child.Add(grandChild);
7052 VisibilityChangedFunctorData parentData;
7053 VisibilityChangedFunctorData childData;
7054 VisibilityChangedFunctorData grandChildData;
7056 tet_infoline("Only connect the child and grandchild, ensure they are called and not the parent");
7057 DevelActor::VisibilityChangedSignal(child).Connect(&application, VisibilityChangedFunctor(childData));
7058 DevelActor::VisibilityChangedSignal(grandChild).Connect(&application, VisibilityChangedFunctor(grandChildData));
7060 parent.SetProperty(Actor::Property::VISIBLE, false);
7061 parentData.Check(false /* not called */, TEST_LOCATION);
7062 childData.Check(true /* called */, child, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7063 grandChildData.Check(true /* called */, grandChild, false /* not visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7065 tet_infoline("Connect to the parent's signal as well and ensure all three are called");
7068 grandChildData.Reset();
7070 DevelActor::VisibilityChangedSignal(parent).Connect(&application, VisibilityChangedFunctor(parentData));
7072 parent.SetProperty(Actor::Property::VISIBLE, true);
7073 parentData.Check(true /* called */, parent, true /* visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7074 childData.Check(true /* called */, child, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7075 grandChildData.Check(true /* called */, grandChild, true /* visible */, DevelActor::VisibilityChange::PARENT, TEST_LOCATION);
7077 tet_infoline("Ensure none of the functors are called if we attempt to change the visibility to what it already is at");
7080 grandChildData.Reset();
7082 parent.SetProperty(Actor::Property::VISIBLE, true);
7083 parentData.Check(false /* not called */, TEST_LOCATION);
7084 childData.Check(false /* not called */, TEST_LOCATION);
7085 grandChildData.Check(false /* not called */, TEST_LOCATION);
7090 int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
7092 TestApplication application;
7093 tet_infoline("Check that the visibility change signal is emitted when the visibility changes when an animation starts");
7095 Actor actor = Actor::New();
7096 application.GetScene().Add(actor);
7098 application.SendNotification();
7099 application.Render();
7101 VisibilityChangedFunctorData data;
7102 DevelActor::VisibilityChangedSignal(actor).Connect(&application, VisibilityChangedFunctor(data));
7104 Animation animation = Animation::New(1.0f);
7105 animation.AnimateTo(Property(actor, Actor::Property::VISIBLE), false);
7107 data.Check(false, TEST_LOCATION);
7108 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7109 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7111 tet_infoline("Play the animation and check the property value");
7114 data.Check(true /* called */, actor, false /* not visible */, DevelActor::VisibilityChange::SELF, TEST_LOCATION);
7115 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7117 tet_infoline("Animation not currently finished, so the current visibility should still be true");
7118 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), true, TEST_LOCATION);
7120 application.SendNotification();
7121 application.Render(1100); // After the animation
7123 DALI_TEST_EQUALS(actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE), false, TEST_LOCATION);
7128 int utcDaliActorVisibilityChangeSignalByName(void)
7130 TestApplication application;
7131 tet_infoline("Check that the visibility change signal is called when the visibility changes for the actor itself");
7133 Actor actor = Actor::New();
7135 bool signalCalled = false;
7136 actor.ConnectSignal(&application, "visibilityChanged", VisibilityChangedVoidFunctor(signalCalled));
7137 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7138 actor.SetProperty(Actor::Property::VISIBLE, false);
7139 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7141 tet_infoline("Ensure functor is not called if we attempt to change the visibility to what it already is at");
7142 signalCalled = false;
7143 actor.SetProperty(Actor::Property::VISIBLE, false);
7144 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7146 tet_infoline("Change the visibility using properties, ensure called");
7147 actor.SetProperty(Actor::Property::VISIBLE, true);
7148 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7150 tet_infoline("Set the visibility to current using properties, ensure not called");
7151 signalCalled = false;
7153 actor.SetProperty(Actor::Property::VISIBLE, true);
7154 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7159 static void LayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
7161 gLayoutDirectionType = type;
7164 int UtcDaliActorLayoutDirectionProperty(void)
7166 TestApplication application;
7167 tet_infoline("Check layout direction property");
7169 Actor actor0 = Actor::New();
7170 DALI_TEST_EQUALS(actor0.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7171 application.GetScene().Add(actor0);
7173 application.SendNotification();
7174 application.Render();
7176 Actor actor1 = Actor::New();
7177 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7178 Actor actor2 = Actor::New();
7179 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7180 Actor actor3 = Actor::New();
7181 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7182 Actor actor4 = Actor::New();
7183 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7184 Actor actor5 = Actor::New();
7185 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7186 Actor actor6 = Actor::New();
7187 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7188 Actor actor7 = Actor::New();
7189 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7190 Actor actor8 = Actor::New();
7191 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7192 Actor actor9 = Actor::New();
7193 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7196 gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
7197 actor2.LayoutDirectionChangedSignal().Connect(LayoutDirectionChanged);
7199 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7200 actor1.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7201 DALI_TEST_EQUALS(actor1.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7203 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7204 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7205 DALI_TEST_EQUALS(gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION);
7207 actor1.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7209 DALI_TEST_EQUALS(actor1.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7210 DALI_TEST_EQUALS(actor2.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7212 application.GetScene().Add(actor3);
7219 actor3.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7220 actor5.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7222 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), true, TEST_LOCATION);
7223 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
7224 DALI_TEST_EQUALS(actor8.GetProperty<bool>(Actor::Property::INHERIT_LAYOUT_DIRECTION), false, TEST_LOCATION);
7226 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7228 DALI_TEST_EQUALS(actor3.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7229 DALI_TEST_EQUALS(actor4.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7230 DALI_TEST_EQUALS(actor5.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7231 DALI_TEST_EQUALS(actor6.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7232 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7233 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7234 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7236 actor8.SetProperty(Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT");
7237 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7238 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7240 actor7.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7241 DALI_TEST_EQUALS(actor7.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7242 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7243 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
7245 actor8.SetProperty(Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
7246 DALI_TEST_EQUALS(actor8.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7247 DALI_TEST_EQUALS(actor9.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7252 struct LayoutDirectionFunctor
7254 LayoutDirectionFunctor(bool& signalCalled)
7255 : mSignalCalled(signalCalled)
7259 LayoutDirectionFunctor(const LayoutDirectionFunctor& rhs)
7260 : mSignalCalled(rhs.mSignalCalled)
7266 mSignalCalled = true;
7269 bool& mSignalCalled;
7272 int UtcDaliActorLayoutDirectionSignal(void)
7274 TestApplication application;
7275 tet_infoline("Check changing layout direction property sends a signal");
7277 Actor actor = Actor::New();
7278 DALI_TEST_EQUALS(actor.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::LEFT_TO_RIGHT), TEST_LOCATION);
7279 application.GetScene().Add(actor);
7280 bool signalCalled = false;
7281 LayoutDirectionFunctor layoutDirectionFunctor(signalCalled);
7283 actor.ConnectSignal(&application, "layoutDirectionChanged", layoutDirectionFunctor);
7284 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7286 // Test that writing the same value doesn't send a signal
7287 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT);
7288 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7290 // Test that writing a different value sends the signal
7291 signalCalled = false;
7292 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7293 DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
7295 signalCalled = false;
7296 actor.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
7297 DALI_TEST_EQUALS(signalCalled, false, TEST_LOCATION);
7302 struct ChildAddedSignalCheck
7304 ChildAddedSignalCheck(bool& signalReceived, Actor& childHandle)
7305 : mSignalReceived(signalReceived),
7306 mChildHandle(childHandle)
7310 void operator()(Actor childHandle)
7312 mSignalReceived = true;
7313 mChildHandle = childHandle;
7317 mSignalReceived = true;
7318 mChildHandle = Actor();
7321 bool& mSignalReceived;
7322 Actor& mChildHandle;
7325 int UtcDaliChildAddedSignalP1(void)
7327 TestApplication application;
7328 auto stage = application.GetScene();
7330 bool signalReceived = false;
7333 ChildAddedSignalCheck signal(signalReceived, childActor);
7334 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7335 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7337 auto actorA = Actor::New();
7339 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7340 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7341 signalReceived = false;
7343 auto actorB = Actor::New();
7345 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7346 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7351 int UtcDaliChildAddedSignalP2(void)
7353 TestApplication application;
7354 auto stage = application.GetScene();
7356 bool signalReceived = false;
7359 ChildAddedSignalCheck signal(signalReceived, childActor);
7360 tet_infoline("Connect to childAdded signal by name");
7362 stage.GetRootLayer().ConnectSignal(&application, "childAdded", signal);
7363 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7365 auto actorA = Actor::New();
7367 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7369 // Can't test which actor was added; signal signature is void() when connecting via name.
7370 signalReceived = false;
7372 auto actorB = Actor::New();
7374 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7379 int UtcDaliChildAddedSignalN(void)
7381 TestApplication application;
7382 auto stage = application.GetScene();
7384 bool signalReceived = false;
7387 ChildAddedSignalCheck signal(signalReceived, childActor);
7388 DevelActor::ChildAddedSignal(stage.GetRootLayer()).Connect(&application, signal);
7389 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7391 auto actorA = Actor::New();
7393 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7394 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7395 signalReceived = false;
7397 auto actorB = Actor::New();
7399 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7403 struct ChildRemovedSignalCheck
7405 ChildRemovedSignalCheck(bool& signalReceived, Actor& childHandle)
7406 : mSignalReceived(signalReceived),
7407 mChildHandle(childHandle)
7411 void operator()(Actor childHandle)
7413 mSignalReceived = true;
7414 mChildHandle = childHandle;
7419 mSignalReceived = true;
7422 bool& mSignalReceived;
7423 Actor& mChildHandle;
7426 int UtcDaliChildRemovedSignalP1(void)
7428 TestApplication application;
7429 auto stage = application.GetScene();
7431 bool signalReceived = false;
7434 ChildRemovedSignalCheck signal(signalReceived, childActor);
7435 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7436 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7438 auto actorA = Actor::New();
7440 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7441 DALI_TEST_CHECK(!childActor);
7443 stage.Remove(actorA);
7444 DALI_TEST_EQUALS(childActor, actorA, TEST_LOCATION);
7445 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7447 signalReceived = false;
7448 auto actorB = Actor::New();
7450 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7452 stage.Remove(actorB);
7453 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7454 DALI_TEST_EQUALS(childActor, actorB, TEST_LOCATION);
7459 int UtcDaliChildRemovedSignalP2(void)
7461 TestApplication application;
7462 auto stage = application.GetScene();
7464 bool signalReceived = false;
7467 ChildAddedSignalCheck signal(signalReceived, childActor);
7468 tet_infoline("Connect to childRemoved signal by name");
7470 stage.GetRootLayer().ConnectSignal(&application, "childRemoved", signal);
7471 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7473 auto actorA = Actor::New();
7475 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7477 stage.Remove(actorA);
7478 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7480 signalReceived = false;
7481 auto actorB = Actor::New();
7483 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7485 stage.Remove(actorB);
7486 DALI_TEST_EQUALS(signalReceived, true, TEST_LOCATION);
7491 int UtcDaliChildRemovedSignalN(void)
7493 TestApplication application;
7494 auto stage = application.GetScene();
7496 bool signalReceived = false;
7499 ChildRemovedSignalCheck signal(signalReceived, childActor);
7500 DevelActor::ChildRemovedSignal(stage.GetRootLayer()).Connect(&application, signal);
7501 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7503 auto actorA = Actor::New();
7506 auto actorB = Actor::New();
7509 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7510 DALI_TEST_CHECK(!childActor);
7512 actorA.Remove(actorB);
7513 DALI_TEST_EQUALS(signalReceived, false, TEST_LOCATION);
7517 int UtcDaliChildMovedSignalP(void)
7519 TestApplication application;
7520 auto stage = application.GetScene();
7522 bool addedASignalReceived = false;
7523 bool removedASignalReceived = false;
7524 bool addedBSignalReceived = false;
7525 bool removedBSignalReceived = false;
7528 auto actorA = Actor::New();
7529 auto actorB = Actor::New();
7533 ChildAddedSignalCheck addedSignalA(addedASignalReceived, childActor);
7534 ChildRemovedSignalCheck removedSignalA(removedASignalReceived, childActor);
7535 ChildAddedSignalCheck addedSignalB(addedBSignalReceived, childActor);
7536 ChildRemovedSignalCheck removedSignalB(removedBSignalReceived, childActor);
7538 DevelActor::ChildAddedSignal(actorA).Connect(&application, addedSignalA);
7539 DevelActor::ChildRemovedSignal(actorA).Connect(&application, removedSignalA);
7540 DevelActor::ChildAddedSignal(actorB).Connect(&application, addedSignalB);
7541 DevelActor::ChildRemovedSignal(actorB).Connect(&application, removedSignalB);
7543 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7544 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7545 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7546 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7548 // Create a child of A
7550 auto child = Actor::New();
7553 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7554 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7555 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7556 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7557 DALI_TEST_EQUALS(childActor, child, TEST_LOCATION);
7560 addedASignalReceived = false;
7561 addedBSignalReceived = false;
7562 removedASignalReceived = false;
7563 removedBSignalReceived = false;
7565 actorB.Add(child); // Expect this child to be re-parented
7566 DALI_TEST_EQUALS(addedASignalReceived, false, TEST_LOCATION);
7567 DALI_TEST_EQUALS(removedASignalReceived, true, TEST_LOCATION);
7568 DALI_TEST_EQUALS(addedBSignalReceived, true, TEST_LOCATION);
7569 DALI_TEST_EQUALS(removedBSignalReceived, false, TEST_LOCATION);
7571 // Move child back to A:
7572 addedASignalReceived = false;
7573 addedBSignalReceived = false;
7574 removedASignalReceived = false;
7575 removedBSignalReceived = false;
7577 actorA.Add(child); // Expect this child to be re-parented
7578 DALI_TEST_EQUALS(addedASignalReceived, true, TEST_LOCATION);
7579 DALI_TEST_EQUALS(removedASignalReceived, false, TEST_LOCATION);
7580 DALI_TEST_EQUALS(addedBSignalReceived, false, TEST_LOCATION);
7581 DALI_TEST_EQUALS(removedBSignalReceived, true, TEST_LOCATION);
7586 int utcDaliActorCulled(void)
7588 TestApplication application;
7589 auto stage = application.GetScene();
7591 tet_infoline("Check that the actor is culled if the actor is out of the screen");
7593 Actor actor = Actor::New();
7594 actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
7596 Geometry geometry = CreateQuadGeometry();
7597 Shader shader = CreateShader();
7598 Renderer renderer = Renderer::New(geometry, shader);
7599 actor.AddRenderer(renderer);
7603 application.SendNotification();
7604 application.Render(0);
7606 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), false, TEST_LOCATION);
7608 PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::CULLED, LessThanCondition(0.5f));
7609 notification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
7611 // Connect NotifySignal
7612 bool propertyNotificationSignal(false);
7613 PropertyNotification source;
7614 CulledPropertyNotificationFunctor f(propertyNotificationSignal, source);
7615 notification.NotifySignal().Connect(&application, f);
7617 actor.SetProperty(Actor::Property::POSITION, Vector2(1000.0f, 1000.0f));
7619 application.SendNotification();
7620 application.Render();
7622 application.SendNotification();
7624 DALI_TEST_EQUALS(actor.GetProperty<bool>(Actor::Property::CULLED), true, TEST_LOCATION);
7626 DALI_TEST_EQUALS(propertyNotificationSignal, true, TEST_LOCATION);
7627 DALI_TEST_EQUALS(source.GetTargetProperty(), static_cast<int>(Actor::Property::CULLED), TEST_LOCATION);
7628 DALI_TEST_EQUALS(source.GetTarget().GetProperty<bool>(source.GetTargetProperty()), true, TEST_LOCATION);
7633 int utcDaliEnsureRenderWhenRemovingLastRenderableActor(void)
7635 TestApplication application;
7636 auto stage = application.GetScene();
7638 tet_infoline("Ensure we clear the screen when the last actor is removed");
7640 Actor actor = CreateRenderableActor();
7641 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7644 application.SendNotification();
7645 application.Render();
7647 auto& glAbstraction = application.GetGlAbstraction();
7648 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7652 application.SendNotification();
7653 application.Render();
7655 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7660 int utcDaliEnsureRenderWhenMakingLastActorInvisible(void)
7662 TestApplication application;
7663 auto stage = application.GetScene();
7665 tet_infoline("Ensure we clear the screen when the last actor is made invisible");
7667 Actor actor = CreateRenderableActor();
7668 actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
7671 application.SendNotification();
7672 application.Render();
7674 auto& glAbstraction = application.GetGlAbstraction();
7675 const auto clearCountBefore = glAbstraction.GetClearCountCalled();
7677 actor.SetProperty(Actor::Property::VISIBLE, false);
7679 application.SendNotification();
7680 application.Render();
7682 DALI_TEST_EQUALS(glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION);
7687 int utcDaliActorGetSizeAfterAnimation(void)
7689 TestApplication application;
7690 tet_infoline("Check the actor size before / after an animation is finished");
7692 Vector3 actorSize(100.0f, 100.0f, 0.0f);
7694 Actor actor = Actor::New();
7695 actor.SetProperty(Actor::Property::SIZE, actorSize);
7696 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7697 application.GetScene().Add(actor);
7699 // Size should be updated without rendering.
7700 Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7701 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7703 application.SendNotification();
7704 application.Render();
7706 // Size and current size should be updated.
7707 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7708 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7709 DALI_TEST_EQUALS(actorSize.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7710 DALI_TEST_EQUALS(actorSize.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7711 DALI_TEST_EQUALS(actorSize.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7713 Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7714 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7715 DALI_TEST_EQUALS(actorSize.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7716 DALI_TEST_EQUALS(actorSize.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7717 DALI_TEST_EQUALS(actorSize.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7720 actorSize = Vector3(200.0f, 200.0f, 0.0f);
7721 actor.SetProperty(Actor::Property::SIZE, actorSize);
7723 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7724 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7726 Vector3 targetValue(10.0f, 20.0f, 0.0f);
7728 Animation animation = Animation::New(1.0f);
7729 animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue);
7732 // Size should be updated without rendering.
7733 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7734 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7736 application.SendNotification();
7737 application.Render(1100); // After the animation
7739 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7740 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7741 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7742 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7743 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7745 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7746 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7747 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7748 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7749 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7751 targetValue.width = 50.0f;
7754 animation.AnimateTo(Property(actor, Actor::Property::SIZE_WIDTH), targetValue.width);
7757 application.SendNotification();
7758 application.Render(1100); // After the animation
7760 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7761 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7762 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7763 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7764 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7766 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7767 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7768 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7769 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7770 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7772 targetValue.height = 70.0f;
7775 animation.AnimateTo(Property(actor, Actor::Property::SIZE_HEIGHT), targetValue.height);
7778 application.SendNotification();
7779 application.Render(1100); // After the animation
7781 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7782 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7783 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7784 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7785 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7787 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7788 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7789 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7790 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7791 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7793 Vector3 offset(10.0f, 20.0f, 0.0f);
7796 animation.AnimateBy(Property(actor, Actor::Property::SIZE), offset);
7799 application.SendNotification();
7800 application.Render(1100); // After the animation
7802 targetValue += offset;
7804 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7805 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7806 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7807 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7808 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7810 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7811 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7812 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7813 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7814 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7816 offset.width = 20.0f;
7819 animation.AnimateBy(Property(actor, Actor::Property::SIZE_WIDTH), offset.width);
7822 application.SendNotification();
7823 application.Render(1100); // After the animation
7825 targetValue.width += offset.width;
7827 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7828 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7829 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7830 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7831 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7833 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7834 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7835 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7836 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7837 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7839 offset.height = 10.0f;
7842 animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height);
7845 application.SendNotification();
7846 application.Render(1100); // After the animation
7848 targetValue.height += offset.height;
7850 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7851 DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7852 DALI_TEST_EQUALS(targetValue.width, actor.GetProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7853 DALI_TEST_EQUALS(targetValue.height, actor.GetProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7854 DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7856 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7857 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7858 DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty<float>(Actor::Property::SIZE_WIDTH), TEST_LOCATION);
7859 DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty<float>(Actor::Property::SIZE_HEIGHT), TEST_LOCATION);
7860 DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty<float>(Actor::Property::SIZE_DEPTH), TEST_LOCATION);
7863 actorSize = Vector3(300.0f, 300.0f, 0.0f);
7865 actor.SetProperty(Actor::Property::SIZE, actorSize);
7867 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7868 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7870 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7871 DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7873 application.SendNotification();
7874 application.Render();
7876 size = actor.GetProperty(Actor::Property::SIZE).Get<Vector3>();
7877 DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7879 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get<Vector3>();
7880 DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION);
7885 int utcDaliActorPartialUpdate(void)
7887 TestApplication application(
7888 TestApplication::DEFAULT_SURFACE_WIDTH,
7889 TestApplication::DEFAULT_SURFACE_HEIGHT,
7890 TestApplication::DEFAULT_HORIZONTAL_DPI,
7891 TestApplication::DEFAULT_VERTICAL_DPI,
7895 tet_infoline("Check the damaged area");
7897 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
7899 std::vector<Rect<int>> damagedRects;
7900 Rect<int> clippingRect;
7901 application.SendNotification();
7902 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7904 // First render pass, nothing to render, adaptor would just do swap buffer.
7905 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
7906 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7908 Actor actor = CreateRenderableActor();
7909 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
7910 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
7911 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
7912 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
7913 application.GetScene().Add(actor);
7915 application.SendNotification();
7917 // 1. Actor added, damaged rect is added size of actor
7918 damagedRects.clear();
7919 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7920 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7923 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
7924 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7925 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7926 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7927 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7928 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7929 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7932 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0));
7933 application.SendNotification();
7935 damagedRects.clear();
7936 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7937 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7940 clippingRect = Rect<int>(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates
7941 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7942 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7943 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7944 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7945 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7946 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7948 // 3. Set new position
7949 actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0));
7950 application.SendNotification();
7952 damagedRects.clear();
7953 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7954 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
7957 clippingRect = Rect<int>(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates
7958 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
7959 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7960 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7961 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7962 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7963 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7965 application.GetScene().Remove(actor);
7966 application.SendNotification();
7968 // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together.
7969 damagedRects.clear();
7970 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
7971 DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION);
7973 clippingRect = damagedRects[0];
7974 clippingRect.Merge(damagedRects[1]);
7975 clippingRect.Merge(damagedRects[2]);
7977 DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION);
7978 DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION);
7979 DALI_TEST_EQUALS<Rect<int>>(clippingRect, Rect<int>(16, 736, 64, 64), TEST_LOCATION);
7981 application.RenderWithPartialUpdate(damagedRects, clippingRect);
7982 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
7983 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
7984 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
7985 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
7990 int utcDaliActorPartialUpdateSetColor(void)
7992 TestApplication application(
7993 TestApplication::DEFAULT_SURFACE_WIDTH,
7994 TestApplication::DEFAULT_SURFACE_HEIGHT,
7995 TestApplication::DEFAULT_HORIZONTAL_DPI,
7996 TestApplication::DEFAULT_VERTICAL_DPI,
8000 tet_infoline("Check uniform update");
8002 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8004 std::vector<Rect<int>> damagedRects;
8005 Rect<int> clippingRect;
8006 application.SendNotification();
8007 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8009 // First render pass, nothing to render, adaptor would just do swap buffer.
8010 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8011 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8013 Actor actor = CreateRenderableActor();
8014 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8015 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8016 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8017 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8018 application.GetScene().Add(actor);
8020 application.SendNotification();
8022 // 1. Actor added, damaged rect is added size of actor
8023 damagedRects.clear();
8024 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8025 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8028 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8029 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8030 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8031 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8032 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8033 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8034 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8036 damagedRects.clear();
8037 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8039 damagedRects.clear();
8040 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8043 actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f));
8044 application.SendNotification();
8046 damagedRects.clear();
8047 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8048 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8051 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8052 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8053 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8054 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8055 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8056 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8057 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8062 const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix");
8063 const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix");
8064 const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor");
8065 const char* const RENDER_SHADOW_VERTEX_SOURCE =
8066 " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
8067 " uniform mediump mat4 uLightCameraViewMatrix;\n"
8071 " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n"
8072 " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n"
8073 " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
8076 const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
8077 "uniform lowp vec4 uShadowColor;\n"
8080 " lowp float alpha;\n"
8081 " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
8082 " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
8085 int utcDaliActorPartialUpdateSetProperty(void)
8087 TestApplication application(
8088 TestApplication::DEFAULT_SURFACE_WIDTH,
8089 TestApplication::DEFAULT_SURFACE_HEIGHT,
8090 TestApplication::DEFAULT_HORIZONTAL_DPI,
8091 TestApplication::DEFAULT_VERTICAL_DPI,
8095 tet_infoline("Set/Update property with partial update");
8097 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8099 std::vector<Rect<int>> damagedRects;
8100 Rect<int> clippingRect;
8101 application.SendNotification();
8102 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8104 // First render pass, nothing to render, adaptor would just do swap buffer.
8105 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8106 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8108 Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
8109 Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
8110 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8111 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8112 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8113 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8114 application.GetScene().Add(actor);
8116 actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
8118 damagedRects.clear();
8119 application.SendNotification();
8120 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8121 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8124 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8125 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8126 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8127 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8128 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8129 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8130 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8132 Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
8133 actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
8135 damagedRects.clear();
8136 application.SendNotification();
8137 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8138 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8140 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8141 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8142 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8143 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8144 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8145 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8147 // Should be no damage rects, nothing changed
8148 damagedRects.clear();
8149 application.SendNotification();
8150 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8151 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8153 // Should be 1 damage rect due to change in size
8154 damagedRects.clear();
8155 actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f));
8156 application.SendNotification();
8157 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8158 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8160 clippingRect = Rect<int>(16, 752, 32, 48); // new clipping rect size increased due to change in actor size
8161 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8162 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8163 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8164 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8165 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8166 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8168 damagedRects.clear();
8169 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8170 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8175 int utcDaliActorPartialUpdateTwoActors(void)
8177 TestApplication application(
8178 TestApplication::DEFAULT_SURFACE_WIDTH,
8179 TestApplication::DEFAULT_SURFACE_HEIGHT,
8180 TestApplication::DEFAULT_HORIZONTAL_DPI,
8181 TestApplication::DEFAULT_VERTICAL_DPI,
8185 tet_infoline("Check the damaged rects with partial update and two actors");
8187 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8189 Actor actor = CreateRenderableActor();
8190 actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f));
8191 actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f));
8192 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8193 application.GetScene().Add(actor);
8195 Actor actor2 = CreateRenderableActor();
8196 actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
8197 actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f));
8198 actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8199 application.GetScene().Add(actor2);
8201 application.SendNotification();
8202 std::vector<Rect<int>> damagedRects;
8203 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8205 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8206 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(64, 672, 64, 64), damagedRects[0], TEST_LOCATION);
8207 DALI_TEST_EQUALS<Rect<int>>(Rect<int>(96, 592, 112, 112), damagedRects[1], TEST_LOCATION);
8209 // in screen coordinates, adaptor would calculate it using previous frames information
8210 Rect<int> clippingRect = Rect<int>(64, 592, 144, 192);
8211 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8213 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8214 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8215 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8216 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8221 int utcDaliActorPartialUpdateActorsWithSizeHint(void)
8223 TestApplication application(
8224 TestApplication::DEFAULT_SURFACE_WIDTH,
8225 TestApplication::DEFAULT_SURFACE_HEIGHT,
8226 TestApplication::DEFAULT_HORIZONTAL_DPI,
8227 TestApplication::DEFAULT_VERTICAL_DPI,
8231 tet_infoline("Check the damaged rect with partial update and actor size hint");
8233 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8235 Actor actor = CreateRenderableActor();
8236 actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f));
8237 actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
8238 actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f));
8239 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8240 application.GetScene().Add(actor);
8242 application.SendNotification();
8243 std::vector<Rect<int>> damagedRects;
8244 application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects);
8246 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8248 Rect<int> clippingRect = Rect<int>(32, 704, 80, 80);
8249 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8251 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8253 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8254 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8255 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8256 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8261 int utcDaliActorPartialUpdateAnimation(void)
8263 TestApplication application(
8264 TestApplication::DEFAULT_SURFACE_WIDTH,
8265 TestApplication::DEFAULT_SURFACE_HEIGHT,
8266 TestApplication::DEFAULT_HORIZONTAL_DPI,
8267 TestApplication::DEFAULT_VERTICAL_DPI,
8271 tet_infoline("Check the damaged area with partial update and animation");
8273 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
8274 drawTrace.Enable(true);
8277 Actor actor1 = CreateRenderableActor();
8278 actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8279 actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
8280 application.GetScene().Add(actor1);
8282 Actor actor2 = CreateRenderableActor();
8283 actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8284 actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8285 application.GetScene().Add(actor2);
8287 std::vector<Rect<int>> damagedRects;
8288 Rect<int> clippingRect;
8289 Rect<int> expectedRect1, expectedRect2;
8291 application.SendNotification();
8292 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8294 DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION);
8297 expectedRect1 = Rect<int>(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates
8298 expectedRect2 = Rect<int>(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates
8299 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[0], TEST_LOCATION);
8300 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[1], TEST_LOCATION);
8302 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8304 damagedRects.clear();
8305 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8306 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8308 // Make an animation
8309 Animation animation = Animation::New(1.0f);
8310 animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f));
8313 application.SendNotification();
8315 damagedRects.clear();
8316 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8317 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8320 damagedRects.clear();
8322 // In animation deley time
8323 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8324 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8327 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8330 damagedRects.clear();
8332 // Also in animation deley time
8333 application.PreRenderWithPartialUpdate(100, nullptr, damagedRects);
8334 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8337 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
8339 // Unparent 2 actors and make a new actor
8343 Actor actor3 = CreateRenderableActor();
8344 actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8345 actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8346 application.GetScene().Add(actor3);
8348 application.SendNotification();
8350 // Started animation
8351 damagedRects.clear();
8352 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8353 DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION);
8355 // The first dirty rect is actor3's.
8356 // We don't know the exact dirty rect of actor2
8357 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8358 DALI_TEST_EQUALS<Rect<int>>(expectedRect1, damagedRects[1], TEST_LOCATION);
8360 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8362 // Finished animation, but the actior was already unparented
8363 damagedRects.clear();
8364 application.PreRenderWithPartialUpdate(500, nullptr, damagedRects);
8366 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8367 DALI_TEST_EQUALS<Rect<int>>(expectedRect2, damagedRects[0], TEST_LOCATION);
8369 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8374 int utcDaliActorPartialUpdateChangeVisibility(void)
8376 TestApplication application(
8377 TestApplication::DEFAULT_SURFACE_WIDTH,
8378 TestApplication::DEFAULT_SURFACE_HEIGHT,
8379 TestApplication::DEFAULT_HORIZONTAL_DPI,
8380 TestApplication::DEFAULT_VERTICAL_DPI,
8384 tet_infoline("Check the damaged rect with partial update and visibility change");
8386 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8388 Actor actor = CreateRenderableActor();
8389 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8390 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8391 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8392 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8393 application.GetScene().Add(actor);
8395 application.SendNotification();
8397 std::vector<Rect<int>> damagedRects;
8398 Rect<int> clippingRect;
8400 // 1. Actor added, damaged rect is added size of actor
8401 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8402 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8405 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8406 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8407 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8408 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8409 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8410 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8411 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8413 damagedRects.clear();
8414 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8415 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8417 damagedRects.clear();
8418 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8419 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8421 // Ensure the damaged rect is empty
8422 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8424 // 2. Make the Actor invisible
8425 actor.SetProperty(Actor::Property::VISIBLE, false);
8426 application.SendNotification();
8428 damagedRects.clear();
8429 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8430 DALI_TEST_CHECK(damagedRects.size() > 0);
8431 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8433 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8434 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8435 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8436 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8437 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8439 // 3. Make the Actor visible again
8440 actor.SetProperty(Actor::Property::VISIBLE, true);
8441 application.SendNotification();
8443 damagedRects.clear();
8444 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8445 DALI_TEST_CHECK(damagedRects.size() > 0);
8446 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8448 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8449 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8450 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8451 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8452 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8457 int utcDaliActorPartialUpdateOnOffScene(void)
8459 TestApplication application(
8460 TestApplication::DEFAULT_SURFACE_WIDTH,
8461 TestApplication::DEFAULT_SURFACE_HEIGHT,
8462 TestApplication::DEFAULT_HORIZONTAL_DPI,
8463 TestApplication::DEFAULT_VERTICAL_DPI,
8467 tet_infoline("Check the damaged rect with partial update and on/off scene");
8469 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
8471 Actor actor = CreateRenderableActor();
8472 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
8473 actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
8474 actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
8475 actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
8476 application.GetScene().Add(actor);
8478 application.SendNotification();
8480 std::vector<Rect<int>> damagedRects;
8481 Rect<int> clippingRect;
8483 // 1. Actor added, damaged rect is added size of actor
8484 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8485 DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
8488 clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
8489 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8490 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8491 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8492 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8493 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8494 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8496 damagedRects.clear();
8497 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8498 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8500 damagedRects.clear();
8501 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8502 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8504 // Ensure the damaged rect is empty
8505 DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
8507 // 2. Remove the Actor from the Scene
8509 application.SendNotification();
8511 damagedRects.clear();
8512 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8513 DALI_TEST_CHECK(damagedRects.size() > 0);
8514 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8516 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8517 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8518 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8519 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8520 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8522 // 3. Add the Actor to the Scene again
8523 application.GetScene().Add(actor);
8524 application.SendNotification();
8526 damagedRects.clear();
8527 application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
8528 DALI_TEST_CHECK(damagedRects.size() > 0);
8529 DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
8531 application.RenderWithPartialUpdate(damagedRects, clippingRect);
8532 DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
8533 DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
8534 DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
8535 DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
8540 int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void)
8542 TestApplication application;
8544 Actor actor = Actor::New();
8545 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), false, TEST_LOCATION);
8546 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true);
8547 DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get<bool>(), true, TEST_LOCATION);
8548 DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION);
8549 DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION);
8550 DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8551 DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION);
8552 DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION);
8556 int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
8558 TestApplication application;
8560 Actor actor = Actor::New();
8562 // Make sure setting invalid types does not cause a crash
8565 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f);
8566 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE);
8567 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE);
8568 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE);
8569 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map());
8570 actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array());
8571 tet_result(TET_PASS);
8575 tet_result(TET_FAIL);
8580 int UtcDaliActorTouchAreaOffsetPropertyP(void)
8582 TestApplication application;
8584 Actor actor = Actor::New();
8585 Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
8586 DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
8587 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
8588 touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
8589 DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
8593 int UtcDaliActorTouchAreaOffsetPropertyN(void)
8595 TestApplication application;
8597 Actor actor = Actor::New();
8599 // Make sure setting invalid types does not cause a crash
8602 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
8603 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
8604 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
8605 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
8606 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
8607 actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
8608 tet_result(TET_PASS);
8612 tet_result(TET_FAIL);
8617 int UtcDaliActorLowerBelowNegative(void)
8619 TestApplication application;
8620 Dali::Actor instance;
8624 instance.LowerBelow(arg1);
8625 DALI_TEST_CHECK(false); // Should not get here
8629 DALI_TEST_CHECK(true); // We expect an assert
8634 int UtcDaliActorRaiseAboveNegative(void)
8636 TestApplication application;
8637 Dali::Actor instance;
8641 instance.RaiseAbove(arg1);
8642 DALI_TEST_CHECK(false); // Should not get here
8646 DALI_TEST_CHECK(true); // We expect an assert
8651 int UtcDaliActorRaiseToTopNegative(void)
8653 TestApplication application;
8654 Dali::Actor instance;
8657 instance.RaiseToTop();
8658 DALI_TEST_CHECK(false); // Should not get here
8662 DALI_TEST_CHECK(true); // We expect an assert
8667 int UtcDaliActorAddRendererNegative(void)
8669 TestApplication application;
8670 Dali::Actor instance;
8673 Dali::Renderer arg1;
8674 instance.AddRenderer(arg1);
8675 DALI_TEST_CHECK(false); // Should not get here
8679 DALI_TEST_CHECK(true); // We expect an assert
8684 int UtcDaliActorTouchedSignalNegative(void)
8686 TestApplication application;
8687 Dali::Actor instance;
8690 instance.TouchedSignal();
8691 DALI_TEST_CHECK(false); // Should not get here
8695 DALI_TEST_CHECK(true); // We expect an assert
8700 int UtcDaliActorTranslateByNegative(void)
8702 TestApplication application;
8703 Dali::Actor instance;
8707 instance.TranslateBy(arg1);
8708 DALI_TEST_CHECK(false); // Should not get here
8712 DALI_TEST_CHECK(true); // We expect an assert
8717 int UtcDaliActorFindChildByIdNegative(void)
8719 TestApplication application;
8720 Dali::Actor instance;
8723 unsigned int arg1 = 0u;
8724 instance.FindChildById(arg1);
8725 DALI_TEST_CHECK(false); // Should not get here
8729 DALI_TEST_CHECK(true); // We expect an assert
8734 int UtcDaliActorGetRendererAtNegative(void)
8736 TestApplication application;
8737 Dali::Actor instance;
8740 unsigned int arg1 = 0u;
8741 instance.GetRendererAt(arg1);
8742 DALI_TEST_CHECK(false); // Should not get here
8746 DALI_TEST_CHECK(true); // We expect an assert
8751 int UtcDaliActorHoveredSignalNegative(void)
8753 TestApplication application;
8754 Dali::Actor instance;
8757 instance.HoveredSignal();
8758 DALI_TEST_CHECK(false); // Should not get here
8762 DALI_TEST_CHECK(true); // We expect an assert
8767 int UtcDaliActorLowerToBottomNegative(void)
8769 TestApplication application;
8770 Dali::Actor instance;
8773 instance.LowerToBottom();
8774 DALI_TEST_CHECK(false); // Should not get here
8778 DALI_TEST_CHECK(true); // We expect an assert
8783 int UtcDaliActorOnSceneSignalNegative(void)
8785 TestApplication application;
8786 Dali::Actor instance;
8789 instance.OnSceneSignal();
8790 DALI_TEST_CHECK(false); // Should not get here
8794 DALI_TEST_CHECK(true); // We expect an assert
8799 int UtcDaliActorOffSceneSignalNegative(void)
8801 TestApplication application;
8802 Dali::Actor instance;
8805 instance.OffSceneSignal();
8806 DALI_TEST_CHECK(false); // Should not get here
8810 DALI_TEST_CHECK(true); // We expect an assert
8815 int UtcDaliActorRemoveRendererNegative01(void)
8817 TestApplication application;
8818 Dali::Actor instance;
8821 unsigned int arg1 = 0u;
8822 instance.RemoveRenderer(arg1);
8823 DALI_TEST_CHECK(false); // Should not get here
8827 DALI_TEST_CHECK(true); // We expect an assert
8832 int UtcDaliActorRemoveRendererNegative02(void)
8834 TestApplication application;
8835 Dali::Actor instance;
8838 Dali::Renderer arg1;
8839 instance.RemoveRenderer(arg1);
8840 DALI_TEST_CHECK(false); // Should not get here
8844 DALI_TEST_CHECK(true); // We expect an assert
8849 int UtcDaliActorFindChildByNameNegative(void)
8851 TestApplication application;
8852 Dali::Actor instance;
8856 instance.FindChildByName(arg1);
8857 DALI_TEST_CHECK(false); // Should not get here
8861 DALI_TEST_CHECK(true); // We expect an assert
8866 int UtcDaliActorSetResizePolicyNegative(void)
8868 TestApplication application;
8869 Dali::Actor instance;
8872 Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE;
8873 Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS;
8874 instance.SetResizePolicy(arg1, arg2);
8875 DALI_TEST_CHECK(false); // Should not get here
8879 DALI_TEST_CHECK(true); // We expect an assert
8884 int UtcDaliActorOnRelayoutSignalNegative(void)
8886 TestApplication application;
8887 Dali::Actor instance;
8890 instance.OnRelayoutSignal();
8891 DALI_TEST_CHECK(false); // Should not get here
8895 DALI_TEST_CHECK(true); // We expect an assert
8900 int UtcDaliActorWheelEventSignalNegative(void)
8902 TestApplication application;
8903 Dali::Actor instance;
8906 instance.WheelEventSignal();
8907 DALI_TEST_CHECK(false); // Should not get here
8911 DALI_TEST_CHECK(true); // We expect an assert
8916 int UtcDaliActorGetHeightForWidthNegative(void)
8918 TestApplication application;
8919 Dali::Actor instance;
8923 instance.GetHeightForWidth(arg1);
8924 DALI_TEST_CHECK(false); // Should not get here
8928 DALI_TEST_CHECK(true); // We expect an assert
8933 int UtcDaliActorGetWidthForHeightNegative(void)
8935 TestApplication application;
8936 Dali::Actor instance;
8940 instance.GetWidthForHeight(arg1);
8941 DALI_TEST_CHECK(false); // Should not get here
8945 DALI_TEST_CHECK(true); // We expect an assert
8950 int UtcDaliActorLayoutDirectionChangedSignalNegative(void)
8952 TestApplication application;
8953 Dali::Actor instance;
8956 instance.LayoutDirectionChangedSignal();
8957 DALI_TEST_CHECK(false); // Should not get here
8961 DALI_TEST_CHECK(true); // We expect an assert
8966 int UtcDaliActorAddNegative(void)
8968 TestApplication application;
8969 Dali::Actor instance;
8974 DALI_TEST_CHECK(false); // Should not get here
8978 DALI_TEST_CHECK(true); // We expect an assert
8983 int UtcDaliActorLowerNegative(void)
8985 TestApplication application;
8986 Dali::Actor instance;
8990 DALI_TEST_CHECK(false); // Should not get here
8994 DALI_TEST_CHECK(true); // We expect an assert
8999 int UtcDaliActorRaiseNegative(void)
9001 TestApplication application;
9002 Dali::Actor instance;
9006 DALI_TEST_CHECK(false); // Should not get here
9010 DALI_TEST_CHECK(true); // We expect an assert
9015 int UtcDaliActorRemoveNegative(void)
9017 TestApplication application;
9018 Dali::Actor instance;
9022 instance.Remove(arg1);
9023 DALI_TEST_CHECK(false); // Should not get here
9027 DALI_TEST_CHECK(true); // We expect an assert
9032 int UtcDaliActorScaleByNegative(void)
9034 TestApplication application;
9035 Dali::Actor instance;
9039 instance.ScaleBy(arg1);
9040 DALI_TEST_CHECK(false); // Should not get here
9044 DALI_TEST_CHECK(true); // We expect an assert
9049 int UtcDaliActorGetLayerNegative(void)
9051 TestApplication application;
9052 Dali::Actor instance;
9055 instance.GetLayer();
9056 DALI_TEST_CHECK(false); // Should not get here
9060 DALI_TEST_CHECK(true); // We expect an assert
9065 int UtcDaliActorRotateByNegative01(void)
9067 TestApplication application;
9068 Dali::Actor instance;
9071 Dali::Quaternion arg1;
9072 instance.RotateBy(arg1);
9073 DALI_TEST_CHECK(false); // Should not get here
9077 DALI_TEST_CHECK(true); // We expect an assert
9082 int UtcDaliActorRotateByNegative02(void)
9084 TestApplication application;
9085 Dali::Actor instance;
9090 instance.RotateBy(arg1, arg2);
9091 DALI_TEST_CHECK(false); // Should not get here
9095 DALI_TEST_CHECK(true); // We expect an assert
9100 int UtcDaliActorUnparentNegative(void)
9102 TestApplication application;
9103 Dali::Actor instance;
9106 instance.Unparent();
9107 DALI_TEST_CHECK(false); // Should not get here
9111 DALI_TEST_CHECK(true); // We expect an assert
9116 int UtcDaliActorGetChildAtNegative(void)
9118 TestApplication application;
9119 Dali::Actor instance;
9122 unsigned int arg1 = 0u;
9123 instance.GetChildAt(arg1);
9124 DALI_TEST_CHECK(false); // Should not get here
9128 DALI_TEST_CHECK(true); // We expect an assert
9133 int UtcDaliActorGetChildCountNegative(void)
9135 TestApplication application;
9136 Dali::Actor instance;
9139 instance.GetChildCount();
9140 DALI_TEST_CHECK(false); // Should not get here
9144 DALI_TEST_CHECK(true); // We expect an assert
9149 int UtcDaliActorGetTargetSizeNegative(void)
9151 TestApplication application;
9152 Dali::Actor instance;
9155 instance.GetTargetSize();
9156 DALI_TEST_CHECK(false); // Should not get here
9160 DALI_TEST_CHECK(true); // We expect an assert
9165 int UtcDaliActorScreenToLocalNegative(void)
9167 TestApplication application;
9168 Dali::Actor instance;
9175 instance.ScreenToLocal(arg1, arg2, arg3, arg4);
9176 DALI_TEST_CHECK(false); // Should not get here
9180 DALI_TEST_CHECK(true); // We expect an assert
9185 int UtcDaliActorGetNaturalSizeNegative(void)
9187 TestApplication application;
9188 Dali::Actor instance;
9191 instance.GetNaturalSize();
9192 DALI_TEST_CHECK(false); // Should not get here
9196 DALI_TEST_CHECK(true); // We expect an assert
9201 int UtcDaliActorGetRelayoutSizeNegative(void)
9203 TestApplication application;
9204 Dali::Actor instance;
9207 Dali::Dimension::Type arg1 = Dimension::HEIGHT;
9208 instance.GetRelayoutSize(arg1);
9209 DALI_TEST_CHECK(false); // Should not get here
9213 DALI_TEST_CHECK(true); // We expect an assert
9218 int UtcDaliActorGetResizePolicyNegative(void)
9220 TestApplication application;
9221 Dali::Actor instance;
9224 Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS;
9225 instance.GetResizePolicy(arg1);
9226 DALI_TEST_CHECK(false); // Should not get here
9230 DALI_TEST_CHECK(true); // We expect an assert
9235 int UtcDaliActorGetRendererCountNegative(void)
9237 TestApplication application;
9238 Dali::Actor instance;
9241 instance.GetRendererCount();
9242 DALI_TEST_CHECK(false); // Should not get here
9246 DALI_TEST_CHECK(true); // We expect an assert
9251 int UtcDaliActorGetParentNegative(void)
9253 TestApplication application;
9254 Dali::Actor instance;
9257 instance.GetParent();
9258 DALI_TEST_CHECK(false); // Should not get here
9262 DALI_TEST_CHECK(true); // We expect an assert
9267 int UtcDaliActorPropertyBlendEquation(void)
9269 TestApplication application;
9271 tet_infoline("Test SetProperty AdvancedBlendEquation");
9273 Geometry geometry = CreateQuadGeometry();
9274 Shader shader = CreateShader();
9275 Renderer renderer1 = Renderer::New(geometry, shader);
9277 Actor actor = Actor::New();
9278 actor.SetProperty(Actor::Property::OPACITY, 0.1f);
9280 actor.AddRenderer(renderer1);
9281 actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
9282 application.GetScene().Add(actor);
9284 if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
9286 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
9287 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
9288 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION);
9291 if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
9293 actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN);
9294 int equation = actor.GetProperty<int>(Dali::DevelActor::Property::BLEND_EQUATION);
9295 DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION);
9298 Renderer renderer2 = Renderer::New(geometry, shader);
9299 actor.AddRenderer(renderer2);
9304 int UtcDaliActorRegisterProperty(void)
9306 tet_infoline("Test property registration and uniform map update\n");
9308 TestApplication application;
9310 Geometry geometry = CreateQuadGeometry();
9311 Shader shader = CreateShader();
9312 Renderer renderer1 = Renderer::New(geometry, shader);
9313 Renderer renderer2 = Renderer::New(geometry, shader);
9315 Actor actor1 = Actor::New();
9316 actor1.AddRenderer(renderer1);
9317 actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9318 actor1.RegisterProperty("uCustom", 1);
9319 application.GetScene().Add(actor1);
9321 Actor actor2 = Actor::New();
9322 actor2.AddRenderer(renderer2);
9323 actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
9324 application.GetScene().Add(actor2);
9326 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
9327 TraceCallStack& callStack = glAbstraction.GetSetUniformTrace();
9328 glAbstraction.EnableSetUniformCallTrace(true);
9330 application.SendNotification();
9331 application.Render();
9333 std::stringstream out;
9337 // Test uniform value of the custom property
9338 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9339 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
9342 actor1[Actor::Property::VISIBLE] = false;
9344 application.SendNotification();
9345 application.Render();
9347 // Make visible again
9348 actor1[Actor::Property::VISIBLE] = true;
9349 actor1["uCustom"] = 2;
9351 glAbstraction.ResetSetUniformCallStack();
9353 application.SendNotification();
9354 application.Render();
9358 // The uniform value should not be changed
9359 DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params));
9360 DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);