X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Actor.cpp;h=9873aa79caeac7e26808d851155aa558d54abcbf;hb=d31b66464764ba00f944b5984947e4fdfadafc3c;hp=1093bf7da83956c2482c79460febdcf40a125e33;hpb=5f30f2007509e8b9306599542c30a82d60564f96;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 old mode 100755 new mode 100644 index 1093bf7..9873aa7 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -20,11 +20,13 @@ #include #include +#include #include #include #include #include #include +#include #include // For FLT_MAX #include @@ -51,6 +53,7 @@ namespace bool gTouchCallBackCalled = false; bool gTouchCallBackCalled2 = false; bool gTouchCallBackCalled3 = false; +bool gHitTestTouchCallBackCalled = false; bool gHoverCallBackCalled = false; @@ -110,6 +113,13 @@ static bool TestTouchCallback3(Actor, const TouchEvent&) END_TEST; } +static bool TestHitTestTouchCallback(Actor, const TouchEvent&) +{ + gHitTestTouchCallBackCalled = true; + return false; + END_TEST; +} + static void ResetTouchCallbacks() { gTouchCallBackCalled = false; @@ -510,7 +520,7 @@ int UtcDaliActorAddN(void) catch(Dali::DaliException& e) { DALI_TEST_PRINT_ASSERT(e); - DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION); + DALI_TEST_ASSERT(e, "&mOwner != &child", TEST_LOCATION); DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION); } catch(...) @@ -635,6 +645,32 @@ int UtcDaliActorRemoveP(void) END_TEST; } +int UtcDaliActorSwitchParentN(void) +{ + tet_infoline("Testing Actor::UtcDaliActorSwitchParentN"); + TestApplication application; + + Actor parent1 = Actor::New(); + Actor child = Actor::New(); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION); + + parent1.Add(child); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION); + + Actor parent2 = Actor::New(); + + DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION); + + // Try switch parent with that both of parent1 and parent2 are off scene. + DevelActor::SwitchParent(child, parent2); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION); + END_TEST; +} + int UtcDaliActorGetChildCount(void) { TestApplication application; @@ -2522,6 +2558,77 @@ int UtcDaliActorIsKeyboardFocusable(void) END_TEST; } +int UtcDaliActorSetKeyboardFocusableChildren(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true); + + actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false); + END_TEST; +} + +int UtcDaliActorAreChildrenKeyBoardFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true); + END_TEST; +} + +int UtcDaliActorSetTouchFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE) == true); + + actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE) == false); + END_TEST; +} + +int UtcDaliActorIsTouchFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE) == false); + END_TEST; +} + +int UtcDaliActorSetUserInteractionEnabled(void) +{ + TestApplication application; + Actor actor = Actor::New(); + + bool enabled = !actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED); + + actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, enabled); + + DALI_TEST_CHECK(enabled == actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED)); + END_TEST; +} + +int UtcDaliActorIsUserInteractionEnabled(void) +{ + TestApplication application; + Actor actor = Actor::New(); + actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true); + + DALI_TEST_CHECK(true == actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED)); + END_TEST; +} + int UtcDaliActorRemoveConstraints(void) { tet_infoline(" UtcDaliActorRemoveConstraints"); @@ -2962,9 +3069,9 @@ int UtcDaliActorSetDrawModeOverlayRender(void) ids.push_back(10); // third rendered actor application.GetGlAbstraction().SetNextTextureIds(ids); - Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); - Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); - Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); + Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); + Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); + Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); Actor a = CreateRenderableActor(imageA); Actor b = CreateRenderableActor(imageB); Actor c = CreateRenderableActor(imageC); @@ -4103,7 +4210,7 @@ int UtcDaliActorRemoveRendererN(void) // Clipping test helper functions: Actor CreateActorWithContent(uint32_t width, uint32_t height) { - Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height); + Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height); Actor actor = CreateRenderableActor(image); // Setup dimensions and position so actor is not skipped by culling. @@ -4141,7 +4248,9 @@ void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue) DALI_TEST_EQUALS(colorMaskParams.red, maskValue, TEST_LOCATION); DALI_TEST_EQUALS(colorMaskParams.green, maskValue, TEST_LOCATION); DALI_TEST_EQUALS(colorMaskParams.blue, maskValue, TEST_LOCATION); - DALI_TEST_EQUALS(colorMaskParams.alpha, maskValue, TEST_LOCATION); + + // @todo only test alpha if the framebuffer has an alpha channel + //DALI_TEST_EQUALS(colorMaskParams.alpha, maskValue, TEST_LOCATION); } int UtcDaliActorPropertyClippingP(void) @@ -4250,7 +4359,9 @@ int UtcDaliActorPropertyClippingActor(void) CheckColorMask(glAbstraction, true); // Check the stencil buffer was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream oss; + oss << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str())); // Check the stencil buffer was cleared. DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex)); @@ -4286,7 +4397,9 @@ int UtcDaliActorPropertyClippingActorEnableThenDisable(void) CheckColorMask(glAbstraction, true); // Check the stencil buffer was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream oss; + oss << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str())); // Check the stencil buffer was cleared. DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex)); @@ -4303,7 +4416,9 @@ int UtcDaliActorPropertyClippingActorEnableThenDisable(void) GenerateTrace(application, enabledDisableTrace, stencilTrace); // Check the stencil buffer was disabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream stencil; + stencil << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str())); // Ensure all values in stencil-mask are set to 1. startIndex = 0u; @@ -4350,7 +4465,9 @@ int UtcDaliActorPropertyClippingNestedChildren(void) CheckColorMask(glAbstraction, true); // Check the stencil buffer was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream oss; + oss << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str())); // Perform the test twice, once for 2D layer, and once for 3D. for(unsigned int i = 0u; i < 2u; ++i) @@ -4366,7 +4483,7 @@ int UtcDaliActorPropertyClippingNestedChildren(void) DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE // Check the correct setup was done to test against first bit-plane (only) of the stencil buffer. - DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 255", startIndex)); // 514 is GL_EQUAL + DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP // Check we are set up to write to the second bitplane of the stencil buffer (only). @@ -4376,7 +4493,7 @@ int UtcDaliActorPropertyClippingNestedChildren(void) // Check we are set up to test against both the first and second bit-planes of the stencil buffer. // (Both must be set to pass the check). - DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 255", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2 + DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2 DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP // If we are on the first loop, set the layer to 3D and loop to perform the test again. @@ -4411,7 +4528,7 @@ int UtcDaliActorPropertyClippingActorDrawOrder(void) Actor actors[5]; for(int i = 0; i < 5; ++i) { - Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u); + Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u); Actor actor = CreateRenderableActor(image); // Setup dimensions and position so actor is not skipped by culling. @@ -4457,10 +4574,15 @@ int UtcDaliActorPropertyClippingActorDrawOrder(void) Note: Correct enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 */ - size_t startIndex = 0u; - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "3042", startIndex)); - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); // 2960 is GL_STENCIL_TEST - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex)); + size_t startIndex = 0u; + std::ostringstream blend; + blend << std::hex << GL_BLEND; + std::ostringstream stencil; + stencil << std::hex << GL_STENCIL_TEST; + + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex)); + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex)); + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex)); // Swap the clipping actor from top of left branch to top of right branch. actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED); @@ -4476,13 +4598,13 @@ int UtcDaliActorPropertyClippingActorDrawOrder(void) // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn). // This proves the draw order has remained the same. startIndex = 0u; - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); - DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex)); + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex)); + DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex)); END_TEST; } -int UtcDaliActorPropertyScissorClippingActor(void) +int UtcDaliActorPropertyScissorClippingActor01(void) { // This test checks that an actor is correctly setup for clipping. tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor"); @@ -4511,7 +4633,10 @@ int UtcDaliActorPropertyScissorClippingActor(void) CheckColorMask(glAbstraction, true); // Check scissor test was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); // Check the scissor was set, and the coordinates are correct. std::stringstream compareParametersString; @@ -4533,6 +4658,68 @@ int UtcDaliActorPropertyScissorClippingActor(void) END_TEST; } +int UtcDaliActorPropertyScissorClippingActor02(void) +{ + // This test checks that an actor is correctly setup for clipping. + tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer"); + TestApplication application; + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace(); + TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace(); + + const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + const Vector2 actorSize(16.0f, 16.0f); + + // Create a clipping actor. + Actor clippingActorA = CreateRenderableActor(); + clippingActorA[Actor::Property::SIZE] = actorSize; + + Renderer renderer = clippingActorA.GetRendererAt(0); + DALI_TEST_CHECK(renderer); + + // Make Renderer opacity 0. + renderer[DevelRenderer::Property::OPACITY] = 0.0f; + + // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system. + // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test. + clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT); + clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT); + clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX); + application.GetScene().Add(clippingActorA); + + // Gather the call trace. + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + // Check we are writing to the color buffer. + CheckColorMask(glAbstraction, true); + + // Check scissor test was enabled. + + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); + + // Check the scissor was set, and the coordinates are correct. + std::stringstream compareParametersString; + compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y; + DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16 + + clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT); + clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT); + + // Gather the call trace. + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + // Check the scissor was set, and the coordinates are correct. + compareParametersString.str(std::string()); + compareParametersString.clear(); + compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y; + DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16 + + END_TEST; +} + int UtcDaliActorPropertyScissorClippingActorSiblings(void) { // This test checks that an actor is correctly setup for clipping. @@ -4572,7 +4759,9 @@ int UtcDaliActorPropertyScissorClippingActorSiblings(void) CheckColorMask(glAbstraction, true); // Check scissor test was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); // Check the scissor was set, and the coordinates are correct. std::stringstream compareParametersString; @@ -4651,7 +4840,9 @@ int UtcDaliActorPropertyScissorClippingActorNested01(void) CheckColorMask(glAbstraction, true); // Check scissor test was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); // Check the scissor was set, and the coordinates are correct. const Vector4& expectResults(expect[test]); @@ -4735,7 +4926,9 @@ int UtcDaliActorPropertyScissorClippingActorNested02(void) CheckColorMask(glAbstraction, true); // Check scissor test was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); // Check the scissor was set, and the coordinates are correct. std::string clipA("0, 500, 480, 200"); @@ -4747,7 +4940,7 @@ int UtcDaliActorPropertyScissorClippingActorNested02(void) DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB)); DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC)); DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD)); - DALI_TEST_CHECK(scissorTrace.CountMethod("Scissor") == 4); // Scissor rect should not be changed in clippingActorE case. So count should be 4. + DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4. END_TEST; } @@ -4777,11 +4970,12 @@ int UtcDaliActorPropertyClippingActorWithRendererOverride(void) CheckColorMask(glAbstraction, true); // Check the stencil buffer was not enabled. - DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream stencil; + stencil << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str())); // Check stencil functions are not called. DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc")); - DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask")); DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp")); // Check that scissor clipping is overriden by the renderer properties. @@ -4793,13 +4987,73 @@ int UtcDaliActorPropertyClippingActorWithRendererOverride(void) GenerateTrace(application, enabledDisableTrace, scissorTrace); // Check the stencil buffer was not enabled. - DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc")); END_TEST; } +int UtcDaliActorPropertyClippingActorCulled(void) +{ + // This test checks that child actors are clipped by an culled parent actor. + tet_infoline("Testing child actors are clipped by an culled parent actor"); + TestApplication application; + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace(); + TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace(); + + const Vector2 actorSize(160.0f, 160.0f); + + // Create a clipping actor. + Actor clippingActorA = CreateRenderableActor(); + clippingActorA[Actor::Property::SIZE] = actorSize; + + // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system. + // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test. + clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT; + clippingActorA[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT; + clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX; + application.GetScene().Add(clippingActorA); + + // Create a child actor + Actor childActor = CreateRenderableActor(); + childActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT; + childActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT; + childActor[Actor::Property::SIZE] = Vector2(50.0f, 50.0f); + childActor[Actor::Property::INHERIT_POSITION] = false; + + // Gather the call trace. + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + // Check scissor test was enabled. + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); + + // Check the scissor was set, and the coordinates are correct. + std::stringstream compareParametersString; + compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y; + DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16 + + // Move the clipping actor out of screen + clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f); + + // Gather the call trace. + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + // Check the scissor was set, and the coordinates are correct. + compareParametersString.str(std::string()); + compareParametersString.clear(); + compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0; + DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty. + + END_TEST; +} + int UtcDaliGetPropertyN(void) { tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range"); @@ -5023,9 +5277,9 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); bool CBA = (indexC > indexB) && (indexB > indexA); @@ -5067,8 +5321,7 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.SendNotification(); application.Render(); @@ -5076,9 +5329,9 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing A above C and B at bottom\n"); bool ACB = (indexA > indexC) && (indexC > indexB); @@ -5104,8 +5357,7 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.SendNotification(); application.Render(); @@ -5113,9 +5365,9 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing B above A and C at bottom\n"); bool BAC = (indexB > indexA) && (indexA > indexC); @@ -5152,8 +5404,7 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.SendNotification(); application.Render(); @@ -5161,9 +5412,9 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing C above A and B at bottom\n"); bool CAB = (indexC > indexA) && (indexA > indexB); @@ -5288,41 +5539,18 @@ int UtcDaliActorRaiseAbove(void) END_TEST; } -int UtcDaliActorLowerBelow(void) +int UtcDaliActorRaiseAbove2(void) { - tet_infoline("UtcDaliActor LowerBelow test \n"); + tet_infoline("UtcDaliActor RaiseToAbove test using SIBLING_ORDER property\n"); TestApplication application; Integration::Scene stage(application.GetScene()); - // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each - // enables checking of which actor the uniform is assigned too - Shader shaderA = CreateShader(); - shaderA.RegisterProperty("uRendererColor", 1.f); - - Shader shaderB = CreateShader(); - shaderB.RegisterProperty("uRendererColor", 2.f); - - Shader shaderC = CreateShader(); - shaderC.RegisterProperty("uRendererColor", 3.f); - Actor actorA = Actor::New(); Actor actorB = Actor::New(); Actor actorC = Actor::New(); - // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C, - Geometry geometry = CreateQuadGeometry(); - - Renderer rendererA = Renderer::New(geometry, shaderA); - actorA.AddRenderer(rendererA); - - Renderer rendererB = Renderer::New(geometry, shaderB); - actorB.AddRenderer(rendererB); - - Renderer rendererC = Renderer::New(geometry, shaderC); - actorC.AddRenderer(rendererC); - actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); @@ -5341,48 +5569,15 @@ int UtcDaliActorLowerBelow(void) actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); - Actor container = Actor::New(); - container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); - stage.Add(container); - - container.Add(actorA); - container.Add(actorB); - container.Add(actorC); + stage.Add(actorA); + stage.Add(actorB); + stage.Add(actorC); ResetTouchCallbacks(); - // Connect ChildOrderChangedSignal - bool orderChangedSignal(false); - Actor orderChangedActor; - ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor); - DevelActor::ChildOrderChangedSignal(container).Connect(&application, f); - - // Set up gl abstraction trace so can query the set uniform order - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - glAbstraction.EnableSetUniformCallTrace(true); - glAbstraction.ResetSetUniformCallStack(); - TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace(); - - glAbstraction.ResetSetUniformCallStack(); - application.SendNotification(); application.Render(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); - - tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); - - // Test order of uniforms in stack - int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); - - tet_infoline("Testing C above B and A at bottom\n"); - bool CBA = (indexC > indexB) && (indexB > indexA); - - DALI_TEST_EQUALS(CBA, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); @@ -5393,6 +5588,11 @@ int UtcDaliActorLowerBelow(void) actorB.TouchedSignal().Connect(TestTouchCallback2); actorC.TouchedSignal().Connect(TestTouchCallback3); + bool orderChangedSignal(false); + Actor orderChangedActor; + ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor); + DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f); + Dali::Integration::Point point; point.SetDeviceId(1); point.SetState(PointState::DOWN); @@ -5400,8 +5600,6 @@ int UtcDaliActorLowerBelow(void) Dali::Integration::TouchEvent touchEvent; touchEvent.AddPoint(point); - tet_infoline("UtcDaliActor Test Set up completed \n"); - application.ProcessEvent(touchEvent); DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); @@ -5410,35 +5608,17 @@ int UtcDaliActorLowerBelow(void) ResetTouchCallbacks(); - tet_printf("Lower actor C below Actor B ( actor B and A on same level due to insertion order) so C is below both \n"); + tet_printf("Raise actor B Above Actor C\n"); DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorC.LowerBelow(actorB); + int newOrder = actorC[DevelActor::Property::SIBLING_ORDER]; + actorB[DevelActor::Property::SIBLING_ORDER] = newOrder; DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); - DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION); // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); - application.Render(); - - application.ProcessEvent(touchEvent); // touch event - - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); - - application.SendNotification(); - application.Render(); - - tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); - - // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); - - tet_infoline("Testing render order is A, C, B"); - DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION); - DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION); + application.ProcessEvent(touchEvent); DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); @@ -5446,106 +5626,64 @@ int UtcDaliActorLowerBelow(void) ResetTouchCallbacks(); - tet_printf("Lower actor C below Actor A leaving B on top\n"); + tet_printf("Raise actor A Above Actor B\n"); orderChangedSignal = false; DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorC.LowerBelow(actorA); + newOrder = actorB[DevelActor::Property::SIBLING_ORDER]; + actorA[DevelActor::Property::SIBLING_ORDER] = newOrder; DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); - DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION); // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); - application.Render(); - application.ProcessEvent(touchEvent); + application.ProcessEvent(touchEvent); // process a touch event on ordered actors. - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); - - application.Render(); - tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); - - // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); - - DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); - DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION); - - DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); ResetTouchCallbacks(); - tet_printf("Lower actor B below Actor C leaving A on top\n"); - - orderChangedSignal = false; - - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorB.LowerBelow(actorC); - DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); - DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION); - - // Ensure sorting happens at end of Core::ProcessEvents() before next touch - application.SendNotification(); - application.Render(); - - application.ProcessEvent(touchEvent); - - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); - - application.Render(); - tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); - - // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); - - DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION); - DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); - END_TEST; } -int UtcDaliActorRaiseAboveDifferentParentsN(void) +int UtcDaliActorLowerBelow(void) { - tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n"); + tet_infoline("UtcDaliActor LowerBelow test \n"); TestApplication application; Integration::Scene stage(application.GetScene()); - Actor parentA = Actor::New(); - Actor parentB = Actor::New(); - parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); - parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); - parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); - parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); - - parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); - parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each + // enables checking of which actor the uniform is assigned too + Shader shaderA = CreateShader(); + shaderA.RegisterProperty("uRendererColor", 1.f); - parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); - parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + Shader shaderB = CreateShader(); + shaderB.RegisterProperty("uRendererColor", 2.f); - stage.Add(parentA); - stage.Add(parentB); + Shader shaderC = CreateShader(); + shaderC.RegisterProperty("uRendererColor", 3.f); Actor actorA = Actor::New(); Actor actorB = Actor::New(); Actor actorC = Actor::New(); - parentA.Add(actorA); - parentA.Add(actorB); + // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C, + Geometry geometry = CreateQuadGeometry(); - tet_printf("Actor C added to different parent from A and B \n"); - parentB.Add(actorC); + Renderer rendererA = Renderer::New(geometry, shaderA); + actorA.AddRenderer(rendererA); + + Renderer rendererB = Renderer::New(geometry, shaderB); + actorB.AddRenderer(rendererB); + + Renderer rendererC = Renderer::New(geometry, shaderC); + actorC.AddRenderer(rendererC); actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); @@ -5565,17 +5703,46 @@ int UtcDaliActorRaiseAboveDifferentParentsN(void) actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); + Actor container = Actor::New(); + container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + stage.Add(container); + + container.Add(actorA); + container.Add(actorB); + container.Add(actorC); + ResetTouchCallbacks(); // Connect ChildOrderChangedSignal bool orderChangedSignal(false); Actor orderChangedActor; ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor); - DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f); + DevelActor::ChildOrderChangedSignal(container).Connect(&application, f); + + // Set up gl abstraction trace so can query the set uniform order + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableSetUniformCallTrace(true); + glAbstraction.ResetSetUniformCallStack(); + TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace(); + + glAbstraction.ResetSetUniformCallStack(); application.SendNotification(); application.Render(); + tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); + + // Test order of uniforms in stack + int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); + + tet_infoline("Testing C above B and A at bottom\n"); + bool CBA = (indexC > indexB) && (indexB > indexA); + + DALI_TEST_EQUALS(CBA, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); @@ -5593,6 +5760,8 @@ int UtcDaliActorRaiseAboveDifferentParentsN(void) Dali::Integration::TouchEvent touchEvent; touchEvent.AddPoint(point); + tet_infoline("UtcDaliActor Test Set up completed \n"); + application.ProcessEvent(touchEvent); DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); @@ -5601,38 +5770,141 @@ int UtcDaliActorRaiseAboveDifferentParentsN(void) ResetTouchCallbacks(); - tet_printf("Raise actor A Above Actor C which have different parents\n"); + tet_printf("Lower actor C below Actor B ( actor B and A on same level due to insertion order) so C is below both \n"); DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorA.RaiseAbove(actorC); - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorC.LowerBelow(actorB); + DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION); // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); + application.Render(); application.ProcessEvent(touchEvent); // touch event + glSetUniformStack.Reset(); + + application.SendNotification(); + application.Render(); + + tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); + + // Test order of uniforms in stack + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); + + tet_infoline("Testing render order is A, C, B"); + DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION); + DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + + ResetTouchCallbacks(); + + tet_printf("Lower actor C below Actor A leaving B on top\n"); + + orderChangedSignal = false; + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorC.LowerBelow(actorA); + DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION); + + // Ensure sorting happens at end of Core::ProcessEvents() before next touch + application.SendNotification(); + application.Render(); + + application.ProcessEvent(touchEvent); + + glSetUniformStack.Reset(); + + application.Render(); + tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); + + // Test order of uniforms in stack + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); + + DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); + DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION); + + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); ResetTouchCallbacks(); + tet_printf("Lower actor B below Actor C leaving A on top\n"); + + orderChangedSignal = false; + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorB.LowerBelow(actorC); + DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION); + + // Ensure sorting happens at end of Core::ProcessEvents() before next touch + application.SendNotification(); + application.Render(); + + application.ProcessEvent(touchEvent); + + glSetUniformStack.Reset(); + + application.Render(); + tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); + + // Test order of uniforms in stack + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); + + DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION); + DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); + END_TEST; } -int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) +int UtcDaliActorLowerBelow2(void) { - tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n"); + tet_infoline("UtcDaliActor LowerBelow test using SIBLING_ORDER property\n"); TestApplication application; Integration::Scene stage(application.GetScene()); + // Set up renderers to add to Actors, float value 1, 2, 3 assigned to each + // enables checking of which actor the uniform is assigned too + Shader shaderA = CreateShader(); + shaderA.RegisterProperty("uRendererColor", 1.f); + + Shader shaderB = CreateShader(); + shaderB.RegisterProperty("uRendererColor", 2.f); + + Shader shaderC = CreateShader(); + shaderC.RegisterProperty("uRendererColor", 3.f); + Actor actorA = Actor::New(); Actor actorB = Actor::New(); Actor actorC = Actor::New(); + // Add renderers to Actors so ( uRendererColor, 1 ) is A, ( uRendererColor, 2 ) is B, and ( uRendererColor, 3 ) is C, + Geometry geometry = CreateQuadGeometry(); + + Renderer rendererA = Renderer::New(geometry, shaderA); + actorA.AddRenderer(rendererA); + + Renderer rendererB = Renderer::New(geometry, shaderB); + actorB.AddRenderer(rendererB); + + Renderer rendererC = Renderer::New(geometry, shaderC); + actorC.AddRenderer(rendererC); + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); @@ -5651,17 +5923,46 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); + Actor container = Actor::New(); + container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + container.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + stage.Add(container); + + container.Add(actorA); + container.Add(actorB); + container.Add(actorC); + ResetTouchCallbacks(); // Connect ChildOrderChangedSignal bool orderChangedSignal(false); Actor orderChangedActor; ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor); - DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f); + DevelActor::ChildOrderChangedSignal(container).Connect(&application, f); + + // Set up gl abstraction trace so can query the set uniform order + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableSetUniformCallTrace(true); + glAbstraction.ResetSetUniformCallStack(); + TraceCallStack& glSetUniformStack = glAbstraction.GetSetUniformTrace(); + + glAbstraction.ResetSetUniformCallStack(); application.SendNotification(); application.Render(); + tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); + + // Test order of uniforms in stack + int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); + + tet_infoline("Testing C above B and A at bottom\n"); + bool CBA = (indexC > indexB) && (indexB > indexA); + + DALI_TEST_EQUALS(CBA, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); @@ -5679,101 +5980,93 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) Dali::Integration::TouchEvent touchEvent; touchEvent.AddPoint(point); - tet_printf("Raise actor A Above Actor C which have no parents\n"); - - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorA.RaiseAbove(actorC); - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - - // Ensure sorting happens at end of Core::ProcessEvents() before next touch - application.SendNotification(); + tet_infoline("UtcDaliActor Test Set up completed \n"); application.ProcessEvent(touchEvent); - tet_printf("Not parented so RaiseAbove should show no effect\n"); - DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION); ResetTouchCallbacks(); - orderChangedSignal = false; - - stage.Add(actorB); - tet_printf("Lower actor A below Actor C when only A is not on stage \n"); + tet_printf("Lower actor C below Actor B ( actor B and A on same level due to insertion order) so C is below both \n"); DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorA.LowerBelow(actorC); - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorC[DevelActor::Property::SIBLING_ORDER] = 1; + DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION); // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); application.Render(); - application.ProcessEvent(touchEvent); - - tet_printf("Actor A not parented so LowerBelow should show no effect\n"); - DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); - - ResetTouchCallbacks(); - - orderChangedSignal = false; + application.ProcessEvent(touchEvent); // touch event - tet_printf("Adding Actor A to stage, will be on top\n"); + glSetUniformStack.Reset(); - stage.Add(actorA); application.SendNotification(); application.Render(); - tet_printf("Raise actor B Above Actor C when only B has a parent\n"); - - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorB.RaiseAbove(actorC); - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); - // Ensure sorting happens at end of Core::ProcessEvents() before next touch - application.SendNotification(); + // Test order of uniforms in stack + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); - application.ProcessEvent(touchEvent); + tet_infoline("Testing render order is A, C, B"); + DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION); + DALI_TEST_EQUALS(indexB > indexC, true, TEST_LOCATION); - tet_printf("C not parented so RaiseAbove should show no effect\n"); - DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); ResetTouchCallbacks(); - orderChangedSignal = false; + tet_printf("Lower actor C below Actor A leaving B on top\n"); - tet_printf("Lower actor A below Actor C when only A has a parent\n"); + orderChangedSignal = false; DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorA.LowerBelow(actorC); - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorC[DevelActor::Property::SIBLING_ORDER] = 0; + DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorC, TEST_LOCATION); // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); + application.Render(); application.ProcessEvent(touchEvent); - tet_printf("C not parented so LowerBelow should show no effect\n"); - DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + glSetUniformStack.Reset(); + + application.Render(); + tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); + + // Test order of uniforms in stack + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); + + DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); + DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION); + + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); ResetTouchCallbacks(); - orderChangedSignal = false; + tet_printf("Lower actor B below Actor C leaving A on top\n"); - stage.Add(actorC); + orderChangedSignal = false; DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorA.RaiseAbove(actorC); + actorB[DevelActor::Property::SIBLING_ORDER] = 0; DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); - DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorB, TEST_LOCATION); // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); @@ -5781,26 +6074,56 @@ int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) application.ProcessEvent(touchEvent); - tet_printf("Raise actor A Above Actor C, now both have same parent \n"); - DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + glSetUniformStack.Reset(); + + application.Render(); + tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); + + // Test order of uniforms in stack + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); + + DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION); + DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); END_TEST; } -int UtcDaliActorTestAllAPIwhenActorNotParented(void) +int UtcDaliActorRaiseAboveDifferentParentsN(void) { - tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n"); + tet_infoline("UtcDaliActor RaiseToAbove test with actor and target actor having different parents \n"); TestApplication application; Integration::Scene stage(application.GetScene()); + Actor parentA = Actor::New(); + Actor parentB = Actor::New(); + parentA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); + parentA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); + parentB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); + parentB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); + + parentA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + parentA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + parentB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + parentB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + stage.Add(parentA); + stage.Add(parentB); + Actor actorA = Actor::New(); Actor actorB = Actor::New(); Actor actorC = Actor::New(); + parentA.Add(actorA); + parentA.Add(actorB); + + tet_printf("Actor C added to different parent from A and B \n"); + parentB.Add(actorC); + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); @@ -5827,6 +6150,13 @@ int UtcDaliActorTestAllAPIwhenActorNotParented(void) ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor); DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + // connect to actor touch signals, will use touch callbacks to determine which actor is on top. // Only top actor will get touched. actorA.TouchedSignal().Connect(TestTouchCallback); @@ -5840,118 +6170,37 @@ int UtcDaliActorTestAllAPIwhenActorNotParented(void) Dali::Integration::TouchEvent touchEvent; touchEvent.AddPoint(point); - stage.Add(actorA); - tet_printf("Raise actor B Above Actor C but B not parented\n"); - - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorB.Raise(); - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - - application.SendNotification(); - application.Render(); - - application.ProcessEvent(touchEvent); - - tet_printf("Not parented so RaiseAbove should show no effect\n"); - - DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); - - tet_printf("Raise actor B Above Actor C but B not parented\n"); - ResetTouchCallbacks(); - - orderChangedSignal = false; - - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorC.Lower(); - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - - // Sort actor tree before next touch event - application.SendNotification(); - application.Render(); - application.ProcessEvent(touchEvent); - tet_printf("Not parented so RaiseAbove should show no effect\n"); - - DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); - ResetTouchCallbacks(); - - orderChangedSignal = false; - - tet_printf("Lower actor C below B but C not parented\n"); - - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorB.Lower(); - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - - // Sort actor tree before next touch event - application.SendNotification(); - application.Render(); - - application.ProcessEvent(touchEvent); - - tet_printf("Not parented so Lower should show no effect\n"); + DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); ResetTouchCallbacks(); - orderChangedSignal = false; - - tet_printf("Raise actor B to top\n"); + tet_printf("Raise actor A Above Actor C which have different parents\n"); DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorB.RaiseToTop(); + actorA.RaiseAbove(actorC); DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - // Sort actor tree before next touch event + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); - application.Render(); - application.ProcessEvent(touchEvent); - - tet_printf("Not parented so RaiseToTop should show no effect\n"); + application.ProcessEvent(touchEvent); // touch event - DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); - ResetTouchCallbacks(); - - orderChangedSignal = false; - - tet_printf("Add ActorB to stage so only Actor C not parented\n"); - - stage.Add(actorB); - - tet_printf("Lower actor C to Bottom, B stays at top\n"); - - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorC.LowerToBottom(); - DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - - application.SendNotification(); - application.Render(); - - application.ProcessEvent(touchEvent); - - tet_printf("Not parented so LowerToBottom should show no effect\n"); + DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); ResetTouchCallbacks(); END_TEST; } -int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void) +int UtcDaliActorRaiseLowerWhenUnparentedTargetN(void) { - tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n"); + tet_infoline("UtcDaliActor Test raiseAbove and lowerBelow api when target Actor has no parent \n"); TestApplication application; @@ -5979,16 +6228,6 @@ int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void) actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); - stage.Add(actorA); - stage.Add(actorB); - stage.Add(actorC); - - // connect to actor touch signals, will use touch callbacks to determine which actor is on top. - // Only top actor will get touched. - actorA.TouchedSignal().Connect(TestTouchCallback); - actorB.TouchedSignal().Connect(TestTouchCallback2); - actorC.TouchedSignal().Connect(TestTouchCallback3); - ResetTouchCallbacks(); // Connect ChildOrderChangedSignal @@ -6000,6 +6239,16 @@ int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void) application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + + // connect to actor touch signals, will use touch callbacks to determine which actor is on top. + // Only top actor will get touched. + actorA.TouchedSignal().Connect(TestTouchCallback); + actorB.TouchedSignal().Connect(TestTouchCallback2); + actorC.TouchedSignal().Connect(TestTouchCallback3); + Dali::Integration::Point point; point.SetDeviceId(1); point.SetState(PointState::DOWN); @@ -6007,47 +6256,109 @@ int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void) Dali::Integration::TouchEvent touchEvent; touchEvent.AddPoint(point); - application.ProcessEvent(touchEvent); - - DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION); - - ResetTouchCallbacks(); - - tet_infoline("Raise actor A Above Actor A which is the same actor!!\n"); + tet_printf("Raise actor A Above Actor C which have no parents\n"); DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorA.RaiseAbove(actorA); - DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); - DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION); + actorA.RaiseAbove(actorC); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); - application.Render(); application.ProcessEvent(touchEvent); - tet_infoline("No target is source Actor so RaiseAbove should show no effect\n"); + tet_printf("Not parented so RaiseAbove should show no effect\n"); DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); - DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); ResetTouchCallbacks(); orderChangedSignal = false; + stage.Add(actorB); + tet_printf("Lower actor A below Actor C when only A is not on stage \n"); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); - actorA.RaiseAbove(actorC); + actorA.LowerBelow(actorC); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + + // Ensure sorting happens at end of Core::ProcessEvents() before next touch + application.SendNotification(); + application.Render(); + + application.ProcessEvent(touchEvent); + + tet_printf("Actor A not parented so LowerBelow should show no effect\n"); + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + + ResetTouchCallbacks(); + + orderChangedSignal = false; + + tet_printf("Adding Actor A to stage, will be on top\n"); + + stage.Add(actorA); + application.SendNotification(); + application.Render(); + + tet_printf("Raise actor B Above Actor C when only B has a parent\n"); + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorB.RaiseAbove(actorC); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + + // Ensure sorting happens at end of Core::ProcessEvents() before next touch + application.SendNotification(); + + application.ProcessEvent(touchEvent); + + tet_printf("C not parented so RaiseAbove should show no effect\n"); + DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + + ResetTouchCallbacks(); + + orderChangedSignal = false; + + tet_printf("Lower actor A below Actor C when only A has a parent\n"); + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorA.LowerBelow(actorC); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + + // Ensure sorting happens at end of Core::ProcessEvents() before next touch + application.SendNotification(); + + application.ProcessEvent(touchEvent); + + tet_printf("C not parented so LowerBelow should show no effect\n"); + DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + + ResetTouchCallbacks(); + + orderChangedSignal = false; + + stage.Add(actorC); + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorA.RaiseAbove(actorC); DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION); + // Ensure sorting happens at end of Core::ProcessEvents() before next touch application.SendNotification(); application.Render(); application.ProcessEvent(touchEvent); - tet_infoline("Raise actor A Above Actor C which will now be successful \n"); + tet_printf("Raise actor A Above Actor C, now both have same parent \n"); DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); @@ -6055,151 +6366,417 @@ int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void) END_TEST; } -int UtcDaliActorGetScreenPosition(void) +int UtcDaliActorTestAllAPIwhenActorNotParented(void) { - tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n"); + tet_infoline("UtcDaliActor Test all raise/lower api when actor has no parent \n"); TestApplication application; Integration::Scene stage(application.GetScene()); Actor actorA = Actor::New(); + Actor actorB = Actor::New(); + Actor actorC = Actor::New(); + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - Vector2 size2(10.0f, 20.0f); - actorA.SetProperty(Actor::Property::SIZE, size2); + actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f)); + actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n"); + actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); + actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); - stage.Add(actorA); + actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); + actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); - application.SendNotification(); - application.Render(); + actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); + actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); - Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); - Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + ResetTouchCallbacks(); - tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y); - tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y); + // Connect ChildOrderChangedSignal + bool orderChangedSignal(false); + Actor orderChangedActor; + ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor); + DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f); - DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION); - DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION); + // connect to actor touch signals, will use touch callbacks to determine which actor is on top. + // Only top actor will get touched. + actorA.TouchedSignal().Connect(TestTouchCallback); + actorB.TouchedSignal().Connect(TestTouchCallback2); + actorC.TouchedSignal().Connect(TestTouchCallback3); - tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n"); + Dali::Integration::Point point; + point.SetDeviceId(1); + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(10.f, 10.f)); + Dali::Integration::TouchEvent touchEvent; + touchEvent.AddPoint(point); - actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + stage.Add(actorA); + tet_printf("Raise actor B Above Actor C but B not parented\n"); + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorB.Raise(); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); application.SendNotification(); application.Render(); - actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); - actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + application.ProcessEvent(touchEvent); - tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y); - tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y); + tet_printf("Not parented so RaiseAbove should show no effect\n"); - DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION); - DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); - tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n"); + tet_printf("Raise actor B Above Actor C but B not parented\n"); + ResetTouchCallbacks(); - actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT); + orderChangedSignal = false; + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorC.Lower(); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + // Sort actor tree before next touch event application.SendNotification(); application.Render(); - actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); - actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + application.ProcessEvent(touchEvent); - tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y); - tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y); + tet_printf("Not parented so RaiseAbove should show no effect\n"); - DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION); - DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + ResetTouchCallbacks(); - tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n"); + orderChangedSignal = false; - actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0)); + tet_printf("Lower actor C below B but C not parented\n"); + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorB.Lower(); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + // Sort actor tree before next touch event application.SendNotification(); application.Render(); - actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); - actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + application.ProcessEvent(touchEvent); - tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y); - tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y); + tet_printf("Not parented so Lower should show no effect\n"); - DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION); - DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + ResetTouchCallbacks(); - tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n"); + orderChangedSignal = false; - actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0)); + tet_printf("Raise actor B to top\n"); + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorB.RaiseToTop(); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + // Sort actor tree before next touch event application.SendNotification(); application.Render(); - actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); - actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + application.ProcessEvent(touchEvent); - DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION); - DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION); + tet_printf("Not parented so RaiseToTop should show no effect\n"); - tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y); - tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y); + DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + ResetTouchCallbacks(); - tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n"); + orderChangedSignal = false; - actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); - actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0)); + tet_printf("Add ActorB to stage so only Actor C not parented\n"); - Actor actorB = Actor::New(); - actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); - actorB.SetProperty(Actor::Property::SIZE, size2); - actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f)); - actorA.Add(actorB); + stage.Add(actorB); - actorA.SetProperty(Actor::Property::SCALE, 2.0f); + tet_printf("Lower actor C to Bottom, B stays at top\n"); + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorC.LowerToBottom(); + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); application.SendNotification(); application.Render(); - actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + application.ProcessEvent(touchEvent); - DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION); - DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION); + tet_printf("Not parented so LowerToBottom should show no effect\n"); + + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + ResetTouchCallbacks(); END_TEST; } -int UtcDaliActorGetScreenPositionAfterScaling(void) +int UtcDaliActorRaiseAboveActorAndTargetTheSameN(void) { - tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n"); + tet_infoline("UtcDaliActor RaiseToAbove and test with actor provided as target resulting in a no operation \n"); TestApplication application; Integration::Scene stage(application.GetScene()); Actor actorA = Actor::New(); - actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + Actor actorB = Actor::New(); + Actor actorC = Actor::New(); - Vector2 size2(10.0f, 20.0f); - actorA.SetProperty(Actor::Property::SIZE, size2); - actorA.SetProperty(Actor::Property::SCALE, 1.5f); - actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f)); + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n"); + actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actorB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - stage.Add(actorA); + actorC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + actorC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - application.SendNotification(); - application.Render(); + actorA.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); + actorA.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); - Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); - Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + actorB.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); + actorB.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); + + actorC.SetProperty(Actor::Property::WIDTH_RESIZE_POLICY, "FILL_TO_PARENT"); + actorC.SetProperty(Actor::Property::HEIGHT_RESIZE_POLICY, "FILL_TO_PARENT"); + + stage.Add(actorA); + stage.Add(actorB); + stage.Add(actorC); + + // connect to actor touch signals, will use touch callbacks to determine which actor is on top. + // Only top actor will get touched. + actorA.TouchedSignal().Connect(TestTouchCallback); + actorB.TouchedSignal().Connect(TestTouchCallback2); + actorC.TouchedSignal().Connect(TestTouchCallback3); + + ResetTouchCallbacks(); + + // Connect ChildOrderChangedSignal + bool orderChangedSignal(false); + Actor orderChangedActor; + ChildOrderChangedFunctor f(orderChangedSignal, orderChangedActor); + DevelActor::ChildOrderChangedSignal(stage.GetRootLayer()).Connect(&application, f); + + application.SendNotification(); + application.Render(); + + Dali::Integration::Point point; + point.SetDeviceId(1); + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(10.f, 10.f)); + Dali::Integration::TouchEvent touchEvent; + touchEvent.AddPoint(point); + + application.ProcessEvent(touchEvent); + + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION); + + ResetTouchCallbacks(); + + tet_infoline("Raise actor A Above Actor A which is the same actor!!\n"); + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorA.RaiseAbove(actorA); + DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + application.ProcessEvent(touchEvent); + + tet_infoline("No target is source Actor so RaiseAbove should show no effect\n"); + + DALI_TEST_EQUALS(gTouchCallBackCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, true, TEST_LOCATION); + + ResetTouchCallbacks(); + + orderChangedSignal = false; + + DALI_TEST_EQUALS(orderChangedSignal, false, TEST_LOCATION); + actorA.RaiseAbove(actorC); + DALI_TEST_EQUALS(orderChangedSignal, true, TEST_LOCATION); + DALI_TEST_EQUALS(orderChangedActor, actorA, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + application.ProcessEvent(touchEvent); + + tet_infoline("Raise actor A Above Actor C which will now be successful \n"); + DALI_TEST_EQUALS(gTouchCallBackCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled2, false, TEST_LOCATION); + DALI_TEST_EQUALS(gTouchCallBackCalled3, false, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliActorGetScreenPosition(void) +{ + tet_infoline("UtcDaliActorGetScreenPosition Get screen coordinates of Actor \n"); + + TestApplication application; + + Integration::Scene stage(application.GetScene()); + + Actor actorA = Actor::New(); + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + + Vector2 size2(10.0f, 20.0f); + actorA.SetProperty(Actor::Property::SIZE, size2); + + actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f)); + + tet_infoline("UtcDaliActorGetScreenPosition Center Anchor Point and 0,0 position \n"); + + stage.Add(actorA); + + application.SendNotification(); + application.Render(); + + Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); + Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + tet_printf("Actor World Position ( %f %f ) AnchorPoint::CENTER \n", actorWorldPosition.x, actorWorldPosition.y); + tet_printf("Actor Screen Position %f %f \n", actorScreenPosition.x, actorScreenPosition.y); + + DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION); + DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION); + + tet_infoline("UtcDaliActorGetScreenPosition Top Left Anchor Point and 0,0 position \n"); + + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + application.SendNotification(); + application.Render(); + + actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); + actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y); + tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorScreenPosition.x, actorScreenPosition.y); + + DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION); + DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION); + + tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 0,0 position \n"); + + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_RIGHT); + + application.SendNotification(); + application.Render(); + + actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); + actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorWorldPosition.x, actorWorldPosition.y); + tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT \n", actorScreenPosition.x, actorScreenPosition.y); + + DALI_TEST_EQUALS(actorScreenPosition.x, 0lu, TEST_LOCATION); + DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION); + + tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,0 position \n"); + + actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 0.0)); + + application.SendNotification(); + application.Render(); + + actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); + actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorWorldPosition.x, actorWorldPosition.y); + tet_printf("Actor Screen Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 0.0 \n", actorScreenPosition.x, actorScreenPosition.y); + + DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION); + DALI_TEST_EQUALS(actorScreenPosition.y, 0lu, TEST_LOCATION); + + tet_infoline("UtcDaliActorGetScreenPosition Bottom right Anchor Point and 30,420 position \n"); + + actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 420.0)); + + application.SendNotification(); + application.Render(); + + actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); + actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + DALI_TEST_EQUALS(actorScreenPosition.x, 30lu, TEST_LOCATION); + DALI_TEST_EQUALS(actorScreenPosition.y, 420lu, TEST_LOCATION); + + tet_printf("Actor World Position ( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0\n", actorWorldPosition.x, actorWorldPosition.y); + tet_printf("Actor Screen Position( %f %f ) AnchorPoint::BOTTOM_RIGHT Position x=30 y = 420.0 \n", actorScreenPosition.x, actorScreenPosition.y); + + tet_infoline("UtcDaliActorGetScreenPosition Scale parent and check child's screen position \n"); + + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actorA.SetProperty(Actor::Property::POSITION, Vector2(30.0, 30.0)); + + Actor actorB = Actor::New(); + actorB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actorB.SetProperty(Actor::Property::SIZE, size2); + actorB.SetProperty(Actor::Property::POSITION, Vector2(10.f, 10.f)); + actorA.Add(actorB); + + actorA.SetProperty(Actor::Property::SCALE, 2.0f); + + application.SendNotification(); + application.Render(); + + actorScreenPosition = actorB.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + DALI_TEST_EQUALS(actorScreenPosition.x, 50lu, TEST_LOCATION); + DALI_TEST_EQUALS(actorScreenPosition.y, 50lu, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliActorGetScreenPositionAfterScaling(void) +{ + tet_infoline("UtcDaliActorGetScreenPositionAfterScaling Get screen coordinates of Actor \n"); + + TestApplication application; + + Integration::Scene stage(application.GetScene()); + + Actor actorA = Actor::New(); + actorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + Vector2 size2(10.0f, 20.0f); + actorA.SetProperty(Actor::Property::SIZE, size2); + actorA.SetProperty(Actor::Property::SCALE, 1.5f); + actorA.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f)); + + tet_infoline("UtcDaliActorGetScreenPositionAfterScaling TopRight Anchor Point, scale 1.5f and 0,0 position \n"); + + stage.Add(actorA); + + application.SendNotification(); + application.Render(); + + Vector3 actorWorldPosition = actorA.GetProperty(Actor::Property::WORLD_POSITION).Get(); + Vector2 actorScreenPosition = actorA.GetProperty(Actor::Property::SCREEN_POSITION).Get(); tet_printf("Actor World Position ( %f %f ) AnchorPoint::TOP_LEFT \n", actorWorldPosition.x, actorWorldPosition.y); tet_printf("Actor Screen Position ( %f %f ) \n", actorScreenPosition.x, actorScreenPosition.y); @@ -7221,6 +7798,61 @@ int UtcDaliChildMovedSignalP(void) END_TEST; } +int UtcDaliActorSwitchParentP(void) +{ + tet_infoline("Testing Actor::UtcDaliActorSwitchParentP"); + TestApplication application; + + Actor parent1 = Actor::New(); + Actor child = Actor::New(); + + application.GetScene().Add(parent1); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION); + + child.OnSceneSignal().Connect(OnSceneCallback); + child.OffSceneSignal().Connect(OffSceneCallback); + + // sanity check + DALI_TEST_CHECK(gOnSceneCallBackCalled == 0); + DALI_TEST_CHECK(gOffSceneCallBackCalled == 0); + + parent1.Add(child); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION); + + DALI_TEST_CHECK(gOnSceneCallBackCalled == 1); + DALI_TEST_CHECK(gOffSceneCallBackCalled == 0); + + Actor parent2 = Actor::New(); + application.GetScene().Add(parent2); + + bool addSignalReceived = false; + ChildAddedSignalCheck addedSignal(addSignalReceived, child); + DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal); + DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION); + + bool removedSignalReceived = false; + ChildRemovedSignalCheck removedSignal(removedSignalReceived, child); + DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal); + DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION); + + DevelActor::SwitchParent(child, parent2); + + DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION); + DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION); + DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION); + + DALI_TEST_CHECK(gOnSceneCallBackCalled == 1); + DALI_TEST_CHECK(gOffSceneCallBackCalled == 0); + DALI_TEST_CHECK(child.GetProperty(Dali::Actor::Property::CONNECTED_TO_SCENE)); + DALI_TEST_CHECK(child.GetParent() == parent2); + + END_TEST; +} + int utcDaliActorCulled(void) { TestApplication application; @@ -7458,69 +8090,984 @@ int utcDaliActorGetSizeAfterAnimation(void) animation.Play(); application.SendNotification(); - application.Render(1100); // After the animation + application.Render(1100); // After the animation + + targetValue.width += offset.width; + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.width, actor.GetProperty(Actor::Property::SIZE_WIDTH), TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.height, actor.GetProperty(Actor::Property::SIZE_HEIGHT), TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty(Actor::Property::SIZE_DEPTH), TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty(Actor::Property::SIZE_WIDTH), TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty(Actor::Property::SIZE_HEIGHT), TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty(Actor::Property::SIZE_DEPTH), TEST_LOCATION); + + offset.height = 10.0f; + + animation.Clear(); + animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height); + animation.Play(); + + application.SendNotification(); + application.Render(1100); // After the animation + + targetValue.height += offset.height; + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.width, actor.GetProperty(Actor::Property::SIZE_WIDTH), TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.height, actor.GetProperty(Actor::Property::SIZE_HEIGHT), TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty(Actor::Property::SIZE_DEPTH), TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty(Actor::Property::SIZE_WIDTH), TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty(Actor::Property::SIZE_HEIGHT), TEST_LOCATION); + DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty(Actor::Property::SIZE_DEPTH), TEST_LOCATION); + + // Set size again + actorSize = Vector3(300.0f, 300.0f, 0.0f); + + actor.SetProperty(Actor::Property::SIZE, actorSize); + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + END_TEST; +} + +int utcDaliActorRelayoutAndAnimation(void) +{ + TestApplication application; + tet_infoline("Check the actor size when relayoutting and playing animation"); + + Vector3 parentSize(300.0f, 300.0f, 0.0f); + Vector3 actorSize(100.0f, 100.0f, 0.0f); + + { + Actor parentA = Actor::New(); + parentA.SetProperty(Actor::Property::SIZE, parentSize); + parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parentA); + + Actor parentB = Actor::New(); + parentB.SetProperty(Actor::Property::SIZE, parentSize); + parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parentB); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, actorSize); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + parentA.Add(actor); + + Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Vector3 targetValue(200.0f, 200.0f, 0.0f); + + Animation animation = Animation::New(1.0f); + animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue); + animation.Play(); + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + application.SendNotification(); + application.Render(1100); // After the animation + + // Size and current size should be updated. + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + // Trigger relayout + parentB.Add(actor); + + application.SendNotification(); + application.Render(); + + // Size and current size should be same. + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + actor.Unparent(); + parentA.Unparent(); + parentB.Unparent(); + } + + { + Actor parentA = Actor::New(); + parentA.SetProperty(Actor::Property::SIZE, parentSize); + parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parentA); + + Actor parentB = Actor::New(); + parentB.SetProperty(Actor::Property::SIZE, parentSize); + parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parentB); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, actorSize); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + parentA.Add(actor); + + Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Vector3 targetValue(200.0f, 200.0f, 0.0f); + + // Make an animation + Animation animation = Animation::New(1.0f); + animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue); + animation.Play(); + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + application.SendNotification(); + application.Render(1100); // After the animation + + // Size and current size should be updated. + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + // Trigger relayout + parentB.Add(actor); + + application.SendNotification(); + application.Render(); + + // Size and current size should be same. + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + actor.Unparent(); + parentA.Unparent(); + parentB.Unparent(); + } + + END_TEST; +} + +int utcDaliActorPartialUpdate(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"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + std::vector> damagedRects; + Rect clippingRect; + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + // First render pass, nothing to render, adaptor would just do swap buffer. + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + Actor actor = CreateRenderableActor(); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + application.SendNotification(); + + // 1. Actor added, damaged rect is added size of actor + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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); + 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); + + // 2. Set new size + actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0)); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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); + 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); + + // 3. Set new position + actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0)); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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); + 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); + + application.GetScene().Remove(actor); + application.SendNotification(); + + // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together. + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 3, 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); + + 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 utcDaliActorPartialUpdateSetColor(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Check uniform update"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + std::vector> damagedRects; + Rect clippingRect; + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + // First render pass, nothing to render, adaptor would just do swap buffer. + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + Actor actor = CreateRenderableActor(); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + application.SendNotification(); + + // 1. Actor added, damaged rect is added size of actor + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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); + 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); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + // 2. Set new color + actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f)); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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); + 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; +} + +const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix"); +const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix"); +const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor"); +const char* const RENDER_SHADOW_VERTEX_SOURCE = + " uniform mediump mat4 uLightCameraProjectionMatrix;\n" + " uniform mediump mat4 uLightCameraViewMatrix;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n" + " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n" + " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n" + "}\n"; + +const char* const RENDER_SHADOW_FRAGMENT_SOURCE = + "uniform lowp vec4 uShadowColor;\n" + "void main()\n" + "{\n" + " lowp float alpha;\n" + " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n" + " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n" + "}\n"; + +int utcDaliActorPartialUpdateSetProperty(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Set/Update property with partial update"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + std::vector> damagedRects; + Rect clippingRect; + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + // First render pass, nothing to render, adaptor would just do swap buffer. + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u); + Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + + damagedRects.clear(); + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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); + 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); + + Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME); + actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f)); + + damagedRects.clear(); + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], 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); + + // Should be no damage rects, nothing changed + damagedRects.clear(); + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Should be 1 damage rect due to change in size + damagedRects.clear(); + actor.SetProperty(Actor::Property::SIZE, Vector3(26.0f, 26.0f, 0.0f)); + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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); + 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); + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + END_TEST; +} + +int utcDaliActorPartialUpdateTwoActors(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 rects with partial update and two actors"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor actor = CreateRenderableActor(); + actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f)); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + Actor actor2 = CreateRenderableActor(); + actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f)); + actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f)); + actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor2); + + application.SendNotification(); + std::vector> damagedRects; + 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); + + // in screen coordinates, adaptor would calculate it using previous frames information + Rect clippingRect = Rect(64, 592, 144, 192); + 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); + + // Change a Renderer of actor1 + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer newRenderer = Renderer::New(geometry, shader); + Renderer renderer = actor.GetRendererAt(0); + + actor.RemoveRenderer(renderer); + actor.AddRenderer(newRenderer); + + damagedRects.clear(); + + application.SendNotification(); + 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); + + // in screen coordinates, adaptor would calculate it using previous frames information + 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 utcDaliActorPartialUpdateActorsWithSizeHint(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.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(64.0f, 64.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(32, 704, 80, 80); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], 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 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 = 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); + + // Make an animation + Animation animation = Animation::New(1.0f); + animation.AnimateTo(Property(actor2, Actor::Property::POSITION_X), 160.0f, TimePeriod(0.5f, 0.5f)); + animation.Play(); + + application.SendNotification(); + + damagedRects.clear(); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + drawTrace.Reset(); + damagedRects.clear(); + + // In animation deley time + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Skip rendering + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION); + + drawTrace.Reset(); + damagedRects.clear(); + + // Also in animation deley time + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.PreRenderWithPartialUpdate(100, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Skip rendering + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION); + + // Unparent 2 actors and make a new actor + actor1.Unparent(); + actor2.Unparent(); + + Actor actor3 = CreateRenderableActor(); + actor3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor3.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + application.GetScene().Add(actor3); + + application.SendNotification(); + + // Started animation + damagedRects.clear(); + application.PreRenderWithPartialUpdate(500, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 5, 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); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Finished animation, but the actor was already unparented + damagedRects.clear(); + application.PreRenderWithPartialUpdate(500, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DALI_TEST_EQUALS>(expectedRect2, damagedRects[0], TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + END_TEST; +} + +int utcDaliActorPartialUpdateChangeVisibility(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 visibility change"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor actor = CreateRenderableActor(); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + application.SendNotification(); + + std::vector> damagedRects; + Rect clippingRect; + + // 1. Actor added, damaged rect is added size of actor + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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); + 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); + + 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); + + // 2. Make the Actor invisible + actor.SetProperty(Actor::Property::VISIBLE, false); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_CHECK(damagedRects.size() > 0); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], 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); + + // 3. Make the Actor visible again + actor.SetProperty(Actor::Property::VISIBLE, true); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_CHECK(damagedRects.size() > 0); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], 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 utcDaliActorPartialUpdateOnOffScene(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 on/off scene"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor actor = CreateRenderableActor(); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + application.SendNotification(); + + std::vector> damagedRects; + Rect clippingRect; + + // 1. Actor added, damaged rect is added size of actor + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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); + 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); + + 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); + + // 2. Remove the Actor from the Scene + actor.Unparent(); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_CHECK(damagedRects.size() > 0); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], 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); + + // 3. Add the Actor to the Scene again + application.GetScene().Add(actor); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_CHECK(damagedRects.size() > 0); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], 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 utcDaliActorPartialUpdateSkipRendering(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Check to skip rendering in case of the empty damaged rect"); + + 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); + + std::vector> damagedRects; + Rect clippingRect; + Rect expectedRect1; + + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - targetValue.width += offset.width; + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - size = actor.GetProperty(Actor::Property::SIZE).Get(); - DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.width, actor.GetProperty(Actor::Property::SIZE_WIDTH), TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.height, actor.GetProperty(Actor::Property::SIZE_HEIGHT), TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty(Actor::Property::SIZE_DEPTH), 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); - currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); - DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty(Actor::Property::SIZE_WIDTH), TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty(Actor::Property::SIZE_HEIGHT), TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty(Actor::Property::SIZE_DEPTH), TEST_LOCATION); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); - offset.height = 10.0f; + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); - animation.Clear(); - animation.AnimateBy(Property(actor, Actor::Property::SIZE_HEIGHT), offset.height); - animation.Play(); + damagedRects.clear(); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Remove the actor + actor1.Unparent(); application.SendNotification(); - application.Render(1100); // After the animation - targetValue.height += offset.height; + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - size = actor.GetProperty(Actor::Property::SIZE).Get(); - DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.width, actor.GetProperty(Actor::Property::SIZE_WIDTH), TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.height, actor.GetProperty(Actor::Property::SIZE_HEIGHT), TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.depth, actor.GetProperty(Actor::Property::SIZE_DEPTH), TEST_LOCATION); + DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); - currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); - DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.width, actor.GetCurrentProperty(Actor::Property::SIZE_WIDTH), TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.height, actor.GetCurrentProperty(Actor::Property::SIZE_HEIGHT), TEST_LOCATION); - DALI_TEST_EQUALS(targetValue.depth, actor.GetCurrentProperty(Actor::Property::SIZE_DEPTH), TEST_LOCATION); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); - // Set size again - actorSize = Vector3(300.0f, 300.0f, 0.0f); + // Render again without any change + damagedRects.clear(); + drawTrace.Reset(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - actor.SetProperty(Actor::Property::SIZE, actorSize); + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); - size = actor.GetProperty(Actor::Property::SIZE).Get(); - DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + clippingRect = Rect(); + application.RenderWithPartialUpdate(damagedRects, clippingRect); - currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); - DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + // Skip rendering + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION); + + // Add the actor again + application.GetScene().Add(actor1); application.SendNotification(); - application.Render(); - size = actor.GetProperty(Actor::Property::SIZE).Get(); - DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + damagedRects.clear(); + drawTrace.Reset(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); - DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); END_TEST; } -int utcDaliActorPartialUpdate(void) +int utcDaliActorPartialUpdate3DNode(void) { TestApplication application( TestApplication::DEFAULT_SURFACE_WIDTH, @@ -7530,91 +9077,118 @@ int utcDaliActorPartialUpdate(void) true, true); - tet_infoline("Check the damaged area"); + tet_infoline("Partial update should be ignored in case of 3d layer of 3d node"); - const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + 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); std::vector> damagedRects; Rect clippingRect; + application.SendNotification(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - // First render pass, nothing to render, adaptor would just do swap buffer. - DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); - Actor actor = CreateRenderableActor(); - actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); - actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); - actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); - actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); - application.GetScene().Add(actor); + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + // Change the layer to 3D + application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D); application.SendNotification(); - // 1. Actor added, damaged rect is added size of actor damagedRects.clear(); 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); - // 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 = TestApplication::DEFAULT_SURFACE_RECT; + drawTrace.Reset(); 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); - // 2. Set new size - actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0)); + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + // Change the layer to 2D + application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI); + application.SendNotification(); damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + 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 = TestApplication::DEFAULT_SURFACE_RECT; 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); - // 3. Set new position - actor.SetProperty(Actor::Property::POSITION, Vector3(32.0f, 32.0f, 0)); + // Make 3D transform + actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS)); + application.SendNotification(); damagedRects.clear(); 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); - // 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 = TestApplication::DEFAULT_SURFACE_RECT; + drawTrace.Reset(); 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); - application.GetScene().Remove(actor); + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + END_TEST; +} + +int utcDaliActorPartialUpdateNotRenderableActor(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 not renderable parent actor"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor parent = Actor::New(); + parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f); + parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parent); + + Actor child = CreateRenderableActor(); + child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + parent.Add(child); + application.SendNotification(); - // Actor removed, last 3 dirty rects are reported. Adaptor would merge them together. - damagedRects.clear(); - application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - DALI_TEST_EQUALS(damagedRects.size(), 3, TEST_LOCATION); + std::vector> damagedRects; - clippingRect = damagedRects[0]; - clippingRect.Merge(damagedRects[1]); - clippingRect.Merge(damagedRects[2]); + // 1. Actor added, damaged rect is added size of actor + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - 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); + // 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); application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); @@ -7622,10 +9196,21 @@ int utcDaliActorPartialUpdate(void) 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); + + 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 utcDaliActorPartialUpdateSetColor(void) +int utcDaliActorPartialUpdateChangeTransparency(void) { TestApplication application( TestApplication::DEFAULT_SURFACE_WIDTH, @@ -7635,36 +9220,29 @@ int utcDaliActorPartialUpdateSetColor(void) true, true); - tet_infoline("Check uniform update"); + tet_infoline("Check the damaged rect with changing transparency"); const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); - std::vector> damagedRects; - Rect clippingRect; - application.SendNotification(); - application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - - // First render pass, nothing to render, adaptor would just do swap buffer. - DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); - application.RenderWithPartialUpdate(damagedRects, clippingRect); - - Actor actor = CreateRenderableActor(); - actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); - actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); - actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); + 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); application.SendNotification(); - // 1. Actor added, damaged rect is added size of actor - damagedRects.clear(); + 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(), 1, TEST_LOCATION); // Aligned by 16 - clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates + Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION); @@ -7673,54 +9251,88 @@ 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); + + // Make the actor transparent by changing opacity of the Renderer + // It changes a uniform value + Renderer renderer = actor.GetRendererAt(0); + renderer[DevelRenderer::Property::OPACITY] = 0.0f; + + application.SendNotification(); + + // 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); + + 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 opaque again + renderer[DevelRenderer::Property::OPACITY] = 1.0f; - // 2. Set new color - actor.SetProperty(Actor::Property::COLOR, Vector3(1.0f, 0.0f, 0.0f)); application.SendNotification(); + // 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); - // Aligned by 16 - clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates + 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); + + // Make the actor culled + actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f); + + application.SendNotification(); + + // 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); + + damagedRects.clear(); + 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); - END_TEST; -} + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); -const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME("uLightCameraProjectionMatrix"); -const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME("uLightCameraViewMatrix"); -const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME("uShadowColor"); -const char* const RENDER_SHADOW_VERTEX_SOURCE = - " uniform mediump mat4 uLightCameraProjectionMatrix;\n" - " uniform mediump mat4 uLightCameraViewMatrix;\n" - "\n" - "void main()\n" - "{\n" - " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n" - " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n" - " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n" - "}\n"; + // Make the actor not culled again + actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f); -const char* const RENDER_SHADOW_FRAGMENT_SOURCE = - "uniform lowp vec4 uShadowColor;\n" - "void main()\n" - "{\n" - " lowp float alpha;\n" - " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n" - " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n" - "}\n"; + application.SendNotification(); -int utcDaliActorPartialUpdateSetProperty(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); + + END_TEST; +} + +int utcDaliActorPartialUpdateChangeParentOpacity(void) { TestApplication application( TestApplication::DEFAULT_SURFACE_WIDTH, @@ -7730,77 +9342,69 @@ int utcDaliActorPartialUpdateSetProperty(void) true, true); - tet_infoline("Set/Update property with partial update"); + tet_infoline("Check the damaged rect with changing parent's opacity"); const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); - std::vector> damagedRects; - Rect clippingRect; - application.SendNotification(); - application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + Actor parent = Actor::New(); + parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f); + parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parent); - // First render pass, nothing to render, adaptor would just do swap buffer. - DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); - application.RenderWithPartialUpdate(damagedRects, clippingRect); + Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u); + Actor child = CreateRenderableActor(texture); + child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + parent.Add(child); - Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u); - Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE); - actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); - actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); - actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f)); - actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); - application.GetScene().Add(actor); + application.SendNotification(); - actor.RegisterProperty(SHADER_SHADOW_COLOR_PROPERTY_NAME, Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + std::vector> damagedRects; - damagedRects.clear(); - application.SendNotification(); + // Actor added, damaged rect is added size of actor application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); 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 + Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates DALI_TEST_EQUALS>(clippingRect, damagedRects[0], 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); - Property::Index shadowColorPropertyIndex = actor.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME); - actor.SetProperty(shadowColorPropertyIndex, Vector4(1.0f, 1.0f, 0.0f, 1.0f)); - damagedRects.clear(); - application.SendNotification(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], 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); - DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - - DALI_TEST_EQUALS>(clippingRect, damagedRects[0], 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); + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Change the parent's opacity + parent[Actor::Property::OPACITY] = 0.5f; + + application.SendNotification(); + + // The damaged rect should be same damagedRects.clear(); application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); - DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_CHECK(damagedRects.size() > 0); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); END_TEST; } -int utcDaliActorPartialUpdateTwoActors(void) +int utcDaliActorPartialAddRemoveRenderer(void) { TestApplication application( TestApplication::DEFAULT_SURFACE_WIDTH, @@ -7810,78 +9414,74 @@ int utcDaliActorPartialUpdateTwoActors(void) true, true); - tet_infoline("Check the damaged rects with partial update and two actors"); + tet_infoline("Check the damaged rect with adding / removing renderer"); const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); - Actor actor = CreateRenderableActor(); - actor.SetProperty(Actor::Property::POSITION, Vector3(100.0f, 100.0f, 0.0f)); - actor.SetProperty(Actor::Property::SIZE, Vector3(50.0f, 50.0f, 0.0f)); + 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); - Actor actor2 = CreateRenderableActor(); - actor2.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f)); - actor2.SetProperty(Actor::Property::SIZE, Vector3(100.0f, 100.0f, 0.0f)); - actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); - application.GetScene().Add(actor2); - application.SendNotification(); + std::vector> damagedRects; - 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); + // Actor added, damaged rect is added size of actor + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - // in screen coordinates, adaptor would calculate it using previous frames information - Rect clippingRect = Rect(64, 592, 144, 192); - application.RenderWithPartialUpdate(damagedRects, clippingRect); + // 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); + 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 utcDaliActorPartialUpdateActorsWithSizeHint(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"); + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); - const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); - Actor actor = CreateRenderableActor(); - actor.SetProperty(Actor::Property::POSITION, Vector3(75.0f, 150.0f, 0.0f)); - actor.SetProperty(Actor::Property::SIZE, Vector3(75.0f, 150.0f, 0.0f)); - actor.SetProperty(DevelActor::Property::UPDATE_SIZE_HINT, Vector3(150, 300, 0)); - actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); - application.GetScene().Add(actor); + // Remove the Renderer + Renderer renderer = actor.GetRendererAt(0); + actor.RemoveRenderer(renderer); application.SendNotification(); - std::vector> damagedRects; - application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); - - DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); - Rect clippingRect = Rect(0, 496, 160, 320); + // The damaged rect should be the actor area + 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); + damagedRects.clear(); + 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); + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Add the Renderer again + actor.AddRenderer(renderer); + + application.SendNotification(); + + // The damaged rect should be the actor area + 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); END_TEST; } @@ -7926,20 +9526,20 @@ int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void) END_TEST; } -int UtcDaliActorTouchAreaPropertyP(void) +int UtcDaliActorTouchAreaOffsetPropertyP(void) { TestApplication application; - Actor actor = Actor::New(); - Vector2 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get(); - DALI_TEST_EQUALS(touchArea, Vector2::ZERO, TEST_LOCATION); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(10.f, 10.f)); - touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get(); - DALI_TEST_EQUALS(touchArea, Vector2(10.f, 10.f), TEST_LOCATION); + 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 UtcDaliActorTouchAreaPropertyN(void) +int UtcDaliActorTouchAreaOffsetPropertyN(void) { TestApplication application; @@ -7948,12 +9548,12 @@ int UtcDaliActorTouchAreaPropertyN(void) // Make sure setting invalid types does not cause a crash try { - actor.SetProperty(DevelActor::Property::TOUCH_AREA, 1.0f); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2::ONE); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector3::ONE); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector4::ONE); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Map()); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Array()); + 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(...) @@ -8612,3 +10212,206 @@ int UtcDaliActorGetParentNegative(void) } END_TEST; } + +int UtcDaliActorPropertyBlendEquation(void) +{ + TestApplication application; + + 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)) + { + 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); + } + + 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); + } + + 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 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); + + ResetTouchCallbacks(); + gHitTestTouchCallBackCalled = false; + ++index; + } + END_TEST; +}