X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-AnimatedVectorImageVisual.cpp;h=b692ebb94daf50cac63214cae7ae54fc0bfb39ba;hp=81369558364ba17a077984e201b86ae3bfb53c3d;hb=HEAD;hpb=aa5eeb204d936237424e8879813d6213735d2cb0 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp index 8136955..55891b8 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -24,6 +24,7 @@ #include #include #include "dummy-control.h" +#include "test-native-image-source.h" #include @@ -68,6 +69,100 @@ void VisualEventSignal(Control control, Dali::Property::Index visualIndex, Dali: } } +/** + * @brief Retry function to get playrange until expect values comes. + * @note This function might consume EventThreadTrigger. + * + * @param[in] dummyControl The control for test. + * @param[in] expectStartFrame Expect start frame. + * @param[in] expectEndFrame Expect end frame. + * @param[in] retrialFrames Retry required frame value list. + * @param[in] testLocation Location info of UTC. It will be used when UTC failed. + */ +void CheckAndRetryPlayRange(DummyControl dummyControl, int expectStartFrame, int expectEndFrame, std::vector> retrialFrames, const char* testLocation) +{ + int tryCount = 0; + int tryCountMax = 25; + while(++tryCount <= tryCountMax) + { + Property::Map resultMap = dummyControl.GetProperty(DummyControl::Property::TEST_VISUAL); + + Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY); + DALI_TEST_CHECK(value); + + Property::Array* result = value->GetArray(); + DALI_TEST_CHECK(result); + DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION); + + bool tryAgain = false; + for(auto& framePair : retrialFrames) + { + if(result->GetElementAt(0).Get() == framePair.first && result->GetElementAt(1).Get() == framePair.second) + { + tryAgain = true; + break; + } + } + if(tryAgain) + { + tet_printf("Retry to get value again! [%d]\n", tryCount); + // Dummy sleep 1 second. + Test::WaitForEventThreadTrigger(1, 1); + continue; + } + + DALI_TEST_EQUALS(result->GetElementAt(0).Get(), expectStartFrame, testLocation); + DALI_TEST_EQUALS(result->GetElementAt(1).Get(), expectEndFrame, testLocation); + break; + } + DALI_TEST_CHECK(tryCount <= tryCountMax); +} + +/** + * @brief Retry function to get current frame until expect values comes. + * @note This function might consume EventThreadTrigger. + * + * @param[in] dummyControl The control for test. + * @param[in] expectCurrentFrame Expect current frame. + * @param[in] retrialFrames Retry required frame value list. + * @param[in] testLocation Location info of UTC. It will be used when UTC failed. + */ +void CheckAndRetryCurrentFrame(DummyControl dummyControl, int expectCurrentFrame, std::vector retrialFrames, const char* testLocation) +{ + int tryCount = 0; + int tryCountMax = 25; + while(++tryCount <= tryCountMax) + { + Property::Map resultMap = dummyControl.GetProperty(DummyControl::Property::TEST_VISUAL); + + Property::Value* value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER); + DALI_TEST_CHECK(value); + + int32_t result = value->Get(); + + bool tryAgain = false; + for(auto& frame : retrialFrames) + { + if(result == frame) + { + tryAgain = true; + break; + } + } + if(tryAgain) + { + tet_printf("Retry to get value again! [%d]\n", tryCount); + // Dummy sleep 1 second. + Test::WaitForEventThreadTrigger(1, 1); + continue; + } + + DALI_TEST_EQUALS(result, expectCurrentFrame, testLocation); + break; + } + DALI_TEST_CHECK(tryCount <= tryCountMax); +} + } // namespace int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void) @@ -173,8 +268,17 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void) // Trigger count is 2 - load & render a frame DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // There might be 1 event triggered if start frame is not 0, and render frame spend long time. + // if ForceRenderOnce triggered before render complete, renderer count could be zero. + // Consume it if required. + if(actor.GetRendererCount() == 0) + { + tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n"); + Test::WaitForEventThreadTrigger(1, 1); + } + // renderer is added to actor - DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0u); DALI_TEST_CHECK(renderer); @@ -207,13 +311,14 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) .Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME) .Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE) .Add("redrawInScalingDown", false) + .Add("enableFrameCache", false) + .Add("notifyAfterRasterization", false) .Add("cornerRadius", cornerRadius) .Add("borderlineWidth", borderlineWidth) .Add("borderlineColor", borderlineColor) .Add("borderlineOffset", borderlineOffset) .Add("desiredWidth", desiredWidth) - .Add("desiredHeight", desiredHeight) - .Add("useFixedCache", false); + .Add("desiredHeight", desiredHeight); Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); DALI_TEST_CHECK(visual); @@ -230,8 +335,17 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) // Trigger count is 1 - render a frame DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // There might be 1 event triggered if start frame is not 0, and render frame spend long time. + // if ForceRenderOnce triggered before render complete, renderer count could be zero. + // Consume it if required. + if(actor.GetRendererCount() == 0) + { + tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n"); + Test::WaitForEventThreadTrigger(1, 1); + } + // renderer is added to actor - DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0u); DALI_TEST_CHECK(renderer); @@ -269,6 +383,14 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) DALI_TEST_CHECK(value); DALI_TEST_CHECK(value->Get() == false); + value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, Property::BOOLEAN); + DALI_TEST_CHECK(value); + DALI_TEST_CHECK(value->Get() == false); + + value = resultMap.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, Property::BOOLEAN); + DALI_TEST_CHECK(value); + DALI_TEST_CHECK(value->Get() == false); + value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4); DALI_TEST_CHECK(value); DALI_TEST_EQUALS(value->Get(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION); @@ -394,6 +516,10 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) DALI_TEST_CHECK(value); DALI_TEST_CHECK(value->Get() == false); // Check default value + value = resultMap.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, Property::BOOLEAN); + DALI_TEST_CHECK(value); + DALI_TEST_CHECK(value->Get() == false); // Check default value + value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN); DALI_TEST_CHECK(value); DALI_TEST_CHECK(value->Get() == true); // Check default value @@ -702,7 +828,7 @@ int UtcDaliAnimatedVectorImageVisualLoopCount(void) DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); // renderer is added to actor - DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0u); DALI_TEST_CHECK(renderer); @@ -746,8 +872,17 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) // Trigger count is 2 - load & render a frame DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // There might be 1 event triggered if start frame is not 0, and render frame spend long time. + // if ForceRenderOnce triggered before render complete, renderer count could be zero. + // Consume it if required. + if(actor.GetRendererCount() == 0) + { + tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n"); + Test::WaitForEventThreadTrigger(1, 1); + } + // renderer is added to actor - DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0u); DALI_TEST_CHECK(renderer); @@ -766,7 +901,7 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) // Set invalid play range array.Clear(); array.PushBack(1); - array.PushBack(100); + array.PushBack(totalFrameNumber + 100); attributes.Clear(); attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array); @@ -780,15 +915,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); - map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); - value = map.Find(DevelImageVisual::Property::PLAY_RANGE); - - result = value->GetArray(); - result->GetElementAt(0).Get(resultStartFrame); - result->GetElementAt(1).Get(resultEndFrame); - - DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION); - DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped + // Should be clamped. + CheckAndRetryPlayRange(actor, 1, totalFrameNumber - 1, {{startFrame, endFrame}}, TEST_LOCATION); DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map()); @@ -797,17 +925,14 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3); - // To make event trigger - actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); - application.SendNotification(); application.Render(); + // Jump to action when paused, will make one or more event trigger DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); - map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); - value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); - DALI_TEST_EQUALS(value->Get(), 3, TEST_LOCATION); + // Test whether current frame is 3. + CheckAndRetryCurrentFrame(actor, 3, {0, 1}, TEST_LOCATION); array.Clear(); array.PushBack(0); @@ -818,23 +943,16 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); // To make event trigger - actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); application.SendNotification(); application.Render(); DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); - map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); - value = map.Find(DevelImageVisual::Property::PLAY_RANGE); - - result = value->GetArray(); - result->GetElementAt(0).Get(resultStartFrame); - result->GetElementAt(1).Get(resultEndFrame); - - DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION); - DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION); + CheckAndRetryPlayRange(actor, 0, 2, {{1, totalFrameNumber - 1}}, TEST_LOCATION); + map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); DALI_TEST_EQUALS(value->Get(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also. @@ -877,8 +995,17 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) // Trigger count is 2 - load & render a frame DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // There might be 1 event triggered if start frame is not 0, and render frame spend long time. + // if ForceRenderOnce triggered before render complete, renderer count could be zero. + // Consume it if required. + if(actor.GetRendererCount() == 0) + { + tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n"); + Test::WaitForEventThreadTrigger(1, 1); + } + // renderer is added to actor - DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0u); DALI_TEST_CHECK(renderer); @@ -1007,7 +1134,7 @@ int UtcDaliAnimatedVectorImageVisualMarkerInfo(void) DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); // renderer is added to actor - DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); Renderer renderer = actor.GetRendererAt(0u); DALI_TEST_CHECK(renderer); @@ -1099,10 +1226,10 @@ int UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid(void) END_TEST; } -int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void) +int UtcDaliAnimatedVectorImageVisualEnableFrameCache(void) { ToolkitTestApplication application; - tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCache"); + tet_infoline("UtcDaliAnimatedVectorImageVisualEnableFrameCache"); Property::Map propertyMap; propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) @@ -1116,13 +1243,12 @@ int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void) DummyControl actor = DummyControl::New(true); DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); - //actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); application.GetScene().Add(actor); application.SendNotification(); application.Render(); - // Trigger count is 1 - render a frame + // Trigger count is 1 - load DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); Vector2 controlSize(200.f, 200.f); @@ -1131,7 +1257,7 @@ int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void) application.SendNotification(); application.Render(); - // Trigger count is 1 - load + // Trigger count is 1 - render a frame DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); // renderer is added to actor @@ -1146,10 +1272,10 @@ int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void) END_TEST; } -int UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed(void) +int UtcDaliAnimatedVectorImageVisualEnableFrameCacheFailed(void) { ToolkitTestApplication application; - tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed"); + tet_infoline("UtcDaliAnimatedVectorImageVisualEnableFrameCacheFailed"); Property::Map propertyMap; propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) @@ -1193,6 +1319,100 @@ int UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed(void) END_TEST; } +int UtcDaliAnimatedVectorImageVisualNotifyAfterRasterization(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedVectorImageVisualNotifyAfterRasterization"); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME) + .Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, true) + .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false); + + Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); + DALI_TEST_CHECK(visual); + + DummyControl actor = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - load + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + Vector2 controlSize(200.f, 200.f); + actor.SetProperty(Actor::Property::SIZE, controlSize); + + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + // Play animation + Property::Map attributes; + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes); + + application.SendNotification(); + application.Render(); + + // There might be 1 event triggered if render frame spend long time. + // if ForceRenderOnce triggered before render complete, renderer count could be zero. + // Consume it if required. + if(actor.GetRendererCount() == 0) + { + tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n"); + Test::WaitForEventThreadTrigger(1, 1); + } + + // renderer is added to actor + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + Renderer renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + // Check renderer behavior + DALI_TEST_CHECK(renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED); + + Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); + Property::Value* value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION); + DALI_TEST_CHECK(value->Get() == true); + + propertyMap.Clear(); + propertyMap.Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, false); + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap); + + application.SendNotification(); + application.Render(); + + // Check renderer behavior again + DALI_TEST_CHECK(renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY); + + map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); + value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION); + DALI_TEST_CHECK(value->Get() == false); + + propertyMap.Clear(); + propertyMap.Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, true); + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap); + + application.SendNotification(); + application.Render(); + + // Check renderer behavior again + DALI_TEST_CHECK(renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED); + + map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); + value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION); + DALI_TEST_CHECK(value->Get() == true); + + END_TEST; +} + int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void) { ToolkitTestApplication application; @@ -1277,12 +1497,10 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2); - // To make event trigger - actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); - application.SendNotification(); application.Render(); + // Trigger count is 1 - Jump to during stopped DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); @@ -1302,7 +1520,7 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3); // To make event trigger - actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); + actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); application.SendNotification(); application.Render(); @@ -1333,16 +1551,16 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) // Wait for animation finish DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Note : AnimationFinished will occure force-render, and it might required another trigger. Test one more trigger now. + Test::WaitForEventThreadTrigger(1, 1); // Jump to 3 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3); - // To make event trigger - actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); - application.SendNotification(); application.Render(); + // Trigger count is 1 - Jump to during stopped. DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); @@ -1416,8 +1634,8 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) Property::Array* result = value->GetArray(); DALI_TEST_CHECK(result); - DALI_TEST_CHECK(result->GetElementAt(0).Get() == startFrame); - DALI_TEST_CHECK(result->GetElementAt(1).Get() == endFrame); + DALI_TEST_EQUALS(result->GetElementAt(0).Get(), startFrame, TEST_LOCATION); + DALI_TEST_EQUALS(result->GetElementAt(1).Get(), endFrame, TEST_LOCATION); playRange.Clear(); playRange.PushBack(0); @@ -1445,8 +1663,8 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) result = value->GetArray(); DALI_TEST_CHECK(result); - DALI_TEST_CHECK(result->GetElementAt(0).Get() == 0); - DALI_TEST_CHECK(result->GetElementAt(1).Get() == 2); + // Ensure that vector data sended well. + CheckAndRetryPlayRange(actor, 0, 2, {{startFrame, endFrame}}, TEST_LOCATION); attributes.Clear(); @@ -1472,8 +1690,8 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) result = value->GetArray(); DALI_TEST_CHECK(result); - DALI_TEST_CHECK(result->GetElementAt(0).Get() == startFrame); - DALI_TEST_CHECK(result->GetElementAt(1).Get() == endFrame); + // Ensure that vector data sended well. + CheckAndRetryPlayRange(actor, startFrame, endFrame, {{0, 2}}, TEST_LOCATION); // Play and update property attributes.Clear(); @@ -2387,45 +2605,6 @@ int UtcDaliAnimatedVectorImageVisualFlushAction(void) application.GetScene().Add(dummyControl); - // Retry function to get playrange until expect values comes. - auto CheckAndRetryPlayRange = [&](int expectStartFrame, int expectEndFrame, std::vector> retrialFrames) { - int tryCount = 0; - int tryCountMax = 30; - while(++tryCount <= tryCountMax) - { - Property::Map resultMap = dummyControl.GetProperty(DummyControl::Property::TEST_VISUAL); - - Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY); - DALI_TEST_CHECK(value); - - Property::Array* result = value->GetArray(); - DALI_TEST_CHECK(result); - DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION); - - bool tryAgain = false; - for(auto& framePair : retrialFrames) - { - if(result->GetElementAt(0).Get() == framePair.first && result->GetElementAt(1).Get() == framePair.second) - { - tryAgain = true; - break; - } - } - if(tryAgain) - { - tet_printf("Retry to get value again! [%d]\n", tryCount); - // Dummy sleep 1 second. - Test::WaitForEventThreadTrigger(1, 1); - continue; - } - - DALI_TEST_EQUALS(result->GetElementAt(0).Get(), expectStartFrame, TEST_LOCATION); - DALI_TEST_EQUALS(result->GetElementAt(1).Get(), expectEndFrame, TEST_LOCATION); - break; - } - DALI_TEST_CHECK(tryCount <= tryCountMax); - }; - tet_printf("Pause lottie first.\n"); Property::Map attributes; @@ -2444,7 +2623,7 @@ int UtcDaliAnimatedVectorImageVisualFlushAction(void) } while(totalFrameCount == 0); // Ensure that vector data sended well. - CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}}); + CheckAndRetryPlayRange(dummyControl, startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}}, TEST_LOCATION); resultMap = dummyControl.GetProperty(DummyControl::Property::TEST_VISUAL); @@ -2489,7 +2668,7 @@ int UtcDaliAnimatedVectorImageVisualFlushAction(void) application.Render(16); // Ensure that vector data sended well. - CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}}); + CheckAndRetryPlayRange(dummyControl, changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}}, TEST_LOCATION); resultMap = dummyControl.GetProperty(DummyControl::Property::TEST_VISUAL); @@ -2501,4 +2680,48 @@ int UtcDaliAnimatedVectorImageVisualFlushAction(void) dummyControl.Unparent(); END_TEST; +} + +int UtcDaliAnimatedVectorImageNativeTextureChangeShader(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedVectorImageNativeTextureChangeShader"); + + VisualFactory factory = VisualFactory::Get(); + Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions()); + DALI_TEST_CHECK(visual); + + DummyControl actor = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + // Make we use native texture now. + Test::VectorAnimationRenderer::UseNativeImageTexture(true); + + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - resource ready + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + Renderer renderer = actor.GetRendererAt(0); + Shader shader = renderer.GetShader(); + Property::Value value = shader.GetProperty(Shader::Property::PROGRAM); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK(map); + + std::string resultFragmentShader, resultVertexShader; + Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp + fragment->Get(resultFragmentShader); + DALI_TEST_CHECK(resultFragmentShader.find(NativeImageSourceTest::GetCustomFragmentPrefix()) != std::string::npos); + + // Reset to make we use normal texture again. + Test::VectorAnimationRenderer::UseNativeImageTexture(false); + + END_TEST; } \ No newline at end of file