2 * Copyright (c) 2020 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 <dali-toolkit/internal/visuals/texture-manager-impl.h>
24 #include <dali-toolkit/internal/visuals/texture-upload-observer.h>
26 using namespace Dali::Toolkit::Internal;
29 void utc_dali_toolkit_texture_manager_startup(void)
31 setenv( "LOG_TEXTURE_MANAGER", "3", 1 );
32 test_return_value = TET_UNDEF;
35 void utc_dali_toolkit_texture_manager_cleanup(void)
37 test_return_value = TET_PASS;
40 class TestObserver : public Dali::Toolkit::TextureUploadObserver
45 mObserverCalled(false)
49 virtual void UploadComplete( bool loadSuccess, int32_t textureId, TextureSet textureSet,
50 bool useAtlasing, const Vector4& atlasRect, bool preMultiplied ) override
52 mLoaded = loadSuccess;
53 mObserverCalled = true;
56 virtual void LoadComplete( bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied ) override
58 mLoaded = loadSuccess;
59 mObserverCalled = true;
67 int UtcTextureManagerRequestLoad(void)
69 ToolkitTestApplication application;
71 TextureManager textureManager; // Create new texture manager
73 TestObserver observer;
74 std::string filename("image.png");
75 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
76 TextureManager::TextureId textureId = textureManager.RequestLoad(
79 FittingMode::SCALE_TO_FILL,
80 SamplingMode::BOX_THEN_LINEAR,
81 TextureManager::NO_ATLAS,
84 TextureManager::ReloadPolicy::CACHED,
87 VisualUrl url = textureManager.GetVisualUrl( textureId );
89 DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );
94 int UtcTextureManagerGenerateHash(void)
96 ToolkitTestApplication application;
98 TextureManager textureManager; // Create new texture manager
100 TestObserver observer;
101 std::string filename( "image.png" );
102 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
103 TextureManager::TextureId textureId = textureManager.RequestLoad(
106 FittingMode::SCALE_TO_FILL,
107 SamplingMode::BOX_THEN_LINEAR,
108 TextureManager::USE_ATLAS,
111 TextureManager::ReloadPolicy::CACHED,
114 VisualUrl url = textureManager.GetVisualUrl( textureId );
116 DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );