X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-TextureManager.cpp;h=f12b096ef705e32a87bef1be9a76960d7ae482b1;hp=8c63d53dad7a1618e326439cd8e380ea713760ae;hb=HEAD;hpb=55105dbc618cc676ed515d463bbc40f921136069 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp index 8c63d53..a4e177c 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.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. @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -28,6 +29,8 @@ #include #include #include ///< For VisualFactory's member TextureManager. +#include +#include #include #include @@ -60,6 +63,9 @@ const char* TEST_IMAGE_3_FILE_NAME = TEST_RESOURCE_DIR "/icon-edit.png"; const char* TEST_IMAGE_4_FILE_NAME = TEST_RESOURCE_DIR "/application-icon-20.png"; const char* TEST_MASK_FILE_NAME = TEST_RESOURCE_DIR "/mask.png"; +const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg"; +const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json"; + class TestObserver : public Dali::Toolkit::TextureUploadObserver { public: @@ -202,7 +208,6 @@ int UtcTextureManagerRequestLoad(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer, true, TextureManager::ReloadPolicy::CACHED, @@ -229,7 +234,6 @@ int UtcTextureManagerGenerateHash(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer, true, TextureManager::ReloadPolicy::CACHED, @@ -256,7 +260,7 @@ int UtcTextureManagerEncodedImageBuffer(void) std::string url1 = textureManager.AddEncodedImageBuffer(buffer1); std::string url2 = textureManager.AddEncodedImageBuffer(buffer1); - std::string url3 = VisualUrl::CreateBufferUrl(""); ///< Impossible Buffer URL. for coverage + std::string url3 = VisualUrl::CreateBufferUrl("", ""); ///< Impossible Buffer URL. for coverage // Check if same EncodedImageBuffer get same url DALI_TEST_CHECK(url1 == url2); @@ -277,7 +281,6 @@ int UtcTextureManagerEncodedImageBuffer(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer1, true, ///< orientationCorrection TextureManager::ReloadPolicy::CACHED, @@ -351,7 +354,6 @@ int UtcTextureManagerEncodedImageBuffer(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer3, true, ///< orientationCorrection TextureManager::ReloadPolicy::CACHED, @@ -368,7 +370,6 @@ int UtcTextureManagerEncodedImageBuffer(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer4, true, ///< orientationCorrection TextureManager::ReloadPolicy::FORCED, @@ -435,6 +436,325 @@ int UtcTextureManagerEncodedImageBuffer(void) END_TEST; } +int UtcTextureManagerEncodedImageBufferWithImageType(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcTextureManagerEncodedImageBufferWithImageType"); + + auto visualFactory = Toolkit::VisualFactory::Get(); + auto& textureManager = GetImplementation(visualFactory).GetTextureManager(); // Use VisualFactory's texture manager + + // Get encoded raw-buffer image and generate url + EncodedImageBuffer buffer1 = ConvertFileToEncodedImageBuffer(TEST_SVG_FILE_NAME); + EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME); + + std::string url1 = textureManager.AddEncodedImageBuffer(buffer1); + std::string url2 = textureManager.AddEncodedImageBuffer(buffer1); + + // Check if same EncodedImageBuffer get same url + DALI_TEST_CHECK(url1 == url2); + // Reduce reference count + textureManager.RemoveEncodedImageBuffer(url1); + // Check whethere url1 still valid + DALI_TEST_CHECK(textureManager.GetEncodedImageBuffer(url1)); + + url2 = textureManager.AddEncodedImageBuffer(buffer2); + // Check if difference EncodedImageBuffer get difference url + DALI_TEST_CHECK(url1 != url2); + + buffer1.SetImageType(EncodedImageBuffer::ImageType::VECTOR_IMAGE); + buffer2.SetImageType(EncodedImageBuffer::ImageType::ANIMATED_VECTOR_IMAGE); + + std::string url1AfterType = textureManager.AddEncodedImageBuffer(buffer1); + std::string url2AfterType = textureManager.AddEncodedImageBuffer(buffer2); + + // Check if EncodedImageBuffer with imagetype get difference url. + DALI_TEST_CHECK(url1 != url1AfterType); + DALI_TEST_CHECK(url2 != url2AfterType); + DALI_TEST_CHECK(url1AfterType != url2AfterType); + + int bufferId = std::atoi(VisualUrl::GetLocationWithoutExtension(url1AfterType).c_str()); + auto urlFromBuffer = textureManager.GetVisualUrl(bufferId); + + // Check url from buffer id is equal with what we know. + DALI_TEST_CHECK(url1AfterType == urlFromBuffer.GetUrl()); + + // Reduce reference count + textureManager.RemoveEncodedImageBuffer(url1AfterType); + // Check whethere url1 still valid + DALI_TEST_CHECK(textureManager.GetEncodedImageBuffer(url1AfterType)); + + // Reduce reference count + textureManager.RemoveEncodedImageBuffer(url1AfterType); + // Check whethere url1 is invalid + DALI_TEST_CHECK(!textureManager.GetEncodedImageBuffer(url1AfterType)); + + // Reduce reference count + textureManager.RemoveEncodedImageBuffer(url2); + // Check whethere url2 is still valid + DALI_TEST_CHECK(textureManager.GetEncodedImageBuffer(url2)); + + // Reduce reference count + textureManager.RemoveEncodedImageBuffer(url2); + // Check whethere url2 is invalid + DALI_TEST_CHECK(!textureManager.GetEncodedImageBuffer(url2)); + + END_TEST; +} + +int UtcTextureManagerExternalTexture(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcTextureManagerExternalTexture check TextureManager using external texture works well"); + + auto visualFactory = Toolkit::VisualFactory::Get(); + auto& textureManager = GetImplementation(visualFactory).GetTextureManager(); // Use VisualFactory's texture manager + + TestObserver observer1; + TestObserver observer2; + + auto textureId1(TextureManager::INVALID_TEXTURE_ID); + auto textureId2(TextureManager::INVALID_TEXTURE_ID); + std::string maskname(TEST_MASK_FILE_NAME); + TextureManager::MaskingDataPointer maskInfo = nullptr; + maskInfo.reset(new TextureManager::MaskingData()); + maskInfo->mAlphaMaskUrl = maskname; + maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID; + maskInfo->mCropToMask = true; + maskInfo->mContentScaleFactor = 1.0f; + Vector4 atlasRect(0.f, 0.f, 1.f, 1.f); + Dali::ImageDimensions atlasRectSize(0, 0); + bool synchronousLoading(false); + bool atlasingStatus(false); + bool loadingStatus(false); + auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY; + ImageAtlasManagerPtr atlasManager = nullptr; + Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr; + + uint32_t width(64); + uint32_t height(64); + uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888); + + uint8_t* buffer = reinterpret_cast(malloc(bufferSize)); + PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE); + + DALI_TEST_CHECK(pixelData); + + Dali::Toolkit::ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true); + std::string url = imageUrl.GetUrl(); + + TextureSet texture1 = textureManager.LoadTexture( + url, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + maskInfo, + synchronousLoading, + textureId1, + atlasRect, + atlasRectSize, + atlasingStatus, + loadingStatus, + &observer1, + atlasUploadObserver, + atlasManager, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply); + + TextureSet texture2 = textureManager.LoadTexture( + url, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + maskInfo, + synchronousLoading, + textureId2, + atlasRect, + atlasRectSize, + atlasingStatus, + loadingStatus, + &observer2, + atlasUploadObserver, + atlasManager, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply); + + DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + DALI_TEST_EQUALS(observer1.mLoaded, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mObserverCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION); + + DALI_TEST_EQUALS(observer2.mLoaded, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mObserverCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION); + + DALI_TEST_EQUALS(textureId1 == textureId2, true, TEST_LOCATION); + + texture1 = textureManager.LoadTexture( + url, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + maskInfo, + synchronousLoading, + textureId1, + atlasRect, + atlasRectSize, + atlasingStatus, + loadingStatus, + &observer1, + atlasUploadObserver, + atlasManager, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply); + + texture2 = textureManager.LoadTexture( + url, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + maskInfo, + synchronousLoading, + textureId2, + atlasRect, + atlasRectSize, + atlasingStatus, + loadingStatus, + &observer2, + atlasUploadObserver, + atlasManager, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(textureId1 == textureId2, true, TEST_LOCATION); + DALI_TEST_EQUALS(texture1 != texture2, true, TEST_LOCATION); + + END_TEST; +} + +int UtcTextureManagerRemoveExternalTextureAndLoadAgain(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcTextureManagerRemoveExternalTextureAndLoadAgain check TextureManager RequestRemove and RemoveExternalTexture lifecycle works well"); + + auto visualFactory = Toolkit::VisualFactory::Get(); + auto& textureManager = GetImplementation(visualFactory).GetTextureManager(); // Use VisualFactory's texture manager + + TestObserver observer1; + TestObserver observer2; + + auto textureId1(TextureManager::INVALID_TEXTURE_ID); + auto textureId2(TextureManager::INVALID_TEXTURE_ID); + TextureManager::MaskingDataPointer maskInfo = nullptr; + + Vector4 atlasRect(0.f, 0.f, 1.f, 1.f); + Dali::ImageDimensions atlasRectSize(0, 0); + bool synchronousLoading(false); + bool atlasingStatus(false); + bool loadingStatus(false); + auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY; + ImageAtlasManagerPtr atlasManager = nullptr; + Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr; + + uint32_t width(64); + uint32_t height(64); + uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888); + + uint8_t* buffer = reinterpret_cast(malloc(bufferSize)); + PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE); + + DALI_TEST_CHECK(pixelData); + + Dali::Toolkit::ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true); + std::string url1 = imageUrl.GetUrl(); + std::string url2 = TEST_IMAGE_FILE_NAME; + + // Step 1 : Load request for external url + TextureSet texture1 = textureManager.LoadTexture( + url1, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + maskInfo, + synchronousLoading, + textureId1, + atlasRect, + atlasRectSize, + atlasingStatus, + loadingStatus, + &observer1, + atlasUploadObserver, + atlasManager, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply); + + DALI_TEST_CHECK(textureId1 != TextureManager::INVALID_TEXTURE_ID); + + // Step 2 : Request remove for external url + textureManager.RequestRemove(textureId1, &observer1); + + // Step 3 : Reduce imageUrl reference count. + imageUrl.Reset(); + + // Step 4 : Request new load by normal image. + TextureSet texture2 = textureManager.LoadTexture( + url2, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + maskInfo, + synchronousLoading, + textureId2, + atlasRect, + atlasRectSize, + atlasingStatus, + loadingStatus, + &observer2, + atlasUploadObserver, + atlasManager, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply); + + DALI_TEST_CHECK(textureId2 != TextureManager::INVALID_TEXTURE_ID); + + DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION); + + DALI_TEST_EQUALS(observer2.mLoaded, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mObserverCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION); + + END_TEST; +} + int UtcTextureManagerEncodedImageBufferReferenceCount(void) { ToolkitTestApplication application; @@ -483,7 +803,6 @@ int UtcTextureManagerEncodedImageBufferReferenceCount(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer1, true, ///< orientationCorrection TextureManager::ReloadPolicy::CACHED, @@ -562,7 +881,6 @@ int UtcTextureManagerCachingForDifferentLoadingType(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer1, true, TextureManager::ReloadPolicy::CACHED, @@ -791,9 +1109,6 @@ int UtcTextureManagerUseInvalidMaskAndMaskLoadedLater(void) DALI_TEST_EQUALS(observer.mLoaded, false, TEST_LOCATION); DALI_TEST_EQUALS(observer.mObserverCalled, false, TEST_LOCATION); - application.SendNotification(); - application.Render(); - // CAPTION : HARD-CODING for coverage. { Dali::Devel::PixelBuffer pixelBuffer = textureManager.LoadPixelBuffer( @@ -1131,7 +1446,6 @@ int UtcTextureManagerQueueRemoveDuringObserve(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer, true, TextureManager::ReloadPolicy::CACHED, @@ -1238,16 +1552,12 @@ int UtcTextureManagerRemoveDuringApplyMasking(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer2, true, ///< orientationCorrection TextureManager::ReloadPolicy::CACHED, preMultiply, synchronousLoading); - application.SendNotification(); - application.Render(); - DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION); DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION); @@ -1613,7 +1923,6 @@ int UtcTextureManagerRemoveDuringGPUMasking(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, data2.addTextureObserver, true, TextureManager::ReloadPolicy::CACHED, @@ -1648,9 +1957,6 @@ int UtcTextureManagerRemoveDuringGPUMasking(void) *data3.observerCalleddPtr = data3.self->mObserverCalled; }); - application.SendNotification(); - application.Render(); - tet_printf("Id info - mask : {%d}, 1 : {%d}, 2 : {%d}, 3 : {%d}, 4 : {%d}\n", static_cast(maskInfo[0]->mAlphaMaskId), static_cast(textureId1), static_cast(textureId2), static_cast(textureId3), static_cast(textureId4)); // CAPTION : HARD-CODING. @@ -1754,7 +2060,6 @@ int UtcTextureManagerDestroyObserverDuringObserve(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer1, true, TextureManager::ReloadPolicy::CACHED, @@ -1765,7 +2070,6 @@ int UtcTextureManagerDestroyObserverDuringObserve(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, observer2, true, TextureManager::ReloadPolicy::CACHED, @@ -1776,7 +2080,6 @@ int UtcTextureManagerDestroyObserverDuringObserve(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, &observer3, true, TextureManager::ReloadPolicy::CACHED, @@ -1890,7 +2193,6 @@ int UtcTextureManagerDestroyObserverDuringObserve(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, data1.resendTextureObserver, true, TextureManager::ReloadPolicy::CACHED, @@ -1905,7 +2207,6 @@ int UtcTextureManagerDestroyObserverDuringObserve(void) ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, - TextureManager::UseAtlas::NO_ATLAS, *data1.removeTextureObserver, true, TextureManager::ReloadPolicy::CACHED, @@ -1938,9 +2239,6 @@ int UtcTextureManagerDestroyObserverDuringObserve(void) *data2.observerCalledPtr = data2.self->mObserverCalled; }); - application.SendNotification(); - application.Render(); - tet_printf("Id info - 1 : {%d}, 2 : {%d}, 3 : {%d}, 4 : {%d}\n", static_cast(textureId1), static_cast(textureId2), static_cast(textureId3), static_cast(textureId4)); DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION); @@ -2018,4 +2316,100 @@ int UtcTextureManagerDestroyObserverDuringObserve(void) } END_TEST; -} \ No newline at end of file +} + +int UtcTextureManagerCachingForDifferentMultiplyOnLoad(void) +{ + /// To insture the order of callback, Make we don't use mutiple thread loading for this UTC. + EnvironmentVariable::SetTestEnvironmentVariable("DALI_ASYNC_MANAGER_THREAD_POOL_SIZE", "1"); + EnvironmentVariable::SetTestEnvironmentVariable("DALI_ASYNC_MANAGER_LOW_PRIORITY_THREAD_POOL_SIZE", "1"); + + ToolkitTestApplication application; + tet_infoline("UtcTextureManagerCachingForDifferentMultiplyOnLoad"); + tet_infoline("Observe1 multiply on load, and Observer2, 3 don't multiply on load."); + tet_infoline("We will use jpg image, with will not premultiply alpha even if we try to load without multiply."); + + tet_infoline("Let we request Observer1 and Observer2 sequencely."); + tet_infoline("After Observer1 complete, we will cache -premultiplyOnLoad = true, premultiplied = false;"); + tet_infoline("Before Observer2 complete, let we request Observer3. It will cache-hit with Observer1 item (since image is not premultiplied.)"); + tet_infoline("At this time, Observer1 and Observer3 loaded, but Observer2 still not."); + + TextureManager textureManager; // Create new texture manager + + TestObserver observer1; + TestObserver observer2; + TestObserver observer3; + std::string filename(TEST_IMAGE_FILE_NAME); + auto preMultiply = TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD; + textureManager.RequestLoad( + filename, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + &observer1, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply); + + DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION); + + preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY; + textureManager.RequestLoad( + filename, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + &observer2, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply); + + DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + tet_printf("We can ensure that observer1 loaded first. (since the number of thread pool is 1)\n"); + DALI_TEST_EQUALS(observer1.mLoaded, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mObserverCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION); + + preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY; + textureManager.RequestLoad( + filename, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + &observer3, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply); + + tet_printf("Request Observer3. It will cache-hit with Observer1.\n"); + DALI_TEST_EQUALS(observer1.mLoaded, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mObserverCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION); + DALI_TEST_EQUALS(observer3.mLoaded, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer3.mObserverCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer3.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mLoaded, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mObserverCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer1.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mLoaded, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mObserverCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer2.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION); + DALI_TEST_EQUALS(observer3.mLoaded, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer3.mObserverCalled, true, TEST_LOCATION); + DALI_TEST_EQUALS(observer3.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION); + + END_TEST; +}