2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <toolkit-event-thread-callback.h>
24 #include <toolkit-timer.h>
26 #include <dali-toolkit/internal/texture-manager/texture-async-loading-helper.h>
27 #include <dali-toolkit/internal/texture-manager/texture-manager-impl.h>
28 #include <dali-toolkit/internal/texture-manager/texture-upload-observer.h>
29 #include <dali-toolkit/internal/visuals/image-atlas-manager.h>
30 #include <dali-toolkit/internal/visuals/visual-factory-impl.h> ///< For VisualFactory's member TextureManager.
31 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
33 #include <test-encoded-image-buffer.h>
35 #if defined(ELDBUS_ENABLED)
36 #include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
39 using namespace Dali::Toolkit::Internal;
41 void utc_dali_toolkit_texture_manager_startup(void)
43 setenv("LOG_TEXTURE_MANAGER", "3", 1);
44 test_return_value = TET_UNDEF;
45 #if defined(ELDBUS_ENABLED)
46 DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
50 void utc_dali_toolkit_texture_manager_cleanup(void)
52 test_return_value = TET_PASS;
57 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
58 const char* TEST_IMAGE_2_FILE_NAME = TEST_RESOURCE_DIR "/icon-delete.png";
59 const char* TEST_MASK_FILE_NAME = TEST_RESOURCE_DIR "/mask.png";
61 class TestObserver : public Dali::Toolkit::TextureUploadObserver
64 enum class CompleteType
73 : mCompleteType(CompleteType::NOT_COMPLETED),
75 mObserverCalled(false),
80 virtual void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override
82 if(textureInformation.returnType == TextureUploadObserver::ReturnType::TEXTURE)
84 mCompleteType = CompleteType::UPLOAD_COMPLETE;
88 mCompleteType = CompleteType::LOAD_COMPLETE;
90 mLoaded = loadSuccess;
91 mObserverCalled = true;
92 mTextureSet = textureInformation.textureSet;
95 CompleteType mCompleteType;
98 TextureSet mTextureSet;
101 class TestObserverRemoveAndGenerateUrl : public TestObserver
104 TestObserverRemoveAndGenerateUrl(TextureManager* textureManagerPtr)
106 mTextureManagerPtr(textureManagerPtr)
110 virtual void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override
112 if(textureInformation.returnType == TextureUploadObserver::ReturnType::TEXTURE)
114 mCompleteType = CompleteType::UPLOAD_COMPLETE;
118 mCompleteType = CompleteType::LOAD_COMPLETE;
120 mLoaded = loadSuccess;
121 mObserverCalled = true;
122 mTextureSet = textureInformation.textureSet;
124 // Remove during LoadComplete
125 mTextureManagerPtr->Remove(textureInformation.textureId, nullptr);
127 // ...And generate string which using texture id.
128 mGeneratedExternalUrl = mTextureManagerPtr->AddExternalTexture(mTextureSet);
132 std::string mGeneratedExternalUrl;
135 TextureManager* mTextureManagerPtr; // Keep the pointer of texture manager.
140 int UtcTextureManagerRequestLoad(void)
142 ToolkitTestApplication application;
144 TextureManager textureManager; // Create new texture manager
146 TestObserver observer;
147 std::string filename("image.png");
148 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
149 TextureManager::TextureId textureId = textureManager.RequestLoad(
152 FittingMode::SCALE_TO_FILL,
153 SamplingMode::BOX_THEN_LINEAR,
154 TextureManager::UseAtlas::NO_ATLAS,
157 TextureManager::ReloadPolicy::CACHED,
160 VisualUrl url = textureManager.GetVisualUrl(textureId);
162 DALI_TEST_EQUALS(url.GetUrl().compare(filename), 0, TEST_LOCATION);
167 int UtcTextureManagerGenerateHash(void)
169 ToolkitTestApplication application;
171 TextureManager textureManager; // Create new texture manager
173 TestObserver observer;
174 std::string filename("image.png");
175 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
176 TextureManager::TextureId textureId = textureManager.RequestLoad(
179 FittingMode::SCALE_TO_FILL,
180 SamplingMode::BOX_THEN_LINEAR,
181 TextureManager::UseAtlas::NO_ATLAS,
184 TextureManager::ReloadPolicy::CACHED,
187 VisualUrl url = textureManager.GetVisualUrl(textureId);
189 DALI_TEST_EQUALS(url.GetUrl().compare(filename), 0, TEST_LOCATION);
194 int UtcTextureManagerEncodedImageBuffer(void)
196 ToolkitTestApplication application;
197 tet_infoline("UtcTextureManagerEncodedImageBuffer");
199 auto visualFactory = Toolkit::VisualFactory::Get();
200 auto& textureManager = GetImplementation(visualFactory).GetTextureManager(); // Use VisualFactory's texture manager
202 // Get encoded raw-buffer image and generate url
203 EncodedImageBuffer buffer1 = ConvertFileToEncodedImageBuffer(TEST_IMAGE_FILE_NAME);
204 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(TEST_IMAGE_FILE_NAME);
206 std::string url1 = textureManager.AddEncodedImageBuffer(buffer1);
207 std::string url2 = textureManager.AddEncodedImageBuffer(buffer1);
208 std::string url3 = VisualUrl::CreateBufferUrl(""); ///< Impossible Buffer URL. for coverage
210 // Check if same EncodedImageBuffer get same url
211 DALI_TEST_CHECK(url1 == url2);
212 // Reduce reference count
213 textureManager.RemoveEncodedImageBuffer(url1);
214 // Check whethere url1 still valid
215 DALI_TEST_CHECK(textureManager.GetEncodedImageBuffer(url1));
217 url2 = textureManager.AddEncodedImageBuffer(buffer2);
218 // Check if difference EncodedImageBuffer get difference url
219 DALI_TEST_CHECK(url1 != url2);
221 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
223 TestObserver observer1;
224 textureManager.RequestLoad(
227 FittingMode::SCALE_TO_FILL,
228 SamplingMode::BOX_THEN_LINEAR,
229 TextureManager::UseAtlas::NO_ATLAS,
231 true, ///< orientationCorrection
232 TextureManager::ReloadPolicy::CACHED,
235 DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION);
236 DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION);
238 application.SendNotification();
239 application.Render();
241 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
243 application.SendNotification();
244 application.Render();
246 DALI_TEST_EQUALS(observer1.mLoaded, true, TEST_LOCATION);
247 DALI_TEST_EQUALS(observer1.mObserverCalled, true, TEST_LOCATION);
248 DALI_TEST_EQUALS(observer1.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
250 TestObserver observer2;
252 Devel::PixelBuffer pixelBuffer = textureManager.LoadPixelBuffer(
255 FittingMode::SCALE_TO_FILL,
256 SamplingMode::BOX_THEN_LINEAR,
257 true, ///< synchronousLoading
259 true, ///< orientationCorrection
262 DALI_TEST_CHECK(pixelBuffer);
263 DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION);
264 DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION);
267 pixelBuffer = textureManager.LoadPixelBuffer(
270 FittingMode::SCALE_TO_FILL,
271 SamplingMode::BOX_THEN_LINEAR,
272 false, ///< synchronousLoading
274 true, ///< orientationCorrection
277 DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION);
278 DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION);
280 application.SendNotification();
281 application.Render();
283 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
285 application.SendNotification();
286 application.Render();
288 DALI_TEST_EQUALS(observer2.mLoaded, true, TEST_LOCATION);
289 DALI_TEST_EQUALS(observer2.mObserverCalled, true, TEST_LOCATION);
290 DALI_TEST_EQUALS(observer2.mCompleteType, TestObserver::CompleteType::LOAD_COMPLETE, TEST_LOCATION);
292 textureManager.RemoveEncodedImageBuffer(url1);
293 textureManager.RemoveEncodedImageBuffer(url2);
295 // Now url1 and url2 is invalid type. mLoaded will return false
297 TestObserver observer3;
298 textureManager.RequestLoad(
301 FittingMode::SCALE_TO_FILL,
302 SamplingMode::BOX_THEN_LINEAR,
303 TextureManager::UseAtlas::NO_ATLAS,
305 true, ///< orientationCorrection
306 TextureManager::ReloadPolicy::CACHED,
309 // Load will be success because url1 is cached
310 DALI_TEST_EQUALS(observer3.mLoaded, true, TEST_LOCATION);
311 DALI_TEST_EQUALS(observer3.mObserverCalled, true, TEST_LOCATION);
312 DALI_TEST_EQUALS(observer3.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
314 TestObserver observer4;
315 textureManager.RequestLoad(
318 FittingMode::SCALE_TO_FILL,
319 SamplingMode::BOX_THEN_LINEAR,
320 TextureManager::UseAtlas::NO_ATLAS,
322 true, ///< orientationCorrection
323 TextureManager::ReloadPolicy::FORCED,
326 DALI_TEST_EQUALS(observer4.mLoaded, false, TEST_LOCATION);
327 DALI_TEST_EQUALS(observer4.mObserverCalled, false, TEST_LOCATION);
328 application.SendNotification();
329 application.Render();
331 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
333 application.SendNotification();
334 application.Render();
336 // Load will be failed becuase reloadpolicy is forced
337 DALI_TEST_EQUALS(observer4.mLoaded, false, TEST_LOCATION);
338 DALI_TEST_EQUALS(observer4.mObserverCalled, true, TEST_LOCATION);
339 DALI_TEST_EQUALS(observer4.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
341 TestObserver observer5;
342 pixelBuffer = textureManager.LoadPixelBuffer(
345 FittingMode::SCALE_TO_FILL,
346 SamplingMode::BOX_THEN_LINEAR,
347 true, ///< synchronousLoading
349 true, ///< orientationCorrection
352 // Load will be faild because synchronousLoading doesn't use cached texture
353 DALI_TEST_CHECK(!pixelBuffer);
354 DALI_TEST_EQUALS(observer5.mLoaded, false, TEST_LOCATION);
355 DALI_TEST_EQUALS(observer5.mObserverCalled, false, TEST_LOCATION);
357 TestObserver observer6;
358 pixelBuffer = textureManager.LoadPixelBuffer(
361 FittingMode::SCALE_TO_FILL,
362 SamplingMode::BOX_THEN_LINEAR,
363 false, ///< synchronousLoading
365 true, ///< orientationCorrection
368 DALI_TEST_EQUALS(observer6.mLoaded, false, TEST_LOCATION);
369 DALI_TEST_EQUALS(observer6.mObserverCalled, false, TEST_LOCATION);
371 application.SendNotification();
372 application.Render();
374 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
376 application.SendNotification();
377 application.Render();
379 // Load will be failed because url3 is invalid URL
380 DALI_TEST_EQUALS(observer6.mLoaded, false, TEST_LOCATION);
381 DALI_TEST_EQUALS(observer6.mObserverCalled, true, TEST_LOCATION);
382 DALI_TEST_EQUALS(observer6.mCompleteType, TestObserver::CompleteType::LOAD_COMPLETE, TEST_LOCATION);
387 int UtcTextureManagerEncodedImageBufferReferenceCount(void)
389 ToolkitTestApplication application;
390 tet_infoline("UtcTextureManagerEncodedImageBuffer check reference count works well");
392 auto visualFactory = Toolkit::VisualFactory::Get();
393 auto& textureManager = GetImplementation(visualFactory).GetTextureManager(); // Use VisualFactory's texture manager
395 // Get encoded raw-buffer image and generate url
396 EncodedImageBuffer buffer1 = ConvertFileToEncodedImageBuffer(TEST_IMAGE_FILE_NAME);
397 EncodedImageBuffer buffer2 = ConvertFileToEncodedImageBuffer(TEST_IMAGE_FILE_NAME);
399 std::string url1 = textureManager.AddEncodedImageBuffer(buffer1);
400 std::string url2 = textureManager.AddEncodedImageBuffer(buffer1);
402 // Check if same EncodedImageBuffer get same url
403 DALI_TEST_CHECK(url1 == url2);
405 // Reduce reference count
406 textureManager.RemoveEncodedImageBuffer(url1);
407 // Check whethere url1 still valid
408 DALI_TEST_CHECK(textureManager.GetEncodedImageBuffer(url1));
410 // Reduce reference count
411 textureManager.RemoveEncodedImageBuffer(url1);
412 // Check whethere url1 is not valid anymore
413 DALI_TEST_CHECK(!textureManager.GetEncodedImageBuffer(url1));
415 // UseExternalTexture doesn't create new buffer.
416 // So, reference count is still zero.
417 textureManager.UseExternalResource(url1);
418 DALI_TEST_CHECK(!textureManager.GetEncodedImageBuffer(url1));
420 url1 = textureManager.AddEncodedImageBuffer(buffer1);
422 url2 = textureManager.AddEncodedImageBuffer(buffer2);
423 // Check if difference EncodedImageBuffer get difference url
424 DALI_TEST_CHECK(url1 != url2);
426 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
428 // url1 load image by cache
429 TestObserver observer1;
430 textureManager.RequestLoad(
433 FittingMode::SCALE_TO_FILL,
434 SamplingMode::BOX_THEN_LINEAR,
435 TextureManager::UseAtlas::NO_ATLAS,
437 true, ///< orientationCorrection
438 TextureManager::ReloadPolicy::CACHED,
441 DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION);
442 DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION);
444 application.SendNotification();
445 application.Render();
447 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
449 application.SendNotification();
450 application.Render();
452 DALI_TEST_EQUALS(observer1.mLoaded, true, TEST_LOCATION);
453 DALI_TEST_EQUALS(observer1.mObserverCalled, true, TEST_LOCATION);
454 DALI_TEST_EQUALS(observer1.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
456 // LoadPixelBuffer doen't use cache. url2 will not be cached
457 TestObserver observer2;
458 Devel::PixelBuffer pixelBuffer = textureManager.LoadPixelBuffer(
461 FittingMode::SCALE_TO_FILL,
462 SamplingMode::BOX_THEN_LINEAR,
463 false, ///< synchronousLoading
465 true, ///< orientationCorrection
468 DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION);
469 DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION);
471 application.SendNotification();
472 application.Render();
474 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
476 application.SendNotification();
477 application.Render();
479 DALI_TEST_EQUALS(observer2.mLoaded, true, TEST_LOCATION);
480 DALI_TEST_EQUALS(observer2.mObserverCalled, true, TEST_LOCATION);
481 DALI_TEST_EQUALS(observer2.mCompleteType, TestObserver::CompleteType::LOAD_COMPLETE, TEST_LOCATION);
483 // Decrease each url's reference count.
484 textureManager.RemoveEncodedImageBuffer(url1);
485 textureManager.RemoveEncodedImageBuffer(url2);
487 // url1 buffer is still have 1 reference count because it is cached.
488 // But url2 not valid because it is not cached.
489 DALI_TEST_CHECK(textureManager.GetEncodedImageBuffer(url1));
490 DALI_TEST_CHECK(!textureManager.GetEncodedImageBuffer(url2));
492 // Check url1 buffer have 1 reference count because it is cached.
493 textureManager.RemoveEncodedImageBuffer(url1);
494 DALI_TEST_CHECK(!textureManager.GetEncodedImageBuffer(url1));
499 int UtcTextureManagerCachingForDifferentLoadingType(void)
501 ToolkitTestApplication application;
502 tet_infoline("UtcTextureManagerCachingForDifferentLoadingType");
504 TextureManager textureManager; // Create new texture manager
506 TestObserver observer1;
507 std::string filename(TEST_IMAGE_FILE_NAME);
508 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
509 textureManager.RequestLoad(
512 FittingMode::SCALE_TO_FILL,
513 SamplingMode::BOX_THEN_LINEAR,
514 TextureManager::UseAtlas::NO_ATLAS,
517 TextureManager::ReloadPolicy::CACHED,
520 DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION);
521 DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION);
523 application.SendNotification();
524 application.Render();
526 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
528 application.SendNotification();
529 application.Render();
531 DALI_TEST_EQUALS(observer1.mLoaded, true, TEST_LOCATION);
532 DALI_TEST_EQUALS(observer1.mObserverCalled, true, TEST_LOCATION);
533 DALI_TEST_EQUALS(observer1.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
535 TestObserver observer2;
536 Devel::PixelBuffer pixelBuffer = textureManager.LoadPixelBuffer(
539 FittingMode::SCALE_TO_FILL,
540 SamplingMode::BOX_THEN_LINEAR,
546 DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION);
547 DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION);
549 application.SendNotification();
550 application.Render();
552 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
554 application.SendNotification();
555 application.Render();
557 DALI_TEST_EQUALS(observer2.mLoaded, true, TEST_LOCATION);
558 DALI_TEST_EQUALS(observer2.mObserverCalled, true, TEST_LOCATION);
559 DALI_TEST_EQUALS(observer2.mCompleteType, TestObserver::CompleteType::LOAD_COMPLETE, TEST_LOCATION);
564 int UtcTextureManagerUseInvalidMask(void)
566 ToolkitTestApplication application;
567 tet_infoline("UtcTextureManagerUseInvalidMask");
569 TextureManager textureManager; // Create new texture manager
571 TestObserver observer;
572 std::string filename(TEST_IMAGE_FILE_NAME);
573 std::string maskname("");
574 TextureManager::MaskingDataPointer maskInfo = nullptr;
575 maskInfo.reset(new TextureManager::MaskingData());
576 maskInfo->mAlphaMaskUrl = maskname;
577 maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
578 maskInfo->mCropToMask = true;
579 maskInfo->mContentScaleFactor = 1.0f;
581 auto textureId(TextureManager::INVALID_TEXTURE_ID);
582 Vector4 atlasRect(0.f, 0.f, 1.f, 1.f);
583 Dali::ImageDimensions atlasRectSize(0, 0);
584 bool synchronousLoading(false);
585 bool atlasingStatus(false);
586 bool loadingStatus(false);
587 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
588 ImageAtlasManagerPtr atlasManager = nullptr;
589 Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr;
591 textureManager.LoadTexture(
594 FittingMode::SCALE_TO_FILL,
595 SamplingMode::BOX_THEN_LINEAR,
607 TextureManager::ReloadPolicy::CACHED,
610 DALI_TEST_EQUALS(observer.mLoaded, false, TEST_LOCATION);
611 DALI_TEST_EQUALS(observer.mObserverCalled, false, TEST_LOCATION);
613 application.SendNotification();
614 application.Render();
616 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
618 application.SendNotification();
619 application.Render();
621 DALI_TEST_EQUALS(observer.mLoaded, true, TEST_LOCATION);
622 DALI_TEST_EQUALS(observer.mObserverCalled, true, TEST_LOCATION);
623 DALI_TEST_EQUALS(observer.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
628 int UtcTextureManagerUseInvalidMaskAndMaskLoadedFirst(void)
630 ToolkitTestApplication application;
631 tet_infoline("UtcTextureManagerUseInvalidMask when normal image loaded first, and mask image loaded first");
632 tet_infoline("Try to check PostLoad works well");
634 TextureManager textureManager; // Create new texture manager
636 TestObserver observer;
637 std::string filename(TEST_IMAGE_FILE_NAME);
638 std::string maskname("invalid.png");
639 TextureManager::MaskingDataPointer maskInfo = nullptr;
640 maskInfo.reset(new TextureManager::MaskingData());
641 maskInfo->mAlphaMaskUrl = maskname;
642 maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
643 maskInfo->mCropToMask = true;
644 maskInfo->mContentScaleFactor = 1.0f;
646 auto textureId(TextureManager::INVALID_TEXTURE_ID);
647 Vector4 atlasRect(0.f, 0.f, 1.f, 1.f);
648 Dali::ImageDimensions atlasRectSize(0, 0);
649 bool synchronousLoading(false);
650 bool atlasingStatus(false);
651 bool loadingStatus(false);
652 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
653 ImageAtlasManagerPtr atlasManager = nullptr;
654 Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr;
656 textureManager.LoadTexture(
659 FittingMode::SCALE_TO_FILL,
660 SamplingMode::BOX_THEN_LINEAR,
672 TextureManager::ReloadPolicy::CACHED,
675 DALI_TEST_EQUALS(observer.mLoaded, false, TEST_LOCATION);
676 DALI_TEST_EQUALS(observer.mObserverCalled, false, TEST_LOCATION);
678 application.SendNotification();
679 application.Render();
681 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
683 application.SendNotification();
684 application.Render();
686 DALI_TEST_EQUALS(observer.mLoaded, true, TEST_LOCATION);
687 DALI_TEST_EQUALS(observer.mObserverCalled, true, TEST_LOCATION);
688 DALI_TEST_EQUALS(observer.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
693 int UtcTextureManagerUseInvalidMaskAndMaskLoadedLater(void)
695 ToolkitTestApplication application;
696 tet_infoline("UtcTextureManagerUseInvalidMask when normal image loaded first, and mask image loaded later");
697 tet_infoline("Try to check CheckForWaitingTexture called");
699 TextureManager textureManager; // Create new texture manager
701 TestObserver observer;
702 std::string filename(TEST_IMAGE_FILE_NAME);
703 std::string maskname("invalid.png");
704 TextureManager::MaskingDataPointer maskInfo = nullptr;
705 maskInfo.reset(new TextureManager::MaskingData());
706 maskInfo->mAlphaMaskUrl = maskname;
707 maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
708 maskInfo->mCropToMask = true;
709 maskInfo->mContentScaleFactor = 1.0f;
711 auto textureId(TextureManager::INVALID_TEXTURE_ID);
712 Vector4 atlasRect(0.f, 0.f, 1.f, 1.f);
713 Dali::ImageDimensions atlasRectSize(0, 0);
714 bool synchronousLoading(false);
715 bool atlasingStatus(false);
716 bool loadingStatus(false);
717 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
718 ImageAtlasManagerPtr atlasManager = nullptr;
719 Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr;
721 textureManager.LoadTexture(
724 FittingMode::SCALE_TO_FILL,
725 SamplingMode::BOX_THEN_LINEAR,
737 TextureManager::ReloadPolicy::CACHED,
740 DALI_TEST_EQUALS(observer.mLoaded, false, TEST_LOCATION);
741 DALI_TEST_EQUALS(observer.mObserverCalled, false, TEST_LOCATION);
743 application.SendNotification();
744 application.Render();
746 // CAPTION : HARD-CODING for coverage. If you are a good boy, Do not follow this code.
748 Dali::Devel::PixelBuffer pixelBuffer = textureManager.LoadPixelBuffer(
751 FittingMode::SCALE_TO_FILL,
752 SamplingMode::BOX_THEN_LINEAR,
753 true, ///< synchronousLoading
755 true, ///< orientationCorrection
758 std::vector<Devel::PixelBuffer> pixelBuffers;
759 pixelBuffers.push_back(pixelBuffer);
760 textureManager.AsyncLoadComplete(textureId, pixelBuffers);
761 std::vector<Devel::PixelBuffer> maskBuffers;
762 textureManager.AsyncLoadComplete(maskInfo->mAlphaMaskId, maskBuffers);
763 textureManager.Remove(maskInfo->mAlphaMaskId, nullptr);
764 textureManager.Remove(textureId, &observer);
767 application.SendNotification();
768 application.Render();
770 DALI_TEST_EQUALS(observer.mLoaded, true, TEST_LOCATION);
771 DALI_TEST_EQUALS(observer.mObserverCalled, true, TEST_LOCATION);
772 DALI_TEST_EQUALS(observer.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
774 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
779 int UtcTextureManagerSynchronousLoadingFail(void)
781 ToolkitTestApplication application;
782 tet_infoline("UtcTextureManagerSynchronousLoadingFail");
784 TextureManager textureManager; // Create new texture manager
786 std::string maskname("");
787 TextureManager::MaskingDataPointer maskInfo = nullptr;
788 maskInfo.reset(new TextureManager::MaskingData());
789 maskInfo->mAlphaMaskUrl = maskname;
790 maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
791 maskInfo->mCropToMask = true;
792 maskInfo->mContentScaleFactor = 1.0f;
794 std::string filename("dummy");
795 auto textureId(TextureManager::INVALID_TEXTURE_ID);
796 Vector4 atlasRect(0.f, 0.f, 0.f, 0.f);
797 Dali::ImageDimensions atlasRectSize(0, 0);
798 bool atlasingStatus(false);
799 bool loadingStatus(false);
800 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
801 ImageAtlasManagerPtr atlasManager = nullptr;
802 Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr;
804 // load image synchronously.
805 TestObserver observer;
806 TextureSet textureSet = textureManager.LoadTexture(
809 FittingMode::SCALE_TO_FILL,
810 SamplingMode::BOX_THEN_LINEAR,
812 true, // synchronous loading.
822 TextureManager::ReloadPolicy::CACHED,
825 DALI_TEST_EQUALS(loadingStatus, false, TEST_LOCATION);
826 DALI_TEST_CHECK(!textureSet); // texture loading fail.
827 DALI_TEST_CHECK(textureId == TextureManager::INVALID_TEXTURE_ID); // invalid texture id is returned.
832 int UtcTextureManagerCachingSynchronousLoading(void)
834 ToolkitTestApplication application;
835 tet_infoline("UtcTextureManagerCachingSynchronousLoading");
837 TextureManager textureManager; // Create new texture manager
839 std::string filename(TEST_IMAGE_FILE_NAME);
841 std::string maskname("");
842 TextureManager::MaskingDataPointer maskInfo = nullptr;
843 maskInfo.reset(new TextureManager::MaskingData());
844 maskInfo->mAlphaMaskUrl = maskname;
845 maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
846 maskInfo->mCropToMask = true;
847 maskInfo->mContentScaleFactor = 1.0f;
849 Vector4 atlasRect(0.f, 0.f, 0.f, 0.f);
850 Dali::ImageDimensions atlasRectSize(0, 0);
851 bool atlasingStatus(false);
852 bool loadingStatus(false);
853 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
854 ImageAtlasManagerPtr atlasManager = nullptr;
855 Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr;
857 // load image synchronously.
858 TestObserver observer;
859 auto textureId(TextureManager::INVALID_TEXTURE_ID);
860 TextureSet textureSet = textureManager.LoadTexture(
863 FittingMode::SCALE_TO_FILL,
864 SamplingMode::BOX_THEN_LINEAR,
866 true, // synchronous loading.
876 TextureManager::ReloadPolicy::CACHED,
879 DALI_TEST_EQUALS(loadingStatus, false, TEST_LOCATION);
880 DALI_TEST_CHECK(textureSet); // texture is loaded.
882 // observer isn't called in synchronous loading.
883 DALI_TEST_EQUALS(observer.mLoaded, false, TEST_LOCATION);
884 DALI_TEST_EQUALS(observer.mObserverCalled, false, TEST_LOCATION);
886 // load same image asynchronously.
887 TestObserver asyncObserver;
888 auto asyncTextureId(TextureManager::INVALID_TEXTURE_ID);
889 loadingStatus = false;
890 TextureSet asyncTextureSet = textureManager.LoadTexture(
893 FittingMode::SCALE_TO_FILL,
894 SamplingMode::BOX_THEN_LINEAR,
896 false, // asynchronous loading.
906 TextureManager::ReloadPolicy::CACHED,
909 DALI_TEST_EQUALS(asyncTextureId, textureId, TEST_LOCATION); // texture is loaded.
910 DALI_TEST_EQUALS(loadingStatus, false, TEST_LOCATION);
911 DALI_TEST_CHECK(asyncTextureSet); // Cached texture.
913 // observer is directly called because textureSet is retrieved by cache.
914 DALI_TEST_EQUALS(asyncObserver.mLoaded, true, TEST_LOCATION);
915 DALI_TEST_EQUALS(asyncObserver.mObserverCalled, true, TEST_LOCATION);
920 int UtcTextureManagerAsyncSyncAsync(void)
922 ToolkitTestApplication application;
923 tet_infoline("UtcTextureManagerAsyncSyncAsync");
925 TextureManager textureManager; // Create new texture manager
927 std::string filename(TEST_IMAGE_FILE_NAME);
929 std::string maskname("");
930 TextureManager::MaskingDataPointer maskInfo = nullptr;
931 maskInfo.reset(new TextureManager::MaskingData());
932 maskInfo->mAlphaMaskUrl = maskname;
933 maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
934 maskInfo->mCropToMask = true;
935 maskInfo->mContentScaleFactor = 1.0f;
937 Vector4 atlasRect(0.f, 0.f, 0.f, 0.f);
938 Dali::ImageDimensions atlasRectSize(0, 0);
939 bool atlasingStatus(false);
940 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
941 ImageAtlasManagerPtr atlasManager = nullptr;
942 Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr;
944 // load image asynchronously.
945 TestObserver asyncObserver1;
946 auto asyncTextureId1(TextureManager::INVALID_TEXTURE_ID);
947 bool asyncLoadingStatus1 = false;
948 TextureSet asyncTextureSet1 = textureManager.LoadTexture(
951 FittingMode::SCALE_TO_FILL,
952 SamplingMode::BOX_THEN_LINEAR,
954 false, // asynchronous loading.
964 TextureManager::ReloadPolicy::CACHED,
967 DALI_TEST_EQUALS(asyncLoadingStatus1, true, TEST_LOCATION); // texture is loading now.
968 DALI_TEST_CHECK(!asyncTextureSet1); // texture is not loaded yet.
970 // observer is still not called.
971 DALI_TEST_EQUALS(asyncObserver1.mLoaded, false, TEST_LOCATION);
972 DALI_TEST_EQUALS(asyncObserver1.mObserverCalled, false, TEST_LOCATION);
974 // load same image synchronously just after asynchronous loading.
975 TestObserver syncObserver;
976 auto textureId(TextureManager::INVALID_TEXTURE_ID);
977 bool syncLoadingStatus = false;
978 TextureSet syncTextureSet = textureManager.LoadTexture(
981 FittingMode::SCALE_TO_FILL,
982 SamplingMode::BOX_THEN_LINEAR,
984 true, // synchronous loading.
994 TextureManager::ReloadPolicy::CACHED,
997 DALI_TEST_EQUALS(asyncTextureId1, textureId, TEST_LOCATION); // texture is loaded.
998 DALI_TEST_EQUALS(syncLoadingStatus, false, TEST_LOCATION); // texture is loaded.
999 DALI_TEST_CHECK(syncTextureSet); // texture is loaded.
1001 // syncObserver isn't called in synchronous loading.
1002 DALI_TEST_EQUALS(syncObserver.mLoaded, false, TEST_LOCATION);
1003 DALI_TEST_EQUALS(syncObserver.mObserverCalled, false, TEST_LOCATION);
1005 // asyncObserver1 is still not called too.
1006 DALI_TEST_EQUALS(asyncObserver1.mLoaded, false, TEST_LOCATION);
1007 DALI_TEST_EQUALS(asyncObserver1.mObserverCalled, false, TEST_LOCATION);
1009 // load image asynchronously.
1010 TestObserver asyncObserver2;
1011 auto asyncTextureId2(TextureManager::INVALID_TEXTURE_ID);
1012 bool asyncLoadingStatus2 = false;
1013 TextureSet asyncTextureSet2 = textureManager.LoadTexture(
1016 FittingMode::SCALE_TO_FILL,
1017 SamplingMode::BOX_THEN_LINEAR,
1019 false, // asynchronous loading.
1024 asyncLoadingStatus2,
1026 atlasUploadObserver,
1029 TextureManager::ReloadPolicy::CACHED,
1032 DALI_TEST_EQUALS(asyncLoadingStatus2, false, TEST_LOCATION); // texture is loaded by previous sync request
1033 DALI_TEST_CHECK(asyncTextureSet2); // texture is loaded
1034 Texture syncTexture = syncTextureSet.GetTexture(0u);
1035 Texture asyncTexture2 = asyncTextureSet2.GetTexture(0u);
1036 DALI_TEST_CHECK(syncTexture);
1037 DALI_TEST_CHECK(asyncTexture2);
1038 DALI_TEST_CHECK(asyncTexture2 == syncTexture); // check loaded two texture is same.
1040 // observer is called synchronously because the texture is cached.
1041 DALI_TEST_EQUALS(asyncObserver2.mLoaded, true, TEST_LOCATION);
1042 DALI_TEST_EQUALS(asyncObserver2.mObserverCalled, true, TEST_LOCATION);
1044 asyncObserver2.mLoaded = false;
1045 asyncObserver2.mObserverCalled = false;
1047 application.SendNotification();
1048 application.Render();
1050 // Requested asynchronous loading at first is finished now and async observer is called now.
1051 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1052 DALI_TEST_EQUALS(asyncObserver1.mLoaded, true, TEST_LOCATION);
1053 DALI_TEST_EQUALS(asyncObserver1.mObserverCalled, true, TEST_LOCATION);
1054 DALI_TEST_CHECK(asyncObserver1.mTextureSet);
1056 Texture observerTexture = asyncObserver1.mTextureSet.GetTexture(0u);
1057 DALI_TEST_CHECK(observerTexture == asyncTexture2); // check loaded two texture is same.
1059 // asyncObserver2 was already called so it isn't called here.
1060 DALI_TEST_EQUALS(asyncObserver2.mLoaded, false, TEST_LOCATION);
1061 DALI_TEST_EQUALS(asyncObserver2.mObserverCalled, false, TEST_LOCATION);
1066 int UtcTextureManagerQueueRemoveDuringObserve(void)
1068 ToolkitTestApplication application;
1069 tet_infoline("UtcTextureManagerQueueRemoveDuringObserve");
1071 TextureManager textureManager; // Create new texture manager
1073 TestObserverRemoveAndGenerateUrl observer(&textureManager); // special observer for this UTC.
1075 std::string filename(TEST_IMAGE_FILE_NAME);
1076 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
1078 TextureManager::TextureId textureId = textureManager.RequestLoad(
1081 FittingMode::SCALE_TO_FILL,
1082 SamplingMode::BOX_THEN_LINEAR,
1083 TextureManager::UseAtlas::NO_ATLAS,
1086 TextureManager::ReloadPolicy::CACHED,
1089 DALI_TEST_EQUALS(observer.mLoaded, false, TEST_LOCATION);
1090 DALI_TEST_EQUALS(observer.mObserverCalled, false, TEST_LOCATION);
1092 application.SendNotification();
1093 application.Render();
1095 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1097 application.SendNotification();
1098 application.Render();
1100 DALI_TEST_EQUALS(observer.mLoaded, true, TEST_LOCATION);
1101 DALI_TEST_EQUALS(observer.mObserverCalled, true, TEST_LOCATION);
1102 DALI_TEST_EQUALS(observer.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
1104 tet_printf("loaded textureId is %d, generated url is %s\n", static_cast<int>(textureId), observer.mGeneratedExternalUrl.c_str());
1106 DALI_TEST_CHECK(static_cast<int>(textureId) != std::stoi(VisualUrl::GetLocation(observer.mGeneratedExternalUrl))); // Check we don't reuse textureId during observe
1108 // Decrease external texture reference count who observer created
1109 textureManager.RemoveExternalTexture(observer.mGeneratedExternalUrl);
1111 application.SendNotification();
1112 application.Render();
1117 int UtcTextureManagerRemoveDuringApplyMasking(void)
1119 ToolkitTestApplication application;
1120 tet_infoline("UtcTextureManagerRemoveDuringApplyMasking");
1122 TextureManager textureManager; // Create new texture manager
1124 TestObserver observer1;
1125 TestObserver observer2;
1127 std::string filename(TEST_IMAGE_FILE_NAME);
1128 std::string maskname(TEST_MASK_FILE_NAME);
1129 TextureManager::MaskingDataPointer maskInfo = nullptr;
1130 maskInfo.reset(new TextureManager::MaskingData());
1131 maskInfo->mAlphaMaskUrl = maskname;
1132 maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
1133 maskInfo->mCropToMask = true;
1134 maskInfo->mContentScaleFactor = 1.0f;
1136 auto textureId1(TextureManager::INVALID_TEXTURE_ID);
1137 Vector4 atlasRect(0.f, 0.f, 1.f, 1.f);
1138 Dali::ImageDimensions atlasRectSize(0, 0);
1139 bool synchronousLoading(false);
1140 bool atlasingStatus(false);
1141 bool loadingStatus(false);
1142 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
1143 ImageAtlasManagerPtr atlasManager = nullptr;
1144 Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr;
1146 textureManager.LoadTexture(
1149 FittingMode::SCALE_TO_FILL,
1150 SamplingMode::BOX_THEN_LINEAR,
1159 atlasUploadObserver,
1162 TextureManager::ReloadPolicy::CACHED,
1165 DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION);
1166 DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION);
1168 application.SendNotification();
1169 application.Render();
1171 // Load image and mask image.
1172 // Now, LoadState become MASK_APPLYING
1173 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1175 tet_printf("Current textureId1:%d's state become MASK_APPLYING\n", static_cast<int>(textureId1));
1177 application.SendNotification();
1178 application.Render();
1180 DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION);
1181 DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION);
1183 // Remove current textureId1. and request new texture again.
1184 textureManager.Remove(textureId1, &observer1);
1185 auto textureId2 = textureManager.RequestLoad(
1188 FittingMode::SCALE_TO_FILL,
1189 SamplingMode::BOX_THEN_LINEAR,
1190 TextureManager::UseAtlas::NO_ATLAS,
1192 true, ///< orientationCorrection
1193 TextureManager::ReloadPolicy::CACHED,
1195 synchronousLoading);
1197 application.SendNotification();
1198 application.Render();
1200 DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION);
1201 DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION);
1202 DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION);
1203 DALI_TEST_EQUALS(observer2.mObserverCalled, false, TEST_LOCATION);
1205 tet_printf("textureId1:%d removed and textureId2:%d requested\n", static_cast<int>(textureId1), static_cast<int>(textureId2));
1207 // CAPTION : HARD-CODING.
1209 std::vector<Devel::PixelBuffer> pixelBuffers;
1210 textureManager.AsyncLoadComplete(textureId2, pixelBuffers);
1211 textureManager.Remove(textureId2, &observer2);
1214 DALI_TEST_EQUALS(observer2.mLoaded, false, TEST_LOCATION); ///< Note that we call AsyncLoadComplete hardly with empty pixelbuffer.
1215 DALI_TEST_EQUALS(observer2.mObserverCalled, true, TEST_LOCATION);
1216 DALI_TEST_EQUALS(observer2.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION);
1221 int UtcTextureManagerMaskCacheTest(void)
1223 ToolkitTestApplication application;
1224 tet_infoline("UtcTextureManagerMaskCacheTest");
1226 TextureManager textureManager; // Create new texture manager
1228 TestObserver observer1;
1229 TestObserver observer2;
1231 std::string filename(TEST_IMAGE_FILE_NAME);
1232 std::string filename2(TEST_IMAGE_2_FILE_NAME);
1233 std::string maskname(TEST_MASK_FILE_NAME);
1234 TextureManager::MaskingDataPointer maskInfo = nullptr;
1235 maskInfo.reset(new TextureManager::MaskingData());
1236 maskInfo->mAlphaMaskUrl = maskname;
1237 maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
1238 maskInfo->mCropToMask = true;
1239 maskInfo->mContentScaleFactor = 1.0f;
1241 TextureManager::MaskingDataPointer maskInfo2 = nullptr;
1242 maskInfo2.reset(new TextureManager::MaskingData());
1243 maskInfo2->mAlphaMaskUrl = maskname;
1244 maskInfo2->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
1245 maskInfo2->mCropToMask = true;
1246 maskInfo2->mContentScaleFactor = 1.0f;
1248 auto textureId1(TextureManager::INVALID_TEXTURE_ID);
1249 auto textureId2(TextureManager::INVALID_TEXTURE_ID);
1250 Vector4 atlasRect(0.f, 0.f, 1.f, 1.f);
1251 Dali::ImageDimensions atlasRectSize(0, 0);
1252 bool synchronousLoading(false);
1253 bool atlasingStatus(false);
1254 bool loadingStatus(false);
1255 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
1256 ImageAtlasManagerPtr atlasManager = nullptr;
1257 Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr;
1259 textureManager.LoadTexture(
1262 FittingMode::SCALE_TO_FILL,
1263 SamplingMode::BOX_THEN_LINEAR,
1272 atlasUploadObserver,
1275 TextureManager::ReloadPolicy::CACHED,
1278 DALI_TEST_EQUALS(observer1.mLoaded, false, TEST_LOCATION);
1279 DALI_TEST_EQUALS(observer1.mObserverCalled, false, TEST_LOCATION);
1281 application.SendNotification();
1282 application.Render();
1284 // Load image and mask image.
1285 // Now, LoadState become MASK_APPLYING
1286 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
1288 tet_printf("Current textureId1:%d's state become MASK_APPLYING\n", static_cast<int>(textureId1));
1290 textureManager.LoadTexture(
1293 FittingMode::SCALE_TO_FILL,
1294 SamplingMode::BOX_THEN_LINEAR,
1303 atlasUploadObserver,
1306 TextureManager::ReloadPolicy::CACHED,
1309 application.SendNotification();
1310 application.Render();
1312 // Load image2 + image1 apply mask + image2 apply mask = total 3 event trigger required.
1313 // Note that we use cached mask image.
1314 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
1316 DALI_TEST_EQUALS(observer1.mLoaded, true, TEST_LOCATION);
1317 DALI_TEST_EQUALS(observer1.mObserverCalled, true, TEST_LOCATION);
1318 DALI_TEST_EQUALS(observer2.mLoaded, true, TEST_LOCATION);
1319 DALI_TEST_EQUALS(observer2.mObserverCalled, true, TEST_LOCATION);
1323 // Remove textureId1 first, and then remove textureId2. Check whether segfault occured.
1324 textureManager.Remove(textureId1, &observer1);
1325 textureManager.Remove(textureId2, &observer2);
1327 TestObserver observer3;
1328 maskInfo.reset(new TextureManager::MaskingData());
1329 maskInfo->mAlphaMaskUrl = maskname;
1330 maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID;
1331 maskInfo->mCropToMask = true;
1332 maskInfo->mContentScaleFactor = 1.0f;
1334 textureManager.LoadTexture(
1337 FittingMode::SCALE_TO_FILL,
1338 SamplingMode::BOX_THEN_LINEAR,
1347 atlasUploadObserver,
1350 TextureManager::ReloadPolicy::CACHED,
1353 DALI_TEST_EQUALS(observer3.mLoaded, false, TEST_LOCATION);
1354 DALI_TEST_EQUALS(observer3.mObserverCalled, false, TEST_LOCATION);
1356 application.SendNotification();
1357 application.Render();
1359 // Load image and mask image.
1360 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1361 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1363 DALI_TEST_EQUALS(observer3.mLoaded, false, TEST_LOCATION);
1364 DALI_TEST_EQUALS(observer3.mObserverCalled, false, TEST_LOCATION);
1367 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1369 DALI_TEST_EQUALS(observer3.mLoaded, true, TEST_LOCATION);
1370 DALI_TEST_EQUALS(observer3.mObserverCalled, true, TEST_LOCATION);
1374 DALI_TEST_CHECK(false);