X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Actor.cpp;h=69e13e8b98491b9483f1dfc659624daef06c4bbf;hb=refs%2Fchanges%2F80%2F286080%2F11;hp=9873aa79caeac7e26808d851155aa558d54abcbf;hpb=d49f57491bd017bc38ca134c3286eb38b7b812b2;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 9873aa7..69e13e8 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ #include #include // For FLT_MAX +#include // For std::multiset #include #include "assert.h" @@ -50,9 +51,9 @@ void utc_dali_actor_cleanup(void) namespace { -bool gTouchCallBackCalled = false; -bool gTouchCallBackCalled2 = false; -bool gTouchCallBackCalled3 = false; +bool gTouchCallBackCalled = false; +bool gTouchCallBackCalled2 = false; +bool gTouchCallBackCalled3 = false; bool gHitTestTouchCallBackCalled = false; bool gHoverCallBackCalled = false; @@ -297,6 +298,53 @@ struct CulledPropertyNotificationFunctor PropertyNotification& mPropertyNotification; }; +// Check dirtyRect is equal with expected multiset. +// Note that the order of damagedRect is not important +struct RectSorter +{ + bool operator()(const Rect& lhs, const Rect& rhs) const + { + if(lhs.x != rhs.x) + { + return lhs.x < rhs.x; + } + if(lhs.y != rhs.y) + { + return lhs.y < rhs.y; + } + if(lhs.width != rhs.width) + { + return lhs.width < rhs.width; + } + return lhs.height < rhs.height; + } +}; + +void DirtyRectChecker(const std::vector>& damagedRects, std::multiset, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation) +{ + // Just check damagedRect contain all expectRectList. + DALI_TEST_GREATER(damagedRects.size() + 1u, expectedRectList.size(), testLocation); + + for(auto& rect : damagedRects) + { + auto iter = expectedRectList.find(rect); + if(iter != expectedRectList.end()) + { + expectedRectList.erase(iter); + } + else if(checkRectsExact) + { + std::ostringstream o; + o << rect << " exist in expectRectList" << std::endl; + fprintf(stderr, "Test failed in %s, checking %s", testLocation, o.str().c_str()); + tet_result(TET_FAIL); + } + } + + // Check all rects are matched + DALI_TEST_EQUALS(expectedRectList.empty(), true, testLocation); +} + } // anonymous namespace //& purpose: Testing New API @@ -1155,6 +1203,33 @@ int UtcDaliActorSetSize04(void) END_TEST; } +int UtcDaliActorSetSize05(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector2 vector(200.0f, 200.0f); + DALI_TEST_CHECK(vector != parent.GetCurrentProperty(Actor::Property::SIZE)); + + parent.SetProperty(Actor::Property::SIZE, vector); + Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Actor child = Actor::New(); + DALI_TEST_CHECK(vector != child.GetCurrentProperty(Actor::Property::SIZE)); + child.SetProperty(Actor::Property::SIZE, vector); + size = parent.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == parent.GetCurrentProperty(Actor::Property::SIZE)); + + END_TEST; +} + int UtcDaliActorSetSizeIndividual(void) { TestApplication application; @@ -1354,10 +1429,12 @@ int UtcDaliActorCalculateScreenExtents(void) actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 2.0f, 16.0f)); actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 1.0f, 1.0f}); + application.GetScene().Add(actor); + application.SendNotification(); application.Render(); - auto expectedExtent = Rect<>{-0.5f, -0.5f, 1.0f, 1.0f}; + auto expectedExtent = Rect<>{1.5f, 1.5f, 1.0f, 1.0f}; auto actualExtent = DevelActor::CalculateScreenExtents(actor); DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION); DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION); @@ -1368,6 +1445,240 @@ int UtcDaliActorCalculateScreenExtents(void) END_TEST; } +int UtcDaliActorCalculateScreenExtentsInCustomCameraAndLayer3D(void) +{ + TestApplication application; + Integration::Scene scene = application.GetScene(); + + // Make 3D Layer + Layer layer = Layer::New(); + layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D); + layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + scene.Add(layer); + + // Build custom camera with top-view + CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor(); + { + // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ]) + Vector3 cameraPos = cameraActor.GetProperty(Actor::Property::POSITION); + Quaternion cameraOrient = cameraActor.GetProperty(Actor::Property::ORIENTATION); + + { + std::ostringstream oss; + oss << cameraPos << "\n"; + oss << cameraOrient << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + + cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f)); + cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient); + + // Now, upside : -Z, leftside : -X, foward : +Y + + cameraPos = cameraActor.GetProperty(Actor::Property::POSITION); + cameraOrient = cameraActor.GetProperty(Actor::Property::ORIENTATION); + { + std::ostringstream oss; + oss << cameraPos << "\n"; + oss << cameraOrient << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + } + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + actor.SetProperty(Actor::Property::POSITION, Vector3(2.0f, 0.0f, 16.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3{1.0f, 0.0f, 3.0f}); + + layer.Add(actor); + + application.SendNotification(); + application.Render(); + + Vector2 sceneSize = scene.GetSize(); + + auto expectedExtent = Rect<>{sceneSize.x * 0.5f + 1.5f, sceneSize.y * 0.5f + 14.5f, 1.0f, 3.0f}; + auto actualExtent = DevelActor::CalculateScreenExtents(actor); + { + std::ostringstream oss; + oss << expectedExtent << "\n"; + oss << actualExtent << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + + DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliActorCalculateScreenInCustomCameraAndOffscreenLayer3D(void) +{ + // TODO : Need to make it works well + TestApplication application; + Integration::Scene scene = application.GetScene(); + Vector2 sceneSize = scene.GetSize(); + + // Make 3D Layer + Layer layer = Layer::New(); + layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D); + layer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + layer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + layer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f)); + layer.SetProperty(Actor::Property::SIZE, sceneSize); + + scene.Add(layer); + + // Build custom camera with top-view + CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT)); + + offscreenCameraActor.SetPerspectiveProjection(sceneSize); + offscreenCameraActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + offscreenCameraActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + scene.Add(offscreenCameraActor); + { + // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ]) + Vector3 cameraPos = offscreenCameraActor.GetProperty(Actor::Property::POSITION); + Quaternion cameraOrient = offscreenCameraActor.GetProperty(Actor::Property::ORIENTATION); + + { + std::ostringstream oss; + oss << cameraPos << "\n"; + oss << cameraOrient << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + + offscreenCameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f)); + offscreenCameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient); + + // Now, upside : -Z, leftside : -X, foward : +Y + + cameraPos = offscreenCameraActor.GetProperty(Actor::Property::POSITION); + cameraOrient = offscreenCameraActor.GetProperty(Actor::Property::ORIENTATION); + { + std::ostringstream oss; + oss << cameraPos << "\n"; + oss << cameraOrient << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + } + Vector3 sourcePosition{2.0f, 0.0f, 16.0f}; + Vector3 sourceSize{1.0f, 0.0f, 3.0f}; + + Actor sourceActor = Actor::New(); + sourceActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + sourceActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + sourceActor.SetProperty(Actor::Property::POSITION, sourcePosition); + sourceActor.SetProperty(Actor::Property::SIZE, sourceSize); + + layer.Add(sourceActor); + + // Create framebuffer + unsigned int width(64); + unsigned int height(64); + Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height); + FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL); + frameBuffer.AttachColorTexture(texture); + + Actor rootActor = Actor::New(); + rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + rootActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + rootActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f)); + rootActor.SetProperty(Actor::Property::SIZE, sceneSize); + scene.Add(rootActor); + + RenderTaskList taskList = scene.GetRenderTaskList(); + RenderTask newTask = taskList.CreateTask(); + newTask.SetCameraActor(offscreenCameraActor); + newTask.SetSourceActor(layer); + newTask.SetInputEnabled(false); + newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f)); + newTask.SetClearEnabled(true); + newTask.SetExclusive(true); + newTask.SetFrameBuffer(frameBuffer); + newTask.SetScreenToFrameBufferMappingActor(rootActor); + + application.SendNotification(); + application.Render(16u); + + auto expectedExtent = Rect<>{sceneSize.x * 0.5f + sourcePosition.x - sourceSize.x * 0.5f, + sceneSize.y * 0.5f + sourcePosition.z - sourceSize.z * 0.5f, + sourceSize.x, + sourceSize.z}; + auto actualExtent = DevelActor::CalculateScreenExtents(sourceActor); + { + std::ostringstream oss; + oss << expectedExtent << "\n"; + oss << actualExtent << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + + auto expectedScreen = Vector2{sceneSize.x * 0.5f + sourcePosition.x, sceneSize.y * 0.5f + sourcePosition.z}; + auto actualScreen = sourceActor.GetProperty(Actor::Property::SCREEN_POSITION); + { + std::ostringstream oss; + oss << expectedScreen << "\n"; + oss << actualScreen << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + + DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + + DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + + // Change rootActor's size and position + + Vector3 rootPosition{100.0f, 200.0f, 0.0f}; + Vector3 rootSize{200.0f, 100.0f, 0.0f}; + + rootActor.SetProperty(Actor::Property::POSITION, rootPosition); + rootActor.SetProperty(Actor::Property::SIZE, rootSize); + + application.SendNotification(); + application.Render(16u); + + expectedExtent = Rect<>{sceneSize.x * 0.5f + rootPosition.x + (sourcePosition.x - sourceSize.x * 0.5f) * rootSize.x / sceneSize.x, + sceneSize.y * 0.5f + rootPosition.y + (sourcePosition.z - sourceSize.z * 0.5f) * rootSize.y / sceneSize.y, + sourceSize.x * rootSize.x / sceneSize.x, + sourceSize.z * rootSize.y / sceneSize.y}; + actualExtent = DevelActor::CalculateScreenExtents(sourceActor); + { + std::ostringstream oss; + oss << expectedExtent << "\n"; + oss << actualExtent << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + + expectedScreen = Vector2{sceneSize.x * 0.5f + rootPosition.x + sourcePosition.x * rootSize.x / sceneSize.x, sceneSize.y * 0.5f + rootPosition.y + sourcePosition.z * rootSize.y / sceneSize.y}; + actualScreen = sourceActor.GetProperty(Actor::Property::SCREEN_POSITION); + { + std::ostringstream oss; + oss << expectedScreen << "\n"; + oss << actualScreen << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + + DALI_TEST_EQUALS(expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + + DALI_TEST_EQUALS(expectedScreen.x, actualScreen.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(expectedScreen.y, actualScreen.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION); + + END_TEST; +} + // SetPosition(float x, float y) int UtcDaliActorSetPosition01(void) { @@ -7043,6 +7354,121 @@ int UtcDaliActorGetScreenPositionPositionUsesAnchorPointFalse(void) END_TEST; } +int UtcDaliActorGetScreenPositionResizeScene(void) +{ + tet_infoline("UtcDaliActorGetScreenPositionResizeScene Check screen position after resizing the scene size"); + + TestApplication application; + Integration::Scene scene = application.GetScene(); + + Actor actorA = Actor::New(); + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + actorA.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + + scene.Add(actorA); + + application.SendNotification(); + application.Render(); + + Vector2 sceneSize = scene.GetSize(); + Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION); + + // Resize the scene + Vector2 newSize(1000.0f, 2000.0f); + DALI_TEST_CHECK(scene.GetSize() != newSize); + + scene.SurfaceResized(newSize.width, newSize.height); + + actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + // The screen position should not be updated yet + DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + // The screen position should be updated + sceneSize = scene.GetSize(); + DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D(void) +{ + tet_infoline("UtcDaliActorGetScreenPositionInCustomCameraAndLayer3D Check screen position under LAYER_3D and custom camera"); + + TestApplication application; + Integration::Scene scene = application.GetScene(); + + // Make 3D Layer + Layer layer = scene.GetRootLayer(); + layer.SetProperty(Layer::Property::BEHAVIOR, Layer::Behavior::LAYER_3D); + + // Build custom camera with top-view + CameraActor cameraActor = scene.GetRenderTaskList().GetTask(0).GetCameraActor(); + { + // Default camera position at +z and looking -z axis. (orientation is [ Axis: [0, 1, 0], Angle: 180 degrees ]) + Vector3 cameraPos = cameraActor.GetProperty(Actor::Property::POSITION); + Quaternion cameraOrient = cameraActor.GetProperty(Actor::Property::ORIENTATION); + + { + std::ostringstream oss; + oss << cameraPos << "\n"; + oss << cameraOrient << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + + cameraActor.SetProperty(Actor::Property::POSITION, Vector3(0.0f, -cameraPos.z, 0.0f)); + cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS) * cameraOrient); + + // Now, upside : -Z, leftside : -X, foward : +Y + + cameraPos = cameraActor.GetProperty(Actor::Property::POSITION); + cameraOrient = cameraActor.GetProperty(Actor::Property::ORIENTATION); + { + std::ostringstream oss; + oss << cameraPos << "\n"; + oss << cameraOrient << "\n"; + tet_printf("%s\n", oss.str().c_str()); + } + } + + Actor actorA = Actor::New(); + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + actorA.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f)); + actorA.SetProperty(Actor::Property::POSITION, Vector3(20.0f, 0.0f, 10.0f)); + + Actor actorB = Actor::New(); + actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + actorB.SetProperty(Actor::Property::SIZE, Vector3(10.0f, 10.0f, 10.0f)); + actorB.SetProperty(Actor::Property::POSITION, Vector3(-20.0f, 0.0f, -10.0f)); + + scene.Add(actorA); + scene.Add(actorB); + + application.SendNotification(); + application.Render(); + + Vector2 sceneSize = scene.GetSize(); + Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 + Vector2(20.0f, 10.0f), TEST_LOCATION); + + actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + DALI_TEST_EQUALS(actorScreenPosition, sceneSize / 2 - Vector2(20.0f, 10.0f), TEST_LOCATION); + + END_TEST; +} + int utcDaliActorPositionUsesAnchorPoint(void) { TestApplication application; @@ -8325,8 +8751,8 @@ int utcDaliActorPartialUpdate(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8342,8 +8768,8 @@ int utcDaliActorPartialUpdate(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - clippingRect = Rect(16, 752, 48, 48); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + clippingRect = Rect(16, 752, 48, 48); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8359,8 +8785,8 @@ int utcDaliActorPartialUpdate(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - clippingRect = Rect(16, 736, 64, 64); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + clippingRect = Rect(16, 736, 64, 64); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8370,18 +8796,15 @@ int utcDaliActorPartialUpdate(void) application.GetScene().Remove(actor); application.SendNotification(); - // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together. + // Actor removed, last a dirty rect is reported. damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); clippingRect = damagedRects[0]; - clippingRect.Merge(damagedRects[1]); - clippingRect.Merge(damagedRects[2]); - DALI_TEST_EQUALS(clippingRect.IsEmpty(), false, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.IsValid(), true, TEST_LOCATION); - DALI_TEST_EQUALS>(clippingRect, Rect(16, 736, 64, 64), TEST_LOCATION); + DALI_TEST_EQUALS>(clippingRect, Rect(32, 736, 48, 48), TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -8432,8 +8855,8 @@ int utcDaliActorPartialUpdateSetColor(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8442,9 +8865,11 @@ int utcDaliActorPartialUpdateSetColor(void) damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); // 2. Set new color actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f)); @@ -8455,8 +8880,8 @@ int utcDaliActorPartialUpdateSetColor(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8530,8 +8955,8 @@ int utcDaliActorPartialUpdateSetProperty(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8546,7 +8971,7 @@ int utcDaliActorPartialUpdateSetProperty(void) application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8567,7 +8992,7 @@ int utcDaliActorPartialUpdateSetProperty(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); clippingRect = Rect(16, 752, 32, 48); // new clipping rect size increased due to change in actor size - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8612,8 +9037,7 @@ int utcDaliActorPartialUpdateTwoActors(void) application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION); - DALI_TEST_EQUALS>(Rect(64, 672, 64, 64), damagedRects[0], TEST_LOCATION); - DALI_TEST_EQUALS>(Rect(96, 592, 112, 112), damagedRects[1], TEST_LOCATION); + DirtyRectChecker(damagedRects, {Rect(64, 672, 64, 64), Rect(96, 592, 112, 112)}, true, TEST_LOCATION); // in screen coordinates, adaptor would calculate it using previous frames information Rect clippingRect = Rect(64, 592, 144, 192); @@ -8639,7 +9063,7 @@ int utcDaliActorPartialUpdateTwoActors(void) application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); DALI_TEST_CHECK(damagedRects.size() > 0); - DALI_TEST_EQUALS>(Rect(64, 672, 64, 64), damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {Rect(64, 672, 64, 64)}, false, TEST_LOCATION); // in screen coordinates, adaptor would calculate it using previous frames information application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -8652,7 +9076,7 @@ int utcDaliActorPartialUpdateTwoActors(void) END_TEST; } -int utcDaliActorPartialUpdateActorsWithSizeHint(void) +int utcDaliActorPartialUpdateActorsWithSizeHint01(void) { TestApplication application( TestApplication::DEFAULT_SURFACE_WIDTH, @@ -8669,7 +9093,7 @@ int utcDaliActorPartialUpdateActorsWithSizeHint(void) Actor actor = CreateRenderableActor(); actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f)); actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f)); - actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.0f, 0.0f)); + actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f)); actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); application.GetScene().Add(actor); @@ -8680,7 +9104,7 @@ int utcDaliActorPartialUpdateActorsWithSizeHint(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); Rect clippingRect = Rect(32, 704, 80, 80); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -8689,57 +9113,217 @@ int utcDaliActorPartialUpdateActorsWithSizeHint(void) DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); - END_TEST; -} + // Reset + actor.Unparent(); -int utcDaliActorPartialUpdateAnimation(void) -{ - TestApplication application( - TestApplication::DEFAULT_SURFACE_WIDTH, - TestApplication::DEFAULT_SURFACE_HEIGHT, - TestApplication::DEFAULT_HORIZONTAL_DPI, - TestApplication::DEFAULT_VERTICAL_DPI, - true, - true); + damagedRects.clear(); + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); - tet_infoline("Check the damaged area with partial update and animation"); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - drawTrace.Reset(); + application.RenderWithPartialUpdate(damagedRects, clippingRect); - Actor actor1 = CreateRenderableActor(); - actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); - actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f)); - application.GetScene().Add(actor1); + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); - Actor actor2 = CreateRenderableActor(); - actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); - actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); - application.GetScene().Add(actor2); + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); - std::vector> damagedRects; - Rect clippingRect; - Rect expectedRect1, expectedRect2; + // Chnage UPDATE_AREA_HINT + actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 32.0f, 32.0f)); + application.GetScene().Add(actor); application.SendNotification(); - application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); - DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - // Aligned by 16 - expectedRect1 = Rect(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates - expectedRect2 = Rect(0, 784, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); - DALI_TEST_EQUALS>(expectedRect2, damagedRects[1], TEST_LOCATION); + clippingRect = Rect(64, 704, 48, 48); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); - clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); - damagedRects.clear(); - clippingRect = TestApplication::DEFAULT_SURFACE_RECT; - application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + // Reset + actor.Unparent(); + + damagedRects.clear(); + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Chnage UPDATE_AREA_HINT + actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(-32.0f, -16.0f, 64.0f, 64.0f)); + application.GetScene().Add(actor); + + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + clippingRect = Rect(0, 720, 80, 80); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + END_TEST; +} + +int utcDaliActorPartialUpdateActorsWithSizeHint02(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Check the damaged rect with partial update and actor size hint"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor actor = CreateRenderableActor(); + actor.SetProperty(Actor::Property::POSITION, Vector3(64.0f, 64.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f)); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + application.SendNotification(); + std::vector> damagedRects; + application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + Rect clippingRect = Rect(48, 720, 48, 48); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Chnage UPDATE_AREA_HINT + actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(0.0f, 0.0f, 64.0f, 64.0f)); + + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + clippingRect = Rect(32, 704, 80, 80); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Chnage UPDATE_AREA_HINT + actor.SetProperty(Actor::Property::UPDATE_AREA_HINT, Vector4(16.0f, 16.0f, 64.0f, 64.0f)); + application.GetScene().Add(actor); + + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + clippingRect = Rect(32, 688, 96, 96); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + END_TEST; +} + +int utcDaliActorPartialUpdateAnimation(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Check the damaged area with partial update and animation"); + + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + drawTrace.Reset(); + + Actor actor1 = CreateRenderableActor(); + actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f)); + application.GetScene().Add(actor1); + + Actor actor2 = CreateRenderableActor(); + actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor2.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + application.GetScene().Add(actor2); + + std::vector> damagedRects; + Rect clippingRect; + Rect expectedRect1, expectedRect2; + + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION); + + // Aligned by 16 + expectedRect1 = Rect(0, 720, 96, 96); // in screen coordinates, includes 1 last frames updates + expectedRect2 = Rect(0, 784, 32, 32); // in screen coordinates, includes 1 last frames updates + DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2}, true, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); // Make an animation Animation animation = Animation::New(1.0f); @@ -8789,12 +9373,11 @@ int utcDaliActorPartialUpdateAnimation(void) // Started animation damagedRects.clear(); application.PreRenderWithPartialUpdate(500, nullptr, damagedRects); - DALI_TEST_EQUALS(damagedRects.size(), 5, TEST_LOCATION); + DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION); - // The first dirty rect is actor3's. - // We don't know the exact dirty rect of actor2 - DALI_TEST_EQUALS>(expectedRect2, damagedRects[0], TEST_LOCATION); - DALI_TEST_EQUALS>(expectedRect1, damagedRects[1], TEST_LOCATION); + // One of dirty rect is actor3's. + // We don't know the exact dirty rect of actor1 and actor2. + DirtyRectChecker(damagedRects, {expectedRect1, expectedRect2, expectedRect2}, true, TEST_LOCATION); clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -8803,8 +9386,7 @@ int utcDaliActorPartialUpdateAnimation(void) damagedRects.clear(); application.PreRenderWithPartialUpdate(500, nullptr, damagedRects); - DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - DALI_TEST_EQUALS>(expectedRect2, damagedRects[0], TEST_LOCATION); + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -8843,8 +9425,8 @@ int utcDaliActorPartialUpdateChangeVisibility(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8855,10 +9437,6 @@ int utcDaliActorPartialUpdateChangeVisibility(void) application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); - damagedRects.clear(); - application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - application.RenderWithPartialUpdate(damagedRects, clippingRect); - // Ensure the damaged rect is empty DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); @@ -8869,7 +9447,7 @@ int utcDaliActorPartialUpdateChangeVisibility(void) damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); DALI_TEST_CHECK(damagedRects.size() > 0); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -8884,7 +9462,7 @@ int utcDaliActorPartialUpdateChangeVisibility(void) damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); DALI_TEST_CHECK(damagedRects.size() > 0); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -8926,8 +9504,8 @@ int utcDaliActorPartialUpdateOnOffScene(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -8952,7 +9530,7 @@ int utcDaliActorPartialUpdateOnOffScene(void) damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); DALI_TEST_CHECK(damagedRects.size() > 0); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -8967,7 +9545,7 @@ int utcDaliActorPartialUpdateOnOffScene(void) damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); DALI_TEST_CHECK(damagedRects.size() > 0); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -9009,8 +9587,8 @@ int utcDaliActorPartialUpdateSkipRendering(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - expectedRect1 = Rect(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); + expectedRect1 = Rect(0, 720, 96, 96); // in screen coordinates + DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION); clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -9030,7 +9608,7 @@ int utcDaliActorPartialUpdateSkipRendering(void) damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION); clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -9057,7 +9635,7 @@ int utcDaliActorPartialUpdateSkipRendering(void) drawTrace.Reset(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {expectedRect1}, true, TEST_LOCATION); clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -9110,7 +9688,7 @@ int utcDaliActorPartialUpdate3DNode(void) application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - DALI_TEST_EQUALS>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION); clippingRect = TestApplication::DEFAULT_SURFACE_RECT; drawTrace.Reset(); @@ -9140,7 +9718,7 @@ int utcDaliActorPartialUpdate3DNode(void) application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - DALI_TEST_EQUALS>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {TestApplication::DEFAULT_SURFACE_RECT}, true, TEST_LOCATION); clippingRect = TestApplication::DEFAULT_SURFACE_RECT; drawTrace.Reset(); @@ -9187,8 +9765,8 @@ int utcDaliActorPartialUpdateNotRenderableActor(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -9240,8 +9818,8 @@ int utcDaliActorPartialUpdateChangeTransparency(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -9253,9 +9831,8 @@ int utcDaliActorPartialUpdateChangeTransparency(void) application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); - damagedRects.clear(); - application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - application.RenderWithPartialUpdate(damagedRects, clippingRect); + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); // Make the actor transparent by changing opacity of the Renderer // It changes a uniform value @@ -9267,9 +9844,9 @@ int utcDaliActorPartialUpdateChangeTransparency(void) // The damaged rect should be same damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); - DALI_TEST_CHECK(damagedRects.size() > 0); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); @@ -9286,18 +9863,55 @@ int utcDaliActorPartialUpdateChangeTransparency(void) // The damaged rect should not be empty damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Make the actor translucent + renderer[DevelRenderer::Property::OPACITY] = 0.5f; + + application.SendNotification(); + + // The damaged rect should not be empty + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Change Renderer opacity - also translucent + renderer[DevelRenderer::Property::OPACITY] = 0.2f; + application.SendNotification(); + + // The damaged rect should not be empty damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + // Make the actor culled actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f); @@ -9306,9 +9920,9 @@ int utcDaliActorPartialUpdateChangeTransparency(void) // The damaged rect should be same damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_CHECK(damagedRects.size() > 0); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); @@ -9325,9 +9939,9 @@ int utcDaliActorPartialUpdateChangeTransparency(void) // The damaged rect should not be empty damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); END_TEST; } @@ -9369,8 +9983,8 @@ int utcDaliActorPartialUpdateChangeParentOpacity(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -9399,12 +10013,12 @@ int utcDaliActorPartialUpdateChangeParentOpacity(void) application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_CHECK(damagedRects.size() > 0); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION); END_TEST; } -int utcDaliActorPartialAddRemoveRenderer(void) +int utcDaliActorPartialUpdateAddRemoveRenderer(void) { TestApplication application( TestApplication::DEFAULT_SURFACE_WIDTH, @@ -9434,8 +10048,8 @@ int utcDaliActorPartialAddRemoveRenderer(void) DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); // Aligned by 16 - Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -9462,7 +10076,7 @@ int utcDaliActorPartialAddRemoveRenderer(void) application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_CHECK(damagedRects.size() > 0); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, false, TEST_LOCATION); damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); @@ -9481,96 +10095,560 @@ int utcDaliActorPartialAddRemoveRenderer(void) application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); END_TEST; } -int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void) +int utcDaliActorPartialUpdate3DTransform(void) { - TestApplication application; + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); - Actor actor = Actor::New(); - DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get(), false, TEST_LOCATION); - actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true); - DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get(), true, TEST_LOCATION); - DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION); - DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION); - DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION); - DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION); - DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION); - END_TEST; -} + tet_infoline("Check the damaged rect with 3D transformed actors"); -int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void) -{ - TestApplication application; + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); - Actor actor = Actor::New(); + Actor actor1 = CreateRenderableActor(); + actor1[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + actor1[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f); + actor1[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor1); - // Make sure setting invalid types does not cause a crash - try - { - actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f); - actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE); - actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE); - actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE); - actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map()); - actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array()); - tet_result(TET_PASS); - } - catch(...) - { - tet_result(TET_FAIL); - } - END_TEST; -} + // Add a new actor + Actor actor2 = CreateRenderableActor(); + actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + actor2[Actor::Property::POSITION] = Vector3(160.0f, 160.0f, 0.0f); + actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor2); -int UtcDaliActorTouchAreaOffsetPropertyP(void) -{ - TestApplication application; + application.SendNotification(); - Actor actor = Actor::New(); - Rect touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get>(); - DALI_TEST_EQUALS(Rect(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION); - actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect(10, 20, 30, 40)); + std::vector> damagedRects; + + // Actor added, damaged rect is added size of actor + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION); + + // Aligned by 16 + Rect clippingRect1 = Rect(16, 768, 32, 32); // in screen coordinates + Rect clippingRect2 = Rect(160, 624, 32, 32); + DirtyRectChecker(damagedRects, {clippingRect1, clippingRect2}, true, TEST_LOCATION); + + Rect surfaceRect = Rect(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + application.RenderWithPartialUpdate(damagedRects, surfaceRect); + + damagedRects.clear(); + surfaceRect = Rect(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, surfaceRect); + + damagedRects.clear(); + surfaceRect = Rect(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, surfaceRect); + + // Rotate actor1 on y axis + actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS); + + // Remove actor2 + actor2.Unparent(); + + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + // Should update full area + surfaceRect = Rect(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, surfaceRect); + + // Add actor2 again + application.GetScene().Add(actor2); + + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + // Should update full area + surfaceRect = Rect(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, surfaceRect); + + // Reset the orientation of actor1 + actor1[Actor::Property::ORIENTATION] = Quaternion::IDENTITY; + + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + // Should update full area + surfaceRect = Rect(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, surfaceRect); + + // Make actor2 dirty + actor2[Actor::Property::SIZE] = Vector3(32.0f, 32.0f, 0.0f); + + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + clippingRect2 = Rect(160, 608, 48, 48); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect2}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect2); + DALI_TEST_EQUALS(clippingRect2.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect2.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect2.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect2.height, glScissorParams.height, TEST_LOCATION); + + // Remove actor1 + actor1.Unparent(); + + application.SendNotification(); + + damagedRects.clear(); + surfaceRect = Rect(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, surfaceRect); + + // Rotate actor1 on y axis + actor1[Actor::Property::ORIENTATION] = Quaternion(Radian(Degree(90.0)), Vector3::YAXIS); + + // Add actor1 again + application.GetScene().Add(actor1); + + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + // Should update full area + surfaceRect = Rect(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {surfaceRect}, true, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, surfaceRect); + + END_TEST; +} + +int utcDaliActorPartialUpdateOneActorMultipleRenderers(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Check the damaged rect with one actor which has multiple renderers"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor actor = CreateRenderableActor(); + + // Create another renderer + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer2 = Renderer::New(geometry, shader); + actor.AddRenderer(renderer2); + + actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f); + actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + application.SendNotification(); + + DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION); + + std::vector> damagedRects; + + // Actor added, damaged rect is added size of actor + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION); + + // Aligned by 16 + Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Make renderer2 dirty + renderer2[DevelRenderer::Property::OPACITY] = 0.5f; + + application.SendNotification(); + + // The damaged rect should be the actor area + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Make renderer2 dirty + renderer2[Renderer::Property::FACE_CULLING_MODE] = FaceCullingMode::BACK; + + application.SendNotification(); + + // The damaged rect should be the actor area + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + END_TEST; +} + +int utcDaliActorPartialUpdateMultipleActorsOneRenderer(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Check the damaged rect with multiple actors which share a same renderer"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor actor = CreateRenderableActor(); + actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f); + actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + // Create another actor which has the same renderer with actor1 + Actor actor2 = Actor::New(); + Renderer renderer = actor.GetRendererAt(0); + actor2.AddRenderer(renderer); + actor2[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + actor2[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f); + actor2[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor2); + + application.SendNotification(); + + std::vector> damagedRects; + + // Actor added, damaged rect is added size of actor + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION); + + // Aligned by 16 + Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); + DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Make renderer dirty + renderer[DevelRenderer::Property::OPACITY] = 0.5f; + + application.SendNotification(); + + // The damaged rect should be the actor area + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + clippingRect = Rect(16, 768, 32, 32); // in screen coordinates + DALI_TEST_EQUALS(damagedRects.size(), 2, TEST_LOCATION); + DirtyRectChecker(damagedRects, {clippingRect, clippingRect}, true, TEST_LOCATION); + + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get(), false, TEST_LOCATION); + actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, true); + DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START).Get(), true, TEST_LOCATION); + DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), Property::BOOLEAN, TEST_LOCATION); + DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), true, TEST_LOCATION); + DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION); + DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), false, TEST_LOCATION); + DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START), "captureAllTouchAfterStart", TEST_LOCATION); + END_TEST; +} + +int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Make sure setting invalid types does not cause a crash + try + { + actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, 1.0f); + actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector2::ONE); + actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector3::ONE); + actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Vector4::ONE); + actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Map()); + actor.SetProperty(DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START, Property::Array()); + tet_result(TET_PASS); + } + catch(...) + { + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliActorTouchAreaOffsetPropertyP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Rect touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get>(); + DALI_TEST_EQUALS(Rect(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect(10, 20, 30, 40)); touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get>(); DALI_TEST_EQUALS(Rect(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION); END_TEST; } -int UtcDaliActorTouchAreaOffsetPropertyN(void) +int UtcDaliActorTouchAreaOffsetPropertyN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Make sure setting invalid types does not cause a crash + try + { + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map()); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array()); + tet_result(TET_PASS); + } + catch(...) + { + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliActorLowerBelowNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + Dali::Actor arg1; + instance.LowerBelow(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorRaiseAboveNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + Dali::Actor arg1; + instance.RaiseAbove(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorRaiseToTopNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + instance.RaiseToTop(); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorAddRendererNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + Dali::Renderer arg1; + instance.AddRenderer(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorTouchedSignalNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + instance.TouchedSignal(); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorTranslateByNegative(void) { TestApplication application; + Dali::Actor instance; + try + { + Dali::Vector3 arg1; + instance.TranslateBy(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} - Actor actor = Actor::New(); +int UtcDaliActorFindChildByIdNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + unsigned int arg1 = 0u; + instance.FindChildById(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} - // Make sure setting invalid types does not cause a crash +int UtcDaliActorGetRendererAtNegative(void) +{ + TestApplication application; + Dali::Actor instance; try { - actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f); - actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE); - actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE); - actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE); - actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map()); - actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array()); - tet_result(TET_PASS); + unsigned int arg1 = 0u; + instance.GetRendererAt(arg1); + DALI_TEST_CHECK(false); // Should not get here } catch(...) { - tet_result(TET_FAIL); + DALI_TEST_CHECK(true); // We expect an assert } END_TEST; } -int UtcDaliActorLowerBelowNegative(void) +int UtcDaliActorHoveredSignalNegative(void) { TestApplication application; Dali::Actor instance; try { - Dali::Actor arg1; - instance.LowerBelow(arg1); + instance.HoveredSignal(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9580,14 +10658,13 @@ int UtcDaliActorLowerBelowNegative(void) END_TEST; } -int UtcDaliActorRaiseAboveNegative(void) +int UtcDaliActorLowerToBottomNegative(void) { TestApplication application; Dali::Actor instance; try { - Dali::Actor arg1; - instance.RaiseAbove(arg1); + instance.LowerToBottom(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9597,13 +10674,13 @@ int UtcDaliActorRaiseAboveNegative(void) END_TEST; } -int UtcDaliActorRaiseToTopNegative(void) +int UtcDaliActorOnSceneSignalNegative(void) { TestApplication application; Dali::Actor instance; try { - instance.RaiseToTop(); + instance.OnSceneSignal(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9613,14 +10690,47 @@ int UtcDaliActorRaiseToTopNegative(void) END_TEST; } -int UtcDaliActorAddRendererNegative(void) +int UtcDaliActorOffSceneSignalNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + instance.OffSceneSignal(); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorRemoveRendererNegative01(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + unsigned int arg1 = 0u; + instance.RemoveRenderer(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorRemoveRendererNegative02(void) { TestApplication application; Dali::Actor instance; try { Dali::Renderer arg1; - instance.AddRenderer(arg1); + instance.RemoveRenderer(arg1); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9630,13 +10740,14 @@ int UtcDaliActorAddRendererNegative(void) END_TEST; } -int UtcDaliActorTouchedSignalNegative(void) +int UtcDaliActorFindChildByNameNegative(void) { TestApplication application; Dali::Actor instance; try { - instance.TouchedSignal(); + std::string arg1; + instance.FindChildByName(arg1); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9646,14 +10757,15 @@ int UtcDaliActorTouchedSignalNegative(void) END_TEST; } -int UtcDaliActorTranslateByNegative(void) +int UtcDaliActorSetResizePolicyNegative(void) { TestApplication application; Dali::Actor instance; try { - Dali::Vector3 arg1; - instance.TranslateBy(arg1); + Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE; + Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS; + instance.SetResizePolicy(arg1, arg2); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9663,14 +10775,13 @@ int UtcDaliActorTranslateByNegative(void) END_TEST; } -int UtcDaliActorFindChildByIdNegative(void) +int UtcDaliActorOnRelayoutSignalNegative(void) { TestApplication application; Dali::Actor instance; try { - unsigned int arg1 = 0u; - instance.FindChildById(arg1); + instance.OnRelayoutSignal(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9680,14 +10791,13 @@ int UtcDaliActorFindChildByIdNegative(void) END_TEST; } -int UtcDaliActorGetRendererAtNegative(void) +int UtcDaliActorWheelEventSignalNegative(void) { TestApplication application; Dali::Actor instance; try { - unsigned int arg1 = 0u; - instance.GetRendererAt(arg1); + instance.WheelEventSignal(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9697,13 +10807,130 @@ int UtcDaliActorGetRendererAtNegative(void) END_TEST; } -int UtcDaliActorHoveredSignalNegative(void) +int UtcDaliActorGetHeightForWidthNegative(void) { TestApplication application; Dali::Actor instance; try { - instance.HoveredSignal(); + float arg1 = 0.0f; + instance.GetHeightForWidth(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorGetWidthForHeightNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + float arg1 = 0.0f; + instance.GetWidthForHeight(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorLayoutDirectionChangedSignalNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + instance.LayoutDirectionChangedSignal(); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorAddNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + Dali::Actor arg1; + instance.Add(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorLowerNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + instance.Lower(); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorRaiseNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + instance.Raise(); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorRemoveNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + Dali::Actor arg1; + instance.Remove(arg1); + DALI_TEST_CHECK(false); // Should not get here + } + catch(...) + { + DALI_TEST_CHECK(true); // We expect an assert + } + END_TEST; +} + +int UtcDaliActorScaleByNegative(void) +{ + TestApplication application; + Dali::Actor instance; + try + { + Dali::Vector3 arg1; + instance.ScaleBy(arg1); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9713,13 +10940,13 @@ int UtcDaliActorHoveredSignalNegative(void) END_TEST; } -int UtcDaliActorLowerToBottomNegative(void) +int UtcDaliActorGetLayerNegative(void) { TestApplication application; Dali::Actor instance; try { - instance.LowerToBottom(); + instance.GetLayer(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9729,13 +10956,14 @@ int UtcDaliActorLowerToBottomNegative(void) END_TEST; } -int UtcDaliActorOnSceneSignalNegative(void) +int UtcDaliActorRotateByNegative01(void) { TestApplication application; Dali::Actor instance; try { - instance.OnSceneSignal(); + Dali::Quaternion arg1; + instance.RotateBy(arg1); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9745,13 +10973,15 @@ int UtcDaliActorOnSceneSignalNegative(void) END_TEST; } -int UtcDaliActorOffSceneSignalNegative(void) +int UtcDaliActorRotateByNegative02(void) { TestApplication application; Dali::Actor instance; try { - instance.OffSceneSignal(); + Dali::Radian arg1; + Dali::Vector3 arg2; + instance.RotateBy(arg1, arg2); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9761,14 +10991,13 @@ int UtcDaliActorOffSceneSignalNegative(void) END_TEST; } -int UtcDaliActorRemoveRendererNegative01(void) +int UtcDaliActorUnparentNegative(void) { TestApplication application; Dali::Actor instance; try { - unsigned int arg1 = 0u; - instance.RemoveRenderer(arg1); + instance.Unparent(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9778,14 +11007,14 @@ int UtcDaliActorRemoveRendererNegative01(void) END_TEST; } -int UtcDaliActorRemoveRendererNegative02(void) +int UtcDaliActorGetChildAtNegative(void) { TestApplication application; Dali::Actor instance; try { - Dali::Renderer arg1; - instance.RemoveRenderer(arg1); + unsigned int arg1 = 0u; + instance.GetChildAt(arg1); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9795,14 +11024,13 @@ int UtcDaliActorRemoveRendererNegative02(void) END_TEST; } -int UtcDaliActorFindChildByNameNegative(void) +int UtcDaliActorGetChildCountNegative(void) { TestApplication application; Dali::Actor instance; try { - std::string arg1; - instance.FindChildByName(arg1); + instance.GetChildCount(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9812,15 +11040,13 @@ int UtcDaliActorFindChildByNameNegative(void) END_TEST; } -int UtcDaliActorSetResizePolicyNegative(void) +int UtcDaliActorGetTargetSizeNegative(void) { TestApplication application; Dali::Actor instance; try { - Dali::ResizePolicy::Type arg1 = ResizePolicy::USE_NATURAL_SIZE; - Dali::Dimension::Type arg2 = Dimension::ALL_DIMENSIONS; - instance.SetResizePolicy(arg1, arg2); + instance.GetTargetSize(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9830,13 +11056,17 @@ int UtcDaliActorSetResizePolicyNegative(void) END_TEST; } -int UtcDaliActorOnRelayoutSignalNegative(void) +int UtcDaliActorScreenToLocalNegative(void) { TestApplication application; Dali::Actor instance; try { - instance.OnRelayoutSignal(); + float arg1 = 0.0f; + float arg2 = 0.0f; + float arg3 = 0.0f; + float arg4 = 0.0f; + instance.ScreenToLocal(arg1, arg2, arg3, arg4); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9846,13 +11076,13 @@ int UtcDaliActorOnRelayoutSignalNegative(void) END_TEST; } -int UtcDaliActorWheelEventSignalNegative(void) +int UtcDaliActorGetNaturalSizeNegative(void) { TestApplication application; Dali::Actor instance; try { - instance.WheelEventSignal(); + instance.GetNaturalSize(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9862,14 +11092,14 @@ int UtcDaliActorWheelEventSignalNegative(void) END_TEST; } -int UtcDaliActorGetHeightForWidthNegative(void) +int UtcDaliActorGetRelayoutSizeNegative(void) { TestApplication application; Dali::Actor instance; try { - float arg1 = 0.0f; - instance.GetHeightForWidth(arg1); + Dali::Dimension::Type arg1 = Dimension::HEIGHT; + instance.GetRelayoutSize(arg1); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9879,14 +11109,14 @@ int UtcDaliActorGetHeightForWidthNegative(void) END_TEST; } -int UtcDaliActorGetWidthForHeightNegative(void) +int UtcDaliActorGetResizePolicyNegative(void) { TestApplication application; Dali::Actor instance; try { - float arg1 = 0.0f; - instance.GetWidthForHeight(arg1); + Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS; + instance.GetResizePolicy(arg1); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9896,13 +11126,13 @@ int UtcDaliActorGetWidthForHeightNegative(void) END_TEST; } -int UtcDaliActorLayoutDirectionChangedSignalNegative(void) +int UtcDaliActorGetRendererCountNegative(void) { TestApplication application; Dali::Actor instance; try { - instance.LayoutDirectionChangedSignal(); + instance.GetRendererCount(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9912,14 +11142,13 @@ int UtcDaliActorLayoutDirectionChangedSignalNegative(void) END_TEST; } -int UtcDaliActorAddNegative(void) +int UtcDaliActorGetParentNegative(void) { TestApplication application; Dali::Actor instance; try { - Dali::Actor arg1; - instance.Add(arg1); + instance.GetParent(); DALI_TEST_CHECK(false); // Should not get here } catch(...) @@ -9929,489 +11158,801 @@ int UtcDaliActorAddNegative(void) END_TEST; } -int UtcDaliActorLowerNegative(void) +int UtcDaliActorPropertyBlendEquation(void) { TestApplication application; - Dali::Actor instance; - try + + tet_infoline("Test SetProperty AdvancedBlendEquation"); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer1 = Renderer::New(geometry, shader); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::OPACITY, 0.1f); + + actor.AddRenderer(renderer1); + actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400)); + application.GetScene().Add(actor); + + if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN)) { - instance.Lower(); - DALI_TEST_CHECK(false); // Should not get here + actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN); + int equation = actor.GetProperty(Dali::DevelActor::Property::BLEND_EQUATION); + DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION); } - catch(...) + + if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN)) { - DALI_TEST_CHECK(true); // We expect an assert + actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN); + int equation = actor.GetProperty(Dali::DevelActor::Property::BLEND_EQUATION); + DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION); } + + Renderer renderer2 = Renderer::New(geometry, shader); + actor.AddRenderer(renderer2); + + END_TEST; +} + +int UtcDaliActorRegisterProperty(void) +{ + tet_infoline("Test property registration and uniform map update\n"); + + TestApplication application; + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer1 = Renderer::New(geometry, shader); + Renderer renderer2 = Renderer::New(geometry, shader); + + Actor actor1 = Actor::New(); + actor1.AddRenderer(renderer1); + actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100)); + actor1.RegisterProperty("uCustom", 1); + application.GetScene().Add(actor1); + + Actor actor2 = Actor::New(); + actor2.AddRenderer(renderer2); + actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100)); + application.GetScene().Add(actor2); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& callStack = glAbstraction.GetSetUniformTrace(); + glAbstraction.EnableSetUniformCallTrace(true); + + application.SendNotification(); + application.Render(); + + std::stringstream out; + out.str("1"); + std::string params; + + // Test uniform value of the custom property + DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params)); + DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION); + + // Make invisible + actor1[Actor::Property::VISIBLE] = false; + + application.SendNotification(); + application.Render(); + + // Make visible again + actor1[Actor::Property::VISIBLE] = true; + actor1["uCustom"] = 2; + + glAbstraction.ResetSetUniformCallStack(); + + application.SendNotification(); + application.Render(); + + out.str("2"); + + // The uniform value should not be changed + DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params)); + DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION); + END_TEST; } -int UtcDaliActorRaiseNegative(void) -{ - TestApplication application; - Dali::Actor instance; - try - { - instance.Raise(); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } - END_TEST; -} +int UtcDaliActorDoesWantedHitTest(void) +{ + struct HitTestData + { + public: + HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result) + : mScale(scale), + mTouchPoint(touchPoint), + mResult(result) + { + } + + Vector3 mScale; + Vector2 mTouchPoint; + bool mResult; + }; + + TestApplication application; + tet_infoline(" UtcDaliActorDoesWantedHitTest"); + + // Fill a vector with different hit tests. + struct HitTestData* hitTestData[] = { + // scale touch point result + new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside) + new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside) + 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. + new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside) + 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. + NULL, + }; + + // get the root layer + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + Actor lowerActor = Actor::New(); + lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + // actor and lowerActor have no relationship. + application.GetScene().Add(lowerActor); + application.GetScene().Add(actor); + + ResetTouchCallbacks(); + gHitTestTouchCallBackCalled = false; + + unsigned int index = 0; + while(NULL != hitTestData[index]) + { + actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f)); + actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z)); + + lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f)); + lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z)); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(!gTouchCallBackCalled); + DALI_TEST_CHECK(!gTouchCallBackCalled2); + DALI_TEST_CHECK(!gHitTestTouchCallBackCalled); + + // connect to its touch signal + actor.TouchedSignal().Connect(TestTouchCallback); + lowerActor.TouchedSignal().Connect(TestTouchCallback2); + + // connect to its hit-test signal + Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback); + + Dali::Integration::Point point; + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y)); + Dali::Integration::TouchEvent event; + event.AddPoint(point); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + application.ProcessEvent(event); + + // check hit-test events + DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult); + // Passed all hit-tests of actor. + DALI_TEST_CHECK(gTouchCallBackCalled == false); + // The lowerActor was hit-tested. + DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult); + + if(gTouchCallBackCalled2 != hitTestData[index]->mResult) + tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n", + hitTestData[index]->mScale.x, + hitTestData[index]->mScale.y, + hitTestData[index]->mScale.z, + hitTestData[index]->mTouchPoint.x, + hitTestData[index]->mTouchPoint.y, + hitTestData[index]->mResult); -int UtcDaliActorRemoveNegative(void) -{ - TestApplication application; - Dali::Actor instance; - try - { - Dali::Actor arg1; - instance.Remove(arg1); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert + ResetTouchCallbacks(); + gHitTestTouchCallBackCalled = false; + ++index; } END_TEST; } -int UtcDaliActorScaleByNegative(void) +int UtcDaliActorAllowOnlyOwnTouchPropertyP(void) { TestApplication application; - Dali::Actor instance; - try - { - Dali::Vector3 arg1; - instance.ScaleBy(arg1); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } - END_TEST; -} -int UtcDaliActorGetLayerNegative(void) -{ - TestApplication application; - Dali::Actor instance; - try - { - instance.GetLayer(); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } + Actor actor = Actor::New(); + DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get(), false, TEST_LOCATION); + actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, true); + DALI_TEST_EQUALS(actor.GetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH).Get(), true, TEST_LOCATION); + DALI_TEST_EQUALS(actor.GetPropertyType(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), Property::BOOLEAN, TEST_LOCATION); + DALI_TEST_EQUALS(actor.IsPropertyWritable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), true, TEST_LOCATION); + DALI_TEST_EQUALS(actor.IsPropertyAnimatable(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION); + DALI_TEST_EQUALS(actor.IsPropertyAConstraintInput(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), false, TEST_LOCATION); + DALI_TEST_EQUALS(actor.GetPropertyName(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH), "allowOnlyOwnTouch", TEST_LOCATION); END_TEST; } -int UtcDaliActorRotateByNegative01(void) +int UtcDaliActorAllowOnlyOwnTouchPropertyN(void) { TestApplication application; - Dali::Actor instance; - try - { - Dali::Quaternion arg1; - instance.RotateBy(arg1); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } - END_TEST; -} -int UtcDaliActorRotateByNegative02(void) -{ - TestApplication application; - Dali::Actor instance; - try - { - Dali::Radian arg1; - Dali::Vector3 arg2; - instance.RotateBy(arg1, arg2); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } - END_TEST; -} + Actor actor = Actor::New(); -int UtcDaliActorUnparentNegative(void) -{ - TestApplication application; - Dali::Actor instance; + // Make sure setting invalid types does not cause a crash try { - instance.Unparent(); - DALI_TEST_CHECK(false); // Should not get here + actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, 1.0f); + actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector2::ONE); + actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector3::ONE); + actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Vector4::ONE); + actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Map()); + actor.SetProperty(DevelActor::Property::ALLOW_ONLY_OWN_TOUCH, Property::Array()); + tet_result(TET_PASS); } catch(...) { - DALI_TEST_CHECK(true); // We expect an assert + tet_result(TET_FAIL); } END_TEST; } -int UtcDaliActorGetChildAtNegative(void) +int UtcDaliActorCalculateWorldTransform01(void) { TestApplication application; - Dali::Actor instance; - try - { - unsigned int arg1 = 0u; - instance.GetChildAt(arg1); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } - END_TEST; -} -int UtcDaliActorGetChildCountNegative(void) -{ - TestApplication application; - Dali::Actor instance; - try - { - instance.GetChildCount(); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } + tet_infoline("Test that actor position inheritance produces right transform matrix"); + + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); + + rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f); + branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f); + leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f); + + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + + // Set anchor point to the same value as parent origin + rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT; + branchActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT; + leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT; + + rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); + + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + + Matrix m = DevelActor::GetWorldTransform(leafActor); + + Matrix actualMatrix = leafActor.GetCurrentProperty(Actor::Property::WORLD_MATRIX); + DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION); + + Vector3 worldPos; + Vector3 worldScale; + Quaternion worldRotation; + m.GetTransformComponents(worldPos, worldRotation, worldScale); + DALI_TEST_EQUALS(worldPos, Vector3(200.0f, 150.0f, 30.0f), 0.0001f, TEST_LOCATION); + END_TEST; } -int UtcDaliActorGetTargetSizeNegative(void) +int UtcDaliActorCalculateWorldTransform02(void) { TestApplication application; - Dali::Actor instance; - try - { - instance.GetTargetSize(); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } + + tet_infoline("Test that actor position produces right transform matrix"); + + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); + + rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f); + branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f); + leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f); + + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + + // Set anchor point to the same value as parent origin + rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); + + leafActor[Actor::Property::INHERIT_POSITION] = false; + leafActor[Actor::Property::INHERIT_ORIENTATION] = false; + leafActor[Actor::Property::INHERIT_SCALE] = false; + + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + + Matrix m = DevelActor::GetWorldTransform(leafActor); + + Matrix actualMatrix = leafActor.GetCurrentProperty(Actor::Property::WORLD_MATRIX); + DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION); + END_TEST; } -int UtcDaliActorScreenToLocalNegative(void) +int UtcDaliActorCalculateWorldTransform03(void) { TestApplication application; - Dali::Actor instance; - try - { - float arg1 = 0.0f; - float arg2 = 0.0f; - float arg3 = 0.0f; - float arg4 = 0.0f; - instance.ScreenToLocal(arg1, arg2, arg3, arg4); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } + + tet_infoline("Test that actor position produces right transform matrix"); + + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); + + rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f); + branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f); + leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f); + + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + + // Set anchor point to the same value as parent origin + rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); + + leafActor[Actor::Property::INHERIT_POSITION] = true; + leafActor[Actor::Property::INHERIT_ORIENTATION] = false; + leafActor[Actor::Property::INHERIT_SCALE] = false; + + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + + Matrix m = DevelActor::GetWorldTransform(leafActor); + + Matrix actualMatrix = leafActor.GetCurrentProperty(Actor::Property::WORLD_MATRIX); + DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION); + END_TEST; } -int UtcDaliActorGetNaturalSizeNegative(void) +int UtcDaliActorCalculateWorldTransform04(void) { TestApplication application; - Dali::Actor instance; - try - { - instance.GetNaturalSize(); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } + + tet_infoline("Test that actor inheritance scale/orientation produces right transform matrix"); + + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); + + rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f); + rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f); + rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); + + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + + // Set anchor point to the same value as parent origin + rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER; + rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + + branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f); + leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f); + + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); + + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + + Matrix m = DevelActor::GetWorldTransform(leafActor); + + Matrix actualMatrix = leafActor.GetCurrentProperty(Actor::Property::WORLD_MATRIX); + DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION); + END_TEST; } -int UtcDaliActorGetRelayoutSizeNegative(void) +int UtcDaliActorCalculateWorldTransform05(void) { TestApplication application; - Dali::Actor instance; - try - { - Dali::Dimension::Type arg1 = Dimension::HEIGHT; - instance.GetRelayoutSize(arg1); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } + + tet_infoline("Test that actor inheritance of scale produces right transform matrix"); + + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); + + rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f); + rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f); + rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); + + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + + // Set anchor point to the same value as parent origin + rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER; + rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + + branchActor[Actor::Property::POSITION] = Vector3(100.0f, 100.0f, 0.0f); + leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f); + + leafActor[Actor::Property::INHERIT_POSITION] = false; + leafActor[Actor::Property::INHERIT_ORIENTATION] = false; + + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); + + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + + Matrix m = DevelActor::GetWorldTransform(leafActor); + + Matrix actualMatrix = leafActor.GetCurrentProperty(Actor::Property::WORLD_MATRIX); + DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION); + END_TEST; } -int UtcDaliActorGetResizePolicyNegative(void) +int UtcDaliActorCalculateWorldTransform06(void) { TestApplication application; - Dali::Actor instance; - try - { - Dali::Dimension::Type arg1 = Dimension::ALL_DIMENSIONS; - instance.GetResizePolicy(arg1); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } + + tet_infoline("Test that actor inheritance of scale produces right transform matrix"); + + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); + + rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f); + rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f); + rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); + + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + + // Set anchor point to the same value as parent origin + rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER; + rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + + branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f); + branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS); + leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f); + + leafActor[Actor::Property::INHERIT_POSITION] = false; + leafActor[Actor::Property::INHERIT_SCALE] = false; + + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); + + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + + Matrix m = DevelActor::GetWorldTransform(leafActor); + + Matrix actualMatrix = leafActor.GetCurrentProperty(Actor::Property::WORLD_MATRIX); + DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION); + END_TEST; } -int UtcDaliActorGetRendererCountNegative(void) +int UtcDaliActorCalculateWorldTransform07(void) { TestApplication application; - Dali::Actor instance; - try - { - instance.GetRendererCount(); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) - { - DALI_TEST_CHECK(true); // We expect an assert - } + + tet_infoline("Test that actor inheritance of scale produces right transform matrix"); + + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); + + rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f); + rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f); + rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); + + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + + // Set anchor point to the same value as parent origin + rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER; + rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + branchActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + + // This should be ignored. + leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER; + + branchActor[Actor::Property::POSITION] = Vector3(100.0f, 30.0f, -50.0f); + branchActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(45.0f), Vector3::XAXIS); + leafActor[Actor::Property::POSITION] = Vector3(100.0f, 50.0f, 30.0f); + + leafActor[Actor::Property::INHERIT_POSITION] = false; + leafActor[Actor::Property::INHERIT_SCALE] = false; + leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = false; + + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); + + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + + Matrix m = DevelActor::GetWorldTransform(leafActor); + + Matrix actualMatrix = leafActor.GetCurrentProperty(Actor::Property::WORLD_MATRIX); + DALI_TEST_EQUALS(m, actualMatrix, 0.001f, TEST_LOCATION); + END_TEST; } -int UtcDaliActorGetParentNegative(void) +int UtcDaliActorCalculateWorldTransform08(void) { TestApplication application; - Dali::Actor instance; - try + + tet_infoline("Test that actor inheritance of scale produces right transform matrix"); + + Vector3 solutions[] = {Vector3(250, 0, 0), Vector3(0, 250, 0), Vector3(650, 0, 0), Vector3(0, 250, 0), Vector3(650, 0, 0), Vector3(400, 250, 0), Vector3(200, -50, 0), Vector3(500, 200, 0)}; + + struct TestCase { - instance.GetParent(); - DALI_TEST_CHECK(false); // Should not get here - } - catch(...) + bool translation; + bool rotation; + bool scaling; + }; + TestCase testCases[] = { + {false, false, true}, + {false, true, false}, + {true, false, false}, + {false, true, true}, + {true, false, true}, + {true, true, false}, + {false, false, false}, + {true, true, true}, + }; + + Actor rootActor = Actor::New(); + Actor leafActor = Actor::New(); + + rootActor[Actor::Property::POSITION] = Vector3(0.0f, 0.0f, 0.0f); + rootActor[Actor::Property::SCALE] = Vector3(1.0f, 2.0f, 1.0f); + rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); + rootActor[Actor::Property::SIZE] = Vector2(200, 400); + rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER; + rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + + leafActor[Actor::Property::POSITION] = Vector3(0.0f, -50.0f, 0.0f); + leafActor[Actor::Property::SCALE] = Vector3(1.0f, 1.0f, 1.0f); + leafActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); + leafActor[Actor::Property::SIZE] = Vector2(200, 400); + leafActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_CENTER; + leafActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_CENTER; + leafActor[Actor::Property::POSITION_USES_ANCHOR_POINT] = true; + + application.GetScene().Add(rootActor); + rootActor.Add(leafActor); + + for(uint32_t i = 0; i < 8; ++i) { - DALI_TEST_CHECK(true); // We expect an assert + leafActor[Actor::Property::INHERIT_POSITION] = testCases[i].translation; + leafActor[Actor::Property::INHERIT_ORIENTATION] = testCases[i].rotation; + leafActor[Actor::Property::INHERIT_SCALE] = testCases[i].scaling; + + application.SendNotification(); + application.Render(0); + application.SendNotification(); + application.Render(0); + + Matrix m = DevelActor::GetWorldTransform(leafActor); + Matrix actualMatrix = leafActor.GetCurrentProperty(Actor::Property::WORLD_MATRIX); + + Vector3 worldPosition1 = Vector3(m.GetTranslation()); + Vector3 worldPosition2 = Vector3(actualMatrix.GetTranslation()); + + DALI_TEST_EQUALS(solutions[i], worldPosition1, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(solutions[i], worldPosition2, 0.001f, TEST_LOCATION); } + END_TEST; } -int UtcDaliActorPropertyBlendEquation(void) +int UtcDaliActorCalculateWorldColor01(void) { TestApplication application; - tet_infoline("Test SetProperty AdvancedBlendEquation"); + tet_infoline("Test that actor inheritance of color produces right final color"); - Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer1 = Renderer::New(geometry, shader); + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); - Actor actor = Actor::New(); - actor.SetProperty(Actor::Property::OPACITY, 0.1f); + rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f); + rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f); + rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); - actor.AddRenderer(renderer1); - actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400)); - application.GetScene().Add(actor); + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); - if(!Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN)) - { - actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN); - int equation = actor.GetProperty(Dali::DevelActor::Property::BLEND_EQUATION); - DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), false, TEST_LOCATION); - } + rootActor[Actor::Property::COLOR] = Color::WHITE; + branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f); + leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f); - if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN)) - { - actor.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN); - int equation = actor.GetProperty(Dali::DevelActor::Property::BLEND_EQUATION); - DALI_TEST_EQUALS((Dali::DevelBlendEquation::SCREEN == equation), true, TEST_LOCATION); - } + // Default is to inherit: + leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA; - Renderer renderer2 = Renderer::New(geometry, shader); - actor.AddRenderer(renderer2); + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); + + application.SendNotification(); + application.Render(0); + + Vector4 color = DevelActor::GetWorldColor(leafActor); + + Vector4 actualColor = leafActor.GetCurrentProperty(Actor::Property::WORLD_COLOR); + DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION); END_TEST; } -int UtcDaliActorRegisterProperty(void) +int UtcDaliActorCalculateWorldColor02(void) { - tet_infoline("Test property registration and uniform map update\n"); - TestApplication application; - Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer1 = Renderer::New(geometry, shader); - Renderer renderer2 = Renderer::New(geometry, shader); - - Actor actor1 = Actor::New(); - actor1.AddRenderer(renderer1); - actor1.SetProperty(Actor::Property::SIZE, Vector2(100, 100)); - actor1.RegisterProperty("uCustom", 1); - application.GetScene().Add(actor1); + tet_infoline("Test that actor uses own color"); - Actor actor2 = Actor::New(); - actor2.AddRenderer(renderer2); - actor2.SetProperty(Actor::Property::SIZE, Vector2(100, 100)); - application.GetScene().Add(actor2); + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - TraceCallStack& callStack = glAbstraction.GetSetUniformTrace(); - glAbstraction.EnableSetUniformCallTrace(true); + rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f); + rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f); + rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); - application.SendNotification(); - application.Render(); + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); - std::stringstream out; - out.str("1"); - std::string params; + rootActor[Actor::Property::COLOR] = Color::WHITE; + branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f); + leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f); - // Test uniform value of the custom property - DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params)); - DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION); + leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_COLOR; - // Make invisible - actor1[Actor::Property::VISIBLE] = false; + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); application.SendNotification(); - application.Render(); + application.Render(0); - // Make visible again - actor1[Actor::Property::VISIBLE] = true; - actor1["uCustom"] = 2; + Vector4 color = DevelActor::GetWorldColor(leafActor); - glAbstraction.ResetSetUniformCallStack(); + Vector4 actualColor = leafActor.GetCurrentProperty(Actor::Property::WORLD_COLOR); + DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(color, Vector4(0.1f, 0.5f, 0.5f, 0.8f), 0.001f, TEST_LOCATION); + END_TEST; +} - application.SendNotification(); - application.Render(); +int UtcDaliActorCalculateWorldColor03(void) +{ + TestApplication application; - out.str("2"); + tet_infoline("Test that actor uses parent color"); - // The uniform value should not be changed - DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("uCustom", params)); - DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION); + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); - END_TEST; -} + rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f); + rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f); + rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); -int UtcDaliActorDoesWantedHitTest(void) -{ - struct HitTestData - { - public: - HitTestData(const Vector3& scale, const Vector2& touchPoint, bool result) - : mScale(scale), - mTouchPoint(touchPoint), - mResult(result) - { - } + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); - Vector3 mScale; - Vector2 mTouchPoint; - bool mResult; - }; + rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f; + branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f); + leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f); - TestApplication application; - tet_infoline(" UtcDaliActorDoesWantedHitTest"); + leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_PARENT_COLOR; - // Fill a vector with different hit tests. - struct HitTestData* hitTestData[] = { - // scale touch point result - new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(289.f, 400.f), true), // touch point close to the right edge (inside) - new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(291.f, 400.f), false), // touch point close to the right edge (outside) - 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. - new HitTestData(Vector3(100.f, 100.f, 1.f), Vector2(200.f, 451.f), false), // touch point close to the down edge (outside) - 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. - NULL, - }; + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); - // get the root layer - Actor actor = Actor::New(); - actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); - actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + application.SendNotification(); + application.Render(0); - Actor lowerActor = Actor::New(); - lowerActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); - lowerActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + Vector4 color = DevelActor::GetWorldColor(leafActor); - // actor and lowerActor have no relationship. - application.GetScene().Add(lowerActor); - application.GetScene().Add(actor); + Vector4 actualColor = leafActor.GetCurrentProperty(Actor::Property::WORLD_COLOR); + DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(color, Vector4(1.0f, 1.0f, 0.5f, 0.72f), 0.001f, TEST_LOCATION); + END_TEST; +} - ResetTouchCallbacks(); - gHitTestTouchCallBackCalled = false; +int UtcDaliActorCalculateWorldColor04(void) +{ + TestApplication application; - unsigned int index = 0; - while(NULL != hitTestData[index]) - { - actor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f)); - actor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z)); + tet_infoline("Test that actor blends with parent color"); - lowerActor.SetProperty(Actor::Property::SIZE, Vector2(1.f, 1.f)); - lowerActor.SetProperty(Actor::Property::SCALE, Vector3(hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z)); + Actor rootActor = Actor::New(); + Actor branchActor = Actor::New(); + Actor leafActor = Actor::New(); - // flush the queue and render once - application.SendNotification(); - application.Render(); + rootActor[Actor::Property::POSITION] = Vector3(100.0f, 0.0f, 0.0f); + rootActor[Actor::Property::SCALE] = Vector3(2.0f, 2.0f, 2.0f); + rootActor[Actor::Property::ORIENTATION] = AngleAxis(Degree(90.0f), Vector3::ZAXIS); - DALI_TEST_CHECK(!gTouchCallBackCalled); - DALI_TEST_CHECK(!gTouchCallBackCalled2); - DALI_TEST_CHECK(!gHitTestTouchCallBackCalled); + rootActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + branchActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + leafActor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); - // connect to its touch signal - actor.TouchedSignal().Connect(TestTouchCallback); - lowerActor.TouchedSignal().Connect(TestTouchCallback2); + rootActor[Actor::Property::COLOR] = Color::WHITE * 0.9f; + branchActor[Actor::Property::COLOR] = Vector4(1.0f, 1.0f, 0.5f, 0.8f); + leafActor[Actor::Property::COLOR] = Vector4(0.1f, 0.5f, 0.5f, 0.8f); - // connect to its hit-test signal - Dali::DevelActor::HitTestResultSignal(actor).Connect(TestHitTestTouchCallback); + leafActor[Actor::Property::COLOR_MODE] = ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR; - Dali::Integration::Point point; - point.SetState(PointState::DOWN); - point.SetScreenPosition(Vector2(hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y)); - Dali::Integration::TouchEvent event; - event.AddPoint(point); + application.GetScene().Add(rootActor); + rootActor.Add(branchActor); + branchActor.Add(leafActor); - // flush the queue and render once - application.SendNotification(); - application.Render(); - application.ProcessEvent(event); + application.SendNotification(); + application.Render(0); - // check hit-test events - DALI_TEST_CHECK(gHitTestTouchCallBackCalled == hitTestData[index]->mResult); - // Passed all hit-tests of actor. - DALI_TEST_CHECK(gTouchCallBackCalled == false); - // The lowerActor was hit-tested. - DALI_TEST_CHECK(gTouchCallBackCalled2 == hitTestData[index]->mResult); + Vector4 color = DevelActor::GetWorldColor(leafActor); - if(gTouchCallBackCalled2 != hitTestData[index]->mResult) - tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n", - hitTestData[index]->mScale.x, - hitTestData[index]->mScale.y, - hitTestData[index]->mScale.z, - hitTestData[index]->mTouchPoint.x, - hitTestData[index]->mTouchPoint.y, - hitTestData[index]->mResult); + Vector4 actualColor = leafActor.GetCurrentProperty(Actor::Property::WORLD_COLOR); + DALI_TEST_EQUALS(color, actualColor, 0.001f, TEST_LOCATION); - ResetTouchCallbacks(); - gHitTestTouchCallBackCalled = false; - ++index; - } END_TEST; }