X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-AnimatedVectorImageVisual.cpp;h=81369558364ba17a077984e201b86ae3bfb53c3d;hb=be815828da2f1406a3e2f1641d6a65d29843adef;hp=09a4dd4e66c27feb0c2744145d95759fd8df2ce8;hpb=3568dcdc24a8deae9d9d954c3f3ef433de9a7474;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp index 09a4dd4..8136955 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) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -190,6 +190,7 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map"); int startFrame = 1, endFrame = 3; + int desiredWidth = 100, desiredHeight = 150; float cornerRadius = 22.0f; float borderlineWidth = 2.0f; Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f); @@ -210,7 +211,9 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) .Add("borderlineWidth", borderlineWidth) .Add("borderlineColor", borderlineColor) .Add("borderlineOffset", borderlineOffset) - .Add("synchronousLoading", true); + .Add("desiredWidth", desiredWidth) + .Add("desiredHeight", desiredHeight) + .Add("useFixedCache", false); Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); DALI_TEST_CHECK(visual); @@ -286,6 +289,14 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) DALI_TEST_CHECK(value); DALI_TEST_EQUALS(value->Get(), borderlineOffset, TEST_LOCATION); + value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER); + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), desiredWidth, TEST_LOCATION); + + value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER); + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), desiredHeight, TEST_LOCATION); + actor.Unparent(); DALI_TEST_CHECK(actor.GetRendererCount() == 0u); @@ -298,6 +309,7 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01"); int startFrame = 1, endFrame = 3; + int desiredWidth = 100, desiredHeight = 150; Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f); float borderlineWidth = 2.3f; Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f); @@ -316,7 +328,9 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) .Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth) .Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor) .Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset) - .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false); + .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false) + .Add(ImageVisual::Property::DESIRED_WIDTH, desiredWidth) + .Add(ImageVisual::Property::DESIRED_HEIGHT, desiredHeight); // request AnimatedVectorImageVisual with a property map VisualFactory factory = VisualFactory::Get(); @@ -373,6 +387,13 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP); DALI_TEST_CHECK(value); + value = resultMap.Find(DevelImageVisual::Property::MARKER_INFO, Property::MAP); + DALI_TEST_CHECK(value); + + value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, 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 @@ -397,6 +418,14 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) DALI_TEST_CHECK(value); DALI_TEST_EQUALS(value->Get(), borderlineOffset, TEST_LOCATION); + value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER); + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), desiredWidth, TEST_LOCATION); + + value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER); + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), desiredHeight, TEST_LOCATION); + // request AnimatedVectorImageVisual with an URL Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions()); @@ -817,6 +846,7 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) ToolkitTestApplication application; tet_infoline("UtcDaliAnimatedVectorImageVisualPlayRangeMarker"); + // Set 1 marker as array Property::Array array; array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1); @@ -863,6 +893,31 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION); + // Set 1 marker as string + array.Clear(); + + attributes.Clear(); + attributes.Add(DevelImageVisual::Property::PLAY_RANGE, VECTOR_ANIMATION_MARKER_NAME_1); + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); + + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(40.0f, 40.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(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); + DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION); + // Set 2 markers array.Clear(); array.PushBack(VECTOR_ANIMATION_MARKER_NAME_1); @@ -920,6 +975,224 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) END_TEST; } +int UtcDaliAnimatedVectorImageVisualMarkerInfo(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfo"); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME) + .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); + + Vector2 controlSize(20.f, 30.f); + actor.SetProperty(Actor::Property::SIZE, controlSize); + + application.GetScene().Add(actor); + + Property::Map attributes; + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes); + + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + // renderer is added to actor + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + Renderer renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); + Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO); + + DALI_TEST_CHECK(value); + + Property::Map* result = value->GetMap(); + DALI_TEST_CHECK(result); + + std::string resultMarkerName; + int resultStartFrame, resultEndFrame; + DALI_TEST_EQUALS(2u, result->Count(), TEST_LOCATION); + + for(uint32_t i = 0u; i < result->Count(); ++i) + { + if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_1) + { + Property::Array* frameArray = result->GetValue(i).GetArray(); + DALI_TEST_CHECK(frameArray); + frameArray->GetElementAt(0).Get(resultStartFrame); + frameArray->GetElementAt(1).Get(resultEndFrame); + + DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION); + DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION); + } + else if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_2) + { + Property::Array* frameArray = result->GetValue(i).GetArray(); + DALI_TEST_CHECK(frameArray); + frameArray->GetElementAt(0).Get(resultStartFrame); + frameArray->GetElementAt(1).Get(resultEndFrame); + + DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_2, resultStartFrame, TEST_LOCATION); + DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION); + } + else + { + DALI_TEST_CHECK(false); + } + } + + END_TEST; +} + +int UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfoFromInvalid"); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, "invalid.json") + .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); + + Vector2 controlSize(20.f, 30.f); + actor.SetProperty(Actor::Property::SIZE, controlSize); + + application.GetScene().Add(actor); + + Property::Map attributes; + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes); + + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - load, and failed. + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + // renderer is added to actor + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + Renderer renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); + Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO); + + // The values when load failed case is invalid. + DALI_TEST_CHECK(value == nullptr || (value->GetMap() == nullptr) || (value->GetMap()->Empty())); + + END_TEST; +} + +int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCache"); + + 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::ENABLE_FRAME_CACHE, 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); + //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 + 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 - load + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + // renderer is added to actor + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + Renderer renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); + Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE); + DALI_TEST_CHECK(value->Get() == true); + + END_TEST; +} + +int UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed"); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME) + .Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, 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); + + Vector2 controlSize(200.f, 200.f); + actor.SetProperty(Actor::Property::SIZE, controlSize); + + application.GetScene().Add(actor); + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - load, and failed. + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + // renderer is added to actor + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + Renderer renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + propertyMap.Clear(); + propertyMap.Add(DevelImageVisual::Property::ENABLE_FRAME_CACHE, true) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME) + .Add(ImageVisual::Property::DESIRED_WIDTH, 100) + .Add(ImageVisual::Property::DESIRED_HEIGHT, 100); + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap); + + Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); + Property::Value* value = map.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE); + DALI_TEST_CHECK(value->Get() == true); + + END_TEST; +} + int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void) { ToolkitTestApplication application; @@ -927,8 +1200,7 @@ int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void) 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::LOOP_COUNT, 3); + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME); Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); DALI_TEST_CHECK(visual); @@ -944,14 +1216,24 @@ int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void) application.GetScene().Add(actor); + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + propertyMap.Clear(); + propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3); + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap); + Property::Map attributes; DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes); application.SendNotification(); application.Render(); - // Wait for animation finish - render, finish - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // Wait for animation finish + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE); @@ -1222,8 +1504,6 @@ int UtcDaliAnimatedVectorImageVisualStopBehavior(void) 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::LOOP_COUNT, 3) - .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME) .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false); Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); @@ -1238,14 +1518,25 @@ int UtcDaliAnimatedVectorImageVisualStopBehavior(void) application.GetScene().Add(actor); + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + propertyMap.Clear(); + propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3); + propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME); + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap); + Property::Map attributes; DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes); application.SendNotification(); application.Render(); - // Trigger count is 3 - load, render, animation finished - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION); + // Trigger count is 1 - animation finished + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -1330,9 +1621,6 @@ int UtcDaliAnimatedVectorImageVisualLoopingMode(void) 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::LOOP_COUNT, 3) - .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME) - .Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE) .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false); Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); @@ -1347,14 +1635,26 @@ int UtcDaliAnimatedVectorImageVisualLoopingMode(void) application.GetScene().Add(actor); + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - load, render + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + propertyMap.Clear(); + propertyMap.Add(DevelImageVisual::Property::LOOP_COUNT, 3); + propertyMap.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME); + propertyMap.Add(DevelImageVisual::Property::LOOPING_MODE, DevelImageVisual::LoopingMode::AUTO_REVERSE); + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap); + Property::Map attributes; DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes); application.SendNotification(); application.Render(); - // Trigger count is 3 - load, render, animation finished - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION); + // Trigger count is 1 - animation finished + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -1519,6 +1819,12 @@ int UtcDaliAnimatedVectorImageVisualMultipleInstances(void) application.GetScene().Add(actor1); + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + propertyMap.Clear(); propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME) @@ -1538,8 +1844,8 @@ int UtcDaliAnimatedVectorImageVisualMultipleInstances(void) application.SendNotification(); application.Render(); - // Trigger count is 4 - load & render a frame for each instance - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map()); @@ -1951,6 +2257,9 @@ int UtcDaliAnimatedVectorImageVisualDynamicProperty(void) DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + Vector2 controlSize(20.f, 30.f); + actor.SetProperty(Actor::Property::SIZE, controlSize); + application.GetScene().Add(actor); gDynamicPropertyCallbackFired = false; @@ -1978,3 +2287,218 @@ int UtcDaliAnimatedVectorImageVisualDynamicProperty(void) END_TEST; } + +int UtcDaliAnimatedVectorImageVisualDesiredSize(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize"); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + int desiredWidth = 150, desiredHeight = 200; + + Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight)); + 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 - resource ready + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + textureTrace.Enable(true); + + application.SendNotification(); + application.Render(); + + { + std::stringstream out; + out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight; + DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); + } + + // Unparent to make next trigger + actor.Unparent(); + + application.SendNotification(); + application.Render(); + + // Set visual size + actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f)); + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - resource ready + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + textureTrace.Reset(); + + application.SendNotification(); + application.Render(); + + { + std::stringstream out; + out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight; + DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed + } + + END_TEST; +} + +int UtcDaliAnimatedVectorImageVisualFlushAction(void) +{ + ToolkitTestApplication application; + + tet_infoline("UtcDaliAnimatedVectorImageVisualFlushAction"); + + int startFrame = 1; + int endFrame = 2; + + int totalFrameCount = 0; + + Property::Array playRange; + playRange.PushBack(startFrame); + playRange.PushBack(endFrame); + + Property::Map resultMap; + Property::Value* value = nullptr; + + // request AnimatedVectorImageVisual with a property map + VisualFactory factory = VisualFactory::Get(); + Visual::Base visual = factory.CreateVisual( + Property::Map() + .Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME) + .Add(DevelImageVisual::Property::PLAY_RANGE, playRange) + .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true)); + + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + + 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; + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes); + + application.SendNotification(); + application.Render(16); + + do + { + resultMap = dummyControl.GetProperty(DummyControl::Property::TEST_VISUAL); + + value = resultMap.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER, Property::INTEGER); + DALI_TEST_CHECK(value); + totalFrameCount = value->Get(); + } while(totalFrameCount == 0); + + // Ensure that vector data sended well. + CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}}); + + resultMap = dummyControl.GetProperty(DummyControl::Property::TEST_VISUAL); + + value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER); + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), startFrame, TEST_LOCATION); + + tet_printf("Now logically, range : [%d~%d], current : %d\n", startFrame, endFrame, startFrame); + + int changedStartFrame1 = startFrame + 2; + int changedEndFrame1 = endFrame + 2; + + playRange.Clear(); + playRange.Add(changedStartFrame1); + playRange.Add(changedEndFrame1); + + tet_printf("Change play range\n"); + attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange); + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); + + tet_printf("Jump to changedEndFrame!\n"); + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, changedEndFrame1); + + attributes.Clear(); + tet_infoline("Flush Action!"); + tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame1, changedEndFrame1, changedEndFrame1); + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::FLUSH, attributes); + + int changedStartFrame2 = startFrame + 1; + int changedEndFrame2 = endFrame + 1; + + playRange.Clear(); + playRange.Add(changedStartFrame2); + playRange.Add(changedEndFrame2); + + tet_printf("Change play range again\n"); + tet_printf("Now logically, range : [%d~%d], current : %d\n", changedStartFrame2, changedEndFrame2, changedEndFrame2); + attributes.Add(DevelImageVisual::Property::PLAY_RANGE, playRange); + DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); + + application.SendNotification(); + application.Render(16); + + // Ensure that vector data sended well. + CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}}); + + resultMap = dummyControl.GetProperty(DummyControl::Property::TEST_VISUAL); + + tet_printf("Test whether current frame number changed well. If Flush not works, current frame become startFrame."); + value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER); + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), changedEndFrame2, TEST_LOCATION); + + dummyControl.Unparent(); + + END_TEST; +} \ No newline at end of file