2 * Copyright (c) 2017 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;
61 int UtcTextureManagerRequestLoad(void)
63 ToolkitTestApplication application;
65 TextureManager textureManager; // Create new texture manager
67 TestObserver observer;
68 std::string filename("image.png");
69 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
70 TextureManager::TextureId textureId = textureManager.RequestLoad(
73 FittingMode::SCALE_TO_FILL,
74 SamplingMode::BOX_THEN_LINEAR,
75 TextureManager::NO_ATLAS,
78 TextureManager::ReloadPolicy::CACHED,
81 VisualUrl url = textureManager.GetVisualUrl( textureId );
83 DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );
88 int UtcTextureManagerGenerateHash(void)
90 ToolkitTestApplication application;
92 TextureManager textureManager; // Create new texture manager
94 TestObserver observer;
95 std::string filename( "image.png" );
96 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
97 TextureManager::TextureId textureId = textureManager.RequestLoad(
100 FittingMode::SCALE_TO_FILL,
101 SamplingMode::BOX_THEN_LINEAR,
102 TextureManager::USE_ATLAS,
105 TextureManager::ReloadPolicy::CACHED,
108 VisualUrl url = textureManager.GetVisualUrl( textureId );
110 DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );