+#include <stdlib.h>
+#include <iostream>
+
+#include <dali-toolkit-test-suite-utils.h>
+
+#include <toolkit-event-thread-callback.h>
+#include <toolkit-timer.h>
+
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+
+#include "dummy-control.h"
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+void dali_animated_image_visual_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_animated_image_visual_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/application-icon-%02d.png";
+const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
+const char* TEST_MASK_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/mask.png";
+const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp";
+} // namespace
+
+void CopyUrlsIntoArray(Property::Array& urls, int startIndex = 0)
+{
+ for(int i = 20 + startIndex; i <= 30; ++i)
+ {
+ char* url;
+ if(asprintf(&url, TEST_IMAGE_FILE_NAME, i) > 0)
+ {
+ Property::Value value(url);
+ urls.Add(value);
+ free(url);
+ }
+ }
+}
+
+int UtcDaliAnimatedImageVisualGetPropertyMap01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap");
+
+ // request AnimatedImageVisual with a property map
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base animatedImageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
+ .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
+ .Add(ImageVisual::Property::PIXEL_AREA, Vector4())
+ .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT)
+ .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT)
+ .Add(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME)
+ .Add(ImageVisual::Property::MASK_CONTENT_SCALE, 1.6f)
+ .Add(ImageVisual::Property::CROP_TO_MASK, true)
+ .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
+ .Add(DevelVisual::Property::CORNER_RADIUS, 22.2f)
+ .Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE)
+ .Add(DevelVisual::Property::BORDERLINE_WIDTH, 33.3f)
+ .Add(DevelVisual::Property::BORDERLINE_COLOR, Color::RED)
+ .Add(DevelVisual::Property::BORDERLINE_OFFSET, 0.3f));
+
+ Property::Map resultMap;
+ animatedImageVisual.CreatePropertyMap(resultMap);
+ // check the property values from the returned map from a visual
+ Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
+
+ value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
+
+ value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(22.2f, 22.2f, 22.2f, 22.2f), TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
+
+ value = resultMap.Find(DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 33.3f, TEST_LOCATION);
+
+ value = resultMap.Find(DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<Vector4>(), Color::RED, TEST_LOCATION);
+
+ value = resultMap.Find(DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 0.3f, TEST_LOCATION);
+
+ // Check mask properties
+ value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, Property::STRING);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
+
+ value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, Property::FLOAT);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, Property::BOOLEAN);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
+
+ value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
+ Vector2 naturalSize;
+ animatedImageVisual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(100, 100), TEST_LOCATION);
+
+ // request AnimatedImageVisual with an URL
+ Visual::Base animatedImageVisual2 = factory.CreateVisual(TEST_GIF_FILE_NAME, ImageDimensions());
+ resultMap.Clear();
+ animatedImageVisual2.CreatePropertyMap(resultMap);
+ // check the property values from the returned map from a visual
+ value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
+
+ value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap for multi image with fixed cache");
+
+ // request AnimatedImageVisual with a property map
+ VisualFactory factory = VisualFactory::Get();
+ Property::Array urls;
+ CopyUrlsIntoArray(urls);
+
+ Visual::Base animatedImageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
+ .Add("url", urls)
+ .Add("batchSize", 4)
+ .Add("cacheSize", 20)
+ .Add("loopCount", 10)
+ .Add("frameDelay", 200)
+ .Add("pixelArea", Vector4())
+ .Add("wrapModeU", WrapMode::REPEAT)
+ .Add("wrapModeV", WrapMode::DEFAULT)
+ .Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
+ .Add("maskContentScale", 1.6f)
+ .Add("cropToMask", true)
+ .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
+ .Add("cornerRadius", Vector4(50.0f, 25.0f, 12.5f, 33.0f))
+ .Add("cornerRadiusPolicy", Visual::Transform::Policy::RELATIVE)
+ .Add("borderlineWidth", 20.0f)
+ .Add("borderlineColor", Vector4())
+ .Add("borderlineOffset", -1.0f));
+
+ Property::Map resultMap;
+ animatedImageVisual.CreatePropertyMap(resultMap);
+ // check the property values from the returned map from a visual
+ Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
+
+ value = resultMap.Find(ImageVisual::Property::URL, "url");
+ DALI_TEST_CHECK(value);
+ Property::Array* resultUrls = value->GetArray();
+ DALI_TEST_CHECK(resultUrls);
+ DALI_TEST_EQUALS(resultUrls->Count(), urls.Count(), TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 20, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::FRAME_DELAY, "frameDelay");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 200, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 11, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(50.0f, 25.0f, 12.5f, 33.0f), TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::RELATIVE);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 20.0f, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4::ZERO, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), -1.0f, TEST_LOCATION);
+
+ // Check mask properties
+ value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, "alphaMaskUrl");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
+
+ value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, "maskContentScale");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, "cropToMask");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
+
+ value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap for multi image rolling cache");
+
+ // request AnimatedImageVisual with a property map
+ VisualFactory factory = VisualFactory::Get();
+ Property::Array urls;
+ CopyUrlsIntoArray(urls);
+
+ Visual::Base animatedImageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
+ .Add("url", urls)
+ .Add("batchSize", 4)
+ .Add("cacheSize", 8)
+ .Add("loopCount", 10)
+ .Add("frameDelay", 200)
+ .Add("pixelArea", Vector4())
+ .Add("wrapModeU", WrapMode::REPEAT)
+ .Add("wrapModeV", WrapMode::DEFAULT)
+ .Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
+ .Add("maskContentScale", 1.6f)
+ .Add("cropToMask", true)
+ .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
+ .Add("cornerRadius", 50.5f));
+
+ Property::Map resultMap;
+ animatedImageVisual.CreatePropertyMap(resultMap);
+ // check the property values from the returned map from a visual
+ Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
+
+ value = resultMap.Find(ImageVisual::Property::URL, "url");
+ DALI_TEST_CHECK(value);
+ Property::Array* resultUrls = value->GetArray();
+ DALI_TEST_CHECK(resultUrls);
+ DALI_TEST_EQUALS(resultUrls->Count(), urls.Count(), TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, "batchSize");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, "cacheSize");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 8, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 10, TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::FRAME_DELAY, "frameDelay");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 200, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 11, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(50.5f, 50.5f, 50.5f, 50.5f), TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == Visual::Transform::Policy::ABSOLUTE);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<Vector4>(), Color::BLACK, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
+
+ // Check mask properties
+ value = resultMap.Find(ImageVisual::Property::ALPHA_MASK_URL, "alphaMaskUrl");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<std::string>() == TEST_MASK_IMAGE_FILE_NAME);
+
+ value = resultMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE, "maskContentScale");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 1.6f, TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::CROP_TO_MASK, "cropToMask");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
+
+ value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<bool>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualGetPropertyMap04(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualGetPropertyMap");
+
+ // request AnimatedImageVisual with a property map
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base animatedImageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add(Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE)
+ .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
+ .Add(ImageVisual::Property::BATCH_SIZE, 1)
+ .Add(ImageVisual::Property::CACHE_SIZE, 1)
+ .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, true)
+ .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED)
+ .Add(ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED)
+ .Add(DevelVisual::Property::BORDERLINE_WIDTH, 0.4f));
+
+ Property::Map resultMap;
+ animatedImageVisual.CreatePropertyMap(resultMap);
+
+ // check the property values from the returned map from a visual
+ Property::Value* value = resultMap.Find(Toolkit::Visual::Property::TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == Visual::ANIMATED_IMAGE);
+
+ value = resultMap.Find(ImageVisual::Property::URL, Property::STRING);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<std::string>() == TEST_GIF_FILE_NAME);
+
+ value = resultMap.Find(ImageVisual::Property::BATCH_SIZE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == 2);
+
+ value = resultMap.Find(ImageVisual::Property::CACHE_SIZE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == 2);
+
+ value = resultMap.Find(ImageVisual::Property::SYNCHRONOUS_LOADING, Property::BOOLEAN);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<bool>() == true);
+
+ value = resultMap.Find(ImageVisual::Property::RELEASE_POLICY, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == ImageVisual::ReleasePolicy::DETACHED);
+
+ value = resultMap.Find(ImageVisual::Property::LOAD_POLICY, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == ImageVisual::LoadPolicy::ATTACHED);
+
+ value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), 4, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 0.4f, TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, "borderlineColor");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(0.0f, 0.0f, 0.0f, 1.0f), TEST_LOCATION);
+
+ value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, "borderlineOffset");
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<float>(), 0.0f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualImageLoadingFail01(void)
+{
+ ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, "dummy.gif");
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(dummyControl);
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 1, TEST_LOCATION);
+
+ DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6);
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 1, TEST_LOCATION);
+
+ dummyControl.Unparent();
+ }
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualSynchronousLoading(void)
+{
+ ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(dummyControl);
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);
+
+ // The first frame is loaded synchronously and load next batch.
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
+
+ DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 3);
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask01 for CPU Alpha Masking");
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ Property::Map testMap;
+ visual.CreatePropertyMap(testMap);
+ DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(dummyControl);
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);
+
+ // The first frame is loaded synchronously and load next batch with masking
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 2, TEST_LOCATION);
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask02 for GPU Alpha Masking");
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
+ propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ Property::Map testMap;
+ visual.CreatePropertyMap(testMap);
+ DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(dummyControl);
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);
+
+ // The first frame is loaded synchronously and load next batch with masking
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualJumpToAction(void)
+{
+ ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ Property::Array urls;
+ CopyUrlsIntoArray(urls);
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 12);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(dummyControl);
+ application.SendNotification();
+ application.Render(20);
+
+ tet_infoline("Ready the visual after the visual is on stage");
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
+
+ tet_infoline("Test that a timer has been started");
+ DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
+
+ DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
+
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
+
+ DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 20);
+
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
+
+ DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6);
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(6), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualStopBehavior(void)
+{
+ ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ Property::Array urls;
+ CopyUrlsIntoArray(urls);
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
+ propertyMap.Insert(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 4);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 8);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ // Expect that a batch of 4 textures has been requested. These will be serially loaded
+ // below.
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(dummyControl);
+ application.SendNotification();
+ application.Render(20);
+
+ tet_infoline("Ready the visual after the visual is on stage");
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
+
+ tet_infoline("Test that a timer has been started");
+ DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
+
+ DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map());
+
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
+
+ DevelControl::DoAction(dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 1);
+
+ // Expect the second batch has been requested
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualStopBehavior02(void)
+{
+ ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ Property::Array urls;
+ CopyUrlsIntoArray(urls);
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, Property::Value(urls));
+ propertyMap.Insert(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME);
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ // Expect that a batch of 4 textures has been requested. These will be serially loaded
+ // below.
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ dummyControl.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(dummyControl);
+
+ tet_infoline("Ready the visual after the visual is on stage");
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);